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
cpu-performance
Justin Clark-Casey (justincc) 2013-07-08 22:03:07 +01:00
parent a38c2abae4
commit e19defde36
43 changed files with 346 additions and 80 deletions

View File

@ -113,7 +113,7 @@ namespace OpenSim.Groups
m_GroupsService = service; m_GroupsService = service;
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);

View File

@ -75,7 +75,7 @@ namespace OpenSim.Groups
m_GroupsService = service; m_GroupsService = service;
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);

View File

@ -75,7 +75,7 @@ namespace OpenSim.OfflineIM
m_OfflineIMService = service; m_OfflineIMService = service;
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);

View File

@ -184,5 +184,17 @@ namespace OpenSim.Framework.Capabilities
return caps; return caps;
} }
/// <summary>
/// Returns a copy of the dictionary of all the HTTP cap handlers
/// </summary>
/// <returns>
/// The dictionary copy. The key is the capability name, the value is the HTTP handler.
/// </returns>
public Dictionary<string, IRequestHandler> GetCapsHandlers()
{
lock (m_capsHandlers)
return new Dictionary<string, IRequestHandler>(m_capsHandlers);
}
} }
} }

View File

@ -56,7 +56,7 @@ namespace OpenSim.Capabilities.Handlers
m_PeopleService = peopleService; m_PeopleService = peopleService;
} }
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
// Try to parse the texture ID from the request URL // Try to parse the texture ID from the request URL
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);

View File

@ -64,7 +64,7 @@ namespace OpenSim.Capabilities.Handlers
m_assetService = assService; m_assetService = assService;
} }
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
// Try to parse the texture ID from the request URL // Try to parse the texture ID from the request URL
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);

View File

@ -48,7 +48,7 @@ namespace OpenSim.Framework.Capabilities
m_method = method; m_method = method;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
//Encoding encoding = Util.UTF8; //Encoding encoding = Util.UTF8;

View File

