diff options
author | Robert Adams | 2013-11-04 22:12:57 -0800 |
---|---|---|
committer | Robert Adams | 2013-11-04 22:12:57 -0800 |
commit | c931b16c1fd50d3b955662c8cd6134d7a235c519 (patch) | |
tree | 8aeca3e6dccf6b177908f3842196f59230777109 /OpenSim/Region/CoreModules | |
parent | varregion: add plumbing to pass region size from Scene down to the (diff) | |
parent | If the LSL state_entry() event definition contains any parameters, then gener... (diff) | |
download | opensim-SC_OLD-c931b16c1fd50d3b955662c8cd6134d7a235c519.zip opensim-SC_OLD-c931b16c1fd50d3b955662c8cd6134d7a235c519.tar.gz opensim-SC_OLD-c931b16c1fd50d3b955662c8cd6134d7a235c519.tar.bz2 opensim-SC_OLD-c931b16c1fd50d3b955662c8cd6134d7a235c519.tar.xz |
Merge branch 'master' into varregion
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 103 |
1 files changed, 60 insertions, 43 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 2afe065..08d4fc0 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -31,17 +31,16 @@ | |||
31 | using System; | 31 | using System; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Collections.Generic; | 33 | using System.Collections.Generic; |
34 | using System.Linq; | ||
34 | using System.Reflection; | 35 | using System.Reflection; |
35 | using System.Runtime.Serialization; | 36 | using System.Runtime.Serialization; |
36 | using System.Runtime.Serialization.Formatters.Binary; | 37 | using System.Runtime.Serialization.Formatters.Binary; |
37 | using System.Threading; | 38 | using System.Threading; |
38 | using System.Timers; | 39 | using System.Timers; |
39 | |||
40 | using log4net; | 40 | using log4net; |
41 | using Nini.Config; | 41 | using Nini.Config; |
42 | using Mono.Addins; | 42 | using Mono.Addins; |
43 | using OpenMetaverse; | 43 | using OpenMetaverse; |
44 | |||
45 | using OpenSim.Framework; | 44 | using OpenSim.Framework; |
46 | using OpenSim.Framework.Console; | 45 | using OpenSim.Framework.Console; |
47 | using OpenSim.Region.Framework.Interfaces; | 46 | using 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>(); |
@@ -429,18 +426,9 @@ namespace OpenSim.Region.CoreModules.Asset | |||
429 | 426 | ||
430 | if (((m_LogLevel >= 1)) && (m_HitRateDisplay != 0) && (m_Requests % m_HitRateDisplay == 0)) | 427 | if (((m_LogLevel >= 1)) && (m_HitRateDisplay != 0) && (m_Requests % m_HitRateDisplay == 0)) |
431 | { | 428 | { |
432 | m_HitRateFile = (double)m_DiskHits / m_Requests * 100.0; | ||
433 | |||
434 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Get :: {0} :: {1}", id, asset == null ? "Miss" : "Hit"); | 429 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Get :: {0} :: {1}", id, asset == null ? "Miss" : "Hit"); |
435 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: File Hit Rate {0}% for {1} requests", m_HitRateFile.ToString("0.00"), m_Requests); | ||
436 | 430 | ||
437 | if (m_MemoryCacheEnabled) | 431 | GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l)); |
438 | { | ||
439 | m_HitRateMemory = (double)m_MemoryHits / m_Requests * 100.0; | ||
440 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Memory Hit Rate {0}% for {1} requests", m_HitRateMemory.ToString("0.00"), m_Requests); | ||
441 | } | ||
442 | |||
443 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0} unnessesary requests due to requests for assets that are currently downloading.", m_RequestsForInprogress); | ||
444 | } | 432 | } |
445 | 433 | ||
446 | return asset; | 434 | return asset; |
@@ -807,45 +795,77 @@ namespace OpenSim.Region.CoreModules.Asset | |||
807 | } | 795 | } |
808 | } | 796 | } |
809 | 797 | ||
798 | private List<string> GenerateCacheHitReport() | ||
799 | { | ||
800 | List<string> outputLines = new List<string>(); | ||
801 | |||
802 | double fileHitRate = (double)m_DiskHits / m_Requests * 100.0; | ||
803 | outputLines.Add( | ||
804 | string.Format("File Hit Rate: {0}% for {1} requests", fileHitRate.ToString("0.00"), m_Requests)); | ||
805 | |||
806 | if (m_MemoryCacheEnabled) | ||
807 | { | ||
808 | double memHitRate = (double)m_MemoryHits / m_Requests * 100.0; | ||
809 | |||
810 | outputLines.Add( | ||
811 | string.Format("Memory Hit Rate: {0}% for {1} requests", memHitRate.ToString("0.00"), m_Requests)); | ||
812 | } | ||
813 | |||
814 | outputLines.Add( | ||
815 | string.Format( | ||
816 | "Unnecessary requests due to requests for assets that are currently downloading: {0}", | ||
817 | m_RequestsForInprogress)); | ||
818 | |||
819 | return outputLines; | ||
820 | } | ||
821 | |||
810 | #region Console Commands | 822 | #region Console Commands |
811 | private void HandleConsoleCommand(string module, string[] cmdparams) | 823 | private void HandleConsoleCommand(string module, string[] cmdparams) |
812 | { | 824 | { |
825 | ICommandConsole con = MainConsole.Instance; | ||
826 | |||
813 | if (cmdparams.Length >= 2) | 827 | if (cmdparams.Length >= 2) |
814 | { | 828 | { |
815 | string cmd = cmdparams[1]; | 829 | string cmd = cmdparams[1]; |
830 | |||
816 | switch (cmd) | 831 | switch (cmd) |
817 | { | 832 | { |
818 | case "status": | 833 | case "status": |
819 | if (m_MemoryCacheEnabled) | 834 | if (m_MemoryCacheEnabled) |
820 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Memory Cache : {0} assets", m_MemoryCache.Count); | 835 | con.OutputFormat("Memory Cache: {0} assets", m_MemoryCache.Count); |
821 | else | 836 | else |
822 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Memory cache disabled"); | 837 | con.OutputFormat("Memory cache disabled"); |
823 | 838 | ||
824 | if (m_FileCacheEnabled) | 839 | if (m_FileCacheEnabled) |
825 | { | 840 | { |
826 | int fileCount = GetFileCacheCount(m_CacheDirectory); | 841 | int fileCount = GetFileCacheCount(m_CacheDirectory); |
827 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: File Cache : {0} assets", fileCount); | 842 | con.OutputFormat("File Cache: {0} assets", fileCount); |
843 | } | ||
844 | else | ||
845 | { | ||
846 | con.Output("File cache disabled"); | ||
847 | } | ||
848 | |||
849 | GenerateCacheHitReport().ForEach(l => con.Output(l)); | ||
850 | |||
851 | if (m_FileCacheEnabled) | ||
852 | { | ||
853 | con.Output("Deep scans have previously been performed on the following regions:"); | ||
828 | 854 | ||
829 | foreach (string s in Directory.GetFiles(m_CacheDirectory, "*.fac")) | 855 | foreach (string s in Directory.GetFiles(m_CacheDirectory, "*.fac")) |
830 | { | 856 | { |
831 | m_log.Info("[FLOTSAM ASSET CACHE]: Deep scans have previously been performed on the following regions:"); | ||
832 | |||
833 | string RegionID = s.Remove(0,s.IndexOf("_")).Replace(".fac",""); | 857 | string RegionID = s.Remove(0,s.IndexOf("_")).Replace(".fac",""); |
834 | DateTime RegionDeepScanTMStamp = File.GetLastWriteTime(s); | 858 | DateTime RegionDeepScanTMStamp = File.GetLastWriteTime(s); |
835 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Region: {0}, {1}", RegionID, RegionDeepScanTMStamp.ToString("MM/dd/yyyy hh:mm:ss")); | 859 | con.OutputFormat("Region: {0}, {1}", RegionID, RegionDeepScanTMStamp.ToString("MM/dd/yyyy hh:mm:ss")); |
836 | } | 860 | } |
837 | } | 861 | } |
838 | else | ||
839 | { | ||
840 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: File cache disabled"); | ||
841 | } | ||
842 | 862 | ||
843 | break; | 863 | break; |
844 | 864 | ||
845 | case "clear": | 865 | case "clear": |
846 | if (cmdparams.Length < 2) | 866 | if (cmdparams.Length < 2) |
847 | { | 867 | { |
848 | m_log.Warn("[FLOTSAM ASSET CACHE]: Usage is fcache clear [file] [memory]"); | 868 | con.Output("Usage is fcache clear [file] [memory]"); |
849 | break; | 869 | break; |
850 | } | 870 | } |
851 | 871 | ||
@@ -869,11 +889,11 @@ namespace OpenSim.Region.CoreModules.Asset | |||
869 | if (m_MemoryCacheEnabled) | 889 | if (m_MemoryCacheEnabled) |
870 | { | 890 | { |
871 | m_MemoryCache.Clear(); | 891 | m_MemoryCache.Clear(); |
872 | m_log.Info("[FLOTSAM ASSET CACHE]: Memory cache cleared."); | 892 | con.Output("Memory cache cleared."); |
873 | } | 893 | } |
874 | else | 894 | else |
875 | { | 895 | { |
876 | m_log.Info("[FLOTSAM ASSET CACHE]: Memory cache not enabled."); | 896 | con.Output("Memory cache not enabled."); |
877 | } | 897 | } |
878 | } | 898 | } |
879 | 899 | ||
@@ -882,24 +902,22 @@ namespace OpenSim.Region.CoreModules.Asset | |||
882 | if (m_FileCacheEnabled) | 902 | if (m_FileCacheEnabled) |
883 | { | 903 | { |
884 | ClearFileCache(); | 904 | ClearFileCache(); |
885 | m_log.Info("[FLOTSAM ASSET CACHE]: File cache cleared."); | 905 | con.Output("File cache cleared."); |
886 | } | 906 | } |
887 | else | 907 | else |
888 | { | 908 | { |
889 | m_log.Info("[FLOTSAM ASSET CACHE]: File cache not enabled."); | 909 | con.Output("File cache not enabled."); |
890 | } | 910 | } |
891 | } | 911 | } |
892 | 912 | ||
893 | break; | 913 | break; |
894 | 914 | ||
895 | case "assets": | 915 | case "assets": |
896 | m_log.Info("[FLOTSAM ASSET CACHE]: Ensuring assets are cached for all scenes."); | 916 | con.Output("Ensuring assets are cached for all scenes."); |
897 | 917 | ||
898 | Util.FireAndForget(delegate { | 918 | Util.FireAndForget(delegate { |
899 | int assetReferenceTotal = TouchAllSceneAssets(true); | 919 | int assetReferenceTotal = TouchAllSceneAssets(true); |
900 | m_log.InfoFormat( | 920 | con.OutputFormat("Completed check with {0} assets.", assetReferenceTotal); |
901 | "[FLOTSAM ASSET CACHE]: Completed check with {0} assets.", | ||
902 | assetReferenceTotal); | ||
903 | }); | 921 | }); |
904 | 922 | ||
905 | break; | 923 | break; |
@@ -907,7 +925,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
907 | case "expire": | 925 | case "expire": |
908 | if (cmdparams.Length < 3) | 926 | if (cmdparams.Length < 3) |
909 | { | 927 | { |
910 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Invalid parameters for Expire, please specify a valid date & time", cmd); | 928 | con.OutputFormat("Invalid parameters for Expire, please specify a valid date & time", cmd); |
911 | break; | 929 | break; |
912 | } | 930 | } |
913 | 931 | ||
@@ -925,28 +943,27 @@ namespace OpenSim.Region.CoreModules.Asset | |||
925 | 943 | ||
926 | if (!DateTime.TryParse(s_expirationDate, out expirationDate)) | 944 | if (!DateTime.TryParse(s_expirationDate, out expirationDate)) |
927 | { | 945 | { |
928 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0} is not a valid date & time", cmd); | 946 | con.OutputFormat("{0} is not a valid date & time", cmd); |
929 | break; | 947 | break; |
930 | } | 948 | } |
931 | 949 | ||
932 | if (m_FileCacheEnabled) | 950 | if (m_FileCacheEnabled) |
933 | CleanExpiredFiles(m_CacheDirectory, expirationDate); | 951 | CleanExpiredFiles(m_CacheDirectory, expirationDate); |
934 | else | 952 | else |
935 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: File cache not active, not clearing."); | 953 | con.OutputFormat("File cache not active, not clearing."); |
936 | 954 | ||
937 | break; | 955 | break; |
938 | default: | 956 | default: |
939 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Unknown command {0}", cmd); | 957 | con.OutputFormat("Unknown command {0}", cmd); |
940 | break; | 958 | break; |
941 | } | 959 | } |
942 | } | 960 | } |
943 | else if (cmdparams.Length == 1) | 961 | else if (cmdparams.Length == 1) |
944 | { | 962 | { |
945 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: fcache status - Display cache status"); | 963 | con.Output("fcache assets - Attempt a deep cache of all assets in all scenes"); |
946 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: fcache clearmem - Remove all assets cached in memory"); | 964 | con.Output("fcache expire <datetime> - Purge assets older then the specified date & time"); |
947 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: fcache clearfile - Remove all assets cached on disk"); | 965 | con.Output("fcache clear [file] [memory] - Remove cached assets"); |
948 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: fcache cachescenes - Attempt a deep cache of all assets in all scenes"); | 966 | con.Output("fcache status - Display cache status"); |
949 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: fcache <datetime> - Purge assets older then the specified date & time"); | ||
950 | } | 967 | } |
951 | } | 968 | } |
952 | 969 | ||