diff options
author | Justin Clarke Casey | 2009-03-09 18:35:26 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-03-09 18:35:26 +0000 |
commit | 1bf05a543c1328c31b7b107a3335f34e8d174ed8 (patch) | |
tree | af6917159ce713048f3a35e29ddc0b86a95ffe87 /OpenSim/Framework/Communications | |
parent | * Apply http://opensimulator.org/mantis/view.php?id=3280 (diff) | |
download | opensim-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
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetCache.cs | 90 |
1 files changed, 10 insertions, 80 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 | ||
38 | namespace OpenSim.Framework.Communications.Cache | 38 | namespace 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 |