@ -31,6 +31,10 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
public abstract class BaseRequestHandler public abstract class BaseRequestHandler
{ {
public int RequestsReceived { get; protected set; }
public int RequestsHandled { get; protected set; }
public virtual string ContentType public virtual string ContentType
{ {
get { return "application/xml"; } get { return "application/xml"; }

View File

@ -29,14 +29,35 @@ using System.IO;
namespace OpenSim.Framework.Servers.HttpServer namespace OpenSim.Framework.Servers.HttpServer
{ {
/// <summary>
/// Base streamed request handler.
/// </summary>
/// <remarks>
/// Inheriting classes should override ProcessRequest() rather than Handle()
/// </remarks>
public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler
{ {
public abstract byte[] Handle(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse);
protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {}
protected BaseStreamHandler(string httpMethod, string path, string name, string description) protected BaseStreamHandler(string httpMethod, string path, string name, string description)
: base(httpMethod, path, name, description) {} : base(httpMethod, path, name, description) {}
public virtual byte[] Handle(
string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
RequestsReceived++;
byte[] result = ProcessRequest(path, request, httpRequest, httpResponse);
RequestsHandled++;
return result;
}
protected virtual byte[] ProcessRequest(
string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
return null;
}
} }
} }

View File

@ -45,7 +45,7 @@ namespace OpenSim.Framework.Servers.HttpServer
m_method = binaryMethod; m_method = binaryMethod;
} }
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
byte[] data = ReadFully(request); byte[] data = ReadFully(request);
string param = GetParam(path); string param = GetParam(path);

View File

@ -32,7 +32,6 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
public interface IRequestHandler public interface IRequestHandler
{ {
/// <summary> /// <summary>
/// Name for this handler. /// Name for this handler.
/// </summary> /// </summary>
@ -59,6 +58,19 @@ namespace OpenSim.Framework.Servers.HttpServer
// Return path // Return path
string Path { get; } string Path { get; }
/// <summary>
/// Number of requests received by this handler
/// </summary>
int RequestsReceived { get; }
/// <summary>
/// Number of requests handled.
/// </summary>
/// <remarks>
/// Should be equal to RequestsReceived unless requested are being handled slowly or there is deadlock.
/// </remarks>
int RequestsHandled { get; }
} }
public interface IStreamedRequestHandler : IRequestHandler public interface IStreamedRequestHandler : IRequestHandler
@ -69,7 +81,6 @@ namespace OpenSim.Framework.Servers.HttpServer
public interface IStreamHandler : IRequestHandler public interface IStreamHandler : IRequestHandler
{ {
// Handle request stream, return byte array
void Handle(string path, Stream request, Stream response, IOSHttpRequest httpReqbuest, IOSHttpResponse httpResponse); void Handle(string path, Stream request, Stream response, IOSHttpRequest httpReqbuest, IOSHttpResponse httpResponse);
} }

View File

@ -33,7 +33,7 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request); public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request);
public class RestDeserialiseHandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler public class RestDeserialiseHandler<TRequest, TResponse> : BaseOutputStreamHandler, IStreamHandler
where TRequest : new() where TRequest : new()
{ {
private RestDeserialiseMethod<TRequest, TResponse> m_method; private RestDeserialiseMethod<TRequest, TResponse> m_method;
@ -48,7 +48,7 @@ namespace OpenSim.Framework.Servers.HttpServer
m_method = method; m_method = method;
} }
public void Handle(string path, Stream request, Stream responseStream, protected override void ProcessRequest(string path, Stream request, Stream responseStream,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
TRequest deserial; TRequest deserial;

View File

@ -183,7 +183,7 @@ namespace OpenSim.Framework.Servers.HttpServer
public delegate bool CheckIdentityMethod(string sid, string aid); public delegate bool CheckIdentityMethod(string sid, string aid);
public class RestDeserialiseSecureHandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler public class RestDeserialiseSecureHandler<TRequest, TResponse> : BaseOutputStreamHandler, IStreamHandler
where TRequest : new() where TRequest : new()
{ {
private static readonly ILog m_log private static readonly ILog m_log
@ -201,7 +201,7 @@ namespace OpenSim.Framework.Servers.HttpServer
m_method = method; m_method = method;
} }
public void Handle(string path, Stream request, Stream responseStream, protected override void ProcessRequest(string path, Stream request, Stream responseStream,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
RestSessionObject<TRequest> deserial = default(RestSessionObject<TRequest>); RestSessionObject<TRequest> deserial = default(RestSessionObject<TRequest>);
@ -237,7 +237,7 @@ namespace OpenSim.Framework.Servers.HttpServer
public delegate bool CheckTrustedSourceMethod(IPEndPoint peer); public delegate bool CheckTrustedSourceMethod(IPEndPoint peer);
public class RestDeserialiseTrustedHandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler public class RestDeserialiseTrustedHandler<TRequest, TResponse> : BaseOutputStreamHandler, IStreamHandler
where TRequest : new() where TRequest : new()
{ {
private static readonly ILog m_log private static readonly ILog m_log
@ -260,7 +260,7 @@ namespace OpenSim.Framework.Servers.HttpServer
m_method = method; m_method = method;
} }
public void Handle(string path, Stream request, Stream responseStream, protected override void ProcessRequest(string path, Stream request, Stream responseStream,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
TRequest deserial = default(TRequest); TRequest deserial = default(TRequest);
@ -293,5 +293,4 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
} }
} }
} }

View File

@ -48,7 +48,7 @@ namespace OpenSim.Framework.Servers.HttpServer
m_restMethod = restMethod; m_restMethod = restMethod;
} }
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
Encoding encoding = Encoding.UTF8; Encoding encoding = Encoding.UTF8;
StreamReader streamReader = new StreamReader(request, encoding); StreamReader streamReader = new StreamReader(request, encoding);

View File

@ -766,7 +766,7 @@ namespace OpenSim
{ {
public SimStatusHandler() : base("GET", "/simstatus", "SimStatus", "Simulator Status") {} 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) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
return Util.UTF8.GetBytes("OK"); return Util.UTF8.GetBytes("OK");
@ -792,7 +792,7 @@ namespace OpenSim
m_opensim = sim; m_opensim = sim;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); 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 /// If the request contains a key, "callback" the response will be wrappend in the
/// associated value for jsonp used with ajax/javascript /// associated value for jsonp used with ajax/javascript
/// </summary> /// </summary>
public class UXSimStatusHandler : BaseStreamHandler protected class UXSimStatusHandler : BaseStreamHandler
{ {
OpenSimBase m_opensim; OpenSimBase m_opensim;
@ -820,7 +820,7 @@ namespace OpenSim
m_opensim = sim; m_opensim = sim;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));

View File

