diff options
author | Justin Clarke Casey | 2008-02-20 17:34:10 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-02-20 17:34:10 +0000 |
commit | 877713999ce9bcf63e9fafa76cc7d2283ee2e6c2 (patch) | |
tree | a777abaadb3556af6933a5ac6fa85af6647629ed /OpenSim/Framework | |
parent | llSetTimerEvent was setting seconds as milliseconds causing major problems in... (diff) | |
download | opensim-SC-877713999ce9bcf63e9fafa76cc7d2283ee2e6c2.zip opensim-SC-877713999ce9bcf63e9fafa76cc7d2283ee2e6c2.tar.gz opensim-SC-877713999ce9bcf63e9fafa76cc7d2283ee2e6c2.tar.bz2 opensim-SC-877713999ce9bcf63e9fafa76cc7d2283ee2e6c2.tar.xz |
* Report 'asset not found' situations back to UserTextureDownloadService
* This fixes some of the 'runaway downloads' problem but not all of it
* Also fix up logging messages so texture requests are reported as such rather than as assets
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetCache.cs | 70 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 9 | ||||
-rw-r--r-- | OpenSim/Framework/IAssetServer.cs | 12 |
3 files changed, 65 insertions, 26 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index dacb321..049df0c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs | |||
@@ -116,7 +116,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
116 | 116 | ||
117 | public void Clear() | 117 | public void Clear() |
118 | { | 118 | { |
119 | m_log.Info("[ASSETSTORAGE]: Clearing Asset cache"); | 119 | m_log.Info("[ASSET CACHE]: Clearing Asset cache"); |
120 | Initialize(); | 120 | Initialize(); |
121 | } | 121 | } |
122 | 122 | ||
@@ -135,7 +135,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
135 | 135 | ||
136 | public AssetCache(IAssetServer assetServer) | 136 | public AssetCache(IAssetServer assetServer) |
137 | { | 137 | { |
138 | m_log.Info("[ASSETSTORAGE]: Creating Asset cache"); | 138 | m_log.Info("[ASSET CACHE]: Creating Asset cache"); |
139 | Initialize(); | 139 | Initialize(); |
140 | 140 | ||
141 | m_assetServer = assetServer; | 141 | m_assetServer = assetServer; |
@@ -161,7 +161,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
161 | } | 161 | } |
162 | catch (Exception e) | 162 | catch (Exception e) |
163 | { | 163 | { |
164 | m_log.Error("[ASSETCACHE]: " + e.ToString()); | 164 | m_log.Error("[ASSET CACHE]: " + e.ToString()); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | } | 167 | } |
@@ -204,21 +204,28 @@ namespace OpenSim.Framework.Communications.Cache | |||
204 | return false; | 204 | return false; |
205 | } | 205 | } |
206 | 206 | ||
207 | public void GetAsset(LLUUID assetId, AssetRequestCallback callback) | 207 | /// <summary> |
208 | /// Asynchronously retrieve an asset. | ||
209 | /// </summary> | ||
210 | /// <param name="assetId"></param> | ||
211 | /// <param name="callback"> | ||
212 | /// A callback invoked when the asset has either been found or not found. | ||
213 | /// If the asset was found this is called with the asset UUID and the asset data | ||
214 | /// If the asset was not found this is still called with the asset UUID but with a null asset data reference</param> | ||
215 | public void GetAsset(LLUUID assetId, AssetRequestCallback callback, bool isTexture) | ||
208 | { | 216 | { |
209 | AssetBase asset; | 217 | AssetBase asset; |
210 | 218 | ||
211 | if (TryGetCachedAsset(assetId, out asset)) | 219 | if (TryGetCachedAsset(assetId, out asset)) |
212 | { | 220 | { |
213 | |||
214 | callback(assetId, asset); | 221 | callback(assetId, asset); |
215 | } | 222 | } |
216 | else | 223 | else |
217 | { | 224 | { |
218 | NewAssetRequest req = new NewAssetRequest(assetId, callback); | 225 | NewAssetRequest req = new NewAssetRequest(assetId, callback); |
219 | 226 | ||
227 | // Make sure we always have a request list to which to add the asset | ||
220 | AssetRequestsList requestList; | 228 | AssetRequestsList requestList; |
221 | |||
222 | lock (RequestLists) | 229 | lock (RequestLists) |
223 | { | 230 | { |
224 | if (RequestLists.TryGetValue(assetId, out requestList)) | 231 | if (RequestLists.TryGetValue(assetId, out requestList)) |
@@ -231,22 +238,22 @@ namespace OpenSim.Framework.Communications.Cache | |||
231 | } | 238 | } |
232 | } | 239 | } |
233 | 240 | ||
234 | m_log.DebugFormat("[ASSETCACHE]: Added request for asset {0}", assetId); | 241 | m_log.DebugFormat("[ASSET CACHE]: Added request for {0} {1}", isTexture ? "texture" : "asset", assetId); |
235 | requestList.Requests.Add(req); | 242 | requestList.Requests.Add(req); |
236 | 243 | ||
237 | m_assetServer.RequestAsset(assetId, false); | 244 | m_assetServer.RequestAsset(assetId, isTexture); |
238 | } | 245 | } |
239 | } | 246 | } |
240 | 247 | ||
241 | /// <summary> | 248 | /// <summary> |
242 | /// Get an asset. If the asset isn't in the cache, a request will be made to the persistent store to | 249 | /// Synchronously retreive an asset. If the asset isn't in the cache, a request will be made to the persistent store to |
243 | /// load it into the cache. | 250 | /// load it into the cache. |
244 | /// | 251 | /// |
245 | /// XXX We'll keep polling the cache until we get the asset or we exceed | 252 | /// XXX We'll keep polling the cache until we get the asset or we exceed |
246 | /// the allowed number of polls. This isn't a very good way of doing things since a single thread | 253 | /// the allowed number of polls. This isn't a very good way of doing things since a single thread |
247 | /// is processing inbound packets, so if the asset server is slow, we could block this for up to | 254 | /// is processing inbound packets, so if the asset server is slow, we could block this for up to |
248 | /// the timeout period. What we might want to do is register asynchronous callbacks on asset | 255 | /// the timeout period. What we might want to do is register asynchronous callbacks on asset |
249 | /// receipt in the same manner as the nascent (but not yet active) TextureDownloadModule. Of course, | 256 | /// receipt in the same manner as the TextureDownloadModule. Of course, |
250 | /// a timeout before asset receipt usually isn't fatal, the operation will work on the retry when the | 257 | /// a timeout before asset receipt usually isn't fatal, the operation will work on the retry when the |
251 | /// asset is much more likely to have made it into the cache. | 258 | /// asset is much more likely to have made it into the cache. |
252 | /// </summary> | 259 | /// </summary> |
@@ -276,7 +283,8 @@ namespace OpenSim.Framework.Communications.Cache | |||
276 | } | 283 | } |
277 | } while (--maxPolls > 0); | 284 | } while (--maxPolls > 0); |
278 | 285 | ||
279 | m_log.WarnFormat("[ASSETCACHE]: Asset {0} was not received before the retrieval timeout was reached", assetID.ToString()); | 286 | m_log.WarnFormat("[ASSET CACHE]: {0} {1} was not received before the retrieval timeout was reached", |
287 | isTexture ? "texture" : "asset", assetID.ToString()); | ||
280 | 288 | ||
281 | return null; | 289 | return null; |
282 | } | 290 | } |
@@ -348,7 +356,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
348 | } | 356 | } |
349 | } | 357 | } |
350 | 358 | ||
351 | m_log.InfoFormat("[ASSETCACHE]: Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result); | 359 | m_log.InfoFormat("[ASSET CACHE]: Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result); |
352 | } | 360 | } |
353 | 361 | ||
354 | public AssetBase CopyAsset(LLUUID assetID) | 362 | public AssetBase CopyAsset(LLUUID assetID) |
@@ -367,9 +375,10 @@ namespace OpenSim.Framework.Communications.Cache | |||
367 | } | 375 | } |
368 | } | 376 | } |
369 | 377 | ||
378 | // See IAssetReceiver | ||
370 | public void AssetReceived(AssetBase asset, bool IsTexture) | 379 | public void AssetReceived(AssetBase asset, bool IsTexture) |
371 | { | 380 | { |
372 | m_log.InfoFormat("[ASSETCACHE]: Recieved {0} [{1}]", IsTexture ? "texture" : "asset", asset.FullID); | 381 | m_log.InfoFormat("[ASSET CACHE]: Recieved {0} [{1}]", IsTexture ? "texture" : "asset", asset.FullID); |
373 | 382 | ||
374 | if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server | 383 | if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server |
375 | { | 384 | { |
@@ -383,7 +392,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
383 | TextureImage image = new TextureImage(asset); | 392 | TextureImage image = new TextureImage(asset); |
384 | if (Textures.ContainsKey(image.FullID)) | 393 | if (Textures.ContainsKey(image.FullID)) |
385 | { | 394 | { |
386 | m_log.InfoFormat("[ASSETCACHE]: There's already an texture {0} in memory. Skipping.", asset.FullID); | 395 | m_log.InfoFormat("[ASSET CACHE]: There's already an texture {0} in memory. Skipping.", asset.FullID); |
387 | } | 396 | } |
388 | else | 397 | else |
389 | { | 398 | { |
@@ -396,7 +405,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
396 | 405 | ||
397 | if (RequestedTextures.ContainsKey(image.FullID)) | 406 | if (RequestedTextures.ContainsKey(image.FullID)) |
398 | { | 407 | { |
399 | m_log.InfoFormat("[ASSETCACHE]: Moving {0} from RequestedTextures to TextureRequests", asset.FullID); | 408 | m_log.InfoFormat("[ASSET CACHE]: Moving {0} from RequestedTextures to TextureRequests", asset.FullID); |
400 | 409 | ||
401 | AssetRequest req = RequestedTextures[image.FullID]; | 410 | AssetRequest req = RequestedTextures[image.FullID]; |
402 | req.ImageInfo = image; | 411 | req.ImageInfo = image; |
@@ -413,7 +422,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
413 | AssetInfo assetInf = new AssetInfo(asset); | 422 | AssetInfo assetInf = new AssetInfo(asset); |
414 | if (Assets.ContainsKey(assetInf.FullID)) | 423 | if (Assets.ContainsKey(assetInf.FullID)) |
415 | { | 424 | { |
416 | m_log.InfoFormat("[ASSETCACHE]: There's already an asset {0} in memory. Skipping.", asset.FullID); | 425 | m_log.InfoFormat("[ASSET CACHE]: There's already an asset {0} in memory. Skipping.", asset.FullID); |
417 | } | 426 | } |
418 | else | 427 | else |
419 | { | 428 | { |
@@ -426,7 +435,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
426 | 435 | ||
427 | if (RequestedAssets.ContainsKey(assetInf.FullID)) | 436 | if (RequestedAssets.ContainsKey(assetInf.FullID)) |
428 | { | 437 | { |
429 | m_log.InfoFormat("[ASSETCACHE]: Moving {0} from RequestedAssets to AssetRequests", asset.FullID); | 438 | m_log.InfoFormat("[ASSET CACHE]: Moving {0} from RequestedAssets to AssetRequests", asset.FullID); |
430 | 439 | ||
431 | AssetRequest req = RequestedAssets[assetInf.FullID]; | 440 | AssetRequest req = RequestedAssets[assetInf.FullID]; |
432 | req.AssetInf = assetInf; | 441 | req.AssetInf = assetInf; |
@@ -455,12 +464,17 @@ namespace OpenSim.Framework.Communications.Cache | |||
455 | } | 464 | } |
456 | } | 465 | } |
457 | 466 | ||
467 | // See IAssetReceiver | ||
458 | public void AssetNotFound(LLUUID assetID) | 468 | public void AssetNotFound(LLUUID assetID) |
459 | { | 469 | { |
460 | //m_log.ErrorFormat("[ASSET CACHE]: Unhandled AssetNotFound for {0}", assetID); | 470 | //m_log.ErrorFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); |
461 | 471 | ||
472 | // The 'image not found' packet needs to happen, but RequestedTextures is not actually used (should be cleaned up) | ||
473 | // It might also be better to do this in the TextureDownloadModule | ||
474 | /* | ||
475 | * | ||
462 | AssetRequest req; | 476 | AssetRequest req; |
463 | 477 | ||
464 | if (RequestedTextures.TryGetValue(assetID, out req)) | 478 | if (RequestedTextures.TryGetValue(assetID, out req)) |
465 | { | 479 | { |
466 | m_log.WarnFormat("[ASSET CACHE]: sending image not found for {0}", assetID); | 480 | m_log.WarnFormat("[ASSET CACHE]: sending image not found for {0}", assetID); |
@@ -473,6 +487,20 @@ namespace OpenSim.Framework.Communications.Cache | |||
473 | { | 487 | { |
474 | m_log.ErrorFormat("[ASSET CACHE]: Asset [{0}] not found, but couldn't find any users to send to ", assetID); | 488 | m_log.ErrorFormat("[ASSET CACHE]: Asset [{0}] not found, but couldn't find any users to send to ", assetID); |
475 | } | 489 | } |
490 | */ | ||
491 | |||
492 | // Notify callers | ||
493 | lock (RequestLists) | ||
494 | { | ||
495 | AssetRequestsList reqList = RequestLists[assetID]; | ||
496 | foreach (NewAssetRequest req in reqList.Requests) | ||
497 | { | ||
498 | req.Callback(assetID, null); | ||
499 | } | ||
500 | |||
501 | RequestLists.Remove(assetID); | ||
502 | reqList.Requests.Clear(); | ||
503 | } | ||
476 | } | 504 | } |
477 | 505 | ||
478 | private int CalculateNumPackets(byte[] data) | 506 | private int CalculateNumPackets(byte[] data) |
@@ -726,4 +754,4 @@ namespace OpenSim.Framework.Communications.Cache | |||
726 | } | 754 | } |
727 | } | 755 | } |
728 | } | 756 | } |
729 | } \ No newline at end of file | 757 | } |
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 9d9bc1e..8e670b5 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs | |||
@@ -37,7 +37,8 @@ namespace OpenSim.Framework.Communications.Cache | |||
37 | { | 37 | { |
38 | public abstract class AssetServerBase : IAssetServer | 38 | public abstract class AssetServerBase : IAssetServer |
39 | { | 39 | { |
40 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 40 | private static readonly log4net.ILog m_log |
41 | = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
41 | 42 | ||
42 | protected IAssetReceiver m_receiver; | 43 | protected IAssetReceiver m_receiver; |
43 | protected BlockingQueue<AssetRequest> m_assetRequests; | 44 | protected BlockingQueue<AssetRequest> m_assetRequests; |
@@ -70,13 +71,13 @@ namespace OpenSim.Framework.Communications.Cache | |||
70 | 71 | ||
71 | if (asset != null) | 72 | if (asset != null) |
72 | { | 73 | { |
73 | //m_log.InfoFormat("[ASSET]: Asset {0} received from asset server", req.AssetID); | 74 | //m_log.InfoFormat("[ASSETSERVER]: Asset {0} received from asset server", req.AssetID); |
74 | 75 | ||
75 | m_receiver.AssetReceived(asset, req.IsTexture); | 76 | m_receiver.AssetReceived(asset, req.IsTexture); |
76 | } | 77 | } |
77 | else | 78 | else |
78 | { | 79 | { |
79 | m_log.ErrorFormat("[ASSET]: Asset {0} not found by asset server", req.AssetID); | 80 | m_log.ErrorFormat("[ASSETSERVER]: Asset {0} not found by asset server", req.AssetID); |
80 | 81 | ||
81 | m_receiver.AssetNotFound(req.AssetID); | 82 | m_receiver.AssetNotFound(req.AssetID); |
82 | } | 83 | } |
@@ -131,7 +132,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
131 | req.IsTexture = isTexture; | 132 | req.IsTexture = isTexture; |
132 | m_assetRequests.Enqueue(req); | 133 | m_assetRequests.Enqueue(req); |
133 | 134 | ||
134 | m_log.InfoFormat("[ASSET]: Added {0} to request queue", assetID); | 135 | m_log.InfoFormat("[ASSETSERVER]: Added {0} to request queue", assetID); |
135 | } | 136 | } |
136 | 137 | ||
137 | public virtual void UpdateAsset(AssetBase asset) | 138 | public virtual void UpdateAsset(AssetBase asset) |
diff --git a/OpenSim/Framework/IAssetServer.cs b/OpenSim/Framework/IAssetServer.cs index df36623..cbf0759 100644 --- a/OpenSim/Framework/IAssetServer.cs +++ b/OpenSim/Framework/IAssetServer.cs | |||
@@ -46,7 +46,17 @@ namespace OpenSim.Framework | |||
46 | // could change to delegate? | 46 | // could change to delegate? |
47 | public interface IAssetReceiver | 47 | public interface IAssetReceiver |
48 | { | 48 | { |
49 | /// <summary> | ||
50 | /// Call back made when a requested asset has been retrieved by an asset server | ||
51 | /// </summary> | ||
52 | /// <param name="asset"></param> | ||
53 | /// <param name="IsTexture"></param> | ||
49 | void AssetReceived(AssetBase asset, bool IsTexture); | 54 | void AssetReceived(AssetBase asset, bool IsTexture); |
55 | |||
56 | /// <summary> | ||
57 | /// Call back made when an asset server could not retrieve a requested asset | ||
58 | /// </summary> | ||
59 | /// <param name="assetID"></param> | ||
50 | void AssetNotFound(LLUUID assetID); | 60 | void AssetNotFound(LLUUID assetID); |
51 | } | 61 | } |
52 | 62 | ||
@@ -54,4 +64,4 @@ namespace OpenSim.Framework | |||
54 | { | 64 | { |
55 | IAssetServer GetAssetServer(); | 65 | IAssetServer GetAssetServer(); |
56 | } | 66 | } |
57 | } \ No newline at end of file | 67 | } |