diff options
Diffstat (limited to 'OpenSim/Region')
4 files changed, 83 insertions, 20 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index c7bd3d0..f06d70d 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -1038,6 +1038,18 @@ namespace OpenSim.Region.CoreModules.Asset | |||
1038 | return true; | 1038 | return true; |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | public bool[] AssetsExist(string[] ids) | ||
1042 | { | ||
1043 | bool[] exist = new bool[ids.Length]; | ||
1044 | |||
1045 | for (int i = 0; i < ids.Length; i++) | ||
1046 | { | ||
1047 | exist[i] = Check(ids[i]); | ||
1048 | } | ||
1049 | |||
1050 | return exist; | ||
1051 | } | ||
1052 | |||
1041 | public string Store(AssetBase asset) | 1053 | public string Store(AssetBase asset) |
1042 | { | 1054 | { |
1043 | if (asset.FullID == UUID.Zero) | 1055 | if (asset.FullID == UUID.Zero) |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index d4fb1ba..532bc74 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | |||
@@ -145,11 +145,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
145 | string id = m_scene.AssetService.Store(asset1); | 145 | string id = m_scene.AssetService.Store(asset1); |
146 | if (id == string.Empty) | 146 | if (id == string.Empty) |
147 | { | 147 | { |
148 | m_log.DebugFormat("[HG ASSET MAPPER]: Asset server {0} did not accept {1}", url, asset.ID); | 148 | m_log.DebugFormat("[HG ASSET MAPPER]: Failed to post asset {0} to asset server {1}: the server did not accept the asset", asset.ID, url); |
149 | success = false; | 149 | success = false; |
150 | } | 150 | } |
151 | else | 151 | else |
152 | m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); | 152 | m_log.DebugFormat("[HG ASSET MAPPER]: Posted asset {0} to asset server {1}", asset1.ID, url); |
153 | } | 153 | } |
154 | return success; | 154 | return success; |
155 | } | 155 | } |
@@ -279,36 +279,65 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
279 | 279 | ||
280 | public void Post(UUID assetID, UUID ownerID, string userAssetURL) | 280 | public void Post(UUID assetID, UUID ownerID, string userAssetURL) |
281 | { | 281 | { |
282 | // Post the item from the local AssetCache onto the remote asset server | 282 | m_log.DebugFormat("[HG ASSET MAPPER]: Starting to send asset {0} with children to asset server {1}", assetID, userAssetURL); |
283 | // and place an entry in m_assetMap | 283 | |
284 | // Find all the embedded assets | ||
284 | 285 | ||
285 | m_log.Debug("[HG ASSET MAPPER]: Posting object " + assetID + " to asset server " + userAssetURL); | ||
286 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); | 286 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); |
287 | if (asset != null) | 287 | if (asset == null) |
288 | { | 288 | { |
289 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); | 289 | m_log.DebugFormat("[HG ASSET MAPPER]: Something wrong with asset {0}, it could not be found", assetID); |
290 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); | 290 | return; |
291 | uuidGatherer.GatherAssetUuids(asset.FullID, asset.Type, ids); | 291 | } |
292 | bool success = false; | 292 | |
293 | foreach (UUID uuid in ids.Keys) | 293 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); |
294 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); | ||
295 | uuidGatherer.GatherAssetUuids(asset.FullID, asset.Type, ids); | ||
296 | |||
297 | // Check which assets already exist in the destination server | ||
298 | |||
299 | string url = userAssetURL; | ||
300 | if (!url.EndsWith("/") && !url.EndsWith("=")) | ||
301 | url = url + "/"; | ||
302 | |||
303 | string[] remoteAssetIDs = new string[ids.Count]; | ||
304 | int i = 0; | ||
305 | foreach (UUID id in ids.Keys) | ||
306 | remoteAssetIDs[i++] = url + id.ToString(); | ||
307 | |||
308 | bool[] exist = m_scene.AssetService.AssetsExist(remoteAssetIDs); | ||
309 | |||
310 | var existSet = new HashSet<string>(); | ||
311 | i = 0; | ||
312 | foreach (UUID id in ids.Keys) | ||
313 | { | ||
314 | if (exist[i]) | ||
315 | existSet.Add(id.ToString()); | ||
316 | ++i; | ||
317 | } | ||
318 | |||
319 | // Send only those assets which don't already exist in the destination server | ||
320 | |||
321 | bool success = true; | ||
322 | |||
323 | foreach (UUID uuid in ids.Keys) | ||
324 | { | ||
325 | if (!existSet.Contains(uuid.ToString())) | ||
294 | { | 326 | { |
295 | asset = m_scene.AssetService.Get(uuid.ToString()); | 327 | asset = m_scene.AssetService.Get(uuid.ToString()); |
296 | if (asset == null) | 328 | if (asset == null) |
297 | m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid); | 329 | m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid); |
298 | else | 330 | else |
299 | success = PostAsset(userAssetURL, asset); | 331 | success &= PostAsset(userAssetURL, asset); |
300 | } | 332 | } |
301 | |||
302 | // maybe all pieces got there... | ||
303 | if (!success) | ||
304 | m_log.DebugFormat("[HG ASSET MAPPER]: Problems posting item {0} to asset server {1}", assetID, userAssetURL); | ||
305 | else | 333 | else |
306 | m_log.DebugFormat("[HG ASSET MAPPER]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL); | 334 | m_log.DebugFormat("[HG ASSET MAPPER]: Didn't post asset {0} because it already exists in asset server {1}", uuid, userAssetURL); |
307 | |||
308 | } | 335 | } |
309 | else | ||
310 | m_log.DebugFormat("[HG ASSET MAPPER]: Something wrong with asset {0}, it could not be found", assetID); | ||
311 | 336 | ||
337 | if (!success) | ||
338 | m_log.DebugFormat("[HG ASSET MAPPER]: Problems sending asset {0} with children to asset server {1}", assetID, userAssetURL); | ||
339 | else | ||
340 | m_log.DebugFormat("[HG ASSET MAPPER]: Successfully sent asset {0} with children to asset server {1}", assetID, userAssetURL); | ||
312 | } | 341 | } |
313 | 342 | ||
314 | #endregion | 343 | #endregion |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs index 9f58175..ff8b051 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs | |||
@@ -312,6 +312,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||
315 | public virtual bool[] AssetsExist(string[] ids) | ||
316 | { | ||
317 | int numHG = 0; | ||
318 | foreach (string id in ids) | ||
319 | { | ||
320 | if (IsHG(id)) | ||
321 | ++numHG; | ||
322 | } | ||
323 | |||
324 | if (numHG == 0) | ||
325 | return m_GridService.AssetsExist(ids); | ||
326 | else if (numHG == ids.Length) | ||
327 | return m_HGService.AssetsExist(ids); | ||
328 | else | ||
329 | throw new Exception("[HG ASSET CONNECTOR]: AssetsExist: all the assets must be either local or foreign"); | ||
330 | } | ||
331 | |||
315 | public string Store(AssetBase asset) | 332 | public string Store(AssetBase asset) |
316 | { | 333 | { |
317 | bool isHG = IsHG(asset.ID); | 334 | bool isHG = IsHG(asset.ID); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs index 52b1039..97b7559 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs | |||
@@ -253,6 +253,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
253 | }); | 253 | }); |
254 | } | 254 | } |
255 | 255 | ||
256 | public bool[] AssetsExist(string[] ids) | ||
257 | { | ||
258 | return m_AssetService.AssetsExist(ids); | ||
259 | } | ||
260 | |||
256 | public string Store(AssetBase asset) | 261 | public string Store(AssetBase asset) |
257 | { | 262 | { |
258 | if (m_Cache != null) | 263 | if (m_Cache != null) |