@ -176,7 +176,7 @@ namespace OpenSim.Region.ClientStack.Linden
m_isGod = m_scene.Permissions.IsGod(agentID); m_isGod = m_scene.Permissions.IsGod(agentID);
} }
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader reader = new StreamReader(request); StreamReader reader = new StreamReader(request);
string message = reader.ReadToEnd(); string message = reader.ReadToEnd();

View File

@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
m_FriendsModule = fmodule; m_FriendsModule = fmodule;
} }
public override byte[] Handle( protected override byte[] ProcessRequest(
string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);

View File

@ -28,6 +28,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using log4net; using log4net;
@ -37,6 +38,7 @@ using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using Caps=OpenSim.Framework.Capabilities.Caps; using Caps=OpenSim.Framework.Capabilities.Caps;
@ -58,6 +60,7 @@ namespace OpenSim.Region.CoreModules.Framework
protected Dictionary<UUID, Caps> m_capsObjects = new Dictionary<UUID, Caps>(); protected Dictionary<UUID, Caps> m_capsObjects = new Dictionary<UUID, Caps>();
protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>(); protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>();
protected Dictionary<UUID, Dictionary<ulong, string>> m_childrenSeeds protected Dictionary<UUID, Dictionary<ulong, string>> m_childrenSeeds
= new Dictionary<UUID, Dictionary<ulong, string>>(); = new Dictionary<UUID, Dictionary<ulong, string>>();
@ -70,9 +73,24 @@ namespace OpenSim.Region.CoreModules.Framework
m_scene = scene; m_scene = scene;
m_scene.RegisterModuleInterface<ICapabilitiesModule>(this); m_scene.RegisterModuleInterface<ICapabilitiesModule>(this);
MainConsole.Instance.Commands.AddCommand("Comms", false, "show caps", MainConsole.Instance.Commands.AddCommand(
"show caps", "Comms", false, "show caps list",
"Shows all registered capabilities for users", HandleShowCapsCommand); "show caps list",
"Shows list of registered capabilities for users.", HandleShowCapsListCommand);
MainConsole.Instance.Commands.AddCommand(
"Comms", false, "show caps stats by user",
"show caps stats [<first-name> <last-name>]",
"Shows statistics on capabilities use by user.",
"If a user name is given, then prints a detailed breakdown of caps use ordered by number of requests received.",
HandleShowCapsStatsByUserCommand);
MainConsole.Instance.Commands.AddCommand(
"Comms", false, "show caps stats by cap",
"show caps stats by cap [<cap-name>]",
"Shows statistics on capabilities use by capability.",
"If a capability name is given, then prints a detailed breakdown of use by each user.",
HandleShowCapsStatsByCapCommand);
} }
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
@ -262,8 +280,11 @@ namespace OpenSim.Region.CoreModules.Framework
} }
} }
private void HandleShowCapsCommand(string module, string[] cmdparams) private void HandleShowCapsListCommand(string module, string[] cmdParams)
{ {
if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
return;
StringBuilder caps = new StringBuilder(); StringBuilder caps = new StringBuilder();
caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName);
@ -286,5 +307,210 @@ namespace OpenSim.Region.CoreModules.Framework
MainConsole.Instance.Output(caps.ToString()); MainConsole.Instance.Output(caps.ToString());
} }
private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams)
{
if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
return;
if (cmdParams.Length != 5 && cmdParams.Length != 6)
{
MainConsole.Instance.Output("Usage: show caps stats by cap [<cap-name>]");
return;
}
StringBuilder sb = new StringBuilder();
sb.AppendFormat("Region {0}:\n", m_scene.Name);
if (cmdParams.Length == 5)
{
BuildSummaryStatsByCapReport(sb);
}
else if (cmdParams.Length == 6)
{
BuildDetailedStatsByCapReport(sb, cmdParams[5]);
}
MainConsole.Instance.Output(sb.ToString());
}
private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName)
{
sb.AppendFormat("Capability name {0}\n", capName);
ConsoleDisplayTable cdt = new ConsoleDisplayTable();
cdt.AddColumn("User Name", 34);
cdt.AddColumn("Req Received", 12);
cdt.AddColumn("Req Handled", 12);
cdt.Indent = 2;
Dictionary<string, int> receivedStats = new Dictionary<string, int>();
Dictionary<string, int> handledStats = new Dictionary<string, int>();
m_scene.ForEachScenePresence(
sp =>
{
Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
if (caps == null)
return;
Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
IRequestHandler reqHandler;
if (capsHandlers.TryGetValue(capName, out reqHandler))
{
receivedStats[sp.Name] = reqHandler.RequestsReceived;
handledStats[sp.Name] = reqHandler.RequestsHandled;
}
}
);
foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value))
{
cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]);
}
sb.Append(cdt.ToString());
}
private void BuildSummaryStatsByCapReport(StringBuilder sb)
{
ConsoleDisplayTable cdt = new ConsoleDisplayTable();
cdt.AddColumn("Name", 34);
cdt.AddColumn("Req Received", 12);
cdt.AddColumn("Req Handled", 12);
cdt.Indent = 2;
Dictionary<string, int> receivedStats = new Dictionary<string, int>();
Dictionary<string, int> handledStats = new Dictionary<string, int>();
m_scene.ForEachScenePresence(
sp =>
{
Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
if (caps == null)
return;
Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
foreach (IRequestHandler reqHandler in capsHandlers.Values)
{
string reqName = reqHandler.Name ?? "";
if (!receivedStats.ContainsKey(reqName))
{
receivedStats[reqName] = reqHandler.RequestsReceived;
handledStats[reqName] = reqHandler.RequestsHandled;
}
else
{
receivedStats[reqName] += reqHandler.RequestsReceived;
handledStats[reqName] += reqHandler.RequestsHandled;
}
}
}
);
foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value))
cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]);
sb.Append(cdt.ToString());
}
private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams)
{
if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
return;
if (cmdParams.Length != 5 && cmdParams.Length != 7)
{
MainConsole.Instance.Output("Usage: show caps stats by user [<first-name> <last-name>]");
return;
}
StringBuilder sb = new StringBuilder();
sb.AppendFormat("Region {0}:\n", m_scene.Name);
if (cmdParams.Length == 5)
{
BuildSummaryStatsByUserReport(sb);
}
else if (cmdParams.Length == 7)
{
string firstName = cmdParams[5];
string lastName = cmdParams[6];
ScenePresence sp = m_scene.GetScenePresence(firstName, lastName);
if (sp == null)
return;
BuildDetailedStatsByUserReport(sb, sp);
}
MainConsole.Instance.Output(sb.ToString());
}
private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp)
{
sb.AppendFormat("Avatar name {0}, type {1}\n", sp.Name, sp.IsChildAgent ? "child" : "root");
ConsoleDisplayTable cdt = new ConsoleDisplayTable();
cdt.AddColumn("Cap Name", 34);
cdt.AddColumn("Req Received", 12);
cdt.AddColumn("Req Handled", 12);
cdt.Indent = 2;
Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
if (caps == null)
return;
Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
foreach (IRequestHandler reqHandler in capsHandlers.Values.OrderByDescending(rh => rh.RequestsReceived))
{
cdt.AddRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled);
}
sb.Append(cdt.ToString());
}
private void BuildSummaryStatsByUserReport(StringBuilder sb)
{
ConsoleDisplayTable cdt = new ConsoleDisplayTable();
cdt.AddColumn("Name", 32);
cdt.AddColumn("Type", 5);
cdt.AddColumn("Req Received", 12);
cdt.AddColumn("Req Handled", 12);
cdt.Indent = 2;
m_scene.ForEachScenePresence(
sp =>
{
Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
if (caps == null)
return;
Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
int totalRequestsReceived = 0;
int totalRequestsHandled = 0;
foreach (IRequestHandler reqHandler in capsHandlers.Values)
{
totalRequestsReceived += reqHandler.RequestsReceived;
totalRequestsHandled += reqHandler.RequestsHandled;
}
cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled);
}
);
sb.Append(cdt.ToString());
}
} }
} }

