aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
diff options
context:
space:
mode:
authorMelanie2013-11-08 17:55:01 +0000
committerMelanie2013-11-08 17:55:01 +0000
commit91b70bf3fe382729a94d9a0855be8b07ef67c360 (patch)
tree3e42c4c536da6c7eaaf1a72ecdbd2a24de4d1658 /OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
parentMerge branch 'master' into careminster (diff)
parentIf the LSL state_entry() event definition contains any parameters, then gener... (diff)
downloadopensim-SC_OLD-91b70bf3fe382729a94d9a0855be8b07ef67c360.zip
opensim-SC_OLD-91b70bf3fe382729a94d9a0855be8b07ef67c360.tar.gz
opensim-SC_OLD-91b70bf3fe382729a94d9a0855be8b07ef67c360.tar.bz2
opensim-SC_OLD-91b70bf3fe382729a94d9a0855be8b07ef67c360.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs')
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs103
1 files changed, 60 insertions, 43 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index d510d82..f1fee63 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -31,17 +31,16 @@
31using System; 31using System;
32using System.IO; 32using System.IO;
33using System.Collections.Generic; 33using System.Collections.Generic;
34using System.Linq;
34using System.Reflection; 35using System.Reflection;
35using System.Runtime.Serialization; 36using System.Runtime.Serialization;
36using System.Runtime.Serialization.Formatters.Binary; 37using System.Runtime.Serialization.Formatters.Binary;
37using System.Threading; 38using System.Threading;
38using System.Timers; 39using System.Timers;
39
40using log4net; 40using log4net;
41using Nini.Config; 41using Nini.Config;
42using Mono.Addins; 42using Mono.Addins;
43using OpenMetaverse; 43using OpenMetaverse;
44
45using OpenSim.Framework; 44using OpenSim.Framework;
46using OpenSim.Framework.Console; 45using OpenSim.Framework.Console;
47using OpenSim.Region.Framework.Interfaces; 46using OpenSim.Region.Framework.Interfaces;
@@ -76,8 +75,6 @@ namespace OpenSim.Region.CoreModules.Asset
76 private static ulong m_RequestsForInprogress; 75 private static ulong m_RequestsForInprogress;
77 private static ulong m_DiskHits; 76 private static ulong m_DiskHits;
78 private static ulong m_MemoryHits; 77 private static ulong m_MemoryHits;
79 private static double m_HitRateMemory;
80 private static double m_HitRateFile;
81 78
82#if WAIT_ON_INPROGRESS_REQUESTS 79#if WAIT_ON_INPROGRESS_REQUESTS
83 private Dictionary<string, ManualResetEvent> m_CurrentlyWriting = new Dictionary<string, ManualResetEvent>(); 80 private Dictionary<string, ManualResetEvent> m_CurrentlyWriting = new Dictionary<string, ManualResetEvent>();
@@ -498,18 +495,9 @@ namespace OpenSim.Region.CoreModules.Asset
498 495
499 if (((m_LogLevel >= 1)) && (m_HitRateDisplay != 0) && (m_Requests % m_HitRateDisplay == 0)) 496 if (((m_LogLevel >= 1)) && (m_HitRateDisplay != 0) && (m_Requests % m_HitRateDisplay == 0))
500 { 497 {
501 m_HitRateFile = (double)m_DiskHits / m_Requests * 100.0;
502
503 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Get :: {0} :: {1}", id, asset == null ? "Miss" : "Hit"); 498 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Get :: {0} :: {1}", id, asset == null ? "Miss" : "Hit");
504 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: File Hit Rate {0}% for {1} requests", m_HitRateFile.ToString("0.00"), m_Requests);
505 499
506 if (m_MemoryCacheEnabled) 500 GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l));
507 {
508 m_HitRateMemory = (double)m_MemoryHits / m_Requests * 100.0;
509 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Memory Hit Rate {0}% for {1} requests", m_HitRateMemory.ToString("0.00"), m_Requests);
510 }
511
512 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0} unnessesary requests due to requests for assets that are currently downloading.", m_RequestsForInprogress);
513 } 501 }
514 502
515 return asset; 503 return asset;
@@ -891,45 +879,77 @@ namespace OpenSim.Region.CoreModules.Asset
891 } 879 }
892 } 880 }
893 881
882 private List<string> GenerateCacheHitReport()
883 {
884 List<string> outputLines = new List<string>();
885
886 double fileHitRate = (double)m_DiskHits / m_Requests * 100.0;
887 outputLines.Add(
888 string.Format("File Hit Rate: {0}% for {1} requests", fileHitRate.ToString("0.00"), m_Requests));
889
890 if (m_MemoryCacheEnabled)
891 {
892 double memHitRate = (double)m_MemoryHits / m_Requests * 100.0;
893
894 outputLines.Add(
895 string.Format("Memory Hit Rate: {0}% for {1} requests", memHitRate.ToString("0.00"), m_Requests));
896 }
897
898 outputLines.Add(
899 string.Format(
900 "Unnecessary requests due to requests for assets that are currently downloading: {0}",
901 m_RequestsForInprogress));
902
903 return outputLines;
904 }
905
894 #region Console Commands 906 #region Console Commands
895 private void HandleConsoleCommand(string module, string[] cmdparams) 907 private void HandleConsoleCommand(string module, string[] cmdparams)
896 { 908 {
909 ICommandConsole con = MainConsole.Instance;
910
897 if (cmdparams.Length >= 2) 911 if (cmdparams.Length >= 2)
898 { 912 {
899 string cmd = cmdparams[1]; 913 string cmd = cmdparams[1];
914
900 switch (cmd) 915 switch (cmd)
901 { 916 {
902 case "status": 917 case "status":
903 if (m_MemoryCacheEnabled) 918 if (m_MemoryCacheEnabled)
904 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Memory Cache : {0} assets", m_MemoryCache.Count); 919 con.OutputFormat("Memory Cache: {0} assets", m_MemoryCache.Count);
905 else 920 else
906 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Memory cache disabled"); 921 con.OutputFormat("Memory cache disabled");
907 922
908 if (m_FileCacheEnabled) 923 if (m_FileCacheEnabled)
909 { 924 {
910 int fileCount = GetFileCacheCount(m_CacheDirectory); 925 int fileCount = GetFileCacheCount(m_CacheDirectory);
911 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: File Cache : {0} assets", fileCount); 926 con.OutputFormat("File Cache: {0} assets", fileCount);
927 }
928 else
929 {
930 con.Output("File cache disabled");
931 }
932
933 GenerateCacheHitReport().ForEach(l => con.Output(l));
934
935 if (m_FileCacheEnabled)
936 {
937 con.Output("Deep scans have previously been performed on the following regions:");
912 938
913 foreach (string s in Directory.GetFiles(m_CacheDirectory, "*.fac")) 939 foreach (string s in Directory.GetFiles(m_CacheDirectory, "*.fac"))
914 { 940 {
915 m_log.Info("[FLOTSAM ASSET CACHE]: Deep scans have previously been performed on the following regions:");
916
917 string RegionID = s.Remove(0,s.IndexOf("_")).Replace(".fac",""); 941 string RegionID = s.Remove(0,s.IndexOf("_")).Replace(".fac","");
918 DateTime RegionDeepScanTMStamp = File.GetLastWriteTime(s); 942 DateTime RegionDeepScanTMStamp = File.GetLastWriteTime(s);
919 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Region: {0}, {1}", RegionID, RegionDeepScanTMStamp.ToString("MM/dd/yyyy hh:mm:ss")); 943 con.OutputFormat("Region: {0}, {1}", RegionID, RegionDeepScanTMStamp.ToString("MM/dd/yyyy hh:mm:ss"));
920 } 944 }
921 } 945 }
922 else
923 {
924 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: File cache disabled");
925 }
926 946
927 break; 947 break;
928 948
929 case "clear": 949 case "clear":
930 if (cmdparams.Length < 2) 950 if (cmdparams.Length < 2)
931 { 951 {
932 m_log.Warn("[FLOTSAM ASSET CACHE]: Usage is fcache clear [file] [memory]"); 952 con.Output("Usage is fcache clear [file] [memory]");
933 break; 953 break;
934 } 954 }
935 955
@@ -953,11 +973,11 @@ namespace OpenSim.Region.CoreModules.Asset
953 if (m_MemoryCacheEnabled) 973 if (m_MemoryCacheEnabled)
954 { 974 {
955 m_MemoryCache.Clear(); 975 m_MemoryCache.Clear();
956 m_log.Info("[FLOTSAM ASSET CACHE]: Memory cache cleared."); 976 con.Output("Memory cache cleared.");
957 } 977 }
958 else 978 else
959 { 979 {
960 m_log.Info("[FLOTSAM ASSET CACHE]: Memory cache not enabled."); 980 con.Output("Memory cache not enabled.");
961 } 981 }
962 } 982 }
963 983
@@ -966,24 +986,22 @@ namespace OpenSim.Region.CoreModules.Asset
966 if (m_FileCacheEnabled) 986 if (m_FileCacheEnabled)
967 { 987 {
968 ClearFileCache(); 988 ClearFileCache();
969 m_log.Info("[FLOTSAM ASSET CACHE]: File cache cleared."); 989 con.Output("File cache cleared.");
970 } 990 }
971 else 991 else
972 { 992 {
973 m_log.Info("[FLOTSAM ASSET CACHE]: File cache not enabled."); 993 con.Output("File cache not enabled.");
974 } 994 }
975 } 995 }
976 996
977 break; 997 break;
978 998
979 case "assets": 999 case "assets":
980 m_log.Info("[FLOTSAM ASSET CACHE]: Ensuring assets are cached for all scenes."); 1000 con.Output("Ensuring assets are cached for all scenes.");
981 1001
982 Util.FireAndForget(delegate { 1002 Util.FireAndForget(delegate {
983 int assetReferenceTotal = TouchAllSceneAssets(true); 1003 int assetReferenceTotal = TouchAllSceneAssets(true);
984 m_log.InfoFormat( 1004 con.OutputFormat("Completed check with {0} assets.", assetReferenceTotal);
985 "[FLOTSAM ASSET CACHE]: Completed check with {0} assets.",
986 assetReferenceTotal);
987 }); 1005 });
988 1006
989 break; 1007 break;
@@ -991,7 +1009,7 @@ namespace OpenSim.Region.CoreModules.Asset
991 case "expire": 1009 case "expire":
992 if (cmdparams.Length < 3) 1010 if (cmdparams.Length < 3)
993 { 1011 {
994 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Invalid parameters for Expire, please specify a valid date & time", cmd); 1012 con.OutputFormat("Invalid parameters for Expire, please specify a valid date & time", cmd);
995 break; 1013 break;
996 } 1014 }
997 1015
@@ -1009,28 +1027,27 @@ namespace OpenSim.Region.CoreModules.Asset
1009 1027
1010 if (!DateTime.TryParse(s_expirationDate, out expirationDate)) 1028 if (!DateTime.TryParse(s_expirationDate, out expirationDate))
1011 { 1029 {
1012 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0} is not a valid date & time", cmd); 1030 con.OutputFormat("{0} is not a valid date & time", cmd);
1013 break; 1031 break;
1014 } 1032 }
1015 1033
1016 if (m_FileCacheEnabled) 1034 if (m_FileCacheEnabled)
1017 CleanExpiredFiles(m_CacheDirectory, expirationDate); 1035 CleanExpiredFiles(m_CacheDirectory, expirationDate);
1018 else 1036 else
1019 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: File cache not active, not clearing."); 1037 con.OutputFormat("File cache not active, not clearing.");
1020 1038
1021 break; 1039 break;
1022 default: 1040 default:
1023 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Unknown command {0}", cmd); 1041 con.OutputFormat("Unknown command {0}", cmd);
1024 break; 1042 break;
1025 } 1043 }
1026 } 1044 }
1027 else if (cmdparams.Length == 1) 1045 else if (cmdparams.Length == 1)
1028 { 1046 {
1029 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: fcache status - Display cache status"); 1047 con.Output("fcache assets - Attempt a deep cache of all assets in all scenes");
1030 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: fcache clearmem - Remove all assets cached in memory"); 1048 con.Output("fcache expire <datetime> - Purge assets older then the specified date & time");
1031 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: fcache clearfile - Remove all assets cached on disk"); 1049 con.Output("fcache clear [file] [memory] - Remove cached assets");
1032 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: fcache cachescenes - Attempt a deep cache of all assets in all scenes"); 1050 con.Output("fcache status - Display cache status");
1033 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: fcache <datetime> - Purge assets older then the specified date & time");
1034 } 1051 }
1035 } 1052 }
1036 1053