diff options
Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 7d7176f..b1bb56b 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -49,12 +49,12 @@ using OpenSim.Region.Framework.Scenes; | |||
49 | using OpenSim.Services.Interfaces; | 49 | using OpenSim.Services.Interfaces; |
50 | 50 | ||
51 | 51 | ||
52 | [assembly: Addin("FlotsamAssetCache", "1.1")] | 52 | //[assembly: Addin("FlotsamAssetCache", "1.1")] |
53 | [assembly: AddinDependency("OpenSim", "0.5")] | 53 | //[assembly: AddinDependency("OpenSim", "0.5")] |
54 | 54 | ||
55 | namespace Flotsam.RegionModules.AssetCache | 55 | namespace OpenSim.Region.CoreModules.Asset |
56 | { | 56 | { |
57 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 57 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FlotsamAssetCache")] |
58 | public class FlotsamAssetCache : ISharedRegionModule, IImprovedAssetCache, IAssetService | 58 | public class FlotsamAssetCache : ISharedRegionModule, IImprovedAssetCache, IAssetService |
59 | { | 59 | { |
60 | private static readonly ILog m_log = | 60 | private static readonly ILog m_log = |
@@ -107,8 +107,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
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 Flotsam.RegionModules.AssetCache | |||
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); |
@@ -226,10 +222,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
226 | scene.RegisterModuleInterface<IImprovedAssetCache>(this); | 222 | scene.RegisterModuleInterface<IImprovedAssetCache>(this); |
227 | m_Scenes.Add(scene); | 223 | m_Scenes.Add(scene); |
228 | 224 | ||
229 | if (m_AssetService == null) | ||
230 | { | ||
231 | m_AssetService = scene.RequestModuleInterface<IAssetService>(); | ||
232 | } | ||
233 | } | 225 | } |
234 | } | 226 | } |
235 | 227 | ||
@@ -244,6 +236,8 @@ namespace Flotsam.RegionModules.AssetCache | |||
244 | 236 | ||
245 | public void RegionLoaded(Scene scene) | 237 | public void RegionLoaded(Scene scene) |
246 | { | 238 | { |
239 | if (m_Enabled && m_AssetService == null) | ||
240 | m_AssetService = scene.RequestModuleInterface<IAssetService>(); | ||
247 | } | 241 | } |
248 | 242 | ||
249 | //////////////////////////////////////////////////////////// | 243 | //////////////////////////////////////////////////////////// |
@@ -519,13 +513,10 @@ namespace Flotsam.RegionModules.AssetCache | |||
519 | // Purge all files last accessed prior to this point | 513 | // Purge all files last accessed prior to this point |
520 | DateTime purgeLine = DateTime.Now - m_FileExpiration; | 514 | DateTime purgeLine = DateTime.Now - m_FileExpiration; |
521 | 515 | ||
522 | // An optional deep scan at this point will ensure assets present in scenes, | 516 | // An asset cache may contain local non-temporary assets that are not in the asset service. Therefore, |
523 | // or referenced by objects in the scene, but not recently accessed | 517 | // before cleaning up expired files we must scan the objects in the scene to make sure that we retain |
524 | // are not purged. | 518 | // such local assets if they have not been recently accessed. |
525 | if (m_DeepScanBeforePurge) | 519 | TouchAllSceneAssets(false); |
526 | { | ||
527 | CacheScenes(); | ||
528 | } | ||
529 | 520 | ||
530 | foreach (string dir in Directory.GetDirectories(m_CacheDirectory)) | 521 | foreach (string dir in Directory.GetDirectories(m_CacheDirectory)) |
531 | { | 522 | { |
@@ -718,11 +709,14 @@ namespace Flotsam.RegionModules.AssetCache | |||
718 | 709 | ||
719 | /// <summary> | 710 | /// <summary> |
720 | /// Iterates through all Scenes, doing a deep scan through assets | 711 | /// Iterates through all Scenes, doing a deep scan through assets |
721 | /// to cache all assets present in the scene or referenced by assets | 712 | /// to update the access time of all assets present in the scene or referenced by assets |
722 | /// in the scene | 713 | /// in the scene. |
723 | /// </summary> | 714 | /// </summary> |
724 | /// <returns></returns> | 715 | /// <param name="storeUncached"> |
725 | private int CacheScenes() | 716 | /// If true, then assets scanned which are not found in cache are added to the cache. |
717 | /// </param> | ||
718 | /// <returns>Number of distinct asset references found in the scene.</returns> | ||
719 | private int TouchAllSceneAssets(bool storeUncached) | ||
726 | { | 720 | { |
727 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); | 721 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); |
728 | 722 | ||
@@ -745,7 +739,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
745 | { | 739 | { |
746 | File.SetLastAccessTime(filename, DateTime.Now); | 740 | File.SetLastAccessTime(filename, DateTime.Now); |
747 | } | 741 | } |
748 | else | 742 | else if (storeUncached) |
749 | { | 743 | { |
750 | m_AssetService.Get(assetID.ToString()); | 744 | m_AssetService.Get(assetID.ToString()); |
751 | } | 745 | } |
@@ -873,13 +867,14 @@ namespace Flotsam.RegionModules.AssetCache | |||
873 | 867 | ||
874 | break; | 868 | break; |
875 | 869 | ||
876 | |||
877 | case "assets": | 870 | case "assets": |
878 | m_log.Info("[FLOTSAM ASSET CACHE]: Caching all assets, in all scenes."); | 871 | m_log.Info("[FLOTSAM ASSET CACHE]: Ensuring assets are cached for all scenes."); |
879 | 872 | ||
880 | Util.FireAndForget(delegate { | 873 | Util.FireAndForget(delegate { |
881 | int assetsCached = CacheScenes(); | 874 | int assetReferenceTotal = TouchAllSceneAssets(true); |
882 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Completed Scene Caching, {0} assets found.", assetsCached); | 875 | m_log.InfoFormat( |
876 | "[FLOTSAM ASSET CACHE]: Completed check with {0} assets.", | ||
877 | assetReferenceTotal); | ||
883 | }); | 878 | }); |
884 | 879 | ||
885 | break; | 880 | break; |