aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-06-16 15:36:01 +0000
committerJustin Clarke Casey2008-06-16 15:36:01 +0000
commitba69cc31e5bfb3386880d4bc142df236531ab055 (patch)
treea1a6013b72f01b336aef115ac34d1cde6a4c29da /OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs
parentthe beginning of the great id format migration. This makes (diff)
downloadopensim-SC_OLD-ba69cc31e5bfb3386880d4bc142df236531ab055.zip
opensim-SC_OLD-ba69cc31e5bfb3386880d4bc142df236531ab055.tar.gz
opensim-SC_OLD-ba69cc31e5bfb3386880d4bc142df236531ab055.tar.bz2
opensim-SC_OLD-ba69cc31e5bfb3386880d4bc142df236531ab055.tar.xz
* Refactor: Break out AssetsRequest to a separate file in the Archiver module
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs74
1 files changed, 6 insertions, 68 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs
index eab80ac..1d7042c 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs
@@ -97,6 +97,12 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
97 m_log.DebugFormat("[ARCHIVER]: Recording asset {0} in object {1}", tit.AssetID, part.UUID); 97 m_log.DebugFormat("[ARCHIVER]: Recording asset {0} in object {1}", tit.AssetID, part.UUID);
98 assetUuids[tit.AssetID] = 1; 98 assetUuids[tit.AssetID] = 1;
99 } 99 }
100 else
101 {
102 // TODO: Need to unpack every tit and go through its textures & items, recursively
103 // this will mean going through the 'assets' received multiple times so that we can
104 // unpack objects within objects before recursively requesting the inner assets
105 }
100 } 106 }
101 } 107 }
102 } 108 }
@@ -159,72 +165,4 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
159 return serialization; 165 return serialization;
160 } 166 }
161 } 167 }
162
163 /// <summary>
164 /// Encapsulate the asynchronous requests for the assets required for an archive operation
165 /// </summary>
166 class AssetsRequest
167 {
168 /// <summary>
169 /// Callback used when all the assets requested have been received.
170 /// </summary>
171 protected AssetsRequestCallback m_assetsRequestCallback;
172
173 /// <summary>
174 /// Assets retrieved in this request
175 /// </summary>
176 protected Dictionary<LLUUID, AssetBase> m_assets = new Dictionary<LLUUID, AssetBase>();
177
178 /// <summary>
179 /// Record the number of asset replies required so we know when we've finished
180 /// </summary>
181 private int m_repliesRequired;
182
183 /// <summary>
184 /// Asset cache used to request the assets
185 /// </summary>
186 protected AssetCache m_assetCache;
187
188 protected internal AssetsRequest(AssetsRequestCallback assetsRequestCallback, AssetCache assetCache, ICollection<LLUUID> uuids)
189 {
190 m_assetsRequestCallback = assetsRequestCallback;
191 m_assetCache = assetCache;
192 m_repliesRequired = uuids.Count;
193
194 // We can stop here if there are no assets to fetch
195 if (m_repliesRequired == 0)
196 m_assetsRequestCallback(m_assets);
197
198 foreach (LLUUID uuid in uuids)
199 {
200 m_assetCache.GetAsset(uuid, AssetRequestCallback, true);
201 }
202 }
203
204 /// <summary>
205 /// Called back by the asset cache when it has the asset
206 /// </summary>
207 /// <param name="assetID"></param>
208 /// <param name="asset"></param>
209 public void AssetRequestCallback(LLUUID assetID, AssetBase asset)
210 {
211 m_assets[assetID] = asset;
212
213 if (m_assets.Count == m_repliesRequired)
214 {
215 // We want to stop using the asset cache thread asap as we now need to do the actual work of producing the archive
216 Thread newThread = new Thread(PerformAssetsRequestCallback);
217 newThread.Name = "OpenSimulator archiving thread post assets receipt";
218 newThread.Start();
219 }
220 }
221
222 /// <summary>
223 /// Perform the callback on the original requester of the assets
224 /// </summary>
225 protected void PerformAssetsRequestCallback()
226 {
227 m_assetsRequestCallback(m_assets);
228 }
229 }
230} 168}