diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index d45c35c..cbdca16 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -61,24 +61,23 @@ namespace Flotsam.RegionModules.AssetCache | |||
61 | LogManager.GetLogger( | 61 | LogManager.GetLogger( |
62 | MethodBase.GetCurrentMethod().DeclaringType); | 62 | MethodBase.GetCurrentMethod().DeclaringType); |
63 | 63 | ||
64 | private bool m_Enabled = false; | 64 | private bool m_Enabled; |
65 | 65 | ||
66 | private const string m_ModuleName = "FlotsamAssetCache"; | 66 | private const string m_ModuleName = "FlotsamAssetCache"; |
67 | private const string m_DefaultCacheDirectory = m_ModuleName; | 67 | private const string m_DefaultCacheDirectory = m_ModuleName; |
68 | private string m_CacheDirectory = m_DefaultCacheDirectory; | 68 | private string m_CacheDirectory = m_DefaultCacheDirectory; |
69 | 69 | ||
70 | 70 | private readonly List<char> m_InvalidChars = new List<char>(); | |
71 | private List<char> m_InvalidChars = new List<char>(); | ||
72 | 71 | ||
73 | private int m_LogLevel = 1; | 72 | private int m_LogLevel = 1; |
74 | private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests | 73 | private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests |
75 | 74 | ||
76 | private static ulong m_Requests = 0; | 75 | private static ulong m_Requests; |
77 | private static ulong m_RequestsForInprogress = 0; | 76 | private static ulong m_RequestsForInprogress; |
78 | private static ulong m_DiskHits = 0; | 77 | private static ulong m_DiskHits; |
79 | private static ulong m_MemoryHits = 0; | 78 | private static ulong m_MemoryHits; |
80 | private static double m_HitRateMemory = 0.0; | 79 | private static double m_HitRateMemory; |
81 | private static double m_HitRateFile = 0.0; | 80 | private static double m_HitRateFile; |
82 | 81 | ||
83 | #if WAIT_ON_INPROGRESS_REQUESTS | 82 | #if WAIT_ON_INPROGRESS_REQUESTS |
84 | private Dictionary<string, ManualResetEvent> m_CurrentlyWriting = new Dictionary<string, ManualResetEvent>(); | 83 | private Dictionary<string, ManualResetEvent> m_CurrentlyWriting = new Dictionary<string, ManualResetEvent>(); |
@@ -87,7 +86,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
87 | private List<string> m_CurrentlyWriting = new List<string>(); | 86 | private List<string> m_CurrentlyWriting = new List<string>(); |
88 | #endif | 87 | #endif |
89 | 88 | ||
90 | private ExpiringCache<string, AssetBase> m_MemoryCache = new ExpiringCache<string, AssetBase>(); | 89 | private ExpiringCache<string, AssetBase> m_MemoryCache; |
91 | private bool m_MemoryCacheEnabled = true; | 90 | private bool m_MemoryCacheEnabled = true; |
92 | 91 | ||
93 | // Expiration is expressed in hours. | 92 | // Expiration is expressed in hours. |
@@ -101,12 +100,12 @@ namespace Flotsam.RegionModules.AssetCache | |||
101 | private static int m_CacheDirectoryTierLen = 3; | 100 | private static int m_CacheDirectoryTierLen = 3; |
102 | private static int m_CacheWarnAt = 30000; | 101 | private static int m_CacheWarnAt = 30000; |
103 | 102 | ||
104 | private System.Timers.Timer m_CachCleanTimer = new System.Timers.Timer(); | 103 | private System.Timers.Timer m_CacheCleanTimer; |
105 | 104 | ||
106 | private IAssetService m_AssetService = null; | 105 | private IAssetService m_AssetService; |
107 | private List<Scene> m_Scenes = new List<Scene>(); | 106 | private List<Scene> m_Scenes = new List<Scene>(); |
108 | 107 | ||
109 | private bool m_DeepScanBeforePurge = false; | 108 | private bool m_DeepScanBeforePurge; |
110 | 109 | ||
111 | public FlotsamAssetCache() | 110 | public FlotsamAssetCache() |
112 | { | 111 | { |
@@ -128,14 +127,15 @@ namespace Flotsam.RegionModules.AssetCache | |||
128 | { | 127 | { |
129 | IConfig moduleConfig = source.Configs["Modules"]; | 128 | IConfig moduleConfig = source.Configs["Modules"]; |
130 | 129 | ||
131 | |||
132 | if (moduleConfig != null) | 130 | if (moduleConfig != null) |
133 | { | 131 | { |
134 | string name = moduleConfig.GetString("AssetCaching", ""); | 132 | string name = moduleConfig.GetString("AssetCaching", String.Empty); |
135 | 133 | ||
136 | if (name == Name) | 134 | if (name == Name) |
137 | { | 135 | { |
136 | m_MemoryCache = new ExpiringCache<string, AssetBase>(); | ||
138 | m_Enabled = true; | 137 | m_Enabled = true; |
138 | |||
139 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0} enabled", this.Name); | 139 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0} enabled", this.Name); |
140 | 140 | ||
141 | IConfig assetConfig = source.Configs["AssetCache"]; | 141 | IConfig assetConfig = source.Configs["AssetCache"]; |
@@ -163,21 +163,11 @@ namespace Flotsam.RegionModules.AssetCache | |||
163 | m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration)); | 163 | m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration)); |
164 | if ((m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero)) | 164 | if ((m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero)) |
165 | { | 165 | { |
166 | m_CachCleanTimer.Interval = m_FileExpirationCleanupTimer.TotalMilliseconds; | 166 | m_CacheCleanTimer = new System.Timers.Timer(m_FileExpirationCleanupTimer.TotalMilliseconds); |
167 | m_CachCleanTimer.AutoReset = true; | 167 | m_CacheCleanTimer.AutoReset = true; |
168 | m_CachCleanTimer.Elapsed += CleanupExpiredFiles; | 168 | m_CacheCleanTimer.Elapsed += CleanupExpiredFiles; |
169 | m_CachCleanTimer.Enabled = true; | 169 | lock (m_CacheCleanTimer) |
170 | lock (m_CachCleanTimer) | 170 | m_CacheCleanTimer.Start(); |
171 | { | ||
172 | m_CachCleanTimer.Start(); | ||
173 | } | ||
174 | } | ||
175 | else | ||
176 | { | ||
177 | lock (m_CachCleanTimer) | ||
178 | { | ||
179 | m_CachCleanTimer.Enabled = false; | ||
180 | } | ||
181 | } | 171 | } |
182 | 172 | ||
183 | m_CacheDirectoryTiers = assetConfig.GetInt("CacheDirectoryTiers", 1); | 173 | m_CacheDirectoryTiers = assetConfig.GetInt("CacheDirectoryTiers", 1); |
@@ -208,7 +198,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
208 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache clear", "fcache clear [file] [memory]", "Remove all assets in the file and/or memory cache", HandleConsoleCommand); | 198 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache clear", "fcache clear [file] [memory]", "Remove all assets in the file and/or memory cache", HandleConsoleCommand); |
209 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache assets", "fcache assets", "Attempt a deep scan and cache of all assets in all scenes", HandleConsoleCommand); | 199 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache assets", "fcache assets", "Attempt a deep scan and cache of all assets in all scenes", HandleConsoleCommand); |
210 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache expire", "fcache expire <datetime>", "Purge cached assets older then the specified date/time", HandleConsoleCommand); | 200 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache expire", "fcache expire <datetime>", "Purge cached assets older then the specified date/time", HandleConsoleCommand); |
211 | |||
212 | } | 201 | } |
213 | } | 202 | } |
214 | } | 203 | } |