From 0d2fd0d914581f755661455b8db2b9e399154632 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 17 Jun 2013 22:39:00 +0100
Subject: Make general server stats available on the robust console as well as
the simulator console
This means the "show stats" command is now active on the robust console.
---
OpenSim/Framework/Servers/BaseOpenSimServer.cs | 46 ++++++++------------------
OpenSim/Framework/Servers/ServerBase.cs | 32 ++++++++++++++++++
2 files changed, 45 insertions(+), 33 deletions(-)
(limited to 'OpenSim/Framework/Servers')
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 035b3ad..4ab6908 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -86,26 +86,23 @@ namespace OpenSim.Framework.Servers
///
protected virtual void StartupSpecific()
{
- if (m_console == null)
- return;
-
+ StatsManager.SimExtraStats = new SimExtraStatsCollector();
RegisterCommonCommands();
-
- m_console.Commands.AddCommand("General", false, "quit",
- "quit",
- "Quit the application", HandleQuit);
+ RegisterCommonComponents(Config);
+ }
+
+ protected override void ShutdownSpecific()
+ {
+ m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting...");
+
+ RemovePIDFile();
+
+ base.ShutdownSpecific();
- m_console.Commands.AddCommand("General", false, "shutdown",
- "shutdown",
- "Quit the application", HandleQuit);
+ Environment.Exit(0);
}
///
- /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing
- ///
- public virtual void ShutdownSpecific() {}
-
- ///
/// Provides a list of help topics that are available. Overriding classes should append their topics to the
/// information returned when the base method is called.
///
@@ -143,25 +140,8 @@ namespace OpenSim.Framework.Servers
timeTaken.Minutes, timeTaken.Seconds);
}
- ///
- /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing
- ///
- public virtual void Shutdown()
+ public string osSecret
{
- ShutdownSpecific();
-
- m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting...");
- RemovePIDFile();
-
- Environment.Exit(0);
- }
-
- private void HandleQuit(string module, string[] args)
- {
- Shutdown();
- }
-
- public string osSecret {
// Secret uuid for the simulator
get { return m_osSecret; }
}
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs
index 2c4a687..5358444 100644
--- a/OpenSim/Framework/Servers/ServerBase.cs
+++ b/OpenSim/Framework/Servers/ServerBase.cs
@@ -62,6 +62,8 @@ namespace OpenSim.Framework.Servers
protected string m_pidFile = String.Empty;
+ protected ServerStatsCollector m_serverStatsCollector;
+
///
/// Server version information. Usually VersionInfo + information about git commit, operating system, etc.
///
@@ -259,6 +261,25 @@ namespace OpenSim.Framework.Servers
"force gc",
"Manually invoke runtime garbage collection. For debugging purposes",
HandleForceGc);
+
+ m_console.Commands.AddCommand(
+ "General", false, "quit",
+ "quit",
+ "Quit the application", (mod, args) => Shutdown());
+
+ m_console.Commands.AddCommand(
+ "General", false, "shutdown",
+ "shutdown",
+ "Quit the application", (mod, args) => Shutdown());
+
+ StatsManager.RegisterConsoleCommands(m_console);
+ }
+
+ public void RegisterCommonComponents(IConfigSource configSource)
+ {
+ m_serverStatsCollector = new ServerStatsCollector();
+ m_serverStatsCollector.Initialise(configSource);
+ m_serverStatsCollector.Start();
}
private void HandleForceGc(string module, string[] args)
@@ -698,5 +719,16 @@ namespace OpenSim.Framework.Servers
if (m_console != null)
m_console.OutputFormat(format, components);
}
+
+ public virtual void Shutdown()
+ {
+ m_serverStatsCollector.Close();
+ ShutdownSpecific();
+ }
+
+ ///
+ /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing
+ ///
+ protected virtual void ShutdownSpecific() {}
}
}
\ No newline at end of file
--
cgit v1.1
From b7c9dee033bad425870540c08832058ac86d4ab5 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 17 Jun 2013 23:57:10 +0100
Subject: refactor: Move existing code to generate report information on the
threadpool to the ServerBase rather than being in Util
---
OpenSim/Framework/Servers/ServerBase.cs | 63 ++++++++++++++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Framework/Servers')
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs
index 5358444..029b848 100644
--- a/OpenSim/Framework/Servers/ServerBase.cs
+++ b/OpenSim/Framework/Servers/ServerBase.cs
@@ -667,7 +667,68 @@ namespace OpenSim.Framework.Servers
sb.AppendFormat("Total threads active: {0}\n\n", totalThreads);
sb.Append("Main threadpool (excluding script engine pools)\n");
- sb.Append(Util.GetThreadPoolReport());
+ sb.Append(GetThreadPoolReport());
+
+ return sb.ToString();
+ }
+
+ ///
+ /// Get a thread pool report.
+ ///
+ ///
+ public static string GetThreadPoolReport()
+ {
+ string threadPoolUsed = null;
+ int maxThreads = 0;
+ int minThreads = 0;
+ int allocatedThreads = 0;
+ int inUseThreads = 0;
+ int waitingCallbacks = 0;
+ int completionPortThreads = 0;
+
+ StringBuilder sb = new StringBuilder();
+ if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool)
+ {
+ STPInfo stpi = Util.GetSmartThreadPoolInfo();
+
+ // ROBUST currently leaves this the FireAndForgetMethod but never actually initializes the threadpool.
+ if (stpi != null)
+ {
+ threadPoolUsed = "SmartThreadPool";
+ maxThreads = stpi.MaxThreads;
+ minThreads = stpi.MinThreads;
+ inUseThreads = stpi.InUseThreads;
+ allocatedThreads = stpi.ActiveThreads;
+ waitingCallbacks = stpi.WaitingCallbacks;
+ }
+ }
+ else if (
+ Util.FireAndForgetMethod == FireAndForgetMethod.QueueUserWorkItem
+ || Util.FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem)
+ {
+ threadPoolUsed = "BuiltInThreadPool";
+ ThreadPool.GetMaxThreads(out maxThreads, out completionPortThreads);
+ ThreadPool.GetMinThreads(out minThreads, out completionPortThreads);
+ int availableThreads;
+ ThreadPool.GetAvailableThreads(out availableThreads, out completionPortThreads);
+ inUseThreads = maxThreads - availableThreads;
+ allocatedThreads = -1;
+ waitingCallbacks = -1;
+ }
+
+ if (threadPoolUsed != null)
+ {
+ sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed);
+ sb.AppendFormat("Max threads : {0}\n", maxThreads);
+ sb.AppendFormat("Min threads : {0}\n", minThreads);
+ sb.AppendFormat("Allocated threads : {0}\n", allocatedThreads < 0 ? "not applicable" : allocatedThreads.ToString());
+ sb.AppendFormat("In use threads : {0}\n", inUseThreads);
+ sb.AppendFormat("Work items waiting : {0}\n", waitingCallbacks < 0 ? "not available" : waitingCallbacks.ToString());
+ }
+ else
+ {
+ sb.AppendFormat("Thread pool not used\n");
+ }
return sb.ToString();
}
--
cgit v1.1
From 9501a583cbc8fd819d2b13db4f9ad76958520ce7 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 18 Jun 2013 23:07:18 +0100
Subject: Make number of inbound http requests handled available as a
httpserver..IncomingHTTPRequestsProcessed stat
---
.../Framework/Servers/HttpServer/BaseHttpServer.cs | 30 ++++++++++++++++++----
1 file changed, 25 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Framework/Servers')
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 96a030b..6687441 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -54,7 +54,6 @@ namespace OpenSim.Framework.Servers.HttpServer
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
-
///
/// This is a pending websocket request before it got an sucessful upgrade response.
/// The consumer must call handler.HandshakeAndUpgrade() to signal to the handler to
@@ -81,6 +80,11 @@ namespace OpenSim.Framework.Servers.HttpServer
///
public int RequestNumber { get; private set; }
+ ///
+ /// Statistic for holding number of requests processed.
+ ///
+ private Stat m_requestsProcessedStat;
+
private volatile int NotSocketErrors = 0;
public volatile bool HTTPDRunning = false;
@@ -436,9 +440,8 @@ namespace OpenSim.Framework.Servers.HttpServer
}
}
- public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request)
+ private void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request)
{
-
OSHttpRequest req = new OSHttpRequest(context, request);
WebSocketRequestDelegate dWebSocketRequestDelegate = null;
lock (m_WebSocketHandlers)
@@ -454,8 +457,7 @@ namespace OpenSim.Framework.Servers.HttpServer
OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
resp.ReuseContext = true;
- HandleRequest(req, resp);
-
+ HandleRequest(req, resp);
// !!!HACK ALERT!!!
// There seems to be a bug in the underlying http code that makes subsequent requests
@@ -1824,6 +1826,21 @@ namespace OpenSim.Framework.Servers.HttpServer
// useful without inbound HTTP.
throw e;
}
+
+ m_requestsProcessedStat
+ = new Stat(
+ "IncomingHTTPRequestsProcessed",
+ "Number of inbound HTTP requests processed",
+ "",
+ "requests",
+ "httpserver",
+ Port.ToString(),
+ StatType.Pull,
+ MeasuresOfInterest.AverageChangeOverTime,
+ stat => stat.Value = RequestNumber,
+ StatVerbosity.Debug);
+
+ StatsManager.RegisterStat(m_requestsProcessedStat);
}
public void httpServerDisconnectMonitor(IHttpClientContext source, SocketError err)
@@ -1854,6 +1871,9 @@ namespace OpenSim.Framework.Servers.HttpServer
public void Stop()
{
HTTPDRunning = false;
+
+ StatsManager.DeregisterStat(m_requestsProcessedStat);
+
try
{
m_PollServiceManager.Stop();
--
cgit v1.1
From 84af1cab9ba991b2356f1025cab7f58433e2ec19 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 19 Jun 2013 20:48:12 +0100
Subject: Display existing statistic of how many http requests a server is
making as server.network.HTTPRequestsMade in "show stats all"
---
OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Framework/Servers')
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 6687441..40b8c5c 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -1829,7 +1829,7 @@ namespace OpenSim.Framework.Servers.HttpServer
m_requestsProcessedStat
= new Stat(
- "IncomingHTTPRequestsProcessed",
+ "HTTPRequestsServed",
"Number of inbound HTTP requests processed",
"",
"requests",
--
cgit v1.1
From a33b6eed6d09661445a638efcbb354b0330f9093 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 20 Jun 2013 00:54:19 +0100
Subject: minor: remove mono compiler warnings in WebsocketServerHandler.cs
---
.../Servers/HttpServer/WebsocketServerHandler.cs | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
(limited to 'OpenSim/Framework/Servers')
diff --git a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs
index ee96b47..de89e2e 100644
--- a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs
@@ -75,7 +75,7 @@ namespace OpenSim.Framework.Servers.HttpServer
///
/// This is a regular HTTP Request... This may be removed in the future.
///
- public event RegularHttpRequestDelegate OnRegularHttpRequest;
+// public event RegularHttpRequestDelegate OnRegularHttpRequest;
///
/// When the upgrade from a HTTP request to a Websocket is completed, this will be fired
@@ -304,15 +304,14 @@ namespace OpenSim.Framework.Servers.HttpServer
if (d != null)
d(this, new UpgradeCompletedEventArgs());
}
- catch (IOException fail)
+ catch (IOException)
{
Close(string.Empty);
}
- catch (ObjectDisposedException fail)
+ catch (ObjectDisposedException)
{
Close(string.Empty);
- }
-
+ }
}
///
@@ -414,8 +413,6 @@ namespace OpenSim.Framework.Servers.HttpServer
_socketState.Header = pheader;
}
-
-
if (_socketState.FrameComplete)
{
ProcessFrame(_socketState);
@@ -424,7 +421,6 @@ namespace OpenSim.Framework.Servers.HttpServer
_socketState.ExpectedBytes = 0;
}
-
}
}
else
@@ -457,8 +453,7 @@ namespace OpenSim.Framework.Servers.HttpServer
_socketState.ReceivedBytes.Clear();
_socketState.ExpectedBytes = 0;
// do some processing
- }
-
+ }
}
}
if (offset > 0)
@@ -477,13 +472,12 @@ namespace OpenSim.Framework.Servers.HttpServer
{
// We can't read the stream anymore...
}
-
}
- catch (IOException fail)
+ catch (IOException)
{
Close(string.Empty);
}
- catch (ObjectDisposedException fail)
+ catch (ObjectDisposedException)
{
Close(string.Empty);
}
--
cgit v1.1