diff options
author | Melanie | 2011-06-11 12:08:02 +0100 |
---|---|---|
committer | Melanie | 2011-06-11 12:08:02 +0100 |
commit | a1c16a42002757f65d77b530571405bd740bf2f7 (patch) | |
tree | 6b86e3ddd09538f83c541a36d02f6668eeed8745 /OpenSim/Region/CoreModules/Asset | |
parent | Merge branch 'master' into careminster-presence-refactor (diff) | |
parent | Added a Sleep in between each site call, to slow the xml-rpc requests down. (diff) | |
download | opensim-SC-a1c16a42002757f65d77b530571405bd740bf2f7.zip opensim-SC-a1c16a42002757f65d77b530571405bd740bf2f7.tar.gz opensim-SC-a1c16a42002757f65d77b530571405bd740bf2f7.tar.bz2 opensim-SC-a1c16a42002757f65d77b530571405bd740bf2f7.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset')
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 99 |
1 files changed, 60 insertions, 39 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 7cba702..9ef5bc9 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -64,13 +64,13 @@ namespace Flotsam.RegionModules.AssetCache | |||
64 | private bool m_Enabled; | 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 = "./assetcache"; |
68 | private string m_CacheDirectory = m_DefaultCacheDirectory; | 68 | private string m_CacheDirectory = m_DefaultCacheDirectory; |
69 | 69 | ||
70 | private readonly List<char> m_InvalidChars = new List<char>(); | 70 | private readonly List<char> m_InvalidChars = new List<char>(); |
71 | 71 | ||
72 | private int m_LogLevel = 0; | 72 | private int m_LogLevel = 0; |
73 | private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests | 73 | private ulong m_HitRateDisplay = 100; // How often to display hit statistics, given in requests |
74 | 74 | ||
75 | private static ulong m_Requests; | 75 | private static ulong m_Requests; |
76 | private static ulong m_RequestsForInprogress; | 76 | private static ulong m_RequestsForInprogress; |
@@ -87,14 +87,14 @@ namespace Flotsam.RegionModules.AssetCache | |||
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | private ExpiringCache<string, AssetBase> m_MemoryCache; | 89 | private ExpiringCache<string, AssetBase> m_MemoryCache; |
90 | private bool m_MemoryCacheEnabled = true; | 90 | private bool m_MemoryCacheEnabled = false; |
91 | 91 | ||
92 | // Expiration is expressed in hours. | 92 | // Expiration is expressed in hours. |
93 | private const double m_DefaultMemoryExpiration = 1.0; | 93 | private const double m_DefaultMemoryExpiration = 2; |
94 | private const double m_DefaultFileExpiration = 48; | 94 | private const double m_DefaultFileExpiration = 48; |
95 | private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration); | 95 | private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration); |
96 | private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration); | 96 | private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration); |
97 | private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(m_DefaultFileExpiration); | 97 | private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(0.166); |
98 | 98 | ||
99 | private static int m_CacheDirectoryTiers = 1; | 99 | private static int m_CacheDirectoryTiers = 1; |
100 | private static int m_CacheDirectoryTierLen = 3; | 100 | private static int m_CacheDirectoryTierLen = 3; |
@@ -141,26 +141,38 @@ namespace Flotsam.RegionModules.AssetCache | |||
141 | IConfig assetConfig = source.Configs["AssetCache"]; | 141 | IConfig assetConfig = source.Configs["AssetCache"]; |
142 | if (assetConfig == null) | 142 | if (assetConfig == null) |
143 | { | 143 | { |
144 | m_log.Warn("[FLOTSAM ASSET CACHE]: AssetCache missing from OpenSim.ini, using defaults."); | 144 | m_log.Warn( |
145 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory); | 145 | "[FLOTSAM ASSET CACHE]: AssetCache section missing from config (not copied config-include/FlotsamCache.ini.example? Using defaults."); |
146 | return; | ||
147 | } | 146 | } |
147 | else | ||
148 | { | ||
149 | m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); | ||
148 | 150 | ||
149 | m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); | 151 | m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", m_MemoryCacheEnabled); |
150 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_CacheDirectory); | 152 | m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); |
153 | |||
154 | #if WAIT_ON_INPROGRESS_REQUESTS | ||
155 | m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000); | ||
156 | #endif | ||
157 | |||
158 | m_LogLevel = assetConfig.GetInt("LogLevel", m_LogLevel); | ||
159 | m_HitRateDisplay = (ulong)assetConfig.GetLong("HitRateDisplay", (long)m_HitRateDisplay); | ||
151 | 160 | ||
152 | m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false); | 161 | m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration)); |
153 | m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); | 162 | m_FileExpirationCleanupTimer |
163 | = TimeSpan.FromHours( | ||
164 | assetConfig.GetDouble("FileCleanupTimer", m_FileExpirationCleanupTimer.TotalHours)); | ||
154 | 165 | ||
155 | #if WAIT_ON_INPROGRESS_REQUESTS | 166 | m_CacheDirectoryTiers = assetConfig.GetInt("CacheDirectoryTiers", m_CacheDirectoryTiers); |
156 | m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000); | 167 | m_CacheDirectoryTierLen = assetConfig.GetInt("CacheDirectoryTierLength", m_CacheDirectoryTierLen); |
157 | #endif | 168 | |
169 | m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", m_CacheWarnAt); | ||
170 | |||
171 | m_DeepScanBeforePurge = assetConfig.GetBoolean("DeepScanBeforePurge", m_DeepScanBeforePurge); | ||
172 | } | ||
158 | 173 | ||
159 | m_LogLevel = assetConfig.GetInt("LogLevel", 0); | 174 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory {0}", m_CacheDirectory); |
160 | m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000); | ||
161 | 175 | ||
162 | m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration)); | ||
163 | m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration)); | ||
164 | if ((m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero)) | 176 | if ((m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero)) |
165 | { | 177 | { |
166 | m_CacheCleanTimer = new System.Timers.Timer(m_FileExpirationCleanupTimer.TotalMilliseconds); | 178 | m_CacheCleanTimer = new System.Timers.Timer(m_FileExpirationCleanupTimer.TotalMilliseconds); |
@@ -170,7 +182,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
170 | m_CacheCleanTimer.Start(); | 182 | m_CacheCleanTimer.Start(); |
171 | } | 183 | } |
172 | 184 | ||
173 | m_CacheDirectoryTiers = assetConfig.GetInt("CacheDirectoryTiers", 1); | ||
174 | if (m_CacheDirectoryTiers < 1) | 185 | if (m_CacheDirectoryTiers < 1) |
175 | { | 186 | { |
176 | m_CacheDirectoryTiers = 1; | 187 | m_CacheDirectoryTiers = 1; |
@@ -180,7 +191,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
180 | m_CacheDirectoryTiers = 3; | 191 | m_CacheDirectoryTiers = 3; |
181 | } | 192 | } |
182 | 193 | ||
183 | m_CacheDirectoryTierLen = assetConfig.GetInt("CacheDirectoryTierLength", 3); | ||
184 | if (m_CacheDirectoryTierLen < 1) | 194 | if (m_CacheDirectoryTierLen < 1) |
185 | { | 195 | { |
186 | m_CacheDirectoryTierLen = 1; | 196 | m_CacheDirectoryTierLen = 1; |
@@ -190,14 +200,10 @@ namespace Flotsam.RegionModules.AssetCache | |||
190 | m_CacheDirectoryTierLen = 4; | 200 | m_CacheDirectoryTierLen = 4; |
191 | } | 201 | } |
192 | 202 | ||
193 | m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", 30000); | 203 | MainConsole.Instance.Commands.AddCommand(Name, true, "fcache status", "fcache status", "Display cache status", HandleConsoleCommand); |
194 | 204 | MainConsole.Instance.Commands.AddCommand(Name, true, "fcache clear", "fcache clear [file] [memory]", "Remove all assets in the cache. If file or memory is specified then only this cache is cleared.", HandleConsoleCommand); | |
195 | m_DeepScanBeforePurge = assetConfig.GetBoolean("DeepScanBeforePurge", false); | 205 | MainConsole.Instance.Commands.AddCommand(Name, true, "fcache assets", "fcache assets", "Attempt a deep scan and cache of all assets in all scenes", HandleConsoleCommand); |
196 | 206 | MainConsole.Instance.Commands.AddCommand(Name, true, "fcache expire", "fcache expire <datetime>", "Purge cached assets older then the specified date/time", HandleConsoleCommand); | |
197 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache status", "fcache status", "Display cache status", 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); | ||
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); | ||
200 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache expire", "fcache expire <datetime>", "Purge cached assets older then the specified date/time", HandleConsoleCommand); | ||
201 | } | 207 | } |
202 | } | 208 | } |
203 | } | 209 | } |
@@ -732,24 +738,39 @@ namespace Flotsam.RegionModules.AssetCache | |||
732 | break; | 738 | break; |
733 | 739 | ||
734 | case "clear": | 740 | case "clear": |
735 | if (cmdparams.Length < 3) | 741 | if (cmdparams.Length < 2) |
736 | { | 742 | { |
737 | m_log.Warn("[FLOTSAM ASSET CACHE] Please specify memory and/or file cache."); | 743 | m_log.Warn("[FLOTSAM ASSET CACHE] Usage is fcache clear [file] [memory]"); |
738 | break; | 744 | break; |
739 | } | 745 | } |
746 | |||
747 | bool clearMemory = false, clearFile = false; | ||
748 | |||
749 | if (cmdparams.Length == 2) | ||
750 | { | ||
751 | clearMemory = true; | ||
752 | clearFile = true; | ||
753 | } | ||
740 | foreach (string s in cmdparams) | 754 | foreach (string s in cmdparams) |
741 | { | 755 | { |
742 | if (s.ToLower() == "memory") | 756 | if (s.ToLower() == "memory") |
743 | { | 757 | clearMemory = true; |
744 | m_MemoryCache.Clear(); | ||
745 | m_log.Info("[FLOTSAM ASSET CACHE] Memory cache cleared."); | ||
746 | } | ||
747 | else if (s.ToLower() == "file") | 758 | else if (s.ToLower() == "file") |
748 | { | 759 | clearFile = true; |
749 | ClearFileCache(); | ||
750 | m_log.Info("[FLOTSAM ASSET CACHE] File cache cleared."); | ||
751 | } | ||
752 | } | 760 | } |
761 | |||
762 | if (clearMemory) | ||
763 | { | ||
764 | m_MemoryCache.Clear(); | ||
765 | m_log.Info("[FLOTSAM ASSET CACHE] Memory cache cleared."); | ||
766 | } | ||
767 | |||
768 | if (clearFile) | ||
769 | { | ||
770 | ClearFileCache(); | ||
771 | m_log.Info("[FLOTSAM ASSET CACHE] File cache cleared."); | ||
772 | } | ||
773 | |||
753 | break; | 774 | break; |
754 | 775 | ||
755 | 776 | ||