aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-07-06 00:12:48 +0100
committerJustin Clark-Casey (justincc)2013-07-06 00:12:48 +0100
commit5dbdd5f8b4856357340357394edc2f9e229a0582 (patch)
tree23d061f124e946327888928fbd2bf618f99a5b18 /OpenSim/Region
parentAdd very basic regression test TestChildAgentSingleRegionCapabilities() which... (diff)
downloadopensim-SC_OLD-5dbdd5f8b4856357340357394edc2f9e229a0582.zip
opensim-SC_OLD-5dbdd5f8b4856357340357394edc2f9e229a0582.tar.gz
opensim-SC_OLD-5dbdd5f8b4856357340357394edc2f9e229a0582.tar.bz2
opensim-SC_OLD-5dbdd5f8b4856357340357394edc2f9e229a0582.tar.xz
refactor: Make stats and sim status simpler by extending BaseStreamHandler like other handlers instead of implementing the IStreamedRequestHandler interface directly
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs74
-rw-r--r--OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs26
2 files changed, 23 insertions, 77 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 7ca87a3..841069c 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -759,73 +759,49 @@ namespace OpenSim
759 /// <summary> 759 /// <summary>
760 /// Handler to supply the current status of this sim 760 /// Handler to supply the current status of this sim
761 /// </summary> 761 /// </summary>
762 /// <remarks>
762 /// Currently this is always OK if the simulator is still listening for connections on its HTTP service 763 /// Currently this is always OK if the simulator is still listening for connections on its HTTP service
763 public class SimStatusHandler : IStreamedRequestHandler 764 /// </remarks>
765 public class SimStatusHandler : BaseStreamHandler
764 { 766 {
765 public byte[] Handle(string path, Stream request, 767 public SimStatusHandler() : base("GET", "/simstatus", "SimStatus", "Simulator Status") {}
768
769 public override byte[] Handle(string path, Stream request,
766 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 770 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
767 { 771 {
768 return Util.UTF8.GetBytes("OK"); 772 return Util.UTF8.GetBytes("OK");
769 } 773 }
770 774
771 public string Name { get { return "SimStatus"; } } 775 public override string ContentType
772 public string Description { get { return "Simulator Status"; } }
773
774 public string ContentType
775 { 776 {
776 get { return "text/plain"; } 777 get { return "text/plain"; }
777 } 778 }
778
779 public string HttpMethod
780 {
781 get { return "GET"; }
782 }
783
784 public string Path
785 {
786 get { return "/simstatus"; }
787 }
788 } 779 }
789 780
790 /// <summary> 781 /// <summary>
791 /// Handler to supply the current extended status of this sim 782 /// Handler to supply the current extended status of this sim
792 /// Sends the statistical data in a json serialization 783 /// Sends the statistical data in a json serialization
793 /// </summary> 784 /// </summary>
794 public class XSimStatusHandler : IStreamedRequestHandler 785 public class XSimStatusHandler : BaseStreamHandler
795 { 786 {
796 OpenSimBase m_opensim; 787 OpenSimBase m_opensim;
797 string osXStatsURI = String.Empty;
798
799 public string Name { get { return "XSimStatus"; } }
800 public string Description { get { return "Simulator XStatus"; } }
801 788
802 public XSimStatusHandler(OpenSimBase sim) 789 public XSimStatusHandler(OpenSimBase sim)
790 : base("GET", "/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus")
803 { 791 {
804 m_opensim = sim; 792 m_opensim = sim;
805 osXStatsURI = Util.SHA1Hash(sim.osSecret);
806 } 793 }
807 794
808 public byte[] Handle(string path, Stream request, 795 public override byte[] Handle(string path, Stream request,
809 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 796 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
810 { 797 {
811 return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); 798 return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
812 } 799 }
813 800
814 public string ContentType 801 public override string ContentType
815 { 802 {
816 get { return "text/plain"; } 803 get { return "text/plain"; }
817 } 804 }
818
819 public string HttpMethod
820 {
821 get { return "GET"; }
822 }
823
824 public string Path
825 {
826 // This is for the OpenSimulator instance and is the osSecret hashed
827 get { return "/" + osXStatsURI; }
828 }
829 } 805 }
830 806
831 /// <summary> 807 /// <summary>
@@ -834,42 +810,26 @@ namespace OpenSim
834 /// If the request contains a key, "callback" the response will be wrappend in the 810 /// If the request contains a key, "callback" the response will be wrappend in the
835 /// associated value for jsonp used with ajax/javascript 811 /// associated value for jsonp used with ajax/javascript
836 /// </summary> 812 /// </summary>
837 public class UXSimStatusHandler : IStreamedRequestHandler 813 public class UXSimStatusHandler : BaseStreamHandler
838 { 814 {
839 OpenSimBase m_opensim; 815 OpenSimBase m_opensim;
840 string osUXStatsURI = String.Empty;
841
842 public string Name { get { return "UXSimStatus"; } }
843 public string Description { get { return "Simulator UXStatus"; } }
844 816
845 public UXSimStatusHandler(OpenSimBase sim) 817 public UXSimStatusHandler(OpenSimBase sim)
818 : base("GET", "/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus")
846 { 819 {
847 m_opensim = sim; 820 m_opensim = sim;
848 osUXStatsURI = sim.userStatsURI;
849
850 } 821 }
851 822
852 public byte[] Handle(string path, Stream request, 823 public override byte[] Handle(string path, Stream request,
853 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 824 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
854 { 825 {
855 return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); 826 return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
856 } 827 }
857 828
858 public string ContentType 829 public override string ContentType
859 { 830 {
860 get { return "text/plain"; } 831 get { return "text/plain"; }
861 } 832 }
862
863 public string HttpMethod
864 {
865 get { return "GET"; }
866 }
867
868 public string Path
869 {
870 // This is for the OpenSimulator instance and is the user provided URI
871 get { return "/" + osUXStatsURI; }
872 }
873 } 833 }
874 834
875 #endregion 835 #endregion
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
index c11174d..726becf 100644
--- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
+++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
@@ -46,47 +46,33 @@ using OpenSim.Region.Framework.Scenes;
46 46
47namespace OpenSim.Region.Framework.Scenes 47namespace OpenSim.Region.Framework.Scenes
48{ 48{
49 public class RegionStatsHandler : IStreamedRequestHandler 49 public class RegionStatsHandler : BaseStreamHandler
50 { 50 {
51 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 52
53 private string osRXStatsURI = String.Empty;
54 private string osXStatsURI = String.Empty; 53 private string osXStatsURI = String.Empty;
55 //private string osSecret = String.Empty; 54 //private string osSecret = String.Empty;
56 private OpenSim.Framework.RegionInfo regionInfo; 55 private OpenSim.Framework.RegionInfo regionInfo;
57 public string localZone = TimeZone.CurrentTimeZone.StandardName; 56 public string localZone = TimeZone.CurrentTimeZone.StandardName;
58 public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now); 57 public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
59 58
60 public string Name { get { return "RegionStats"; } } 59 public RegionStatsHandler(RegionInfo region_info)
61 public string Description { get { return "Region Statistics"; } } 60 : base("GET", "/" + Util.SHA1Hash(region_info.regionSecret), "RegionStats", "Region Statistics")
62
63 public RegionStatsHandler(RegionInfo region_info)
64 { 61 {
65 regionInfo = region_info; 62 regionInfo = region_info;
66 osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret);
67 osXStatsURI = Util.SHA1Hash(regionInfo.osSecret); 63 osXStatsURI = Util.SHA1Hash(regionInfo.osSecret);
68 } 64 }
69 65
70 public byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 66 public override byte[] Handle(
67 string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
71 { 68 {
72 return Util.UTF8.GetBytes(Report()); 69 return Util.UTF8.GetBytes(Report());
73 } 70 }
74 71
75 public string ContentType 72 public override string ContentType
76 { 73 {
77 get { return "text/plain"; } 74 get { return "text/plain"; }
78 } 75 }
79
80 public string HttpMethod
81 {
82 get { return "GET"; }
83 }
84
85 public string Path
86 {
87 // This is for the region and is the regionSecret hashed
88 get { return "/" + osRXStatsURI; }
89 }
90 76
91 private string Report() 77 private string Report()
92 { 78 {