aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
diff options
context:
space:
mode:
authorteravus2012-11-15 10:05:16 -0500
committerteravus2012-11-15 10:05:16 -0500
commite9153e1d1aae50024d8cd05fe14a9bce34343a0e (patch)
treebc111d34f95a26b99c7e34d9e495dc14d1802cc3 /OpenSim/Region/Framework/Scenes/UuidGatherer.cs
parentMerge master into teravuswork (diff)
downloadopensim-SC-e9153e1d1aae50024d8cd05fe14a9bce34343a0e.zip
opensim-SC-e9153e1d1aae50024d8cd05fe14a9bce34343a0e.tar.gz
opensim-SC-e9153e1d1aae50024d8cd05fe14a9bce34343a0e.tar.bz2
opensim-SC-e9153e1d1aae50024d8cd05fe14a9bce34343a0e.tar.xz
Revert "Merge master into teravuswork", it should have been avination, not master.
This reverts commit dfac269032300872c4d0dc507f4f9062d102b0f4, reversing changes made to 619c39e5144f15aca129d6d999bcc5c34133ee64.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs138
1 files changed, 47 insertions, 91 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 2279e62..411e421 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -52,23 +52,26 @@ namespace OpenSim.Region.Framework.Scenes
52 public class UuidGatherer 52 public class UuidGatherer
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55
56 /// <summary>
57 /// Asset cache used for gathering assets
58 /// </summary>
59 protected IAssetService m_assetCache;
60
61 /// <summary>
62 /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
63 /// asset was found by the asset service.
64 /// </summary>
65 private AssetBase m_requestedObjectAsset;
55 66
56 protected IAssetService m_assetService; 67 /// <summary>
57 68 /// Signal whether we are currently waiting for the asset service to deliver an asset.
58// /// <summary> 69 /// </summary>
59// /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate 70 private bool m_waitingForObjectAsset;
60// /// asset was found by the asset service.
61// /// </summary>
62// private AssetBase m_requestedObjectAsset;
63//
64// /// <summary>
65// /// Signal whether we are currently waiting for the asset service to deliver an asset.
66// /// </summary>
67// private bool m_waitingForObjectAsset;
68 71
69 public UuidGatherer(IAssetService assetService) 72 public UuidGatherer(IAssetService assetCache)
70 { 73 {
71 m_assetService = assetService; 74 m_assetCache = assetCache;
72 } 75 }
73 76
74 /// <summary> 77 /// <summary>
@@ -188,18 +191,18 @@ namespace OpenSim.Region.Framework.Scenes
188 } 191 }
189 } 192 }
190 193
191// /// <summary> 194 /// <summary>
192// /// The callback made when we request the asset for an object from the asset service. 195 /// The callback made when we request the asset for an object from the asset service.
193// /// </summary> 196 /// </summary>
194// private void AssetReceived(string id, Object sender, AssetBase asset) 197 private void AssetReceived(string id, Object sender, AssetBase asset)
195// { 198 {
196// lock (this) 199 lock (this)
197// { 200 {
198// m_requestedObjectAsset = asset; 201 m_requestedObjectAsset = asset;
199// m_waitingForObjectAsset = false; 202 m_waitingForObjectAsset = false;
200// Monitor.Pulse(this); 203 Monitor.Pulse(this);
201// } 204 }
202// } 205 }
203 206
204 /// <summary> 207 /// <summary>
205 /// Get an asset synchronously, potentially using an asynchronous callback. If the 208 /// Get an asset synchronously, potentially using an asynchronous callback. If the
@@ -209,29 +212,25 @@ namespace OpenSim.Region.Framework.Scenes
209 /// <returns></returns> 212 /// <returns></returns>
210 protected virtual AssetBase GetAsset(UUID uuid) 213 protected virtual AssetBase GetAsset(UUID uuid)
211 { 214 {
212 return m_assetService.Get(uuid.ToString()); 215 m_waitingForObjectAsset = true;
216 m_assetCache.Get(uuid.ToString(), this, AssetReceived);
217
218 // The asset cache callback can either
219 //
220 // 1. Complete on the same thread (if the asset is already in the cache) or
221 // 2. Come in via a different thread (if we need to go fetch it).
222 //
223 // The code below handles both these alternatives.
224 lock (this)
225 {
226 if (m_waitingForObjectAsset)
227 {
228 Monitor.Wait(this);
229 m_waitingForObjectAsset = false;
230 }
231 }
213 232
214 // XXX: Switching to do this synchronously where the call was async before but we always waited for it 233 return m_requestedObjectAsset;
215 // to complete anyway!
216// m_waitingForObjectAsset = true;
217// m_assetCache.Get(uuid.ToString(), this, AssetReceived);
218//
219// // The asset cache callback can either
220// //
221// // 1. Complete on the same thread (if the asset is already in the cache) or
222// // 2. Come in via a different thread (if we need to go fetch it).
223// //
224// // The code below handles both these alternatives.
225// lock (this)
226// {
227// if (m_waitingForObjectAsset)
228// {
229// Monitor.Wait(this);
230// m_waitingForObjectAsset = false;
231// }
232// }
233//
234// return m_requestedObjectAsset;
235 } 234 }
236 235
237 /// <summary> 236 /// <summary>
@@ -362,47 +361,4 @@ namespace OpenSim.Region.Framework.Scenes
362 } 361 }
363 } 362 }
364 } 363 }
365
366 public class HGUuidGatherer : UuidGatherer
367 {
368 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
369
370 protected string m_assetServerURL;
371
372 public HGUuidGatherer(IAssetService assetService, string assetServerURL)
373 : base(assetService)
374 {
375 m_assetServerURL = assetServerURL;
376 if (!m_assetServerURL.EndsWith("/") && !m_assetServerURL.EndsWith("="))
377 m_assetServerURL = m_assetServerURL + "/";
378 }
379
380 protected override AssetBase GetAsset(UUID uuid)
381 {
382 if (string.Empty == m_assetServerURL)
383 return base.GetAsset(uuid);
384 else
385 return FetchAsset(uuid);
386 }
387
388 public AssetBase FetchAsset(UUID assetID)
389 {
390
391 // Test if it's already here
392 AssetBase asset = m_assetService.Get(assetID.ToString());
393 if (asset == null)
394 {
395 // It's not, so fetch it from abroad
396 asset = m_assetService.Get(m_assetServerURL + assetID.ToString());
397 if (asset != null)
398 m_log.DebugFormat("[HGUUIDGatherer]: Copied asset {0} from {1} to local asset server", assetID, m_assetServerURL);
399 else
400 m_log.DebugFormat("[HGUUIDGatherer]: Failed to fetch asset {0} from {1}", assetID, m_assetServerURL);
401 }
402 //else
403 // m_log.DebugFormat("[HGUUIDGatherer]: Asset {0} from {1} was already here", assetID, m_assetServerURL);
404
405 return asset;
406 }
407 }
408} 364}