From bceef401fa9f7b9d56c5d1173ca5204aead0a57c Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 21 Sep 2012 01:36:23 +0100
Subject: Simplify UuidGatherer by performing asset fetch synchronously rather
than using the async call but waiting for completion anyway!
---
OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 84 +++++++++++++------------
1 file changed, 44 insertions(+), 40 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/UuidGatherer.cs')
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index efb68a2..af99090 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -57,17 +57,17 @@ namespace OpenSim.Region.Framework.Scenes
/// Asset cache used for gathering assets
///
protected IAssetService m_assetCache;
-
- ///
- /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
- /// asset was found by the asset service.
- ///
- private AssetBase m_requestedObjectAsset;
- ///
- /// Signal whether we are currently waiting for the asset service to deliver an asset.
- ///
- private bool m_waitingForObjectAsset;
+// ///
+// /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
+// /// asset was found by the asset service.
+// ///
+// private AssetBase m_requestedObjectAsset;
+//
+// ///
+// /// Signal whether we are currently waiting for the asset service to deliver an asset.
+// ///
+// private bool m_waitingForObjectAsset;
public UuidGatherer(IAssetService assetCache)
{
@@ -195,18 +195,18 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- ///
- /// The callback made when we request the asset for an object from the asset service.
- ///
- private void AssetReceived(string id, Object sender, AssetBase asset)
- {
- lock (this)
- {
- m_requestedObjectAsset = asset;
- m_waitingForObjectAsset = false;
- Monitor.Pulse(this);
- }
- }
+// ///
+// /// The callback made when we request the asset for an object from the asset service.
+// ///
+// private void AssetReceived(string id, Object sender, AssetBase asset)
+// {
+// lock (this)
+// {
+// m_requestedObjectAsset = asset;
+// m_waitingForObjectAsset = false;
+// Monitor.Pulse(this);
+// }
+// }
///
/// Get an asset synchronously, potentially using an asynchronous callback. If the
@@ -216,25 +216,29 @@ namespace OpenSim.Region.Framework.Scenes
///
protected virtual AssetBase GetAsset(UUID uuid)
{
- m_waitingForObjectAsset = true;
- m_assetCache.Get(uuid.ToString(), this, AssetReceived);
-
- // The asset cache callback can either
- //
- // 1. Complete on the same thread (if the asset is already in the cache) or
- // 2. Come in via a different thread (if we need to go fetch it).
- //
- // The code below handles both these alternatives.
- lock (this)
- {
- if (m_waitingForObjectAsset)
- {
- Monitor.Wait(this);
- m_waitingForObjectAsset = false;
- }
- }
+ return m_assetCache.Get(uuid.ToString());
- return m_requestedObjectAsset;
+ // XXX: Switching to do this synchronously where the call was async before but we always waited for it
+ // to complete anyway!
+// m_waitingForObjectAsset = true;
+// m_assetCache.Get(uuid.ToString(), this, AssetReceived);
+//
+// // The asset cache callback can either
+// //
+// // 1. Complete on the same thread (if the asset is already in the cache) or
+// // 2. Come in via a different thread (if we need to go fetch it).
+// //
+// // The code below handles both these alternatives.
+// lock (this)
+// {
+// if (m_waitingForObjectAsset)
+// {
+// Monitor.Wait(this);
+// m_waitingForObjectAsset = false;
+// }
+// }
+//
+// return m_requestedObjectAsset;
}
///
--
cgit v1.1
From 632a42e2b1e9a649be812ed57de1189778a370c9 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 21 Sep 2012 01:57:13 +0100
Subject: Rename UuidGather.m_assetCache to m_assetService. If HGUuidGatherer
hasn't been instantiated with an assetServerURL then call down to overriden
UuidGatherer.GetAsset() instead of calling m_assetService.GetAsset() itself -
these two codepaths are now identical.
---
OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/UuidGatherer.cs')
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index af99090..dc4a082 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -52,11 +52,8 @@ namespace OpenSim.Region.Framework.Scenes
public class UuidGatherer
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- ///
- /// Asset cache used for gathering assets
- ///
- protected IAssetService m_assetCache;
+
+ protected IAssetService m_assetService;
// ///
// /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
@@ -71,7 +68,7 @@ namespace OpenSim.Region.Framework.Scenes
public UuidGatherer(IAssetService assetCache)
{
- m_assetCache = assetCache;
+ m_assetService = assetCache;
}
///
@@ -216,7 +213,7 @@ namespace OpenSim.Region.Framework.Scenes
///
protected virtual AssetBase GetAsset(UUID uuid)
{
- return m_assetCache.Get(uuid.ToString());
+ return m_assetService.Get(uuid.ToString());
// XXX: Switching to do this synchronously where the call was async before but we always waited for it
// to complete anyway!
--
cgit v1.1
From cfa022700d3d099eee7cd25d18da875639506ea8 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Fri, 21 Sep 2012 16:45:16 -0700
Subject: Moved the small HGUuidGatherer class to the file where its parent
class is. No need to keep 2 separate files.
---
OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 36 +++++++++++++++++++++++++
1 file changed, 36 insertions(+)
(limited to 'OpenSim/Region/Framework/Scenes/UuidGatherer.cs')
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index dc4a082..383604d 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -366,4 +366,40 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
+
+ public class HGUuidGatherer : UuidGatherer
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ protected string m_assetServerURL;
+
+ public HGUuidGatherer(IAssetService assetService, string assetServerURL)
+ : base(assetService)
+ {
+ m_assetServerURL = assetServerURL;
+ }
+
+ protected override AssetBase GetAsset(UUID uuid)
+ {
+ if (string.Empty == m_assetServerURL)
+ return base.GetAsset(uuid);
+ else
+ return FetchAsset(m_assetServerURL, uuid);
+ }
+
+ public AssetBase FetchAsset(string url, UUID assetID)
+ {
+ if (!url.EndsWith("/") && !url.EndsWith("="))
+ url = url + "/";
+
+ AssetBase asset = m_assetService.Get(url + assetID.ToString());
+
+ if (asset != null)
+ {
+ m_log.DebugFormat("[HGUUIDGatherer]: Copied asset {0} from {1} to local asset server. ", asset.ID, url);
+ return asset;
+ }
+ return null;
+ }
+ }
}
--
cgit v1.1
From 21a6ef5bb63e56612b8e03002dbee9ff1fcdc4c0 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Fri, 21 Sep 2012 17:58:44 -0700
Subject: This fixes HG attachments' missing assets (textures, etc). Also,
further improvements on HGUuidGatherer: if the assets are already in this
grid don't fetch them again.
---
OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 27 ++++++++++++++++---------
1 file changed, 17 insertions(+), 10 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/UuidGatherer.cs')
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 383604d..28cd09f 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -377,6 +377,8 @@ namespace OpenSim.Region.Framework.Scenes
: base(assetService)
{
m_assetServerURL = assetServerURL;
+ if (!m_assetServerURL.EndsWith("/") && !m_assetServerURL.EndsWith("="))
+ m_assetServerURL = m_assetServerURL + "/";
}
protected override AssetBase GetAsset(UUID uuid)
@@ -384,22 +386,27 @@ namespace OpenSim.Region.Framework.Scenes
if (string.Empty == m_assetServerURL)
return base.GetAsset(uuid);
else
- return FetchAsset(m_assetServerURL, uuid);
+ return FetchAsset(uuid);
}
- public AssetBase FetchAsset(string url, UUID assetID)
+ public AssetBase FetchAsset(UUID assetID)
{
- if (!url.EndsWith("/") && !url.EndsWith("="))
- url = url + "/";
- AssetBase asset = m_assetService.Get(url + assetID.ToString());
-
- if (asset != null)
+ // Test if it's already here
+ AssetBase asset = m_assetService.Get(assetID.ToString());
+ if (asset == null)
{
- m_log.DebugFormat("[HGUUIDGatherer]: Copied asset {0} from {1} to local asset server. ", asset.ID, url);
- return asset;
+ // It's not, so fetch it from abroad
+ asset = m_assetService.Get(m_assetServerURL + assetID.ToString());
+ if (asset != null)
+ m_log.DebugFormat("[HGUUIDGatherer]: Copied asset {0} from {1} to local asset server", assetID, m_assetServerURL);
+ else
+ m_log.DebugFormat("[HGUUIDGatherer]: Failed to fetch asset {0} from {1}", assetID, m_assetServerURL);
}
- return null;
+ //else
+ // m_log.DebugFormat("[HGUUIDGatherer]: Asset {0} from {1} was already here", assetID, m_assetServerURL);
+
+ return asset;
}
}
}
--
cgit v1.1