From e9602656f8deda12dd343ba77d9ef5f58a239129 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 6 Mar 2012 23:21:17 +0000 Subject: [PATCH] Add sensor, dataserver requests, timer and listener counts to "xengine status" command. This is for diagnostic purposes. --- .../Scripting/WorldComm/WorldCommModule.cs | 20 +++++++ .../Region/Framework/Interfaces/IWorldComm.cs | 5 ++ .../Api/Implementation/AsyncCommandManager.cs | 53 ++++++++++++++++++- .../Api/Implementation/Plugins/Dataserver.cs | 9 ++++ .../Api/Implementation/Plugins/Listener.cs | 25 +++++---- .../Implementation/Plugins/SensorRepeat.cs | 12 +++++ .../Api/Implementation/Plugins/Timer.cs | 9 ++++ .../Region/ScriptEngine/XEngine/XEngine.cs | 15 ++++++ 8 files changed, 136 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 640a60be04..ef9b4e069b 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -151,6 +151,14 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm #region IWorldComm Members + public int ListenerCount + { + get + { + return m_listenerManager.ListenerCount; + } + } + /// /// Create a listen event callback with the specified filters. /// The parameters localID,itemID are needed to uniquely identify @@ -438,6 +446,18 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm private int m_maxhandles; private int m_curlisteners; + /// + /// Total number of listeners + /// + public int ListenerCount + { + get + { + lock (m_listeners) + return m_listeners.Count; + } + } + public ListenerManager(int maxlisteners, int maxhandles) { m_maxlisteners = maxlisteners; diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs index dafbf30bfc..e8e375e037 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs @@ -49,6 +49,11 @@ namespace OpenSim.Region.Framework.Interfaces public interface IWorldComm { + /// + /// Total number of listeners + /// + int ListenerCount { get; } + /// /// Create a listen event callback with the specified filters. /// The parameters localID,itemID are needed to uniquely identify diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 14edde41d4..993d10f909 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs @@ -247,7 +247,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Remove Sensors m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); + } + /// + /// Get the sensor repeat plugin for this script engine. + /// + /// + /// + public static SensorRepeat GetSensorRepeatPlugin(IScriptEngine engine) + { + if (m_SensorRepeat.ContainsKey(engine)) + return m_SensorRepeat[engine]; + else + return null; + } + + /// + /// Get the dataserver plugin for this script engine. + /// + /// + /// + public static Dataserver GetDataserverPlugin(IScriptEngine engine) + { + if (m_Dataserver.ContainsKey(engine)) + return m_Dataserver[engine]; + else + return null; + } + + /// + /// Get the timer plugin for this script engine. + /// + /// + /// + public static Timer GetTimerPlugin(IScriptEngine engine) + { + if (m_Timer.ContainsKey(engine)) + return m_Timer[engine]; + else + return null; + } + + /// + /// Get the listener plugin for this script engine. + /// + /// + /// + public static Listener GetListenerPlugin(IScriptEngine engine) + { + if (m_Listener.ContainsKey(engine)) + return m_Listener[engine]; + else + return null; } public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) @@ -270,7 +321,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api data.AddRange(timers); } - Object[] sensors=m_SensorRepeat[engine].GetSerializationData(itemID); + Object[] sensors = m_SensorRepeat[engine].GetSerializationData(itemID); if (sensors.Length > 0) { data.Add("sensor"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs index 7fa19b17a2..9f78a49c0f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs @@ -38,6 +38,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins { public AsyncCommandManager m_CmdManager; + public int DataserverRequestsCount + { + get + { + lock (DataserverRequests) + return DataserverRequests.Count; + } + } + private Dictionary DataserverRequests = new Dictionary(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs index 740816fd08..93e0261da6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs @@ -42,22 +42,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins public AsyncCommandManager m_CmdManager; + private IWorldComm m_commsPlugin; + + public int ListenerCount + { + get { return m_commsPlugin.ListenerCount; } + } + public Listener(AsyncCommandManager CmdManager) { m_CmdManager = CmdManager; + m_commsPlugin = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); } public void CheckListeners() { if (m_CmdManager.m_ScriptEngine.World == null) return; - IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); - if (comms != null) + if (m_commsPlugin != null) { - while (comms.HasMessages()) + while (m_commsPlugin.HasMessages()) { - ListenerInfo lInfo = (ListenerInfo)comms.GetNextMessage(); + ListenerInfo lInfo = (ListenerInfo)m_commsPlugin.GetNextMessage(); //Deliver data to prim's listen handler object[] resobj = new object[] @@ -81,17 +88,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins public Object[] GetSerializationData(UUID itemID) { - IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); - - return comms.GetSerializationData(itemID); + return m_commsPlugin.GetSerializationData(itemID); } public void CreateFromData(uint localID, UUID itemID, UUID hostID, Object[] data) { - IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); - - comms.CreateFromData(localID, itemID, hostID, data); + m_commsPlugin.CreateFromData(localID, itemID, hostID, data); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index fbb7c39265..1c272f8a39 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -44,6 +44,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins public AsyncCommandManager m_CmdManager; + /// + /// Number of sensors active. + /// + public int SensorsCount + { + get + { + lock (SenseRepeatListLock) + return SenseRepeaters.Count; + } + } + public SensorRepeat(AsyncCommandManager CmdManager) { m_CmdManager = CmdManager; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index eeb59d9877..bc63030ec2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs @@ -37,6 +37,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins { public AsyncCommandManager m_CmdManager; + public int TimersCount + { + get + { + lock (TimerListLock) + return Timers.Count; + } + } + public Timer(AsyncCommandManager CmdManager) { m_CmdManager = CmdManager; diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index c68f03ff87..d1cac9c1d3 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -49,7 +49,10 @@ using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenSim.Region.ScriptEngine.Shared.CodeTools; using OpenSim.Region.ScriptEngine.Shared.Instance; +using OpenSim.Region.ScriptEngine.Shared.Api; +using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; using OpenSim.Region.ScriptEngine.Interfaces; +using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; using ScriptCompileQueue = OpenSim.Framework.LocklessQueue; @@ -386,6 +389,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine sb.AppendFormat("Work items waiting : {0}\n", m_ThreadPool.WaitingCallbacks); // sb.AppendFormat("Assemblies loaded : {0}\n", m_Assemblies.Count); + SensorRepeat sr = AsyncCommandManager.GetSensorRepeatPlugin(this); + sb.AppendFormat("Sensors : {0}\n", sr.SensorsCount); + + Dataserver ds = AsyncCommandManager.GetDataserverPlugin(this); + sb.AppendFormat("Dataserver requests : {0}\n", ds.DataserverRequestsCount); + + Timer t = AsyncCommandManager.GetTimerPlugin(this); + sb.AppendFormat("Timers : {0}\n", t.TimersCount); + + Listener l = AsyncCommandManager.GetListenerPlugin(this); + sb.AppendFormat("Listeners : {0}\n", l.ListenerCount); + MainConsole.Instance.OutputFormat(sb.ToString()); }