View File

@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
m_EstateModule = fmodule; m_EstateModule = fmodule;
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);

View File

@ -63,7 +63,7 @@ namespace OpenSim.Region.Framework.Scenes
osXStatsURI = Util.SHA1Hash(regionInfo.osSecret); osXStatsURI = Util.SHA1Hash(regionInfo.osSecret);
} }
public override byte[] Handle( protected override byte[] ProcessRequest(
string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
return Util.UTF8.GetBytes(Report()); return Util.UTF8.GetBytes(Report());

View File

@ -281,7 +281,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
m_module = module; m_module = module;
} }
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader reader = new StreamReader(request); StreamReader reader = new StreamReader(request);
string requestBody = reader.ReadToEnd(); string requestBody = reader.ReadToEnd();

View File

@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.World.WorldView
m_WorldViewModule = fmodule; m_WorldViewModule = fmodule;
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
httpResponse.ContentType = "image/jpeg"; httpResponse.ContentType = "image/jpeg";

View File

@ -70,7 +70,7 @@ namespace OpenSim.Server.Handlers.Asset
m_allowedTypes = allowedTypes; m_allowedTypes = allowedTypes;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
bool result = false; bool result = false;

View File

@ -54,7 +54,7 @@ namespace OpenSim.Server.Handlers.Asset
m_AssetService = service; m_AssetService = service;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
byte[] result = new byte[0]; byte[] result = new byte[0];

