diff options
author | Justin Clarke Casey | 2008-06-16 15:36:01 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-06-16 15:36:01 +0000 |
commit | ba69cc31e5bfb3386880d4bc142df236531ab055 (patch) | |
tree | a1a6013b72f01b336aef115ac34d1cde6a4c29da /OpenSim/Region/Environment | |
parent | the beginning of the great id format migration. This makes (diff) | |
download | opensim-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 '')
3 files changed, 113 insertions, 70 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 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs new file mode 100644 index 0000000..2021b70 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using OpenSim.Framework; | ||
29 | using OpenSim.Framework.Communications.Cache; | ||
30 | using OpenSim.Region.Environment.Interfaces; | ||
31 | using OpenSim.Region.Environment.Scenes; | ||
32 | using System.Collections.Generic; | ||
33 | using System.Threading; | ||
34 | using libsecondlife; | ||
35 | |||
36 | namespace OpenSim.Region.Environment.Modules.World.Archiver | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Encapsulate the asynchronous requests for the assets required for an archive operation | ||
40 | /// </summary> | ||
41 | class AssetsRequest | ||
42 | { | ||
43 | /// <summary> | ||
44 | /// Callback used when all the assets requested have been received. | ||
45 | /// </summary> | ||
46 | protected AssetsRequestCallback m_assetsRequestCallback; | ||
47 | |||
48 | /// <summary> | ||
49 | /// Assets retrieved in this request | ||
50 | /// </summary> | ||
51 | protected Dictionary<LLUUID, AssetBase> m_assets = new Dictionary<LLUUID, AssetBase>(); | ||
52 | |||
53 | /// <summary> | ||
54 | /// Record the number of asset replies required so we know when we've finished | ||
55 | /// </summary> | ||
56 | private int m_repliesRequired; | ||
57 | |||
58 | /// <summary> | ||
59 | /// Asset cache used to request the assets | ||
60 | /// </summary> | ||
61 | protected AssetCache m_assetCache; | ||
62 | |||
63 | protected internal AssetsRequest(AssetsRequestCallback assetsRequestCallback, AssetCache assetCache, ICollection<LLUUID> uuids) | ||
64 | { | ||
65 | m_assetsRequestCallback = assetsRequestCallback; | ||
66 | m_assetCache = assetCache; | ||
67 | m_repliesRequired = uuids.Count; | ||
68 | |||
69 | // We can stop here if there are no assets to fetch | ||
70 | if (m_repliesRequired == 0) | ||
71 | m_assetsRequestCallback(m_assets); | ||
72 | |||
73 | foreach (LLUUID uuid in uuids) | ||
74 | { | ||
75 | m_assetCache.GetAsset(uuid, AssetRequestCallback, true); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | /// <summary> | ||
80 | /// Called back by the asset cache when it has the asset | ||
81 | /// </summary> | ||
82 | /// <param name="assetID"></param> | ||
83 | /// <param name="asset"></param> | ||
84 | public void AssetRequestCallback(LLUUID assetID, AssetBase asset) | ||
85 | { | ||
86 | m_assets[assetID] = asset; | ||
87 | |||
88 | if (m_assets.Count == m_repliesRequired) | ||
89 | { | ||
90 | // We want to stop using the asset cache thread asap as we now need to do the actual work of producing the archive | ||
91 | Thread newThread = new Thread(PerformAssetsRequestCallback); | ||
92 | newThread.Name = "OpenSimulator archiving thread post assets receipt"; | ||
93 | newThread.Start(); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | /// <summary> | ||
98 | /// Perform the callback on the original requester of the assets | ||
99 | /// </summary> | ||
100 | protected void PerformAssetsRequestCallback() | ||
101 | { | ||
102 | m_assetsRequestCallback(m_assets); | ||
103 | } | ||
104 | } | ||
105 | } | ||
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index dcc92cc..e274139 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -863,12 +863,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
863 | } | 863 | } |
864 | 864 | ||
865 | /// <summary> | 865 | /// <summary> |
866 | /// | 866 | /// Backup the scene. This acts as the main method of the backup thread. |
867 | /// </summary> | 867 | /// </summary> |
868 | /// <returns></returns> | 868 | /// <returns></returns> |
869 | public void Backup() | 869 | public void Backup() |
870 | { | 870 | { |
871 | EventManager.TriggerOnBackup(m_storageManager.DataStore); | 871 | EventManager.TriggerOnBackup(m_storageManager.DataStore); |
872 | m_backingup = false; | 872 | m_backingup = false; |
873 | //return true; | 873 | //return true; |
874 | } | 874 | } |