From 08606ae409b400b6f9b83006ed04826eede8a9c7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 8 Jan 2015 20:21:40 +0000 Subject: Make the IteratingUuidGatherer the only UuidGatherer. This UUID gatherer provides a superset of the previous gatherer's functionality as it also allows the caller to control gathering iterations for load purposes. --- .../Region/CoreModules/Asset/FlotsamAssetCache.cs | 14 +++++++------- .../Archiver/InventoryArchiveWriteRequest.cs | 14 ++++++-------- .../EntityTransfer/HGEntityTransferModule.cs | 4 ++-- .../Framework/InventoryAccess/HGAssetMapper.cs | 21 ++++++++++----------- .../World/Archiver/ArchiveWriteRequest.cs | 10 +++++----- 5 files changed, 30 insertions(+), 33 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 59b30a9..7d9c9a9 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -776,7 +776,6 @@ namespace OpenSim.Region.CoreModules.Asset { UuidGatherer gatherer = new UuidGatherer(m_AssetService); - Dictionary assetIdsToCheck = new Dictionary(); Dictionary assetsFound = new Dictionary(); foreach (Scene s in m_Scenes) @@ -784,10 +783,11 @@ namespace OpenSim.Region.CoreModules.Asset StampRegionStatusFile(s.RegionInfo.RegionID); s.ForEachSOG(delegate(SceneObjectGroup e) - { - gatherer.GatherAssetUuids(e, assetIdsToCheck); + { + gatherer.AddForInspection(e); + gatherer.GatherAll(); - foreach (UUID assetID in assetIdsToCheck.Keys) + foreach (UUID assetID in gatherer.GatheredUuids.Keys) { if (!assetsFound.ContainsKey(assetID)) { @@ -800,7 +800,7 @@ namespace OpenSim.Region.CoreModules.Asset else if (storeUncached) { AssetBase cachedAsset = m_AssetService.Get(assetID.ToString()); - if (cachedAsset == null && assetIdsToCheck[assetID] != (sbyte)AssetType.Unknown) + if (cachedAsset == null && gatherer.GatheredUuids[assetID] != (sbyte)AssetType.Unknown) assetsFound[assetID] = false; else assetsFound[assetID] = true; @@ -810,11 +810,11 @@ namespace OpenSim.Region.CoreModules.Asset { m_log.DebugFormat( "[FLOTSAM ASSET CACHE]: Could not find asset {0}, type {1} referenced by object {2} at {3} in scene {4} when pre-caching all scene assets", - assetID, assetIdsToCheck[assetID], e.Name, e.AbsolutePosition, s.Name); + assetID, gatherer.GatheredUuids[assetID], e.Name, e.AbsolutePosition, s.Name); } } - assetIdsToCheck.Clear(); + gatherer.GatheredUuids.Clear(); }); } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 6dab227..42a4c7a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -94,11 +94,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver protected UUID m_id; /// - /// Used to collect the uuids of the assets that we need to save into the archive - /// - protected Dictionary m_assetUuids = new Dictionary(); - - /// /// Used to collect the uuids of the users that we need to save into the archive /// protected Dictionary m_userUuids = new Dictionary(); @@ -225,7 +220,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // Don't chase down link asset items as they actually point to their target item IDs rather than an asset if (SaveAssets && itemAssetType != AssetType.Link && itemAssetType != AssetType.LinkFolder) - m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (sbyte)inventoryItem.AssetType, m_assetUuids); + m_assetGatherer.AddForInspection(inventoryItem.AssetID); } /// @@ -422,12 +417,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (SaveAssets) { - m_log.DebugFormat("[INVENTORY ARCHIVER]: Saving {0} assets for items", m_assetUuids.Count); + m_assetGatherer.GatherAll(); + + m_log.DebugFormat( + "[INVENTORY ARCHIVER]: Saving {0} assets for items", m_assetGatherer.GatheredUuids.Count); AssetsRequest ar = new AssetsRequest( new AssetsArchiver(m_archiveWriter), - m_assetUuids, m_scene.AssetService, + m_assetGatherer.GatheredUuids, m_scene.AssetService, m_scene.UserAccountService, m_scene.RegionInfo.ScopeID, options, ReceivedAllAssets); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 2ddb599..fceda80 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -605,8 +605,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // so.Name, so.AttachedAvatar, url); IDictionary ids = new Dictionary(); - IteratingHGUuidGatherer uuidGatherer - = new IteratingHGUuidGatherer(Scene.AssetService, url, ids); + HGUuidGatherer uuidGatherer + = new HGUuidGatherer(Scene.AssetService, url, ids); uuidGatherer.AddForInspection(so); while (!uuidGatherer.Complete) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index 2ac1517..6343a81 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs @@ -412,12 +412,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // The act of gathering UUIDs downloads some assets from the remote server // but not all... - Dictionary ids = new Dictionary(); HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL); - uuidGatherer.GatherAssetUuids(assetID, meta.Type, ids); - m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", ids.Count); + uuidGatherer.AddForInspection(assetID); + uuidGatherer.GatherAll(); + + m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", uuidGatherer.GatheredUuids.Count); bool success = true; - foreach (UUID uuid in ids.Keys) + foreach (UUID uuid in uuidGatherer.GatheredUuids.Keys) if (FetchAsset(userAssetURL, uuid) == null) success = false; @@ -428,7 +429,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_log.DebugFormat("[HG ASSET MAPPER]: Successfully got item {0} from asset server {1}", assetID, userAssetURL); } - public void Post(UUID assetID, UUID ownerID, string userAssetURL) { m_log.DebugFormat("[HG ASSET MAPPER]: Starting to send asset {0} with children to asset server {1}", assetID, userAssetURL); @@ -442,9 +442,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess return; } - Dictionary ids = new Dictionary(); HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); - uuidGatherer.GatherAssetUuids(asset.FullID, asset.Type, ids); + uuidGatherer.AddForInspection(asset.FullID); // Check which assets already exist in the destination server @@ -452,16 +451,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (!url.EndsWith("/") && !url.EndsWith("=")) url = url + "/"; - string[] remoteAssetIDs = new string[ids.Count]; + string[] remoteAssetIDs = new string[uuidGatherer.GatheredUuids.Count]; int i = 0; - foreach (UUID id in ids.Keys) + foreach (UUID id in uuidGatherer.GatheredUuids.Keys) remoteAssetIDs[i++] = url + id.ToString(); bool[] exist = m_scene.AssetService.AssetsExist(remoteAssetIDs); var existSet = new HashSet(); i = 0; - foreach (UUID id in ids.Keys) + foreach (UUID id in uuidGatherer.GatheredUuids.Keys) { if (exist[i]) existSet.Add(id.ToString()); @@ -472,7 +471,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess bool success = true; - foreach (UUID uuid in ids.Keys) + foreach (UUID uuid in uuidGatherer.GatheredUuids.Keys) { if (!existSet.Contains(uuid.ToString())) { diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index b7d7c26..d67bdce 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs @@ -219,7 +219,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary assetUuids) { - m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName); + m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.Name); EntityBase[] entities = scene.GetEntities(); List sceneObjects = new List(); @@ -253,13 +253,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (SaveAssets) { - UuidGatherer assetGatherer = new UuidGatherer(scene.AssetService); + UuidGatherer assetGatherer = new UuidGatherer(scene.AssetService, assetUuids); int prevAssets = assetUuids.Count; foreach (SceneObjectGroup sceneObject in sceneObjects) - { - assetGatherer.GatherAssetUuids(sceneObject, assetUuids); - } + assetGatherer.AddForInspection(sceneObject); + + assetGatherer.GatherAll(); m_log.DebugFormat( "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets", -- cgit v1.1