diff options
author | Justin Clark-Casey (justincc) | 2012-09-15 01:08:15 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-09-15 01:08:15 +0100 |
commit | d5c8c6bc12d434bb6a4bbc6f326a4ae784c12861 (patch) | |
tree | f14b5c393907f1adc342f3764cbf8d02c29813f6 /OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |
parent | Added unit tests for multi-region OARs (diff) | |
download | opensim-SC_OLD-d5c8c6bc12d434bb6a4bbc6f326a4ae784c12861.zip opensim-SC_OLD-d5c8c6bc12d434bb6a4bbc6f326a4ae784c12861.tar.gz opensim-SC_OLD-d5c8c6bc12d434bb6a4bbc6f326a4ae784c12861.tar.bz2 opensim-SC_OLD-d5c8c6bc12d434bb6a4bbc6f326a4ae784c12861.tar.xz |
For FlotsamAssetCache, always update access times of cached scene assets before looking for files to expire.
This is to resolve a problem where an asset marked as local but not temporary but still used in the scene would be removed.
The timed expiry scan no longer tries to refetch assets from the scene that are not currently in the cache - this is not helpful since it just drags a lot of data into the cache that may never be referenced.
This removes the DeepScanBeforePurge option since setting this to false will introduce the above problem. This previously had a default of true.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 5d8a278..8aa173a 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -107,8 +107,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
107 | private IAssetService m_AssetService; | 107 | private IAssetService m_AssetService; |
108 | private List<Scene> m_Scenes = new List<Scene>(); | 108 | private List<Scene> m_Scenes = new List<Scene>(); |
109 | 109 | ||
110 | private bool m_DeepScanBeforePurge; | ||
111 | |||
112 | public FlotsamAssetCache() | 110 | public FlotsamAssetCache() |
113 | { | 111 | { |
114 | m_InvalidChars.AddRange(Path.GetInvalidPathChars()); | 112 | m_InvalidChars.AddRange(Path.GetInvalidPathChars()); |
@@ -170,8 +168,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
170 | m_CacheDirectoryTierLen = assetConfig.GetInt("CacheDirectoryTierLength", m_CacheDirectoryTierLen); | 168 | m_CacheDirectoryTierLen = assetConfig.GetInt("CacheDirectoryTierLength", m_CacheDirectoryTierLen); |
171 | 169 | ||
172 | m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", m_CacheWarnAt); | 170 | m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", m_CacheWarnAt); |
173 | |||
174 | m_DeepScanBeforePurge = assetConfig.GetBoolean("DeepScanBeforePurge", m_DeepScanBeforePurge); | ||
175 | } | 171 | } |
176 | 172 | ||
177 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory {0}", m_CacheDirectory); | 173 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory {0}", m_CacheDirectory); |
@@ -506,13 +502,10 @@ namespace OpenSim.Region.CoreModules.Asset | |||
506 | // Purge all files last accessed prior to this point | 502 | // Purge all files last accessed prior to this point |
507 | DateTime purgeLine = DateTime.Now - m_FileExpiration; | 503 | DateTime purgeLine = DateTime.Now - m_FileExpiration; |
508 | 504 | ||
509 | // An optional deep scan at this point will ensure assets present in scenes, | 505 | // An asset cache may contain local non-temporary assets that are not in the asset service. Therefore, |
510 | // or referenced by objects in the scene, but not recently accessed | 506 | // before cleaning up expired files we must scan the objects in the scene to make sure that we retain |
511 | // are not purged. | 507 | // such local assets if they have not been recently accessed. |
512 | if (m_DeepScanBeforePurge) | 508 | TouchAllSceneAssets(false); |
513 | { | ||
514 | CacheScenes(); | ||
515 | } | ||
516 | 509 | ||
517 | foreach (string dir in Directory.GetDirectories(m_CacheDirectory)) | 510 | foreach (string dir in Directory.GetDirectories(m_CacheDirectory)) |
518 | { | 511 | { |
@@ -705,11 +698,14 @@ namespace OpenSim.Region.CoreModules.Asset | |||
705 | 698 | ||
706 | /// <summary> | 699 | /// <summary> |
707 | /// Iterates through all Scenes, doing a deep scan through assets | 700 | /// Iterates through all Scenes, doing a deep scan through assets |
708 | /// to cache all assets present in the scene or referenced by assets | 701 | /// to update the access time of all assets present in the scene or referenced by assets |
709 | /// in the scene | 702 | /// in the scene. |
710 | /// </summary> | 703 | /// </summary> |
711 | /// <returns></returns> | 704 | /// <param name="storeUncached"> |
712 | private int CacheScenes() | 705 | /// If true, then assets scanned which are not found in cache are added to the cache. |
706 | /// </param> | ||
707 | /// <returns>Number of distinct asset references found in the scene.</returns> | ||
708 | private int TouchAllSceneAssets(bool storeUncached) | ||
713 | { | 709 | { |
714 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); | 710 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); |
715 | 711 | ||
@@ -732,7 +728,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
732 | { | 728 | { |
733 | File.SetLastAccessTime(filename, DateTime.Now); | 729 | File.SetLastAccessTime(filename, DateTime.Now); |
734 | } | 730 | } |
735 | else | 731 | else if (storeUncached) |
736 | { | 732 | { |
737 | m_AssetService.Get(assetID.ToString()); | 733 | m_AssetService.Get(assetID.ToString()); |
738 | } | 734 | } |
@@ -860,13 +856,14 @@ namespace OpenSim.Region.CoreModules.Asset | |||
860 | 856 | ||
861 | break; | 857 | break; |
862 | 858 | ||
863 | |||
864 | case "assets": | 859 | case "assets": |
865 | m_log.Info("[FLOTSAM ASSET CACHE]: Caching all assets, in all scenes."); | 860 | m_log.Info("[FLOTSAM ASSET CACHE]: Ensuring assets are cached for all scenes."); |
866 | 861 | ||
867 | Util.FireAndForget(delegate { | 862 | Util.FireAndForget(delegate { |
868 | int assetsCached = CacheScenes(); | 863 | int assetReferenceTotal = TouchAllSceneAssets(true); |
869 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Completed Scene Caching, {0} assets found.", assetsCached); | 864 | m_log.InfoFormat( |
865 | "[FLOTSAM ASSET CACHE]: Completed check with {0} assets.", | ||
866 | assetReferenceTotal); | ||
870 | }); | 867 | }); |
871 | 868 | ||
872 | break; | 869 | break; |