Add "show eq" console command to show numbers of messages in agent event queues.

For debugging purposes.
0.7.4-extended
Justin Clark-Casey (justincc) 2013-03-28 01:36:34 +00:00
parent 44434e8200
commit 0d67aa23d5
1 changed files with 64 additions and 56 deletions

View File

@ -55,8 +55,8 @@ namespace OpenSim.Region.ClientStack.Linden
public OSDMap body;
}
//[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class EventQueueGetModule : IEventQueue, IRegionModule
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EventQueueGetModule")]
public class EventQueueGetModule : IEventQueue, INonSharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -66,8 +66,6 @@ namespace OpenSim.Region.ClientStack.Linden
public int DebugLevel { get; set; }
protected Scene m_scene;
private IConfigSource m_gConfig;
bool enabledYN;
private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>();
@ -75,60 +73,54 @@ namespace OpenSim.Region.ClientStack.Linden
private Dictionary<UUID, UUID> m_QueueUUIDAvatarMapping = new Dictionary<UUID, UUID>();
private Dictionary<UUID, UUID> m_AvatarQueueUUIDMapping = new Dictionary<UUID, UUID>();
#region IRegionModule methods
public virtual void Initialise(Scene scene, IConfigSource config)
#region INonSharedRegionModule methods
public virtual void Initialise(IConfigSource config)
{
m_gConfig = config;
IConfig startupConfig = m_gConfig.Configs["Startup"];
ReadConfigAndPopulate(scene, startupConfig, "Startup");
if (enabledYN)
{
m_scene = scene;
scene.RegisterModuleInterface<IEventQueue>(this);
// Register fallback handler
// Why does EQG Fail on region crossings!
//scene.CommsManager.HttpServer.AddLLSDHandler("/CAPS/EQG/", EventQueueFallBack);
// scene.EventManager.OnNewClient += OnNewClient;
// TODO: Leaving these open, or closing them when we
// become a child is incorrect. It messes up TP in a big
// way. CAPS/EQ need to be active as long as the UDP
// circuit is there.
scene.EventManager.OnClientClosed += ClientClosed;
scene.EventManager.OnMakeChildAgent += MakeChildAgent;
scene.EventManager.OnRegisterCaps += OnRegisterCaps;
MainConsole.Instance.Commands.AddCommand(
"Debug",
false,
"debug eq",
"debug eq [0|1|2]",
"Turn on event queue debugging\n"
+ " <= 0 - turns off all event queue logging\n"
+ " >= 1 - turns on outgoing event logging\n"
+ " >= 2 - turns on poll notification",
HandleDebugEq);
}
else
{
m_gConfig = null;
}
}
private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p)
public void AddRegion(Scene scene)
{
enabledYN = startupConfig.GetBoolean("EventQueue", true);
m_scene = scene;
scene.RegisterModuleInterface<IEventQueue>(this);
scene.EventManager.OnClientClosed += ClientClosed;
scene.EventManager.OnMakeChildAgent += MakeChildAgent;
scene.EventManager.OnRegisterCaps += OnRegisterCaps;
MainConsole.Instance.Commands.AddCommand(
"Debug",
false,
"debug eq",
"debug eq [0|1|2]",
"Turn on event queue debugging\n"
+ " <= 0 - turns off all event queue logging\n"
+ " >= 1 - turns on outgoing event logging\n"
+ " >= 2 - turns on poll notification",
HandleDebugEq);
MainConsole.Instance.Commands.AddCommand(
"Debug",
false,
"show eq",
"show eq",
"Show contents of event queues for logged in avatars. Used for debugging.",
HandleShowEq);
}
public void PostInitialise()
public void RemoveRegion(Scene scene)
{
if (m_scene != scene)
return;
scene.EventManager.OnClientClosed -= ClientClosed;
scene.EventManager.OnMakeChildAgent -= MakeChildAgent;
scene.EventManager.OnRegisterCaps -= OnRegisterCaps;
scene.UnregisterModuleInterface<IEventQueue>(this);
m_scene = null;
}
public void RegionLoaded(Scene scene)
{
}
@ -141,10 +133,11 @@ namespace OpenSim.Region.ClientStack.Linden
get { return "EventQueueGetModule"; }
}
public bool IsSharedModule
public Type ReplaceableInterface
{
get { return false; }
get { return null; }
}
#endregion
protected void HandleDebugEq(string module, string[] args)
@ -153,7 +146,7 @@ namespace OpenSim.Region.ClientStack.Linden
if (!(args.Length == 3 && int.TryParse(args[2], out debugLevel)))
{
MainConsole.Instance.OutputFormat("Usage: debug eq [0|1]");
MainConsole.Instance.OutputFormat("Usage: debug eq [0|1|2]");
}
else
{
@ -163,6 +156,21 @@ namespace OpenSim.Region.ClientStack.Linden
}
}
protected void HandleShowEq(string module, string[] args)
{
MainConsole.Instance.OutputFormat("For scene {0}", m_scene.Name);
lock (queues)
{
foreach (KeyValuePair<UUID, Queue<OSD>> kvp in queues)
{
MainConsole.Instance.OutputFormat(
"For agent {0} there are {1} messages queued for send.",
kvp.Key, kvp.Value.Count);
}
}
}
/// <summary>
/// Always returns a valid queue
/// </summary>