From 5dbdd5f8b4856357340357394edc2f9e229a0582 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 6 Jul 2013 00:12:48 +0100
Subject: refactor: Make stats and sim status simpler by extending
BaseStreamHandler like other handlers instead of implementing the
IStreamedRequestHandler interface directly
---
OpenSim/Region/Application/OpenSimBase.cs | 74 +++++++------------------------
1 file changed, 17 insertions(+), 57 deletions(-)
(limited to 'OpenSim/Region/Application/OpenSimBase.cs')
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
///
/// Handler to supply the current status of this sim
///
+ ///
/// Currently this is always OK if the simulator is still listening for connections on its HTTP service
- public class SimStatusHandler : IStreamedRequestHandler
+ ///
+ public class SimStatusHandler : BaseStreamHandler
{
- public byte[] Handle(string path, Stream request,
+ public SimStatusHandler() : base("GET", "/simstatus", "SimStatus", "Simulator Status") {}
+
+ public override byte[] Handle(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
return Util.UTF8.GetBytes("OK");
}
- public string Name { get { return "SimStatus"; } }
- public string Description { get { return "Simulator Status"; } }
-
- public string ContentType
+ public override string ContentType
{
get { return "text/plain"; }
}
-
- public string HttpMethod
- {
- get { return "GET"; }
- }
-
- public string Path
- {
- get { return "/simstatus"; }
- }
}
///
/// Handler to supply the current extended status of this sim
/// Sends the statistical data in a json serialization
///
- public class XSimStatusHandler : IStreamedRequestHandler
+ public class XSimStatusHandler : BaseStreamHandler
{
OpenSimBase m_opensim;
- string osXStatsURI = String.Empty;
-
- public string Name { get { return "XSimStatus"; } }
- public string Description { get { return "Simulator XStatus"; } }
- public XSimStatusHandler(OpenSimBase sim)
+ public XSimStatusHandler(OpenSimBase sim)
+ : base("GET", "/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus")
{
m_opensim = sim;
- osXStatsURI = Util.SHA1Hash(sim.osSecret);
}
- public byte[] Handle(string path, Stream request,
+ public override byte[] Handle(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
}
- public string ContentType
+ public override string ContentType
{
get { return "text/plain"; }
}
-
- public string HttpMethod
- {
- get { return "GET"; }
- }
-
- public string Path
- {
- // This is for the OpenSimulator instance and is the osSecret hashed
- get { return "/" + osXStatsURI; }
- }
}
///
@@ -834,42 +810,26 @@ namespace OpenSim
/// If the request contains a key, "callback" the response will be wrappend in the
/// associated value for jsonp used with ajax/javascript
///
- public class UXSimStatusHandler : IStreamedRequestHandler
+ public class UXSimStatusHandler : BaseStreamHandler
{
OpenSimBase m_opensim;
- string osUXStatsURI = String.Empty;
-
- public string Name { get { return "UXSimStatus"; } }
- public string Description { get { return "Simulator UXStatus"; } }
public UXSimStatusHandler(OpenSimBase sim)
+ : base("GET", "/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus")
{
- m_opensim = sim;
- osUXStatsURI = sim.userStatsURI;
-
+ m_opensim = sim;
}
- public byte[] Handle(string path, Stream request,
+ public override byte[] Handle(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
}
- public string ContentType
+ public override string ContentType
{
get { return "text/plain"; }
}
-
- public string HttpMethod
- {
- get { return "GET"; }
- }
-
- public string Path
- {
- // This is for the OpenSimulator instance and is the user provided URI
- get { return "/" + osUXStatsURI; }
- }
}
#endregion
--
cgit v1.1
From e19defde36ddbd5ff90d8304c6fe3b57110f8078 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 8 Jul 2013 22:03:07 +0100
Subject: Add "show caps stats by user" and "show caps stats by cap" console
commands to print various counts of capability invocation by user and by cap
This currently prints caps requests received and handled, so that overload of received compared to handled or deadlock can be detected.
This involves making BaseStreamHandler and BaseOutputStream record the ints, which means inheritors should subclass ProcessRequest() instead of Handle()
However, existing inheriting classes overriding Handle() will still work, albeit without stats recording.
"show caps" becomes "show caps list" to disambiguate between show caps commands
---
OpenSim/Region/Application/OpenSimBase.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/Application/OpenSimBase.cs')
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 841069c..f0c088a 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -766,7 +766,7 @@ namespace OpenSim
{
public SimStatusHandler() : base("GET", "/simstatus", "SimStatus", "Simulator Status") {}
- public override byte[] Handle(string path, Stream request,
+ protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
return Util.UTF8.GetBytes("OK");
@@ -792,7 +792,7 @@ namespace OpenSim
m_opensim = sim;
}
- public override byte[] Handle(string path, Stream request,
+ protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
@@ -810,7 +810,7 @@ namespace OpenSim
/// If the request contains a key, "callback" the response will be wrappend in the
/// associated value for jsonp used with ajax/javascript
///
- public class UXSimStatusHandler : BaseStreamHandler
+ protected class UXSimStatusHandler : BaseStreamHandler
{
OpenSimBase m_opensim;
@@ -820,7 +820,7 @@ namespace OpenSim
m_opensim = sim;
}
- public override byte[] Handle(string path, Stream request,
+ protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
--
cgit v1.1