aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-03-09 18:35:26 +0000
committerJustin Clarke Casey2009-03-09 18:35:26 +0000
commit1bf05a543c1328c31b7b107a3335f34e8d174ed8 (patch)
treeaf6917159ce713048f3a35e29ddc0b86a95ffe87
parent* Apply http://opensimulator.org/mantis/view.php?id=3280 (diff)
downloadopensim-SC-1bf05a543c1328c31b7b107a3335f34e8d174ed8.zip
opensim-SC-1bf05a543c1328c31b7b107a3335f34e8d174ed8.tar.gz
opensim-SC-1bf05a543c1328c31b7b107a3335f34e8d174ed8.tar.bz2
opensim-SC-1bf05a543c1328c31b7b107a3335f34e8d174ed8.tar.xz
* Move method documentation from AssetCache up to IAssetCache
* No functional changes
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs90
-rw-r--r--OpenSim/Framework/IAssetCache.cs71
2 files changed, 76 insertions, 85 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 30f7ddf..dfbdb09 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -37,8 +37,6 @@ using OpenSim.Framework.Statistics;
37 37
38namespace OpenSim.Framework.Communications.Cache 38namespace OpenSim.Framework.Communications.Cache
39{ 39{
40 // public delegate void AssetRequestCallback(UUID assetID, AssetBase asset);
41
42 /// <summary> 40 /// <summary>
43 /// Manages local cache of assets and their sending to viewers. 41 /// Manages local cache of assets and their sending to viewers.
44 /// </summary> 42 /// </summary>
@@ -49,7 +47,6 @@ namespace OpenSim.Framework.Communications.Cache
49 /// AssetNotFound(), which means they do share the same asset and texture caches. 47 /// AssetNotFound(), which means they do share the same asset and texture caches.
50 public class AssetCache : IAssetCache 48 public class AssetCache : IAssetCache
51 { 49 {
52
53 #region IPlugin 50 #region IPlugin
54 51
55 /// <summary> 52 /// <summary>
@@ -88,7 +85,6 @@ namespace OpenSim.Framework.Communications.Cache
88 assetCacheThread.IsBackground = true; 85 assetCacheThread.IsBackground = true;
89 assetCacheThread.Start(); 86 assetCacheThread.Start();
90 ThreadTracker.Add(assetCacheThread); 87 ThreadTracker.Add(assetCacheThread);
91
92 } 88 }
93 89
94 public virtual void Initialise(ConfigSettings settings, IAssetServer assetServer) 90 public virtual void Initialise(ConfigSettings settings, IAssetServer assetServer)
@@ -113,44 +109,27 @@ namespace OpenSim.Framework.Communications.Cache
113 private static readonly ILog m_log 109 private static readonly ILog m_log
114 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 110 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
115 111
116 /// <summary> 112 /// <value>
117 /// The cache of assets. This does not include textures.
118 /// </summary>
119 //private Dictionary<UUID, AssetInfo> Assets;
120
121 /// <summary>
122 /// The cache of textures.
123 /// </summary>
124 //private Dictionary<UUID, TextureImage> Textures;
125
126 /// <summary>
127 /// Assets requests which are waiting for asset server data. This includes texture requests 113 /// Assets requests which are waiting for asset server data. This includes texture requests
128 /// </summary> 114 /// </value>
129 private Dictionary<UUID, AssetRequest> RequestedAssets; 115 private Dictionary<UUID, AssetRequest> RequestedAssets;
130 116
131 /// <summary> 117 /// <value>
132 /// Asset requests with data which are ready to be sent back to requesters. This includes textures. 118 /// Asset requests with data which are ready to be sent back to requesters. This includes textures.
133 /// </summary> 119 /// </value>
134 private List<AssetRequest> AssetRequests; 120 private List<AssetRequest> AssetRequests;
135 121
136 /// <summary> 122 /// <value>
137 /// Until the asset request is fulfilled, each asset request is associated with a list of requesters 123 /// Until the asset request is fulfilled, each asset request is associated with a list of requesters
138 /// </summary> 124 /// </value>
139 private Dictionary<UUID, AssetRequestsList> RequestLists; 125 private Dictionary<UUID, AssetRequestsList> RequestLists;
140
141 /// <summary>
142 /// The 'server' from which assets can be requested and to which assets are persisted.
143 /// </summary>
144 private IAssetServer m_assetServer;
145 126
146 public IAssetServer AssetServer 127 public IAssetServer AssetServer
147 { 128 {
148 get { return m_assetServer; } 129 get { return m_assetServer; }
149 } 130 }
131 private IAssetServer m_assetServer;
150 132
151 /// <summary>
152 /// Report statistical data.
153 /// </summary>
154 public void ShowState() 133 public void ShowState()
155 { 134 {
156 m_log.InfoFormat("Memcache:{0} RequestLists:{1}", 135 m_log.InfoFormat("Memcache:{0} RequestLists:{1}",
@@ -160,9 +139,6 @@ namespace OpenSim.Framework.Communications.Cache
160 RequestLists.Count); 139 RequestLists.Count);
161 } 140 }
162 141
163 /// <summary>
164 /// Clear the asset cache.
165 /// </summary>
166 public void Clear() 142 public void Clear()
167 { 143 {
168 m_log.Info("[ASSET CACHE]: Clearing Asset cache"); 144 m_log.Info("[ASSET CACHE]: Clearing Asset cache");
@@ -214,12 +190,6 @@ namespace OpenSim.Framework.Communications.Cache
214 } 190 }
215 } 191 }
216 192
217 /// <summary>
218 /// Only get an asset if we already have it in the cache.
219 /// </summary>
220 /// <param name="assetId"></param>
221 /// <param name="asset"></param>
222 /// <returns>true if the asset was in the cache, false if it was not</returns>
223 public bool TryGetCachedAsset(UUID assetId, out AssetBase asset) 193 public bool TryGetCachedAsset(UUID assetId, out AssetBase asset)
224 { 194 {
225 Object tmp; 195 Object tmp;
@@ -234,15 +204,6 @@ namespace OpenSim.Framework.Communications.Cache
234 return false; 204 return false;
235 } 205 }
236 206
237 /// <summary>
238 /// Asynchronously retrieve an asset.
239 /// </summary>
240 /// <param name="assetId"></param>
241 /// <param name="callback">
242 /// <param name="isTexture"></param>
243 /// A callback invoked when the asset has either been found or not found.
244 /// If the asset was found this is called with the asset UUID and the asset data
245 /// If the asset was not found this is still called with the asset UUID but with a null asset data reference</param>
246 public void GetAsset(UUID assetId, AssetRequestCallback callback, bool isTexture) 207 public void GetAsset(UUID assetId, AssetRequestCallback callback, bool isTexture)
247 { 208 {
248 //m_log.DebugFormat("[ASSET CACHE]: Requesting {0} {1}", isTexture ? "texture" : "asset", assetId); 209 //m_log.DebugFormat("[ASSET CACHE]: Requesting {0} {1}", isTexture ? "texture" : "asset", assetId);
@@ -288,19 +249,6 @@ namespace OpenSim.Framework.Communications.Cache
288 } 249 }
289 } 250 }
290 251
291 /// <summary>
292 /// Synchronously retreive an asset. If the asset isn't in the cache, a request will be made to the persistent store to
293 /// load it into the cache.
294 /// </summary>
295 ///
296 /// XXX We'll keep polling the cache until we get the asset or we exceed
297 /// the allowed number of polls. This isn't a very good way of doing things since a single thread
298 /// is processing inbound packets, so if the asset server is slow, we could block this for up to
299 /// the timeout period. Whereever possible we want to use the asynchronous callback GetAsset()
300 ///
301 /// <param name="assetID"></param>
302 /// <param name="isTexture"></param>
303 /// <returns>null if the asset could not be retrieved</returns>
304 public AssetBase GetAsset(UUID assetID, bool isTexture) 252 public AssetBase GetAsset(UUID assetID, bool isTexture)
305 { 253 {
306 // I'm not going over 3 seconds since this will be blocking processing of all the other inbound 254 // I'm not going over 3 seconds since this will be blocking processing of all the other inbound
@@ -334,10 +282,6 @@ namespace OpenSim.Framework.Communications.Cache
334 return null; 282 return null;
335 } 283 }
336 284
337 /// <summary>
338 /// Add an asset to both the persistent store and the cache.
339 /// </summary>
340 /// <param name="asset"></param>
341 public void AddAsset(AssetBase asset) 285 public void AddAsset(AssetBase asset)
342 { 286 {
343 if (!m_memcache.Contains(asset.FullID)) 287 if (!m_memcache.Contains(asset.FullID))
@@ -371,13 +315,6 @@ namespace OpenSim.Framework.Communications.Cache
371 } 315 }
372 } 316 }
373 317
374 /// <summary>
375 /// Allows you to clear a specific asset by uuid out
376 /// of the asset cache. This is needed because the osdynamic
377 /// texture code grows the asset cache without bounds. The
378 /// real solution here is a much better cache archicture, but
379 /// this is a stop gap measure until we have such a thing.
380 /// </summary>
381 public void ExpireAsset(UUID uuid) 318 public void ExpireAsset(UUID uuid)
382 { 319 {
383 // uuid is unique, so no need to worry about it showing up 320 // uuid is unique, so no need to worry about it showing up
@@ -393,7 +330,6 @@ namespace OpenSim.Framework.Communications.Cache
393 // See IAssetReceiver 330 // See IAssetReceiver
394 public virtual void AssetReceived(AssetBase asset, bool IsTexture) 331 public virtual void AssetReceived(AssetBase asset, bool IsTexture)
395 { 332 {
396
397 AssetInfo assetInf = new AssetInfo(asset); 333 AssetInfo assetInf = new AssetInfo(asset);
398 if (!m_memcache.Contains(assetInf.FullID)) 334 if (!m_memcache.Contains(assetInf.FullID))
399 { 335 {
@@ -488,11 +424,6 @@ namespace OpenSim.Framework.Communications.Cache
488 return numPackets; 424 return numPackets;
489 } 425 }
490 426
491 /// <summary>
492 /// Handle an asset request from the client. The result will be sent back asynchronously.
493 /// </summary>
494 /// <param name="userInfo"></param>
495 /// <param name="transferRequest"></param>
496 public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) 427 public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest)
497 { 428 {
498 UUID requestID = UUID.Zero; 429 UUID requestID = UUID.Zero;
@@ -581,8 +512,8 @@ namespace OpenSim.Framework.Communications.Cache
581 { 512 {
582 req2 = new AssetRequestToClient(); 513 req2 = new AssetRequestToClient();
583 } 514 }
584 // Trying to limit memory usage by only creating AssetRequestToClient if needed 515
585 //req2 = new AssetRequestToClient(); 516 // Trying to limit memory usage by only creating AssetRequestToClient if needed
586 req2.AssetInf = req.AssetInf; 517 req2.AssetInf = req.AssetInf;
587 req2.AssetRequestSource = req.AssetRequestSource; 518 req2.AssetRequestSource = req.AssetRequestSource;
588 req2.DataPointer = req.DataPointer; 519 req2.DataPointer = req.DataPointer;
@@ -595,7 +526,6 @@ namespace OpenSim.Framework.Communications.Cache
595 req2.RequestAssetID = req.RequestAssetID; 526 req2.RequestAssetID = req.RequestAssetID;
596 req2.TransferRequestID = req.TransferRequestID; 527 req2.TransferRequestID = req.TransferRequestID;
597 req.RequestUser.SendAsset(req2); 528 req.RequestUser.SendAsset(req2);
598
599 } 529 }
600 530
601 //remove requests that have been completed 531 //remove requests that have been completed
diff --git a/OpenSim/Framework/IAssetCache.cs b/OpenSim/Framework/IAssetCache.cs
index 22f5755..8a184bb 100644
--- a/OpenSim/Framework/IAssetCache.cs
+++ b/OpenSim/Framework/IAssetCache.cs
@@ -30,25 +30,86 @@ using OpenMetaverse.Packets;
30 30
31namespace OpenSim.Framework 31namespace OpenSim.Framework
32{ 32{
33
34 public delegate void AssetRequestCallback(UUID assetId, AssetBase asset); 33 public delegate void AssetRequestCallback(UUID assetId, AssetBase asset);
35 34
35 /// <summary>
36 /// Interface to the local asset cache. This is the mechanism through which assets can be added and requested.
37 /// </summary>
36 public interface IAssetCache : IAssetReceiver, IPlugin 38 public interface IAssetCache : IAssetReceiver, IPlugin
37 { 39 {
38 40 /// <value>
41 /// The 'server' from which assets can be requested and to which assets are persisted.
42 /// </value>
39 IAssetServer AssetServer { get; } 43 IAssetServer AssetServer { get; }
44
45 void Initialise(ConfigSettings cs, IAssetServer server);
40 46
47 /// <summary>
48 /// Report statistical data to the log.
49 /// </summary>
41 void ShowState(); 50 void ShowState();
51
52 /// <summary>
53 /// Clear the asset cache.
54 /// </summary>
42 void Clear(); 55 void Clear();
56
57 /// <summary>
58 /// Get an asset only if it's already in the cache.
59 /// </summary>
60 /// <param name="assetId"></param>
61 /// <param name="asset"></param>
62 /// <returns>true if the asset was in the cache, false if it was not</returns>
43 bool TryGetCachedAsset(UUID assetID, out AssetBase asset); 63 bool TryGetCachedAsset(UUID assetID, out AssetBase asset);
64
65 /// <summary>
66 /// Asynchronously retrieve an asset.
67 /// </summary>
68 /// <param name="assetId"></param>
69 /// <param name="callback">
70 /// <param name="isTexture"></param>
71 /// A callback invoked when the asset has either been found or not found.
72 /// If the asset was found this is called with the asset UUID and the asset data
73 /// If the asset was not found this is still called with the asset UUID but with a null asset data reference</param>
44 void GetAsset(UUID assetID, AssetRequestCallback callback, bool isTexture); 74 void GetAsset(UUID assetID, AssetRequestCallback callback, bool isTexture);
75
76 /// <summary>
77 /// Synchronously retreive an asset. If the asset isn't in the cache, a request will be made to the persistent store to
78 /// load it into the cache.
79 /// </summary>
80 ///
81 /// XXX We'll keep polling the cache until we get the asset or we exceed
82 /// the allowed number of polls. This isn't a very good way of doing things since a single thread
83 /// is processing inbound packets, so if the asset server is slow, we could block this for up to
84 /// the timeout period. Whereever possible we want to use the asynchronous callback GetAsset()
85 ///
86 /// <param name="assetID"></param>
87 /// <param name="isTexture"></param>
88 /// <returns>null if the asset could not be retrieved</returns>
45 AssetBase GetAsset(UUID assetID, bool isTexture); 89 AssetBase GetAsset(UUID assetID, bool isTexture);
90
91 /// <summary>
92 /// Add an asset to both the persistent store and the cache.
93 /// </summary>
94 /// <param name="asset"></param>
46 void AddAsset(AssetBase asset); 95 void AddAsset(AssetBase asset);
96
97 /// <summary>
98 /// Expire an asset from the cache
99 /// </summary>
100 /// Allows you to clear a specific asset by uuid out
101 /// of the asset cache. This is needed because the osdynamic
102 /// texture code grows the asset cache without bounds. The
103 /// real solution here is a much better cache archicture, but
104 /// this is a stop gap measure until we have such a thing.
47 void ExpireAsset(UUID assetID); 105 void ExpireAsset(UUID assetID);
106
107 /// <summary>
108 /// Handle an asset request from the client. The result will be sent back asynchronously.
109 /// </summary>
110 /// <param name="userInfo"></param>
111 /// <param name="transferRequest"></param>
48 void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest); 112 void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest);
49
50 void Initialise(ConfigSettings cs, IAssetServer server);
51
52 } 113 }
53 114
54 public class AssetCachePluginInitialiser : PluginInitialiserBase 115 public class AssetCachePluginInitialiser : PluginInitialiserBase