View File

@ -54,7 +54,7 @@ namespace OpenSim.Server.Handlers.Asset
m_AssetService = service; m_AssetService = service;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
AssetBase asset; AssetBase asset;

View File

@ -70,7 +70,7 @@ namespace OpenSim.Server.Handlers.Authentication
} }
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
string[] p = SplitParams(path); string[] p = SplitParams(path);

View File

@ -147,7 +147,7 @@ namespace OpenSim.Server.Handlers.Authentication
#endregion #endregion
} }
public class OpenIdStreamHandler : IStreamHandler public class OpenIdStreamHandler : BaseOutputStreamHandler
{ {
#region HTML #region HTML
@ -191,42 +191,34 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>.
#endregion HTML #endregion HTML
public string Name { get { return "OpenId"; } }
public string Description { get { return null; } }
public string ContentType { get { return m_contentType; } }
public string HttpMethod { get { return m_httpMethod; } }
public string Path { get { return m_path; } }
string m_contentType;
string m_httpMethod;
string m_path;
IAuthenticationService m_authenticationService; IAuthenticationService m_authenticationService;
IUserAccountService m_userAccountService; IUserAccountService m_userAccountService;
ProviderMemoryStore m_openidStore = new ProviderMemoryStore(); ProviderMemoryStore m_openidStore = new ProviderMemoryStore();
public override string ContentType { get { return "text/html"; } }
/// <summary> /// <summary>
/// Constructor /// Constructor
/// </summary> /// </summary>
public OpenIdStreamHandler(string httpMethod, string path, IUserAccountService userService, IAuthenticationService authService) public OpenIdStreamHandler(
string httpMethod, string path, IUserAccountService userService, IAuthenticationService authService)
: base(httpMethod, path, "OpenId", "OpenID stream handler")
{ {
m_authenticationService = authService; m_authenticationService = authService;
m_userAccountService = userService; m_userAccountService = userService;
m_httpMethod = httpMethod;
m_path = path;
m_contentType = "text/html";
} }
/// <summary> /// <summary>
/// Handles all GET and POST requests for OpenID identifier pages and endpoint /// Handles all GET and POST requests for OpenID identifier pages and endpoint
/// server communication /// server communication
/// </summary> /// </summary>
public void Handle(string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) protected override void ProcessRequest(
string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
Uri providerEndpoint = new Uri(String.Format("{0}://{1}{2}", httpRequest.Url.Scheme, httpRequest.Url.Authority, httpRequest.Url.AbsolutePath)); Uri providerEndpoint = new Uri(String.Format("{0}://{1}{2}", httpRequest.Url.Scheme, httpRequest.Url.Authority, httpRequest.Url.AbsolutePath));
// Defult to returning HTML content // Defult to returning HTML content
m_contentType = "text/html"; httpResponse.ContentType = ContentType;
try try
{ {
@ -276,7 +268,7 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>.
string[] contentTypeValues = provider.Request.Response.Headers.GetValues("Content-Type"); string[] contentTypeValues = provider.Request.Response.Headers.GetValues("Content-Type");
if (contentTypeValues != null && contentTypeValues.Length == 1) if (contentTypeValues != null && contentTypeValues.Length == 1)
m_contentType = contentTypeValues[0]; httpResponse.ContentType = contentTypeValues[0];
// Set the response code and document body based on the OpenID result // Set the response code and document body based on the OpenID result
httpResponse.StatusCode = (int)provider.Request.Response.Code; httpResponse.StatusCode = (int)provider.Request.Response.Code;

View File

@ -54,7 +54,7 @@ namespace OpenSim.Server.Handlers.Authorization
m_AuthorizationService = service; m_AuthorizationService = service;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
XmlSerializer xs = new XmlSerializer(typeof (AuthorizationRequest)); XmlSerializer xs = new XmlSerializer(typeof (AuthorizationRequest));

View File

@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.Avatar
m_AvatarService = service; m_AvatarService = service;
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);

View File

@ -57,7 +57,7 @@ namespace OpenSim.Server.Handlers.Friends
m_FriendsService = service; m_FriendsService = service;
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);

View File

@ -57,7 +57,7 @@ namespace OpenSim.Server.Handlers.Grid
m_GridService = service; m_GridService = service;
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);

View File

@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.GridUser
m_GridUserService = service; m_GridUserService = service;
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);

View File

@ -68,7 +68,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
m_log.ErrorFormat("[HGFRIENDS HANDLER]: TheService is null!"); m_log.ErrorFormat("[HGFRIENDS HANDLER]: TheService is null!");
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);

