diff options
author | Mike Mazur | 2009-02-04 00:01:36 +0000 |
---|---|---|
committer | Mike Mazur | 2009-02-04 00:01:36 +0000 |
commit | 0c03a48fb2060eda4d288e2d2ca4e650ce000b4b (patch) | |
tree | a90465075960c92367b0a5e62db3121e4e3a139d /OpenSim/Framework/Communications/Cache/AssetCache.cs | |
parent | * Add another object to the existing save oar test (diff) | |
download | opensim-SC-0c03a48fb2060eda4d288e2d2ca4e650ce000b4b.zip opensim-SC-0c03a48fb2060eda4d288e2d2ca4e650ce000b4b.tar.gz opensim-SC-0c03a48fb2060eda4d288e2d2ca4e650ce000b4b.tar.bz2 opensim-SC-0c03a48fb2060eda4d288e2d2ca4e650ce000b4b.tar.xz |
- add OpenSim.Framework.AssetMetadata class. AssetBase is now composed of it
- trim trailing whitespace
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/AssetCache.cs')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetCache.cs | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 653597b..2b2467c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs | |||
@@ -42,7 +42,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
42 | /// <summary> | 42 | /// <summary> |
43 | /// Manages local cache of assets and their sending to viewers. | 43 | /// Manages local cache of assets and their sending to viewers. |
44 | /// </summary> | 44 | /// </summary> |
45 | /// | 45 | /// |
46 | /// This class actually encapsulates two largely separate mechanisms. One mechanism fetches assets either | 46 | /// This class actually encapsulates two largely separate mechanisms. One mechanism fetches assets either |
47 | /// synchronously or async and passes the data back to the requester. The second mechanism fetches assets and | 47 | /// synchronously or async and passes the data back to the requester. The second mechanism fetches assets and |
48 | /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and | 48 | /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and |
@@ -80,7 +80,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
80 | private Dictionary<UUID, AssetRequestsList> RequestLists; | 80 | private Dictionary<UUID, AssetRequestsList> RequestLists; |
81 | 81 | ||
82 | /// <summary> | 82 | /// <summary> |
83 | /// The 'server' from which assets can be requested and to which assets are persisted. | 83 | /// The 'server' from which assets can be requested and to which assets are persisted. |
84 | /// </summary> | 84 | /// </summary> |
85 | private readonly IAssetServer m_assetServer; | 85 | private readonly IAssetServer m_assetServer; |
86 | 86 | ||
@@ -211,7 +211,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
211 | else | 211 | else |
212 | { | 212 | { |
213 | // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); | 213 | // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); |
214 | 214 | ||
215 | NewAssetRequest req = new NewAssetRequest(callback); | 215 | NewAssetRequest req = new NewAssetRequest(callback); |
216 | AssetRequestsList requestList; | 216 | AssetRequestsList requestList; |
217 | 217 | ||
@@ -228,10 +228,10 @@ namespace OpenSim.Framework.Communications.Cache | |||
228 | // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); | 228 | // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); |
229 | requestList = new AssetRequestsList(); | 229 | requestList = new AssetRequestsList(); |
230 | requestList.TimeRequested = DateTime.Now; | 230 | requestList.TimeRequested = DateTime.Now; |
231 | requestList.Requests.Add(req); | 231 | requestList.Requests.Add(req); |
232 | 232 | ||
233 | RequestLists.Add(assetId, requestList); | 233 | RequestLists.Add(assetId, requestList); |
234 | 234 | ||
235 | m_assetServer.RequestAsset(assetId, isTexture); | 235 | m_assetServer.RequestAsset(assetId, isTexture); |
236 | } | 236 | } |
237 | } | 237 | } |
@@ -247,7 +247,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
247 | /// the allowed number of polls. This isn't a very good way of doing things since a single thread | 247 | /// the allowed number of polls. This isn't a very good way of doing things since a single thread |
248 | /// is processing inbound packets, so if the asset server is slow, we could block this for up to | 248 | /// is processing inbound packets, so if the asset server is slow, we could block this for up to |
249 | /// the timeout period. Whereever possible we want to use the asynchronous callback GetAsset() | 249 | /// the timeout period. Whereever possible we want to use the asynchronous callback GetAsset() |
250 | /// | 250 | /// |
251 | /// <param name="assetID"></param> | 251 | /// <param name="assetID"></param> |
252 | /// <param name="isTexture"></param> | 252 | /// <param name="isTexture"></param> |
253 | /// <returns>null if the asset could not be retrieved</returns> | 253 | /// <returns>null if the asset could not be retrieved</returns> |
@@ -264,7 +264,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
264 | { | 264 | { |
265 | return asset; | 265 | return asset; |
266 | } | 266 | } |
267 | 267 | ||
268 | m_assetServer.RequestAsset(assetID, isTexture); | 268 | m_assetServer.RequestAsset(assetID, isTexture); |
269 | 269 | ||
270 | do | 270 | do |
@@ -275,7 +275,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
275 | { | 275 | { |
276 | return asset; | 276 | return asset; |
277 | } | 277 | } |
278 | } | 278 | } |
279 | while (--maxPolls > 0); | 279 | while (--maxPolls > 0); |
280 | 280 | ||
281 | m_log.WarnFormat("[ASSET CACHE]: {0} {1} was not received before the retrieval timeout was reached", | 281 | m_log.WarnFormat("[ASSET CACHE]: {0} {1} was not received before the retrieval timeout was reached", |
@@ -290,17 +290,17 @@ namespace OpenSim.Framework.Communications.Cache | |||
290 | /// <param name="asset"></param> | 290 | /// <param name="asset"></param> |
291 | public void AddAsset(AssetBase asset) | 291 | public void AddAsset(AssetBase asset) |
292 | { | 292 | { |
293 | if (!m_memcache.Contains(asset.FullID)) | 293 | if (!m_memcache.Contains(asset.Metadata.FullID)) |
294 | { | 294 | { |
295 | m_log.Info("[CACHE] Caching " + asset.FullID + " for 24 hours from last access"); | 295 | m_log.Info("[CACHE] Caching " + asset.Metadata.FullID + " for 24 hours from last access"); |
296 | // Use 24 hour rolling asset cache. | 296 | // Use 24 hour rolling asset cache. |
297 | m_memcache.AddOrUpdate(asset.FullID, asset, TimeSpan.FromHours(24)); | 297 | m_memcache.AddOrUpdate(asset.Metadata.FullID, asset, TimeSpan.FromHours(24)); |
298 | 298 | ||
299 | // According to http://wiki.secondlife.com/wiki/AssetUploadRequest, Local signifies that the | 299 | // According to http://wiki.secondlife.com/wiki/AssetUploadRequest, Local signifies that the |
300 | // information is stored locally. It could disappear, in which case we could send the | 300 | // information is stored locally. It could disappear, in which case we could send the |
301 | // ImageNotInDatabase packet to tell the client this. | 301 | // ImageNotInDatabase packet to tell the client this. |
302 | // | 302 | // |
303 | // However, this doesn't quite appear to work with local textures that are part of an avatar's | 303 | // However, this doesn't quite appear to work with local textures that are part of an avatar's |
304 | // appearance texture set. Whilst sending an ImageNotInDatabase does trigger an automatic rebake | 304 | // appearance texture set. Whilst sending an ImageNotInDatabase does trigger an automatic rebake |
305 | // and reupload by the client, if those assets aren't pushed to the asset server anyway, then | 305 | // and reupload by the client, if those assets aren't pushed to the asset server anyway, then |
306 | // on crossing onto another region server, other avatars can no longer get the required textures. | 306 | // on crossing onto another region server, other avatars can no longer get the required textures. |
@@ -314,7 +314,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
314 | // But for now, we're going to take the easy way out and store local assets globally. | 314 | // But for now, we're going to take the easy way out and store local assets globally. |
315 | // | 315 | // |
316 | // TODO: Also, Temporary is now deprecated. We should start ignoring it and not passing it out from LLClientView. | 316 | // TODO: Also, Temporary is now deprecated. We should start ignoring it and not passing it out from LLClientView. |
317 | if (!asset.Temporary || asset.Local) | 317 | if (!asset.Metadata.Temporary || asset.Metadata.Local) |
318 | { | 318 | { |
319 | m_assetServer.StoreAsset(asset); | 319 | m_assetServer.StoreAsset(asset); |
320 | } | 320 | } |
@@ -345,25 +345,25 @@ namespace OpenSim.Framework.Communications.Cache | |||
345 | { | 345 | { |
346 | 346 | ||
347 | AssetInfo assetInf = new AssetInfo(asset); | 347 | AssetInfo assetInf = new AssetInfo(asset); |
348 | if (!m_memcache.Contains(assetInf.FullID)) | 348 | if (!m_memcache.Contains(assetInf.Metadata.FullID)) |
349 | { | 349 | { |
350 | m_memcache.AddOrUpdate(assetInf.FullID, assetInf, TimeSpan.FromHours(24)); | 350 | m_memcache.AddOrUpdate(assetInf.Metadata.FullID, assetInf, TimeSpan.FromHours(24)); |
351 | 351 | ||
352 | if (StatsManager.SimExtraStats != null) | 352 | if (StatsManager.SimExtraStats != null) |
353 | { | 353 | { |
354 | StatsManager.SimExtraStats.AddAsset(assetInf); | 354 | StatsManager.SimExtraStats.AddAsset(assetInf); |
355 | } | 355 | } |
356 | 356 | ||
357 | if (RequestedAssets.ContainsKey(assetInf.FullID)) | 357 | if (RequestedAssets.ContainsKey(assetInf.Metadata.FullID)) |
358 | { | 358 | { |
359 | AssetRequest req = RequestedAssets[assetInf.FullID]; | 359 | AssetRequest req = RequestedAssets[assetInf.Metadata.FullID]; |
360 | req.AssetInf = assetInf; | 360 | req.AssetInf = assetInf; |
361 | req.NumPackets = CalculateNumPackets(assetInf.Data); | 361 | req.NumPackets = CalculateNumPackets(assetInf.Data); |
362 | 362 | ||
363 | RequestedAssets.Remove(assetInf.FullID); | 363 | RequestedAssets.Remove(assetInf.Metadata.FullID); |
364 | // If it's a direct request for a script, drop it | 364 | // If it's a direct request for a script, drop it |
365 | // because it's a hacked client | 365 | // because it's a hacked client |
366 | if (req.AssetRequestSource != 2 || assetInf.Type != 10) | 366 | if (req.AssetRequestSource != 2 || assetInf.Metadata.Type != 10) |
367 | AssetRequests.Add(req); | 367 | AssetRequests.Add(req); |
368 | } | 368 | } |
369 | } | 369 | } |
@@ -373,8 +373,8 @@ namespace OpenSim.Framework.Communications.Cache | |||
373 | 373 | ||
374 | lock (RequestLists) | 374 | lock (RequestLists) |
375 | { | 375 | { |
376 | if (RequestLists.TryGetValue(asset.FullID, out reqList)) | 376 | if (RequestLists.TryGetValue(asset.Metadata.FullID, out reqList)) |
377 | RequestLists.Remove(asset.FullID); | 377 | RequestLists.Remove(asset.Metadata.FullID); |
378 | } | 378 | } |
379 | 379 | ||
380 | if (reqList != null) | 380 | if (reqList != null) |
@@ -385,8 +385,8 @@ namespace OpenSim.Framework.Communications.Cache | |||
385 | foreach (NewAssetRequest req in reqList.Requests) | 385 | foreach (NewAssetRequest req in reqList.Requests) |
386 | { | 386 | { |
387 | // Xantor 20080526 are we really calling all the callbacks if multiple queued for 1 request? -- Yes, checked | 387 | // Xantor 20080526 are we really calling all the callbacks if multiple queued for 1 request? -- Yes, checked |
388 | // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.FullID); | 388 | // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.Metadata.FullID); |
389 | req.Callback(asset.FullID, asset); | 389 | req.Callback(asset.Metadata.FullID, asset); |
390 | } | 390 | } |
391 | } | 391 | } |
392 | } | 392 | } |
@@ -398,12 +398,12 @@ namespace OpenSim.Framework.Communications.Cache | |||
398 | 398 | ||
399 | // Remember the fact that this asset could not be found to prevent delays from repeated requests | 399 | // Remember the fact that this asset could not be found to prevent delays from repeated requests |
400 | m_memcache.Add(assetID, null, TimeSpan.FromHours(24)); | 400 | m_memcache.Add(assetID, null, TimeSpan.FromHours(24)); |
401 | 401 | ||
402 | // Notify requesters for this asset | 402 | // Notify requesters for this asset |
403 | AssetRequestsList reqList; | 403 | AssetRequestsList reqList; |
404 | lock (RequestLists) | 404 | lock (RequestLists) |
405 | { | 405 | { |
406 | if (RequestLists.TryGetValue(assetID, out reqList)) | 406 | if (RequestLists.TryGetValue(assetID, out reqList)) |
407 | RequestLists.Remove(assetID); | 407 | RequestLists.Remove(assetID); |
408 | } | 408 | } |
409 | 409 | ||
@@ -411,7 +411,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
411 | { | 411 | { |
412 | if (StatsManager.SimExtraStats != null) | 412 | if (StatsManager.SimExtraStats != null) |
413 | StatsManager.SimExtraStats.AddAssetRequestTimeAfterCacheMiss(DateTime.Now - reqList.TimeRequested); | 413 | StatsManager.SimExtraStats.AddAssetRequestTimeAfterCacheMiss(DateTime.Now - reqList.TimeRequested); |
414 | 414 | ||
415 | foreach (NewAssetRequest req in reqList.Requests) | 415 | foreach (NewAssetRequest req in reqList.Requests) |
416 | { | 416 | { |
417 | req.Callback(assetID, null); | 417 | req.Callback(assetID, null); |
@@ -461,7 +461,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
461 | source = 3; | 461 | source = 3; |
462 | //Console.WriteLine("asset request " + requestID); | 462 | //Console.WriteLine("asset request " + requestID); |
463 | } | 463 | } |
464 | 464 | ||
465 | //check to see if asset is in local cache, if not we need to request it from asset server. | 465 | //check to see if asset is in local cache, if not we need to request it from asset server. |
466 | //Console.WriteLine("asset request " + requestID); | 466 | //Console.WriteLine("asset request " + requestID); |
467 | if (!m_memcache.Contains(requestID)) | 467 | if (!m_memcache.Contains(requestID)) |
@@ -494,7 +494,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
494 | } | 494 | } |
495 | 495 | ||
496 | // Scripts cannot be retrieved by direct request | 496 | // Scripts cannot be retrieved by direct request |
497 | if (transferRequest.TransferInfo.SourceType == 2 && asset.Type == 10) | 497 | if (transferRequest.TransferInfo.SourceType == 2 && asset.Metadata.Type == 10) |
498 | return; | 498 | return; |
499 | 499 | ||
500 | // The asset is knosn to exist and is in our cache, so add it to the AssetRequests list | 500 | // The asset is knosn to exist and is in our cache, so add it to the AssetRequests list |
@@ -520,7 +520,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
520 | //no requests waiting | 520 | //no requests waiting |
521 | return; | 521 | return; |
522 | } | 522 | } |
523 | 523 | ||
524 | // if less than 5, do all of them | 524 | // if less than 5, do all of them |
525 | int num = Math.Min(5, AssetRequests.Count); | 525 | int num = Math.Min(5, AssetRequests.Count); |
526 | 526 | ||
@@ -580,10 +580,10 @@ namespace OpenSim.Framework.Communications.Cache | |||
580 | public AssetInfo(AssetBase aBase) | 580 | public AssetInfo(AssetBase aBase) |
581 | { | 581 | { |
582 | Data = aBase.Data; | 582 | Data = aBase.Data; |
583 | FullID = aBase.FullID; | 583 | Metadata.FullID = aBase.Metadata.FullID; |
584 | Type = aBase.Type; | 584 | Metadata.Type = aBase.Metadata.Type; |
585 | Name = aBase.Name; | 585 | Metadata.Name = aBase.Metadata.Name; |
586 | Description = aBase.Description; | 586 | Metadata.Description = aBase.Metadata.Description; |
587 | } | 587 | } |
588 | } | 588 | } |
589 | 589 | ||
@@ -592,10 +592,10 @@ namespace OpenSim.Framework.Communications.Cache | |||
592 | public TextureImage(AssetBase aBase) | 592 | public TextureImage(AssetBase aBase) |
593 | { | 593 | { |
594 | Data = aBase.Data; | 594 | Data = aBase.Data; |
595 | FullID = aBase.FullID; | 595 | Metadata.FullID = aBase.Metadata.FullID; |
596 | Type = aBase.Type; | 596 | Metadata.Type = aBase.Metadata.Type; |
597 | Name = aBase.Name; | 597 | Metadata.Name = aBase.Metadata.Name; |
598 | Description = aBase.Description; | 598 | Metadata.Description = aBase.Metadata.Description; |
599 | } | 599 | } |
600 | } | 600 | } |
601 | 601 | ||
@@ -608,7 +608,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
608 | /// A list of requests for assets | 608 | /// A list of requests for assets |
609 | /// </summary> | 609 | /// </summary> |
610 | public List<NewAssetRequest> Requests = new List<NewAssetRequest>(); | 610 | public List<NewAssetRequest> Requests = new List<NewAssetRequest>(); |
611 | 611 | ||
612 | /// <summary> | 612 | /// <summary> |
613 | /// Record the time that this request was first made. | 613 | /// Record the time that this request was first made. |
614 | /// </summary> | 614 | /// </summary> |