aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs66
-rw-r--r--OpenSim/Services/AssetService/HGAssetService.cs13
3 files changed, 48 insertions, 40 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs
index 34bb85a..aef04bf 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs
@@ -178,8 +178,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset
178 178
179 if (asset != null) 179 if (asset != null)
180 return asset; 180 return asset;
181 else
182 m_log.DebugFormat("[HG ASSSET CONNECTOR]: Requested asset is not in cache. This shouldn't happen.");
183 } 181 }
184 182
185 if (IsHG(id)) 183 if (IsHG(id))
@@ -295,7 +293,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset
295 293
296 public string Store(AssetBase asset) 294 public string Store(AssetBase asset)
297 { 295 {
298 if (m_Cache != null) 296 bool isHG = IsHG(asset.ID);
297
298 if ((m_Cache != null) && !isHG)
299 // Don't store it in the cache if the asset is to
300 // be sent to the other grid, because this is already
301 // a copy of the local asset.
299 m_Cache.Cache(asset); 302 m_Cache.Cache(asset);
300 303
301 if (asset.Temporary || asset.Local) 304 if (asset.Temporary || asset.Local)
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index e659ad1..b6b2172 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -120,25 +120,30 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
120 return null; 120 return null;
121 } 121 }
122 122
123 private bool PostAsset(GridAssetClient asscli, UUID assetID, bool isTexture) 123 private bool PostAsset(string url, AssetBase asset)
124 { 124 {
125 AssetBase asset1; 125 if (asset != null)
126 //m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset1);
127 asset1 = m_scene.CommsManager.AssetCache.GetAsset(assetID, isTexture);
128
129 if (asset1 != null)
130 { 126 {
131 // See long comment in AssetCache.AddAsset 127 // See long comment in AssetCache.AddAsset
132 if (!asset1.Temporary || asset1.Local) 128 if (!asset.Temporary || asset.Local)
133 { 129 {
134 // The asset cache returns instances of subclasses of AssetBase: 130 // We need to copy the asset into a new asset, because
135 // TextureImage or AssetInfo. So in passing them to the remote 131 // we need to set its ID to be URL+UUID, so that the
136 // server we first need to convert this to instances of AssetBase, 132 // HGAssetService dispatches it to the remote grid.
137 // which is the serializable class for assets. 133 // It's not pretty, but the best that can be done while
138 AssetBase asset = new AssetBase(); 134 // not having a global naming infrastructure
139 Copy(asset1, asset); 135 AssetBase asset1 = new AssetBase();
140 136 Copy(asset, asset1);
141 asscli.StoreAsset(asset); 137 try
138 {
139 asset1.ID = url + "/" + asset.ID;
140 }
141 catch
142 {
143 m_log.Warn("[HGScene]: This won't work until Melanie kills a few more dragons");
144 }
145
146 m_scene.AssetService.Store(asset1);
142 } 147 }
143 return true; 148 return true;
144 } 149 }
@@ -315,46 +320,35 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
315 { 320 {
316 if (!IsLocalUser(ownerID)) 321 if (!IsLocalUser(ownerID))
317 { 322 {
318 // Post the item from the local AssetCache ontp the remote asset server 323 // Post the item from the local AssetCache onto the remote asset server
319 // and place an entry in m_assetMap 324 // and place an entry in m_assetMap
320 325
321 GridAssetClient asscli = null;
322 string userAssetURL = UserAssetURL(ownerID); 326 string userAssetURL = UserAssetURL(ownerID);
323 if (userAssetURL != null) 327 if (userAssetURL != null)
324 { 328 {
325 m_assetServers.TryGetValue(userAssetURL, out asscli);
326 if (asscli == null)
327 {
328 m_log.Debug("[HGScene]: Starting new GridAssetClient for " + userAssetURL);
329 asscli = new GridAssetClient(userAssetURL);
330 asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache!
331 m_assetServers.Add(userAssetURL, asscli);
332 }
333 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); 329 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
334 AssetBase ass1 = null; 330 AssetBase ass1 = m_scene.AssetService.Get(assetID.ToString());
335 m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out ass1);
336 if (ass1 != null) 331 if (ass1 != null)
337 { 332 {
338 bool success = PostAsset(asscli, assetID, (ass1.Type == (sbyte)AssetType.Texture)); 333 bool success = PostAsset(userAssetURL, ass1);
339 334
340 // Now the inside 335 // Now the inside
341 Dictionary<UUID, bool> ids = SniffUUIDs(assetID); 336 Dictionary<UUID, bool> ids = SniffUUIDs(assetID);
342 Dump(ids); 337 Dump(ids);
343 foreach (KeyValuePair<UUID, bool> kvp in ids) 338 foreach (KeyValuePair<UUID, bool> kvp in ids)
344 PostAsset(asscli, kvp.Key, kvp.Value);
345
346 if (success)
347 { 339 {
348 m_log.Debug("[HGScene]: Successfully posted item to remote asset server " + userAssetURL); 340 ass1 = m_scene.AssetService.Get(kvp.Key.ToString());
349 if (!m_assetMap.ContainsKey(assetID)) 341 PostAsset(userAssetURL, ass1);
350 m_assetMap.Add(assetID, asscli);
351 } 342 }
343
344 if (success)
345 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to remote asset server {1}", assetID, userAssetURL);
352 else 346 else
353 m_log.Warn("[HGScene]: Could not post asset to remote asset server " + userAssetURL); 347 m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL);
354 348
355 } 349 }
356 else 350 else
357 m_log.Debug("[HGScene]: Something wrong with asset"); 351 m_log.Debug("[HGScene]: Something wrong with asset, it could not be found");
358 } 352 }
359 else 353 else
360 m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); 354 m_log.Warn("[HGScene]: Unable to locate foreign user's asset server");
diff --git a/OpenSim/Services/AssetService/HGAssetService.cs b/OpenSim/Services/AssetService/HGAssetService.cs
index 415a0f5..cf275ab 100644
--- a/OpenSim/Services/AssetService/HGAssetService.cs
+++ b/OpenSim/Services/AssetService/HGAssetService.cs
@@ -94,7 +94,7 @@ namespace OpenSim.Services.AssetService
94 // We're instantiating this class explicitly, but this won't 94 // We're instantiating this class explicitly, but this won't
95 // work in general, because the remote grid may be running 95 // work in general, because the remote grid may be running
96 // an asset server that has a different protocol. 96 // an asset server that has a different protocol.
97 // Eventually we will want a piece of meta-protocol asking 97 // Eventually we will want a piece of protocol asking
98 // the remote server about its kind. Definitely cool thing to do! 98 // the remote server about its kind. Definitely cool thing to do!
99 connector = new AssetServicesConnector(url); 99 connector = new AssetServicesConnector(url);
100 m_connectors.Add(url, connector); 100 m_connectors.Add(url, connector);
@@ -152,6 +152,17 @@ namespace OpenSim.Services.AssetService
152 152
153 public string Store(AssetBase asset) 153 public string Store(AssetBase asset)
154 { 154 {
155 string url = string.Empty;
156 string assetID = string.Empty;
157
158 if (StringToUrlAndAssetID(asset.ID, out url, out assetID))
159 {
160 IAssetService connector = GetConnector(url);
161 // Restore the assetID to a simple UUID
162 asset.ID = assetID;
163 return connector.Store(asset);
164 }
165
155 return String.Empty; 166 return String.Empty;
156 } 167 }
157 168