View File

@ -91,7 +91,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
m_HandlersType = handlersType; m_HandlersType = handlersType;
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
return OKResponse(httpResponse); return OKResponse(httpResponse);

View File

@ -68,6 +68,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
{ {
return new ExtendedAgentDestinationData(); return new ExtendedAgentDestinationData();
} }
protected override void UnpackData(OSDMap args, AgentDestinationData d, Hashtable request) protected override void UnpackData(OSDMap args, AgentDestinationData d, Hashtable request)
{ {
base.UnpackData(args, d, request); base.UnpackData(args, d, request);

View File

@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.Inventory
m_InventoryService = service; m_InventoryService = service;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
XmlSerializer xs = new XmlSerializer(typeof (List<InventoryItemBase>)); XmlSerializer xs = new XmlSerializer(typeof (List<InventoryItemBase>));

View File

@ -87,7 +87,7 @@ namespace OpenSim.Server.Handlers.Asset
m_InventoryService = service; m_InventoryService = service;
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);

View File

@ -99,7 +99,7 @@ namespace OpenSim.Server.Handlers.MapImage
m_Proxy = proxy; m_Proxy = proxy;
} }
public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path); // m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path);
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);

View File

@ -80,7 +80,7 @@ namespace OpenSim.Server.Handlers.MapImage
m_MapService = service; m_MapService = service;
} }
public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
byte[] result = new byte[0]; byte[] result = new byte[0];

View File

@ -58,7 +58,7 @@ namespace OpenSim.Server.Handlers.Neighbour
// TODO: unused: m_AuthenticationService = authentication; // TODO: unused: m_AuthenticationService = authentication;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
// Not implemented yet // Not implemented yet
@ -83,7 +83,7 @@ namespace OpenSim.Server.Handlers.Neighbour
// TODO: unused: m_AllowForeignGuests = foreignGuests; // TODO: unused: m_AllowForeignGuests = foreignGuests;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
byte[] result = new byte[0]; byte[] result = new byte[0];
@ -176,7 +176,7 @@ namespace OpenSim.Server.Handlers.Neighbour
// TODO: unused: m_AuthenticationService = authentication; // TODO: unused: m_AuthenticationService = authentication;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
// Not implemented yet // Not implemented yet
@ -197,7 +197,7 @@ namespace OpenSim.Server.Handlers.Neighbour
// TODO: unused: m_AuthenticationService = authentication; // TODO: unused: m_AuthenticationService = authentication;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
// Not implemented yet // Not implemented yet

View File

@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.Presence
m_PresenceService = service; m_PresenceService = service;
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);

View File

@ -251,7 +251,7 @@ namespace OpenSim.Server.Handlers.Simulation
m_SimulationService = null; m_SimulationService = null;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
// m_log.DebugFormat("[SIMULATION]: Stream handler called"); // m_log.DebugFormat("[SIMULATION]: Stream handler called");
@ -457,7 +457,7 @@ namespace OpenSim.Server.Handlers.Simulation
m_SimulationService = null; m_SimulationService = null;
} }
public override byte[] Handle(string path, Stream request, protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
// m_log.DebugFormat("[SIMULATION]: Stream handler called"); // m_log.DebugFormat("[SIMULATION]: Stream handler called");

View File

@ -68,7 +68,7 @@ namespace OpenSim.Server.Handlers.UserAccounts
} }
} }
public override byte[] Handle(string path, Stream requestData, protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);