From 0b49773ab315d51d9f92e508c4119a3ab8cf41f0 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 10 Jan 2012 21:30:12 +0000 Subject: [PATCH] Add "show image queue " region console command This is so that we can inspect the image download queue (texture download via udp) for debugging purposes. --- .../ClientStack/Linden/UDP/LLClientView.cs | 14 +-- .../ClientStack/Linden/UDP/LLImageManager.cs | 10 +++ .../Agent/UDP/Linden/LindenUDPInfoModule.cs | 89 ++++++++++++++++++- 3 files changed, 107 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 057372f806..9c1224722b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -303,6 +303,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected static Dictionary PacketHandlers = new Dictionary(); //Global/static handlers for all clients + /// + /// Handles UDP texture download. + /// + public LLImageManager ImageManager { get; private set; } + private readonly LLUDPServer m_udpServer; private readonly LLUDPClient m_udpClient; private readonly UUID m_sessionId; @@ -347,7 +352,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected Dictionary m_packetHandlers = new Dictionary(); protected Dictionary m_genericPacketHandlers = new Dictionary(); //PauPaw:Local Generic Message handlers protected Scene m_scene; - private LLImageManager m_imageManager; protected string m_firstName; protected string m_lastName; protected Thread m_clientThread; @@ -456,7 +460,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_assetService = m_scene.RequestModuleInterface(); m_GroupsModule = scene.RequestModuleInterface(); - m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface()); + ImageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface()); m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion()); m_agentId = agentId; m_sessionId = sessionId; @@ -496,7 +500,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP IsActive = false; // Shutdown the image manager - m_imageManager.Close(); + ImageManager.Close(); // Fire the callback for this connection closing if (OnConnectionClosed != null) @@ -3931,7 +3935,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0) - m_imageManager.ProcessImageQueue(m_udpServer.TextureSendLimit); + ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit); } public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) @@ -7461,7 +7465,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if ((ImageType)block.Type == ImageType.Baked) args.Priority *= 2.0f; - m_imageManager.EnqueueReq(args); + ImageManager.EnqueueReq(args); } return true; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index 3e31b7d9cc..db428f1c35 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs @@ -245,6 +245,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_shuttingdown = true; } + /// + /// Returns an array containing all the images in the queue. + /// + /// + public J2KImage[] GetImages() + { + lock (m_priorityQueue) + return m_priorityQueue.ToArray(); + } + #region Priority Queue Helpers private J2KImage GetHighestPriorityImage() diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index c754019b1e..16f6821267 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -95,7 +95,13 @@ namespace OpenSim.Region.CoreModules.UDP.Linden "Show queue data for each client", "Without the 'full' option, only root agents are shown." + " With the 'full' option child agents are also shown.", - ShowQueuesReport); + ShowQueuesReport); + + scene.AddCommand( + this, "show image queue", + "show image queue ", + "Show the image queue (textures downloaded via UDP) for a particular client.", + ShowImageQueuesReport); scene.AddCommand( this, "show throttles", @@ -135,6 +141,11 @@ namespace OpenSim.Region.CoreModules.UDP.Linden { MainConsole.Instance.Output(GetQueuesReport(cmd)); } + + protected void ShowImageQueuesReport(string module, string[] cmd) + { + MainConsole.Instance.Output(GetImageQueuesReport(cmd)); + } protected void ShowThrottlesReport(string module, string[] cmd) { @@ -240,6 +251,82 @@ namespace OpenSim.Region.CoreModules.UDP.Linden return report.ToString(); } + + /// + /// Generate an image queue report + /// + /// + /// + private string GetImageQueuesReport(string[] showParams) + { + if (showParams.Length < 5 || showParams.Length > 6) + { + MainConsole.Instance.OutputFormat("Usage: show image queue [full]"); + return ""; + } + + string firstName = showParams[3]; + string lastName = showParams[4]; + + bool showChildAgents = showParams.Length == 6; + + List foundAgents = new List(); + + lock (m_scenes) + { + foreach (Scene scene in m_scenes.Values) + { + ScenePresence sp = scene.GetScenePresence(firstName, lastName); + if (sp != null && (showChildAgents || !sp.IsChildAgent)) + foundAgents.Add(sp); + } + } + + if (foundAgents.Count == 0) + { + MainConsole.Instance.OutputFormat("No agents found for {0} {1}", firstName, lastName); + return ""; + } + + StringBuilder report = new StringBuilder(); + + foreach (ScenePresence agent in foundAgents) + { + LLClientView client = agent.ControllingClient as LLClientView; + + if (client == null) + { + MainConsole.Instance.OutputFormat("This command is only supported for LLClientView"); + return ""; + } + + J2KImage[] images = client.ImageManager.GetImages(); + + report.AppendFormat( + "In region {0} ({1} agent)\n", + agent.Scene.RegionInfo.RegionName, agent.IsChildAgent ? "child" : "root"); + report.AppendFormat("Images in queue: {0}\n", images.Length); + + if (images.Length > 0) + { + report.AppendFormat( + "{0,-36} {1,-8} {2,-9} {3,-9} {4,-9} {5,-7}\n", + "Texture ID", + "Last Seq", + "Priority", + "Start Pkt", + "Has Asset", + "Decoded"); + + foreach (J2KImage image in images) + report.AppendFormat( + "{0,36} {1,8} {2,9} {3,10} {4,9} {5,7}\n", + image.TextureID, image.LastSequence, image.Priority, image.StartPacket, image.HasAsset, image.IsDecoded); + } + } + + return report.ToString(); + } /// /// Generate UDP Queue data report for each client