From 542d0753769f939d914b5bd0a8fc5c2e03f9f2f8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Oct 2012 00:39:59 +0100 Subject: minor: Use LogIncomingToContentTypeHandler() method for incoming HTTP data where this wasn't already used. This allows log level 5 (log sample or large part of incoming post data) to operate and removes copy/paste. --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index b018e57..5d731f4 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -542,11 +542,8 @@ namespace OpenSim.Framework.Servers.HttpServer { case null: case "text/html": - if (DebugLevel >= 3) - m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", - RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); + LogIncomingToContentTypeHandler(request); buffer = HandleHTTPRequest(request, response); break; @@ -554,11 +551,8 @@ namespace OpenSim.Framework.Servers.HttpServer case "application/llsd+xml": case "application/xml+llsd": case "application/llsd+json": - if (DebugLevel >= 3) - m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", - RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); + LogIncomingToContentTypeHandler(request); buffer = HandleLLSDRequests(request, response); break; -- cgit v1.1 From 2206132ab992469f200048aa25a724d48290b9f3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Oct 2012 00:44:47 +0100 Subject: minor: Get content type handler logger to log "unset" for the content type instead of blank if no content type was set. --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 5d731f4..410a76a 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -687,7 +687,7 @@ namespace OpenSim.Framework.Servers.HttpServer "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", RequestNumber, Port, - request.ContentType, + (request.ContentType == null || request.ContentType == "") ? "not set" : request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); -- cgit v1.1 From 4578ff74fec7500902f58fbdee6ce5a6b39601fb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Oct 2012 01:50:05 +0100 Subject: Add object count stats for new IncomingPacket and UDPPacketBuffer pools if they are enabled. Add count stats for existing LLUDP pool. This introduces a pull stat type in addition to the push stat type. A pull stat takes a method on construction which knows how to update the stat on request. In this way, special interfaces for pull stat collection are not necessary. --- OpenSim/Framework/Monitoring/StatsManager.cs | 75 +++++++++++++++++++++++++--- OpenSim/Framework/Pool.cs | 15 ++++++ 2 files changed, 84 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 31989e5..116b2c0 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -249,6 +249,19 @@ namespace OpenSim.Framework.Monitoring } /// + /// Stat type. + /// + /// + /// A push stat is one which is continually updated and so it's value can simply by read. + /// A pull stat is one where reading the value triggers a collection method - the stat is not continually updated. + /// + public enum StatType + { + Push, + Pull + } + + /// /// Verbosity of stat. /// /// @@ -285,29 +298,65 @@ namespace OpenSim.Framework.Monitoring /// public string Container { get; private set; } + public StatType StatType { get; private set; } + + /// + /// Action used to update this stat when the value is requested if it's a pull type. + /// + public Action PullAction { get; private set; } + public StatVerbosity Verbosity { get; private set; } public string ShortName { get; private set; } public string Name { get; private set; } public string Description { get; private set; } public virtual string UnitName { get; private set; } - public virtual double Value { get; set; } + public virtual double Value + { + get + { + // Asking for an update here means that the updater cannot access this value without infinite recursion. + // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being + // called by the pull action and just return the value. + if (StatType == StatType.Pull) + PullAction(this); + + return m_value; + } + + set + { + m_value = value; + } + } + + private double m_value; /// /// Constructor /// /// Short name for the stat. Must not contain spaces. e.g. "LongFrames" /// Human readable name for the stat. e.g. "Long frames" + /// Description of stat /// /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value. /// e.g. " frames" /// /// Category under which this stat should appear, e.g. "scene". Do not capitalize. /// Entity to which this stat relates. e.g. scene name if this is a per scene stat. + /// Push or pull + /// Pull stats need an action to update the stat on request. Push stats should set null here. /// Verbosity of stat. Controls whether it will appear in short stat display or only full display. - /// Description of stat public Stat( - string shortName, string name, string unitName, string category, string container, StatVerbosity verbosity, string description) + string shortName, + string name, + string description, + string unitName, + string category, + string container, + StatType type, + Action pullAction, + StatVerbosity verbosity) { if (StatsManager.SubCommands.Contains(category)) throw new Exception( @@ -315,11 +364,18 @@ namespace OpenSim.Framework.Monitoring ShortName = shortName; Name = name; + Description = description; UnitName = unitName; Category = category; Container = container; + StatType = type; + + if (StatType == StatType.Push && pullAction != null) + throw new Exception("A push stat cannot have a pull action"); + else + PullAction = pullAction; + Verbosity = verbosity; - Description = description; UniqueName = GenUniqueName(Container, Category, ShortName); } @@ -361,8 +417,15 @@ namespace OpenSim.Framework.Monitoring } public PercentageStat( - string shortName, string name, string category, string container, StatVerbosity verbosity, string description) - : base(shortName, name, "%", category, container, verbosity, description) {} + string shortName, + string name, + string description, + string category, + string container, + StatType type, + Action pullAction, + StatVerbosity verbosity) + : base(shortName, name, description, "%", category, container, type, pullAction, verbosity) {} public override string ToConsoleString() { diff --git a/OpenSim/Framework/Pool.cs b/OpenSim/Framework/Pool.cs index 1ca06c3..5484f5c 100644 --- a/OpenSim/Framework/Pool.cs +++ b/OpenSim/Framework/Pool.cs @@ -38,8 +38,23 @@ namespace OpenSim.Framework /// public class Pool { + /// + /// Number of objects in the pool. + /// + public int Count + { + get + { + lock (m_pool) + return m_pool.Count; + } + } + private Stack m_pool; + /// + /// Maximum pool size. Beyond this, any returned objects are not pooled. + /// private int m_maxPoolSize; private Func m_createFunction; -- cgit v1.1 From 319ebaca06db3d4a38beff74725d321b7c836157 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Oct 2012 02:44:15 +0100 Subject: Make it possible to turn the base UDP object packet pools on and off whilst running via the "debug lludp pool " console command. For debug purposes. This does not currently apply to the higher LLUDP packetpool. --- OpenSim/Framework/Monitoring/StatsManager.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 116b2c0..4844336 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -207,7 +207,7 @@ namespace OpenSim.Framework.Monitoring return false; newContainer = new Dictionary(container); - newContainer.Remove(stat.UniqueName); + newContainer.Remove(stat.ShortName); newCategory = new Dictionary>(category); newCategory.Remove(stat.Container); @@ -279,11 +279,6 @@ namespace OpenSim.Framework.Monitoring public class Stat { /// - /// Unique stat name used for indexing. Each ShortName in a Category must be unique. - /// - public string UniqueName { get; private set; } - - /// /// Category of this stat (e.g. cache, scene, etc). /// public string Category { get; private set; } @@ -376,13 +371,6 @@ namespace OpenSim.Framework.Monitoring PullAction = pullAction; Verbosity = verbosity; - - UniqueName = GenUniqueName(Container, Category, ShortName); - } - - public static string GenUniqueName(string container, string category, string shortName) - { - return string.Format("{0}+{1}+{2}", container, category, shortName); } public virtual string ToConsoleString() -- cgit v1.1 From 938fa96b9f5377ef330171232262b4d8aaca0918 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Oct 2012 01:33:21 +0100 Subject: minor: Move co-ordinate related help to object commands to common ConsoleUtil.CoordHelp --- OpenSim/Framework/Console/ConsoleUtil.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index a7cf0c0..027753d 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -36,6 +36,23 @@ public class ConsoleUtil { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// + /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section + /// rather than in each help summary. + /// + public const string CoordHelp += @"Each component of the coord is comma separated. There must be no spaces between the commas. +If you don't care about the z component you can simply omit it. +If you don't care about the x or y components then you can leave them blank (though a comma is still required) +If you want to specify the maxmimum value of a component then you can use ~ instead of a number +If you want to specify the minimum value of a component then you can use -~ instead of a number +e.g. +delete object pos 20,20,20 to 40,40,40 +delete object pos 20,20 to 40,40 +delete object pos ,20,20 to ,40,40 +delete object pos ,,30 to ,,~ +delete object pos ,,-~ to ,,30"; + public const string MinRawConsoleVectorValue = "-~"; public const string MaxRawConsoleVectorValue = "~"; -- cgit v1.1 From 73db057fa1dbda7d6dff7de770cef8670b234f84 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Oct 2012 02:05:28 +0100 Subject: Add "dump object uuid" console command. This allows any object in the scene to be serialized and dumped to XML for debug purposes. --- OpenSim/Framework/Console/ConsoleUtil.cs | 206 +++++++++++++++++-------------- 1 file changed, 115 insertions(+), 91 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index 027753d..5c25ccb 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -32,100 +32,124 @@ using System.Reflection; using log4net; using OpenMetaverse; -public class ConsoleUtil +namespace OpenSim.Framework.Console { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section - /// rather than in each help summary. - /// - public const string CoordHelp -= @"Each component of the coord is comma separated. There must be no spaces between the commas. -If you don't care about the z component you can simply omit it. -If you don't care about the x or y components then you can leave them blank (though a comma is still required) -If you want to specify the maxmimum value of a component then you can use ~ instead of a number -If you want to specify the minimum value of a component then you can use -~ instead of a number -e.g. -delete object pos 20,20,20 to 40,40,40 -delete object pos 20,20 to 40,40 -delete object pos ,20,20 to ,40,40 -delete object pos ,,30 to ,,~ -delete object pos ,,-~ to ,,30"; - - public const string MinRawConsoleVectorValue = "-~"; - public const string MaxRawConsoleVectorValue = "~"; - - public const string VectorSeparator = ","; - public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); - - /// - /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 - /// - /// /param> - /// - /// - public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector) + public class ConsoleUtil { - return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector); - } - - /// - /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3 - /// - /// /param> - /// - /// - public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector) - { - return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector); - } - - /// - /// Convert a vector input from the console to an OpenMetaverse.Vector3 - /// - /// - /// A string in the form ,, where there is no space between values. - /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value - /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40) - /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue - /// Other than that, component values must be numeric. - /// - /// - /// - /// - public static bool TryParseConsoleVector( - string rawConsoleVector, Func blankComponentFunc, out Vector3 vector) - { - List components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); - - if (components.Count < 1 || components.Count > 3) + // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + /// + /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section + /// rather than in each help summary. + /// + public const string CoordHelp + = @"Each component of the coord is comma separated. There must be no spaces between the commas. + If you don't care about the z component you can simply omit it. + If you don't care about the x or y components then you can leave them blank (though a comma is still required) + If you want to specify the maxmimum value of a component then you can use ~ instead of a number + If you want to specify the minimum value of a component then you can use -~ instead of a number + e.g. + delete object pos 20,20,20 to 40,40,40 + delete object pos 20,20 to 40,40 + delete object pos ,20,20 to ,40,40 + delete object pos ,,30 to ,,~ + delete object pos ,,-~ to ,,30"; + + public const string MinRawConsoleVectorValue = "-~"; + public const string MaxRawConsoleVectorValue = "~"; + + public const string VectorSeparator = ","; + public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); + + /// + /// Try to parse a console UUID from the console. + /// + /// + /// Will complain to the console if parsing fails. + /// + /// + /// + /// + /// + public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid) { - vector = Vector3.Zero; - return false; + if (!UUID.TryParse(rawUuid, out uuid)) + { + console.OutputFormat("{0} is not a valid uuid", rawUuid); + return false; + } + + return true; + } + + /// + /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 + /// + /// /param> + /// + /// + public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector) + { + return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector); + } + + /// + /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3 + /// + /// /param> + /// + /// + public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector) + { + return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector); + } + + /// + /// Convert a vector input from the console to an OpenMetaverse.Vector3 + /// + /// + /// A string in the form ,, where there is no space between values. + /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value + /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40) + /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue + /// Other than that, component values must be numeric. + /// + /// + /// + /// + public static bool TryParseConsoleVector( + string rawConsoleVector, Func blankComponentFunc, out Vector3 vector) + { + List components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); + + if (components.Count < 1 || components.Count > 3) + { + vector = Vector3.Zero; + return false; + } + + for (int i = components.Count; i < 3; i++) + components.Add(""); + + List semiDigestedComponents + = components.ConvertAll( + c => + { + if (c == "") + return blankComponentFunc.Invoke(c); + else if (c == MaxRawConsoleVectorValue) + return float.MaxValue.ToString(); + else if (c == MinRawConsoleVectorValue) + return float.MinValue.ToString(); + else + return c; + }); + + string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray()); + + // m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector); + + return Vector3.TryParse(semiDigestedConsoleVector, out vector); } - - for (int i = components.Count; i < 3; i++) - components.Add(""); - - List semiDigestedComponents - = components.ConvertAll( - c => - { - if (c == "") - return blankComponentFunc.Invoke(c); - else if (c == MaxRawConsoleVectorValue) - return float.MaxValue.ToString(); - else if (c == MinRawConsoleVectorValue) - return float.MinValue.ToString(); - else - return c; - }); - - string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray()); - -// m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector); - - return Vector3.TryParse(semiDigestedConsoleVector, out vector); } } \ No newline at end of file -- cgit v1.1 From f76dceb90b5a76a7b6a5243c9032996c007c0cf5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Oct 2012 03:08:58 +0100 Subject: Get "save oar" and "save iar" to tell you in a more friendly manner if the filename to save already exists, rather than exception throwing. Also changes ConsoleUtil.CheckFileExists to CheckFileDoesNotExist() since this is more meaningful in the context, even though it does result in double negatives. --- OpenSim/Framework/Console/ConsoleUtil.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index 5c25ccb..3ebfdf8 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Reflection; using log4net; @@ -60,6 +61,24 @@ namespace OpenSim.Framework.Console public const string VectorSeparator = ","; public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); + + /// + /// Check if the given file path exists. + /// + /// If not, warning is printed to the given console. + /// true if the file does not exist, false otherwise. + /// + /// + public static bool CheckFileDoesNotExist(ICommandConsole console, string path) + { + if (File.Exists(path)) + { + console.OutputFormat("File {0} already exists. Please move or remove it.", path); + return false; + } + + return true; + } /// /// Try to parse a console UUID from the console. -- cgit v1.1 From 81aeecc90723658187668baa49bd168b7b333afb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Oct 2012 04:10:22 +0100 Subject: Allow "show object", "show part", "dump object" and "delete object" to accept a local ID as well as a UUID. This means that the sub-commands are now id rather than uuid, e.g. show object id --- OpenSim/Framework/Console/ConsoleUtil.cs | 58 ++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index 3ebfdf8..16a63e0 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -38,6 +38,8 @@ namespace OpenSim.Framework.Console public class ConsoleUtil { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public const int LocalIdNotFound = 0; /// /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section @@ -87,19 +89,71 @@ namespace OpenSim.Framework.Console /// Will complain to the console if parsing fails. /// /// - /// + /// If null then no complaint is printed. /// /// public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid) { if (!UUID.TryParse(rawUuid, out uuid)) { - console.OutputFormat("{0} is not a valid uuid", rawUuid); + if (console != null) + console.OutputFormat("{0} is not a valid uuid", rawUuid); + return false; } return true; } + + public static bool TryParseConsoleLocalId(ICommandConsole console, string rawLocalId, out uint localId) + { + if (!uint.TryParse(rawLocalId, out localId)) + { + if (console != null) + console.OutputFormat("{0} is not a valid local id", localId); + + return false; + } + + if (localId == 0) + { + if (console != null) + console.OutputFormat("{0} is not a valid local id - it must be greater than 0", localId); + + return false; + } + + return true; + } + + /// + /// Tries to parse the input as either a UUID or a local ID. + /// + /// true if parsing succeeded, false otherwise. + /// + /// + /// + /// + /// Will be set to ConsoleUtil.LocalIdNotFound if parsing result was a UUID or no parse succeeded. + /// + public static bool TryParseConsoleId(ICommandConsole console, string rawId, out UUID uuid, out uint localId) + { + if (TryParseConsoleUuid(null, rawId, out uuid)) + { + localId = LocalIdNotFound; + return true; + } + + if (TryParseConsoleLocalId(null, rawId, out localId)) + { + return true; + } + + if (console != null) + console.OutputFormat("{0} is not a valid UUID or local id", rawId); + + return false; + } /// /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 -- cgit v1.1 From 5d4ac5a90fea758e18c8a9e97b06e799186b5a14 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 25 Oct 2012 00:59:27 +0100 Subject: Add TestOsNpcLoadAppearance() --- OpenSim/Framework/AvatarAppearance.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 4f598b0..95e9667 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -330,6 +330,9 @@ namespace OpenSim.Framework SetVisualParams(visualParams); } + /// + /// Set avatar height by a calculation based on their visual parameters. + /// public virtual void SetHeight() { // Start with shortest possible female avatar height -- cgit v1.1 From c13a99dc5cc82efac5497dab27dcb6b0d9865cea Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 25 Oct 2012 03:26:12 +0100 Subject: Fix script error messages not showing up in viewer 3 and associated viewers. Viewer 3 will discard such a message if the chat message owner does not match the avatar. We were filling the ownerID with the primID, so this never matched, hence viewer 3 did not see any script error messages. This commit fills the ownerID in with the prim ownerID so the script owner will receive script error messages. This does not affect viewer 1 and associated viewers which continue to process script errors as normal. --- OpenSim/Framework/Client/IClientChat.cs | 7 ++++--- OpenSim/Framework/IClientAPI.cs | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Client/IClientChat.cs b/OpenSim/Framework/Client/IClientChat.cs index 078ea9b..86b1faa 100644 --- a/OpenSim/Framework/Client/IClientChat.cs +++ b/OpenSim/Framework/Client/IClientChat.cs @@ -33,7 +33,8 @@ namespace OpenSim.Framework.Client { event ChatMessage OnChatFromClient; - void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source, - byte audible); + void SendChatMessage( + string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, + byte audible); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 9856978..87433cc 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1099,8 +1099,20 @@ namespace OpenSim.Framework void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs); void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args); - void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source, - byte audible); + /// + /// Send chat to the viewer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + void SendChatMessage( + string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, + byte audible); void SendInstantMessage(GridInstantMessage im); -- cgit v1.1 From c97890ca69df91e6590ac7dd234a3e86cf7fbaf1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 29 Oct 2012 22:53:06 +0000 Subject: Add "force gc" region console command which manually invokes garbage collection. For debugging purposes. --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index aac9c45..5b2d7dc 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -192,8 +192,19 @@ namespace OpenSim.Framework.Servers "threads show", "Show thread status. Synonym for \"show threads\"", (string module, string[] args) => Notice(GetThreadsReport())); + + m_console.Commands.AddCommand("General", false, "force gc", + "force gc", + "Manually invoke runtime garbage collection. For debugging purposes", + HandleForceGc); } } + + private void HandleForceGc(string module, string[] args) + { + MainConsole.Instance.Output("Manually invoking runtime garbage collection"); + GC.Collect(); + } /// /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing -- cgit v1.1 From 56965dd9599597bf5c51ab795f278db8291514c2 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 13:00:16 +0100 Subject: fixing poorly-formatted xml doc string for Util.IsInsideBox --- OpenSim/Framework/Util.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 5c7797a..c369dbc 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -536,7 +536,7 @@ namespace OpenSim.Framework /// /// Determines whether a point is inside a bounding box. /// - /// /param> + /// /// /// /// -- cgit v1.1 From 9e05067a4f029983a749c348259112a8a18432d1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 30 Oct 2012 21:45:39 +0100 Subject: Add AnimState to CADU --- OpenSim/Framework/ChildAgentDataUpdate.cs | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index 6d048f4..dfe60aa 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs @@ -306,6 +306,8 @@ namespace OpenSim.Framework public AgentGroupData[] Groups; public Animation[] Anims; + public Animation DefaultAnim = null; + public Animation AnimState = null; public UUID GranterID; @@ -390,6 +392,16 @@ namespace OpenSim.Framework args["animations"] = anims; } + if (DefaultAnim != null) + { + args["default_animation"] = DefaultAnim.PackUpdateMessage(); + } + + if (AnimState != null) + { + args["animation_state"] = AnimState.PackUpdateMessage(); + } + if (Appearance != null) args["packed_appearance"] = Appearance.Pack(); @@ -583,6 +595,30 @@ namespace OpenSim.Framework } } + if (args["default_animation"] != null) + { + try + { + DefaultAnim = new Animation((OSDMap)args["default_animation"]); + } + catch + { + DefaultAnim = null; + } + } + + if (args["animation_state"] != null) + { + try + { + AnimState = new Animation((OSDMap)args["animation_state"]); + } + catch + { + AnimState = null; + } + } + //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) //{ // OSDArray textures = (OSDArray)(args["agent_textures"]); -- cgit v1.1 From 6235d16c3148bb6f9f881b0dc286deccfdf9148a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 31 Oct 2012 00:31:18 +0000 Subject: Make "show object part" command correctly display script status. Uses new IEntityInventory.TryGetScriptInstanceRunning() Makes it clearer that TaskInventoryItem.ScriptRunning cannot be used as it is temporary and not updated. --- OpenSim/Framework/TaskInventoryDictionary.cs | 4 +++- OpenSim/Framework/TaskInventoryItem.cs | 19 ++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs index 421bd5d..8af2c41 100644 --- a/OpenSim/Framework/TaskInventoryDictionary.cs +++ b/OpenSim/Framework/TaskInventoryDictionary.cs @@ -35,10 +35,12 @@ using OpenMetaverse; namespace OpenSim.Framework { /// - /// A dictionary for task inventory. + /// A dictionary containing task inventory items. Indexed by item UUID. /// + /// /// This class is not thread safe. Callers must synchronize on Dictionary methods or Clone() this object before /// iterating over it. + /// public class TaskInventoryDictionary : Dictionary, ICloneable, IXmlSerializable { diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index 3b40381..a06f8e7 100644 --- a/OpenSim/Framework/TaskInventoryItem.cs +++ b/OpenSim/Framework/TaskInventoryItem.cs @@ -73,9 +73,6 @@ namespace OpenSim.Framework private bool _ownerChanged = false; - // This used ONLY during copy. It can't be relied on at other times! - private bool _scriptRunning = true; - public UUID AssetID { get { return _assetID; @@ -353,14 +350,13 @@ namespace OpenSim.Framework } } - public bool ScriptRunning { - get { - return _scriptRunning; - } - set { - _scriptRunning = value; - } - } + /// + /// This used ONLY during copy. It can't be relied on at other times! + /// + /// + /// For true script running status, use IEntityInventory.TryGetScriptInstanceRunning() for now. + /// + public bool ScriptRunning { get; set; } // See ICloneable @@ -388,6 +384,7 @@ namespace OpenSim.Framework public TaskInventoryItem() { + ScriptRunning = true; CreationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; } } -- cgit v1.1 From e4cb7af98a122773e84baf9be38b8b34f02e89a4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 13 Nov 2012 19:26:43 -0800 Subject: Updated all existing AssemblyVersions's to 0.7.5.*. Many DLLs still don't have an AssemblyInfo file. --- OpenSim/Framework/AssemblyInfo.cs | 2 +- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 2 +- OpenSim/Framework/Console/AssemblyInfo.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/AssemblyInfo.cs b/OpenSim/Framework/AssemblyInfo.cs index adeaeb2..02986d5 100644 --- a/OpenSim/Framework/AssemblyInfo.cs +++ b/OpenSim/Framework/AssemblyInfo.cs @@ -59,5 +59,5 @@ using System.Runtime.InteropServices; // Revision // -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] [assembly : AssemblyFileVersion("0.6.5.0")] \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 2df6ace..9bafa57 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] [assembly : AssemblyFileVersion("0.6.5.0")] diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs index 75e35bf..b9e4076 100644 --- a/OpenSim/Framework/Console/AssemblyInfo.cs +++ b/OpenSim/Framework/Console/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] -- cgit v1.1 From 27b12cebbba8df2f03fe7918b9672be23bc41a09 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 14 Nov 2012 08:10:15 -0800 Subject: A few more AssemblyInfos in a few more dlls. --- .../Filesystem/Properties/AssemblyInfo.cs | 33 ++++++++++++++++++++++ .../Communications/Properties/AssemblyInfo.cs | 6 ++-- .../Configuration/HTTP/Properties/AssemblyInfo.cs | 33 ++++++++++++++++++++++ .../Configuration/XML/Properties/AssemblyInfo.cs | 33 ++++++++++++++++++++++ OpenSim/Framework/Console/AssemblyInfo.cs | 2 +- .../Monitoring/Properties/AssemblyInfo.cs | 33 ++++++++++++++++++++++ .../Filesystem/Properties/AssemblyInfo.cs | 33 ++++++++++++++++++++++ .../RegionLoader/Web/Properties/AssemblyInfo.cs | 33 ++++++++++++++++++++++ .../Serialization/Properties/AssemblyInfo.cs | 33 ++++++++++++++++++++++ .../Servers/HttpServer/Properties/AssemblyInfo.cs | 33 ++++++++++++++++++++++ .../Framework/Servers/Properties/AssemblyInfo.cs | 33 ++++++++++++++++++++++ 11 files changed, 301 insertions(+), 4 deletions(-) create mode 100644 OpenSim/Framework/AssetLoader/Filesystem/Properties/AssemblyInfo.cs create mode 100644 OpenSim/Framework/Configuration/HTTP/Properties/AssemblyInfo.cs create mode 100644 OpenSim/Framework/Configuration/XML/Properties/AssemblyInfo.cs create mode 100644 OpenSim/Framework/Monitoring/Properties/AssemblyInfo.cs create mode 100644 OpenSim/Framework/RegionLoader/Filesystem/Properties/AssemblyInfo.cs create mode 100644 OpenSim/Framework/RegionLoader/Web/Properties/AssemblyInfo.cs create mode 100644 OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs create mode 100644 OpenSim/Framework/Servers/HttpServer/Properties/AssemblyInfo.cs create mode 100644 OpenSim/Framework/Servers/Properties/AssemblyInfo.cs (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/AssetLoader/Filesystem/Properties/AssemblyInfo.cs b/OpenSim/Framework/AssetLoader/Filesystem/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0498ed4 --- /dev/null +++ b/OpenSim/Framework/AssetLoader/Filesystem/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.AssetLoader.Filesystem")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8cb9cf69-4771-4d3a-a2ba-bac7230de326")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 9bafa57..6d1c03a 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -32,12 +32,12 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly : AssemblyTitle("OpenGrid.Framework.Communications")] +[assembly : AssemblyTitle("OpenSim.Framework.Communications")] [assembly : AssemblyDescription("")] [assembly : AssemblyConfiguration("")] [assembly : AssemblyCompany("http://opensimulator.org")] -[assembly : AssemblyProduct("OpenGrid.Framework.Communications")] -[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] +[assembly : AssemblyProduct("OpenSim")] +[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] [assembly : AssemblyTrademark("")] [assembly : AssemblyCulture("")] diff --git a/OpenSim/Framework/Configuration/HTTP/Properties/AssemblyInfo.cs b/OpenSim/Framework/Configuration/HTTP/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0674656 --- /dev/null +++ b/OpenSim/Framework/Configuration/HTTP/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.Configuration.HTTP")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator develoeprs")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("cb78b672-d000-4f93-88f9-dae151cc0061")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Configuration/XML/Properties/AssemblyInfo.cs b/OpenSim/Framework/Configuration/XML/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1095b23 --- /dev/null +++ b/OpenSim/Framework/Configuration/XML/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.Configuration.XML")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("eeb880df-0112-4c3d-87ed-b2108d614c55")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs index b9e4076..37c7304 100644 --- a/OpenSim/Framework/Console/AssemblyInfo.cs +++ b/OpenSim/Framework/Console/AssemblyInfo.cs @@ -39,7 +39,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("http://opensimulator.org")] [assembly : AssemblyProduct("ServerConsole")] -[assembly: AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] +[assembly: AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/OpenSim/Framework/Monitoring/Properties/AssemblyInfo.cs b/OpenSim/Framework/Monitoring/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1f2bb40 --- /dev/null +++ b/OpenSim/Framework/Monitoring/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.Monitoring")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("74506fe3-2f9d-44c1-94c9-a30f79d9e0cb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/RegionLoader/Filesystem/Properties/AssemblyInfo.cs b/OpenSim/Framework/RegionLoader/Filesystem/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d670f2f --- /dev/null +++ b/OpenSim/Framework/RegionLoader/Filesystem/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.RegionLoader.Filesystem")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4ab5c74b-e886-40a1-b67d-a04df285e706")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/RegionLoader/Web/Properties/AssemblyInfo.cs b/OpenSim/Framework/RegionLoader/Web/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7309a12 --- /dev/null +++ b/OpenSim/Framework/RegionLoader/Web/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.RegionLoader.Web")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("985afff8-e7ed-4056-acce-39abf7a43d33")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs b/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..11efa4b --- /dev/null +++ b/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.Serialization")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("919db41e-4ac0-4f24-9992-81d62c0ee183")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Servers/HttpServer/Properties/AssemblyInfo.cs b/OpenSim/Framework/Servers/HttpServer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..02ecc25 --- /dev/null +++ b/OpenSim/Framework/Servers/HttpServer/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.Servers.HttpServer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c4ea5baa-81c4-4867-a645-1ec360c1f164")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Servers/Properties/AssemblyInfo.cs b/OpenSim/Framework/Servers/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..021f63c --- /dev/null +++ b/OpenSim/Framework/Servers/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.Servers")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b48e8b3e-5c5c-4673-b31f-21e13b8e568b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] -- cgit v1.1 From 038528dc80e0fe03956d61872ba30a887b2890a1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 Nov 2012 02:02:59 +0000 Subject: Make PacketPool class stats pull stats instead of push stats so they can be lifted up into LLUDPServer and be distiguished by scene name --- OpenSim/Framework/Monitoring/StatsManager.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 4844336..cebe905 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -382,14 +382,20 @@ namespace OpenSim.Framework.Monitoring public class PercentageStat : Stat { - public int Antecedent { get; set; } - public int Consequent { get; set; } + public long Antecedent { get; set; } + public long Consequent { get; set; } public override double Value { get { - int c = Consequent; + // Asking for an update here means that the updater cannot access this value without infinite recursion. + // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being + // called by the pull action and just return the value. + if (StatType == StatType.Pull) + PullAction(this); + + long c = Consequent; // Avoid any chance of a multi-threaded divide-by-zero if (c == 0) @@ -400,7 +406,7 @@ namespace OpenSim.Framework.Monitoring set { - throw new Exception("Cannot set value on a PercentageStat"); + throw new InvalidOperationException("Cannot set value on a PercentageStat"); } } -- cgit v1.1 From cd088757e96217defc9a2b0bf323747615c3255e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Nov 2012 04:36:22 +0000 Subject: Add a first draft mechanism for the IncomingPacketsProcessedStat to show the delta over time. The chief motivation for this is to be able to tell whether there's any impact on incoming packet processing from enabling extra packet pooling. --- OpenSim/Framework/Monitoring/StatsManager.cs | 139 ++++++++++++++++++++++++++- OpenSim/Framework/Monitoring/Watchdog.cs | 4 +- 2 files changed, 139 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index cebe905..eae7505 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Text; namespace OpenSim.Framework.Monitoring { @@ -246,6 +247,24 @@ namespace OpenSim.Framework.Monitoring return false; } + + public static void RecordStats() + { + lock (RegisteredStats) + { + foreach (Dictionary> category in RegisteredStats.Values) + { + foreach (Dictionary container in category.Values) + { + foreach (Stat stat in container.Values) + { + if (stat.MeasuresOfInterest != MeasuresOfInterest.None) + stat.RecordValue(); + } + } + } + } + } } /// @@ -262,6 +281,16 @@ namespace OpenSim.Framework.Monitoring } /// + /// Measures of interest for this stat. + /// + [Flags] + public enum MeasuresOfInterest + { + None, + AverageChangeOverTime + } + + /// /// Verbosity of stat. /// /// @@ -295,6 +324,8 @@ namespace OpenSim.Framework.Monitoring public StatType StatType { get; private set; } + public MeasuresOfInterest MeasuresOfInterest { get; private set; } + /// /// Action used to update this stat when the value is requested if it's a pull type. /// @@ -328,6 +359,47 @@ namespace OpenSim.Framework.Monitoring private double m_value; /// + /// Historical samples for calculating measures of interest average. + /// + /// + /// Will be null if no measures of interest require samples. + /// + private static Queue m_samples; + + /// + /// Maximum number of statistical samples. + /// + /// + /// At the moment this corresponds to 1 minute since the sampling rate is every 2.5 seconds as triggered from + /// the main Watchdog. + /// + private static int m_maxSamples = 24; + + public Stat( + string shortName, + string name, + string description, + string unitName, + string category, + string container, + StatType type, + Action pullAction, + StatVerbosity verbosity) + : this( + shortName, + name, + description, + unitName, + category, + container, + type, + MeasuresOfInterest.None, + pullAction, + verbosity) + { + } + + /// /// Constructor /// /// Short name for the stat. Must not contain spaces. e.g. "LongFrames" @@ -341,6 +413,7 @@ namespace OpenSim.Framework.Monitoring /// Entity to which this stat relates. e.g. scene name if this is a per scene stat. /// Push or pull /// Pull stats need an action to update the stat on request. Push stats should set null here. + /// Measures of interest /// Verbosity of stat. Controls whether it will appear in short stat display or only full display. public Stat( string shortName, @@ -350,6 +423,7 @@ namespace OpenSim.Framework.Monitoring string category, string container, StatType type, + MeasuresOfInterest moi, Action pullAction, StatVerbosity verbosity) { @@ -370,13 +444,66 @@ namespace OpenSim.Framework.Monitoring else PullAction = pullAction; + MeasuresOfInterest = moi; + + if ((moi & MeasuresOfInterest.AverageChangeOverTime) == MeasuresOfInterest.AverageChangeOverTime) + m_samples = new Queue(m_maxSamples); + Verbosity = verbosity; } + /// + /// Record a value in the sample set. + /// + /// + /// Do not call this if MeasuresOfInterest.None + /// + public void RecordValue() + { + double newValue = Value; + + lock (m_samples) + { + if (m_samples.Count >= m_maxSamples) + m_samples.Dequeue(); + + m_samples.Enqueue(newValue); + } + } + public virtual string ToConsoleString() { - return string.Format( - "{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName); + StringBuilder sb = new StringBuilder(); + sb.AppendFormat("{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName); + + AppendMeasuresOfInterest(sb); + + return sb.ToString(); + } + + protected void AppendMeasuresOfInterest(StringBuilder sb) + { + if ((MeasuresOfInterest & MeasuresOfInterest.AverageChangeOverTime) + == MeasuresOfInterest.AverageChangeOverTime) + { + double totalChange = 0; + double? lastSample = null; + + lock (m_samples) + { + foreach (double s in m_samples) + { + if (lastSample != null) + totalChange += s - (double)lastSample; + + lastSample = s; + } + } + + int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1; + + sb.AppendFormat(", {0:0.##}{1}/s", totalChange / divisor / (Watchdog.WATCHDOG_INTERVAL_MS / 1000), UnitName); + } } } @@ -423,9 +550,15 @@ namespace OpenSim.Framework.Monitoring public override string ToConsoleString() { - return string.Format( + StringBuilder sb = new StringBuilder(); + + sb.AppendFormat( "{0}.{1}.{2} : {3:0.##}{4} ({5}/{6})", Category, Container, ShortName, Value, UnitName, Antecedent, Consequent); + + AppendMeasuresOfInterest(sb); + + return sb.ToString(); } } } \ No newline at end of file diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index a20326d..3f992b1 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs @@ -39,7 +39,7 @@ namespace OpenSim.Framework.Monitoring public static class Watchdog { /// Timer interval in milliseconds for the watchdog timer - const double WATCHDOG_INTERVAL_MS = 2500.0d; + public const double WATCHDOG_INTERVAL_MS = 2500.0d; /// Default timeout in milliseconds before a thread is considered dead public const int DEFAULT_WATCHDOG_TIMEOUT_MS = 5000; @@ -380,6 +380,8 @@ namespace OpenSim.Framework.Monitoring if (MemoryWatchdog.Enabled) MemoryWatchdog.Update(); + StatsManager.RecordStats(); + m_watchdogTimer.Start(); } } -- cgit v1.1 From 55f889cc66d78268c530c65a5fd111395cc26dc5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Nov 2012 05:02:06 +0000 Subject: refactor: Move stat classes out of StatManager and into their own files for clarity. --- .../Framework/Monitoring/Stats/PercentageStat.cs | 88 +++++++ OpenSim/Framework/Monitoring/Stats/Stat.cs | 238 +++++++++++++++++++ OpenSim/Framework/Monitoring/StatsManager.cs | 260 --------------------- 3 files changed, 326 insertions(+), 260 deletions(-) create mode 100644 OpenSim/Framework/Monitoring/Stats/PercentageStat.cs create mode 100644 OpenSim/Framework/Monitoring/Stats/Stat.cs (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Monitoring/Stats/PercentageStat.cs b/OpenSim/Framework/Monitoring/Stats/PercentageStat.cs new file mode 100644 index 0000000..60bed55 --- /dev/null +++ b/OpenSim/Framework/Monitoring/Stats/PercentageStat.cs @@ -0,0 +1,88 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Monitoring +{ + public class PercentageStat : Stat + { + public long Antecedent { get; set; } + public long Consequent { get; set; } + + public override double Value + { + get + { + // Asking for an update here means that the updater cannot access this value without infinite recursion. + // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being + // called by the pull action and just return the value. + if (StatType == StatType.Pull) + PullAction(this); + + long c = Consequent; + + // Avoid any chance of a multi-threaded divide-by-zero + if (c == 0) + return 0; + + return (double)Antecedent / c * 100; + } + + set + { + throw new InvalidOperationException("Cannot set value on a PercentageStat"); + } + } + + public PercentageStat( + string shortName, + string name, + string description, + string category, + string container, + StatType type, + Action pullAction, + StatVerbosity verbosity) + : base(shortName, name, description, "%", category, container, type, pullAction, verbosity) {} + + public override string ToConsoleString() + { + StringBuilder sb = new StringBuilder(); + + sb.AppendFormat( + "{0}.{1}.{2} : {3:0.##}{4} ({5}/{6})", + Category, Container, ShortName, Value, UnitName, Antecedent, Consequent); + + AppendMeasuresOfInterest(sb); + + return sb.ToString(); + } + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs new file mode 100644 index 0000000..f91251b --- /dev/null +++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs @@ -0,0 +1,238 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Monitoring +{ + /// + /// Holds individual statistic details + /// + public class Stat + { + /// + /// Category of this stat (e.g. cache, scene, etc). + /// + public string Category { get; private set; } + + /// + /// Containing name for this stat. + /// FIXME: In the case of a scene, this is currently the scene name (though this leaves + /// us with a to-be-resolved problem of non-unique region names). + /// + /// + /// The container. + /// + public string Container { get; private set; } + + public StatType StatType { get; private set; } + + public MeasuresOfInterest MeasuresOfInterest { get; private set; } + + /// + /// Action used to update this stat when the value is requested if it's a pull type. + /// + public Action PullAction { get; private set; } + + public StatVerbosity Verbosity { get; private set; } + public string ShortName { get; private set; } + public string Name { get; private set; } + public string Description { get; private set; } + public virtual string UnitName { get; private set; } + + public virtual double Value + { + get + { + // Asking for an update here means that the updater cannot access this value without infinite recursion. + // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being + // called by the pull action and just return the value. + if (StatType == StatType.Pull) + PullAction(this); + + return m_value; + } + + set + { + m_value = value; + } + } + + private double m_value; + + /// + /// Historical samples for calculating measures of interest average. + /// + /// + /// Will be null if no measures of interest require samples. + /// + private static Queue m_samples; + + /// + /// Maximum number of statistical samples. + /// + /// + /// At the moment this corresponds to 1 minute since the sampling rate is every 2.5 seconds as triggered from + /// the main Watchdog. + /// + private static int m_maxSamples = 24; + + public Stat( + string shortName, + string name, + string description, + string unitName, + string category, + string container, + StatType type, + Action pullAction, + StatVerbosity verbosity) + : this( + shortName, + name, + description, + unitName, + category, + container, + type, + MeasuresOfInterest.None, + pullAction, + verbosity) + { + } + + /// + /// Constructor + /// + /// Short name for the stat. Must not contain spaces. e.g. "LongFrames" + /// Human readable name for the stat. e.g. "Long frames" + /// Description of stat + /// + /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value. + /// e.g. " frames" + /// + /// Category under which this stat should appear, e.g. "scene". Do not capitalize. + /// Entity to which this stat relates. e.g. scene name if this is a per scene stat. + /// Push or pull + /// Pull stats need an action to update the stat on request. Push stats should set null here. + /// Measures of interest + /// Verbosity of stat. Controls whether it will appear in short stat display or only full display. + public Stat( + string shortName, + string name, + string description, + string unitName, + string category, + string container, + StatType type, + MeasuresOfInterest moi, + Action pullAction, + StatVerbosity verbosity) + { + if (StatsManager.SubCommands.Contains(category)) + throw new Exception( + string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category)); + + ShortName = shortName; + Name = name; + Description = description; + UnitName = unitName; + Category = category; + Container = container; + StatType = type; + + if (StatType == StatType.Push && pullAction != null) + throw new Exception("A push stat cannot have a pull action"); + else + PullAction = pullAction; + + MeasuresOfInterest = moi; + + if ((moi & MeasuresOfInterest.AverageChangeOverTime) == MeasuresOfInterest.AverageChangeOverTime) + m_samples = new Queue(m_maxSamples); + + Verbosity = verbosity; + } + + /// + /// Record a value in the sample set. + /// + /// + /// Do not call this if MeasuresOfInterest.None + /// + public void RecordValue() + { + double newValue = Value; + + lock (m_samples) + { + if (m_samples.Count >= m_maxSamples) + m_samples.Dequeue(); + + m_samples.Enqueue(newValue); + } + } + + public virtual string ToConsoleString() + { + StringBuilder sb = new StringBuilder(); + sb.AppendFormat("{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName); + + AppendMeasuresOfInterest(sb); + + return sb.ToString(); + } + + protected void AppendMeasuresOfInterest(StringBuilder sb) + { + if ((MeasuresOfInterest & MeasuresOfInterest.AverageChangeOverTime) + == MeasuresOfInterest.AverageChangeOverTime) + { + double totalChange = 0; + double? lastSample = null; + + lock (m_samples) + { + foreach (double s in m_samples) + { + if (lastSample != null) + totalChange += s - (double)lastSample; + + lastSample = s; + } + } + + int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1; + + sb.AppendFormat(", {0:0.##}{1}/s", totalChange / divisor / (Watchdog.WATCHDOG_INTERVAL_MS / 1000), UnitName); + } + } + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index eae7505..0762b01 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -301,264 +301,4 @@ namespace OpenSim.Framework.Monitoring Debug, Info } - - /// - /// Holds individual static details - /// - public class Stat - { - /// - /// Category of this stat (e.g. cache, scene, etc). - /// - public string Category { get; private set; } - - /// - /// Containing name for this stat. - /// FIXME: In the case of a scene, this is currently the scene name (though this leaves - /// us with a to-be-resolved problem of non-unique region names). - /// - /// - /// The container. - /// - public string Container { get; private set; } - - public StatType StatType { get; private set; } - - public MeasuresOfInterest MeasuresOfInterest { get; private set; } - - /// - /// Action used to update this stat when the value is requested if it's a pull type. - /// - public Action PullAction { get; private set; } - - public StatVerbosity Verbosity { get; private set; } - public string ShortName { get; private set; } - public string Name { get; private set; } - public string Description { get; private set; } - public virtual string UnitName { get; private set; } - - public virtual double Value - { - get - { - // Asking for an update here means that the updater cannot access this value without infinite recursion. - // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being - // called by the pull action and just return the value. - if (StatType == StatType.Pull) - PullAction(this); - - return m_value; - } - - set - { - m_value = value; - } - } - - private double m_value; - - /// - /// Historical samples for calculating measures of interest average. - /// - /// - /// Will be null if no measures of interest require samples. - /// - private static Queue m_samples; - - /// - /// Maximum number of statistical samples. - /// - /// - /// At the moment this corresponds to 1 minute since the sampling rate is every 2.5 seconds as triggered from - /// the main Watchdog. - /// - private static int m_maxSamples = 24; - - public Stat( - string shortName, - string name, - string description, - string unitName, - string category, - string container, - StatType type, - Action pullAction, - StatVerbosity verbosity) - : this( - shortName, - name, - description, - unitName, - category, - container, - type, - MeasuresOfInterest.None, - pullAction, - verbosity) - { - } - - /// - /// Constructor - /// - /// Short name for the stat. Must not contain spaces. e.g. "LongFrames" - /// Human readable name for the stat. e.g. "Long frames" - /// Description of stat - /// - /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value. - /// e.g. " frames" - /// - /// Category under which this stat should appear, e.g. "scene". Do not capitalize. - /// Entity to which this stat relates. e.g. scene name if this is a per scene stat. - /// Push or pull - /// Pull stats need an action to update the stat on request. Push stats should set null here. - /// Measures of interest - /// Verbosity of stat. Controls whether it will appear in short stat display or only full display. - public Stat( - string shortName, - string name, - string description, - string unitName, - string category, - string container, - StatType type, - MeasuresOfInterest moi, - Action pullAction, - StatVerbosity verbosity) - { - if (StatsManager.SubCommands.Contains(category)) - throw new Exception( - string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category)); - - ShortName = shortName; - Name = name; - Description = description; - UnitName = unitName; - Category = category; - Container = container; - StatType = type; - - if (StatType == StatType.Push && pullAction != null) - throw new Exception("A push stat cannot have a pull action"); - else - PullAction = pullAction; - - MeasuresOfInterest = moi; - - if ((moi & MeasuresOfInterest.AverageChangeOverTime) == MeasuresOfInterest.AverageChangeOverTime) - m_samples = new Queue(m_maxSamples); - - Verbosity = verbosity; - } - - /// - /// Record a value in the sample set. - /// - /// - /// Do not call this if MeasuresOfInterest.None - /// - public void RecordValue() - { - double newValue = Value; - - lock (m_samples) - { - if (m_samples.Count >= m_maxSamples) - m_samples.Dequeue(); - - m_samples.Enqueue(newValue); - } - } - - public virtual string ToConsoleString() - { - StringBuilder sb = new StringBuilder(); - sb.AppendFormat("{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName); - - AppendMeasuresOfInterest(sb); - - return sb.ToString(); - } - - protected void AppendMeasuresOfInterest(StringBuilder sb) - { - if ((MeasuresOfInterest & MeasuresOfInterest.AverageChangeOverTime) - == MeasuresOfInterest.AverageChangeOverTime) - { - double totalChange = 0; - double? lastSample = null; - - lock (m_samples) - { - foreach (double s in m_samples) - { - if (lastSample != null) - totalChange += s - (double)lastSample; - - lastSample = s; - } - } - - int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1; - - sb.AppendFormat(", {0:0.##}{1}/s", totalChange / divisor / (Watchdog.WATCHDOG_INTERVAL_MS / 1000), UnitName); - } - } - } - - public class PercentageStat : Stat - { - public long Antecedent { get; set; } - public long Consequent { get; set; } - - public override double Value - { - get - { - // Asking for an update here means that the updater cannot access this value without infinite recursion. - // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being - // called by the pull action and just return the value. - if (StatType == StatType.Pull) - PullAction(this); - - long c = Consequent; - - // Avoid any chance of a multi-threaded divide-by-zero - if (c == 0) - return 0; - - return (double)Antecedent / c * 100; - } - - set - { - throw new InvalidOperationException("Cannot set value on a PercentageStat"); - } - } - - public PercentageStat( - string shortName, - string name, - string description, - string category, - string container, - StatType type, - Action pullAction, - StatVerbosity verbosity) - : base(shortName, name, description, "%", category, container, type, pullAction, verbosity) {} - - public override string ToConsoleString() - { - StringBuilder sb = new StringBuilder(); - - sb.AppendFormat( - "{0}.{1}.{2} : {3:0.##}{4} ({5}/{6})", - Category, Container, ShortName, Value, UnitName, Antecedent, Consequent); - - AppendMeasuresOfInterest(sb); - - return sb.ToString(); - } - } } \ No newline at end of file -- cgit v1.1 From 392e84e55402166f5b4ec708d3338efe70a94c2e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 17 Nov 2012 01:23:29 +0000 Subject: Remove unnecessary ability to directly set InventoryItemBase.CreatorIdAsUuid This was necessary historically but hasn't been for many years. Can still get CreatorIdAsUuid, which is really just a UUID cached version of the string CreatorId --- OpenSim/Framework/InventoryItemBase.cs | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs index a663680..3d45e76 100644 --- a/OpenSim/Framework/InventoryItemBase.cs +++ b/OpenSim/Framework/InventoryItemBase.cs @@ -87,16 +87,7 @@ namespace OpenSim.Framework protected string m_creatorId; /// - /// The UUID for the creator. This may be different from the canonical CreatorId. This property is used - /// for communication with the client over the Second Life protocol, since that protocol can only understand - /// UUIDs. As this is a basic framework class, this means that both the string creator id and the uuid - /// reference have to be settable separately - /// - /// Database plugins don't need to set this, it will be set by - /// upstream code (or set by the get accessor if left unset). - /// - /// XXX: An alternative to having a separate uuid property would be to hash the CreatorId appropriately - /// every time there was communication with a UUID-only client. This may be much more expensive. + /// The CreatorId expressed as a UUID.tely /// public UUID CreatorIdAsUuid { @@ -109,20 +100,18 @@ namespace OpenSim.Framework return m_creatorIdAsUuid; } - - set - { - m_creatorIdAsUuid = value; - } } protected UUID m_creatorIdAsUuid = UUID.Zero; - protected string m_creatorData = string.Empty; + /// + /// Extended creator information of the form ; + /// public string CreatorData // = ; { get { return m_creatorData; } set { m_creatorData = value; } } + protected string m_creatorData = string.Empty; /// /// Used by the DB layer to retrieve / store the entire user identification. @@ -162,7 +151,6 @@ namespace OpenSim.Framework name = parts[2]; m_creatorData += ';' + name; - } } } -- cgit v1.1 From dc5711ad6221f087b6250179ac9a6a389581058c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Nov 2012 04:10:03 +0000 Subject: minor: If logging full incoming HTTP data, don't deceptively print ... at the end of the body. --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 410a76a..66d80cf 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -719,8 +719,11 @@ namespace OpenSim.Framework.Servers.HttpServer if (DebugLevel == 5) { const int sampleLength = 80; - char[] sampleChars = new char[sampleLength]; + char[] sampleChars = new char[sampleLength + 3]; reader.Read(sampleChars, 0, sampleLength); + sampleChars[80] = '.'; + sampleChars[81] = '.'; + sampleChars[82] = '.'; output = new string(sampleChars); } else @@ -728,7 +731,7 @@ namespace OpenSim.Framework.Servers.HttpServer output = reader.ReadToEnd(); } - m_log.DebugFormat("[BASE HTTP SERVER]: {0}...", output.Replace("\n", @"\n")); + m_log.DebugFormat("[BASE HTTP SERVER]: {0}", output.Replace("\n", @"\n")); } } -- cgit v1.1 From 74a20a62eee8c565a9410d6896754242eb602abc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Nov 2012 03:43:21 +0000 Subject: refactor: Factor out copy/pasted server uptime report code --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 29 ++----------- OpenSim/Framework/Servers/ServerBase.cs | 58 ++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 25 deletions(-) create mode 100644 OpenSim/Framework/Servers/ServerBase.cs (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 5b2d7dc..6346279 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -38,6 +38,8 @@ using log4net; using log4net.Appender; using log4net.Core; using log4net.Repository; +using OpenMetaverse; +using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Monitoring; @@ -45,16 +47,12 @@ using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using Timer=System.Timers.Timer; -using OpenMetaverse; -using OpenMetaverse.StructuredData; - - namespace OpenSim.Framework.Servers { /// /// Common base for the main OpenSimServers (user, grid, inventory, region, etc) /// - public abstract class BaseOpenSimServer + public abstract class BaseOpenSimServer : ServerBase { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -69,11 +67,6 @@ namespace OpenSim.Framework.Servers protected IAppender m_logFileAppender = null; /// - /// Time at which this server was started - /// - protected DateTime m_startuptime; - - /// /// Record the initial startup directory for info purposes /// protected string m_startupDirectory = Environment.CurrentDirectory; @@ -96,9 +89,8 @@ namespace OpenSim.Framework.Servers get { return m_httpServer; } } - public BaseOpenSimServer() + public BaseOpenSimServer() : base() { - m_startuptime = DateTime.Now; m_version = VersionInfo.Version; // Random uuid for private data @@ -284,19 +276,6 @@ namespace OpenSim.Framework.Servers } /// - /// Return a report about the uptime of this server - /// - /// - protected string GetUptimeReport() - { - StringBuilder sb = new StringBuilder(String.Format("Time now is {0}\n", DateTime.Now)); - sb.Append(String.Format("Server has been running since {0}, {1}\n", m_startuptime.DayOfWeek, m_startuptime)); - sb.Append(String.Format("That is an elapsed time of {0}\n", DateTime.Now - m_startuptime)); - - return sb.ToString(); - } - - /// /// Performs initialisation of the scene, such as loading configuration from disk. /// public virtual void Startup() diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs new file mode 100644 index 0000000..d19234b --- /dev/null +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -0,0 +1,58 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Text; + +namespace OpenSim.Framework.Servers +{ + public class ServerBase + { + /// + /// Time at which this server was started + /// + protected DateTime m_startuptime; + + public ServerBase() + { + m_startuptime = DateTime.Now; + } + + /// + /// Return a report about the uptime of this server + /// + /// + protected string GetUptimeReport() + { + StringBuilder sb = new StringBuilder(String.Format("Time now is {0}\n", DateTime.Now)); + sb.Append(String.Format("Server has been running since {0}, {1}\n", m_startuptime.DayOfWeek, m_startuptime)); + sb.Append(String.Format("That is an elapsed time of {0}\n", DateTime.Now - m_startuptime)); + + return sb.ToString(); + } + } +} \ No newline at end of file -- cgit v1.1 From 5c48d7a378ff066f59b9cee02f2803ebe1616481 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Nov 2012 04:05:09 +0000 Subject: factor out common HandleShow code for "show uptime" --- OpenSim/Framework/Console/CommandConsole.cs | 2 +- OpenSim/Framework/Console/ConsoleBase.cs | 10 +----- OpenSim/Framework/Console/MockConsole.cs | 7 +++- OpenSim/Framework/ICommandConsole.cs | 5 +++ OpenSim/Framework/IConsole.cs | 2 +- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 39 +++----------------- OpenSim/Framework/Servers/ServerBase.cs | 50 ++++++++++++++++++++++++++ 7 files changed, 69 insertions(+), 46 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index bd23d1c..d1e29b4 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -711,7 +711,7 @@ namespace OpenSim.Framework.Console /// public void Prompt() { - string line = ReadLine(m_defaultPrompt + "# ", true, true); + string line = ReadLine(DefaultPrompt + "# ", true, true); if (line != String.Empty) Output("Invalid command"); diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 4b375d9..2d8e723 100755 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs @@ -43,15 +43,7 @@ namespace OpenSim.Framework.Console public object ConsoleScene { get; set; } - /// - /// The default prompt text. - /// - public string DefaultPrompt - { - set { m_defaultPrompt = value; } - get { return m_defaultPrompt; } - } - protected string m_defaultPrompt; + public string DefaultPrompt { get; set; } public ConsoleBase(string defaultPrompt) { diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index b489f93..8ba58e4 100644 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs @@ -46,13 +46,18 @@ namespace OpenSim.Framework.Console public ICommands Commands { get { return m_commands; } } + public string DefaultPrompt { get; set; } + public void Prompt() {} public void RunCommand(string cmd) {} public string ReadLine(string p, bool isCommand, bool e) { return ""; } - public object ConsoleScene { get { return null; } } + public object ConsoleScene { + get { return null; } + set {} + } public void Output(string text, string level) {} public void Output(string text) {} diff --git a/OpenSim/Framework/ICommandConsole.cs b/OpenSim/Framework/ICommandConsole.cs index 8cd20da..a6573f8 100644 --- a/OpenSim/Framework/ICommandConsole.cs +++ b/OpenSim/Framework/ICommandConsole.cs @@ -83,6 +83,11 @@ namespace OpenSim.Framework ICommands Commands { get; } /// + /// The default prompt text. + /// + string DefaultPrompt { get; set; } + + /// /// Display a command prompt on the console and wait for user input /// void Prompt(); diff --git a/OpenSim/Framework/IConsole.cs b/OpenSim/Framework/IConsole.cs index 33024b2..79560d8 100644 --- a/OpenSim/Framework/IConsole.cs +++ b/OpenSim/Framework/IConsole.cs @@ -32,7 +32,7 @@ namespace OpenSim.Framework { public interface IConsole { - object ConsoleScene { get; } + object ConsoleScene { get; set; } void Output(string text, string level); void Output(string text); diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 6346279..4f9ac08 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -62,7 +62,6 @@ namespace OpenSim.Framework.Servers /// private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000); - protected CommandConsole m_console; protected OpenSimAppender m_consoleAppender; protected IAppender m_logFileAppender = null; @@ -139,7 +138,8 @@ namespace OpenSim.Framework.Servers } else { - m_consoleAppender.Console = m_console; + // FIXME: This should be done through an interface rather than casting. + m_consoleAppender.Console = (ConsoleBase)m_console; // If there is no threshold set then the threshold is effectively everything. if (null == m_consoleAppender.Threshold) @@ -367,8 +367,10 @@ namespace OpenSim.Framework.Servers } } - public virtual void HandleShow(string module, string[] cmd) + public override void HandleShow(string module, string[] cmd) { + base.HandleShow(module, cmd); + List args = new List(cmd); args.RemoveAt(0); @@ -385,10 +387,6 @@ namespace OpenSim.Framework.Servers Notice(GetThreadsReport()); break; - case "uptime": - Notice(GetUptimeReport()); - break; - case "version": Notice(GetVersionText()); break; @@ -430,33 +428,6 @@ namespace OpenSim.Framework.Servers } /// - /// Console output is only possible if a console has been established. - /// That is something that cannot be determined within this class. So - /// all attempts to use the console MUST be verified. - /// - /// - protected void Notice(string msg) - { - if (m_console != null) - { - m_console.Output(msg); - } - } - - /// - /// Console output is only possible if a console has been established. - /// That is something that cannot be determined within this class. So - /// all attempts to use the console MUST be verified. - /// - /// - /// - protected void Notice(string format, params string[] components) - { - if (m_console != null) - m_console.OutputFormat(format, components); - } - - /// /// Enhance the version string with extra information if it's available. /// protected void EnhanceVersionInformation() diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index d19234b..afe1f73 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -26,13 +26,20 @@ */ using System; +using System.Collections.Generic; using System.Text; +using OpenSim.Framework.Console; namespace OpenSim.Framework.Servers { public class ServerBase { /// + /// Console to be used for any command line output. Can be null, in which case there should be no output. + /// + protected ICommandConsole m_console; + + /// /// Time at which this server was started /// protected DateTime m_startuptime; @@ -42,6 +49,22 @@ namespace OpenSim.Framework.Servers m_startuptime = DateTime.Now; } + public virtual void HandleShow(string module, string[] cmd) + { + List args = new List(cmd); + + args.RemoveAt(0); + + string[] showParams = args.ToArray(); + + switch (showParams[0]) + { + case "uptime": + Notice(GetUptimeReport()); + break; + } + } + /// /// Return a report about the uptime of this server /// @@ -54,5 +77,32 @@ namespace OpenSim.Framework.Servers return sb.ToString(); } + + /// + /// Console output is only possible if a console has been established. + /// That is something that cannot be determined within this class. So + /// all attempts to use the console MUST be verified. + /// + /// + protected void Notice(string msg) + { + if (m_console != null) + { + m_console.Output(msg); + } + } + + /// + /// Console output is only possible if a console has been established. + /// That is something that cannot be determined within this class. So + /// all attempts to use the console MUST be verified. + /// + /// + /// + protected void Notice(string format, params string[] components) + { + if (m_console != null) + m_console.OutputFormat(format, components); + } } } \ No newline at end of file -- cgit v1.1 From cf03d6ea9223e71c27ca91633a30abcf1368ec58 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Nov 2012 04:11:03 +0000 Subject: Factor out common registration of "show uptime" command --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 130 ++++++++++++------------- OpenSim/Framework/Servers/ServerBase.cs | 12 +++ 2 files changed, 76 insertions(+), 66 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 4f9ac08..019b68b 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -118,78 +118,76 @@ namespace OpenSim.Framework.Servers /// protected virtual void StartupSpecific() { - if (m_console != null) - { - ILoggerRepository repository = LogManager.GetRepository(); - IAppender[] appenders = repository.GetAppenders(); + if (m_console == null) + return; - foreach (IAppender appender in appenders) - { - if (appender.Name == "Console") - { - m_consoleAppender = (OpenSimAppender)appender; - break; - } - } + ILoggerRepository repository = LogManager.GetRepository(); + IAppender[] appenders = repository.GetAppenders(); - if (null == m_consoleAppender) - { - Notice("No appender named Console found (see the log4net config file for this executable)!"); - } - else + foreach (IAppender appender in appenders) + { + if (appender.Name == "Console") { - // FIXME: This should be done through an interface rather than casting. - m_consoleAppender.Console = (ConsoleBase)m_console; - - // If there is no threshold set then the threshold is effectively everything. - if (null == m_consoleAppender.Threshold) - m_consoleAppender.Threshold = Level.All; - - Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); + m_consoleAppender = (OpenSimAppender)appender; + break; } + } + + if (null == m_consoleAppender) + { + Notice("No appender named Console found (see the log4net config file for this executable)!"); + } + else + { + // FIXME: This should be done through an interface rather than casting. + m_consoleAppender.Console = (ConsoleBase)m_console; - m_console.Commands.AddCommand("General", false, "quit", - "quit", - "Quit the application", HandleQuit); - - m_console.Commands.AddCommand("General", false, "shutdown", - "shutdown", - "Quit the application", HandleQuit); - - m_console.Commands.AddCommand("General", false, "set log level", - "set log level ", - "Set the console logging level", HandleLogLevel); - - m_console.Commands.AddCommand("General", false, "show info", - "show info", - "Show general information about the server", HandleShow); - - m_console.Commands.AddCommand("General", false, "show threads", - "show threads", - "Show thread status", HandleShow); - - m_console.Commands.AddCommand("General", false, "show uptime", - "show uptime", - "Show server uptime", HandleShow); - - m_console.Commands.AddCommand("General", false, "show version", - "show version", - "Show server version", HandleShow); - - m_console.Commands.AddCommand("General", false, "threads abort", - "threads abort ", - "Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort); - - m_console.Commands.AddCommand("General", false, "threads show", - "threads show", - "Show thread status. Synonym for \"show threads\"", - (string module, string[] args) => Notice(GetThreadsReport())); - - m_console.Commands.AddCommand("General", false, "force gc", - "force gc", - "Manually invoke runtime garbage collection. For debugging purposes", - HandleForceGc); + // If there is no threshold set then the threshold is effectively everything. + if (null == m_consoleAppender.Threshold) + m_consoleAppender.Threshold = Level.All; + + Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); } + + RegisterCommonCommands(); + + m_console.Commands.AddCommand("General", false, "quit", + "quit", + "Quit the application", HandleQuit); + + m_console.Commands.AddCommand("General", false, "shutdown", + "shutdown", + "Quit the application", HandleQuit); + + m_console.Commands.AddCommand("General", false, "set log level", + "set log level ", + "Set the console logging level", HandleLogLevel); + + m_console.Commands.AddCommand("General", false, "show info", + "show info", + "Show general information about the server", HandleShow); + + m_console.Commands.AddCommand("General", false, "show threads", + "show threads", + "Show thread status", HandleShow); + + m_console.Commands.AddCommand("General", false, "show version", + "show version", + "Show server version", HandleShow); + + m_console.Commands.AddCommand("General", false, "threads abort", + "threads abort ", + "Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort); + + m_console.Commands.AddCommand("General", false, "threads show", + "threads show", + "Show thread status. Synonym for \"show threads\"", + (string module, string[] args) => Notice(GetThreadsReport())); + + m_console.Commands.AddCommand("General", false, "force gc", + "force gc", + "Manually invoke runtime garbage collection. For debugging purposes", + HandleForceGc); } private void HandleForceGc(string module, string[] args) diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index afe1f73..0835aad 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -49,6 +49,18 @@ namespace OpenSim.Framework.Servers m_startuptime = DateTime.Now; } + /// + /// Register common commands once m_console has been set if it is going to be set + /// + public void RegisterCommonCommands() + { + if (m_console == null) + return; + + m_console.Commands.AddCommand( + "General", false, "show uptime", "show uptime", "Show server uptime", HandleShow); + } + public virtual void HandleShow(string module, string[] cmd) { List args = new List(cmd); -- cgit v1.1 From 45d1e6ab09309e21f96979548b5d1b4904800f65 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Nov 2012 04:45:53 +0000 Subject: Make "show info" command available across all servers This helpfully lists version information, startup location and console log level --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 178 +----------------------- OpenSim/Framework/Servers/ServerBase.cs | 184 ++++++++++++++++++++++++- 2 files changed, 183 insertions(+), 179 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 019b68b..9560171 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -62,19 +62,6 @@ namespace OpenSim.Framework.Servers /// private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000); - protected OpenSimAppender m_consoleAppender; - protected IAppender m_logFileAppender = null; - - /// - /// Record the initial startup directory for info purposes - /// - protected string m_startupDirectory = Environment.CurrentDirectory; - - /// - /// Server version information. Usually VersionInfo + information about git commit, operating system, etc. - /// - protected string m_version; - protected string m_pidFile = String.Empty; /// @@ -90,27 +77,11 @@ namespace OpenSim.Framework.Servers public BaseOpenSimServer() : base() { - m_version = VersionInfo.Version; - // Random uuid for private data m_osSecret = UUID.Random().ToString(); m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); m_periodicDiagnosticsTimer.Enabled = true; - - // This thread will go on to become the console listening thread - Thread.CurrentThread.Name = "ConsoleThread"; - - ILoggerRepository repository = LogManager.GetRepository(); - IAppender[] appenders = repository.GetAppenders(); - - foreach (IAppender appender in appenders) - { - if (appender.Name == "LogFileAppender") - { - m_logFileAppender = appender; - } - } } /// @@ -121,34 +92,6 @@ namespace OpenSim.Framework.Servers if (m_console == null) return; - ILoggerRepository repository = LogManager.GetRepository(); - IAppender[] appenders = repository.GetAppenders(); - - foreach (IAppender appender in appenders) - { - if (appender.Name == "Console") - { - m_consoleAppender = (OpenSimAppender)appender; - break; - } - } - - if (null == m_consoleAppender) - { - Notice("No appender named Console found (see the log4net config file for this executable)!"); - } - else - { - // FIXME: This should be done through an interface rather than casting. - m_consoleAppender.Console = (ConsoleBase)m_console; - - // If there is no threshold set then the threshold is effectively everything. - if (null == m_consoleAppender.Threshold) - m_consoleAppender.Threshold = Level.All; - - Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); - } - RegisterCommonCommands(); m_console.Commands.AddCommand("General", false, "quit", @@ -163,10 +106,6 @@ namespace OpenSim.Framework.Servers "set log level ", "Set the console logging level", HandleLogLevel); - m_console.Commands.AddCommand("General", false, "show info", - "show info", - "Show general information about the server", HandleShow); - m_console.Commands.AddCommand("General", false, "show threads", "show threads", "Show thread status", HandleShow); @@ -279,8 +218,6 @@ namespace OpenSim.Framework.Servers public virtual void Startup() { m_log.Info("[STARTUP]: Beginning startup processing"); - - EnhanceVersionInformation(); m_log.Info("[STARTUP]: OpenSimulator version: " + m_version + Environment.NewLine); // clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and @@ -377,10 +314,6 @@ namespace OpenSim.Framework.Servers switch (showParams[0]) { - case "info": - ShowInfo(); - break; - case "threads": Notice(GetThreadsReport()); break; @@ -410,116 +343,7 @@ namespace OpenSim.Framework.Servers MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId); else MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId); - } - - protected void ShowInfo() - { - Notice(GetVersionText()); - Notice("Startup directory: " + m_startupDirectory); - if (null != m_consoleAppender) - Notice(String.Format("Console log level: {0}", m_consoleAppender.Threshold)); - } - - protected string GetVersionText() - { - return String.Format("Version: {0} (interface version {1})", m_version, VersionInfo.MajorInterfaceVersion); - } - - /// - /// Enhance the version string with extra information if it's available. - /// - protected void EnhanceVersionInformation() - { - string buildVersion = string.Empty; - - // The subversion information is deprecated and will be removed at a later date - // Add subversion revision information if available - // Try file "svn_revision" in the current directory first, then the .svn info. - // This allows to make the revision available in simulators not running from the source tree. - // FIXME: Making an assumption about the directory we're currently in - we do this all over the place - // elsewhere as well - string gitDir = "../.git/"; - string gitRefPointerPath = gitDir + "HEAD"; - - string svnRevisionFileName = "svn_revision"; - string svnFileName = ".svn/entries"; - string manualVersionFileName = ".version"; - string inputLine; - int strcmp; - - if (File.Exists(manualVersionFileName)) - { - using (StreamReader CommitFile = File.OpenText(manualVersionFileName)) - buildVersion = CommitFile.ReadLine(); - - m_version += buildVersion ?? ""; - } - else if (File.Exists(gitRefPointerPath)) - { -// m_log.DebugFormat("[OPENSIM]: Found {0}", gitRefPointerPath); - - string rawPointer = ""; - - using (StreamReader pointerFile = File.OpenText(gitRefPointerPath)) - rawPointer = pointerFile.ReadLine(); - -// m_log.DebugFormat("[OPENSIM]: rawPointer [{0}]", rawPointer); - - Match m = Regex.Match(rawPointer, "^ref: (.+)$"); - - if (m.Success) - { -// m_log.DebugFormat("[OPENSIM]: Matched [{0}]", m.Groups[1].Value); - - string gitRef = m.Groups[1].Value; - string gitRefPath = gitDir + gitRef; - if (File.Exists(gitRefPath)) - { -// m_log.DebugFormat("[OPENSIM]: Found gitRefPath [{0}]", gitRefPath); - - using (StreamReader refFile = File.OpenText(gitRefPath)) - { - string gitHash = refFile.ReadLine(); - m_version += gitHash.Substring(0, 7); - } - } - } - } - else - { - // Remove the else logic when subversion mirror is no longer used - if (File.Exists(svnRevisionFileName)) - { - StreamReader RevisionFile = File.OpenText(svnRevisionFileName); - buildVersion = RevisionFile.ReadLine(); - buildVersion.Trim(); - RevisionFile.Close(); - } - - if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName)) - { - StreamReader EntriesFile = File.OpenText(svnFileName); - inputLine = EntriesFile.ReadLine(); - while (inputLine != null) - { - // using the dir svn revision at the top of entries file - strcmp = String.Compare(inputLine, "dir"); - if (strcmp == 0) - { - buildVersion = EntriesFile.ReadLine(); - break; - } - else - { - inputLine = EntriesFile.ReadLine(); - } - } - EntriesFile.Close(); - } - - m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6); - } - } + } protected void CreatePIDFile(string path) { diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 0835aad..129b5fa 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -27,26 +27,90 @@ using System; using System.Collections.Generic; +using System.IO; +using System.Reflection; using System.Text; +using System.Text.RegularExpressions; +using log4net; +using log4net.Appender; +using log4net.Core; +using log4net.Repository; +using Nini.Config; using OpenSim.Framework.Console; namespace OpenSim.Framework.Servers { public class ServerBase { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// /// Console to be used for any command line output. Can be null, in which case there should be no output. /// protected ICommandConsole m_console; + protected OpenSimAppender m_consoleAppender; + protected FileAppender m_logFileAppender; + + protected DateTime m_startuptime; + protected string m_startupDirectory = Environment.CurrentDirectory; + /// - /// Time at which this server was started + /// Server version information. Usually VersionInfo + information about git commit, operating system, etc. /// - protected DateTime m_startuptime; + protected string m_version; public ServerBase() { m_startuptime = DateTime.Now; + m_version = VersionInfo.Version; + EnhanceVersionInformation(); + } + + public void RegisterCommonAppenders(IConfig startupConfig) + { + ILoggerRepository repository = LogManager.GetRepository(); + IAppender[] appenders = repository.GetAppenders(); + + foreach (IAppender appender in appenders) + { + if (appender.Name == "Console") + { + m_consoleAppender = (OpenSimAppender)appender; + } + else if (appender.Name == "LogFileAppender") + { + m_logFileAppender = (FileAppender)appender; + } + } + + if (null == m_consoleAppender) + { + Notice("No appender named Console found (see the log4net config file for this executable)!"); + } + else + { + // FIXME: This should be done through an interface rather than casting. + m_consoleAppender.Console = (ConsoleBase)m_console; + + // If there is no threshold set then the threshold is effectively everything. + if (null == m_consoleAppender.Threshold) + m_consoleAppender.Threshold = Level.All; + + Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); + } + + if (m_logFileAppender != null && startupConfig != null) + { + string cfgFileName = startupConfig.GetString("LogFile", null); + if (cfgFileName != null) + { + m_logFileAppender.File = cfgFileName; + m_logFileAppender.ActivateOptions(); + } + + m_log.InfoFormat("[LOGGING]: Logging started to file {0}", m_logFileAppender.File); + } } /// @@ -58,6 +122,9 @@ namespace OpenSim.Framework.Servers return; m_console.Commands.AddCommand( + "General", false, "show info", "show info", "Show general information about the server", HandleShow); + + m_console.Commands.AddCommand( "General", false, "show uptime", "show uptime", "Show server uptime", HandleShow); } @@ -71,6 +138,10 @@ namespace OpenSim.Framework.Servers switch (showParams[0]) { + case "info": + ShowInfo(); + break; + case "uptime": Notice(GetUptimeReport()); break; @@ -90,6 +161,115 @@ namespace OpenSim.Framework.Servers return sb.ToString(); } + protected void ShowInfo() + { + Notice(GetVersionText()); + Notice("Startup directory: " + m_startupDirectory); + if (null != m_consoleAppender) + Notice(String.Format("Console log level: {0}", m_consoleAppender.Threshold)); + } + + /// + /// Enhance the version string with extra information if it's available. + /// + protected void EnhanceVersionInformation() + { + string buildVersion = string.Empty; + + // The subversion information is deprecated and will be removed at a later date + // Add subversion revision information if available + // Try file "svn_revision" in the current directory first, then the .svn info. + // This allows to make the revision available in simulators not running from the source tree. + // FIXME: Making an assumption about the directory we're currently in - we do this all over the place + // elsewhere as well + string gitDir = "../.git/"; + string gitRefPointerPath = gitDir + "HEAD"; + + string svnRevisionFileName = "svn_revision"; + string svnFileName = ".svn/entries"; + string manualVersionFileName = ".version"; + string inputLine; + int strcmp; + + if (File.Exists(manualVersionFileName)) + { + using (StreamReader CommitFile = File.OpenText(manualVersionFileName)) + buildVersion = CommitFile.ReadLine(); + + m_version += buildVersion ?? ""; + } + else if (File.Exists(gitRefPointerPath)) + { +// m_log.DebugFormat("[OPENSIM]: Found {0}", gitRefPointerPath); + + string rawPointer = ""; + + using (StreamReader pointerFile = File.OpenText(gitRefPointerPath)) + rawPointer = pointerFile.ReadLine(); + +// m_log.DebugFormat("[OPENSIM]: rawPointer [{0}]", rawPointer); + + Match m = Regex.Match(rawPointer, "^ref: (.+)$"); + + if (m.Success) + { +// m_log.DebugFormat("[OPENSIM]: Matched [{0}]", m.Groups[1].Value); + + string gitRef = m.Groups[1].Value; + string gitRefPath = gitDir + gitRef; + if (File.Exists(gitRefPath)) + { +// m_log.DebugFormat("[OPENSIM]: Found gitRefPath [{0}]", gitRefPath); + + using (StreamReader refFile = File.OpenText(gitRefPath)) + { + string gitHash = refFile.ReadLine(); + m_version += gitHash.Substring(0, 7); + } + } + } + } + else + { + // Remove the else logic when subversion mirror is no longer used + if (File.Exists(svnRevisionFileName)) + { + StreamReader RevisionFile = File.OpenText(svnRevisionFileName); + buildVersion = RevisionFile.ReadLine(); + buildVersion.Trim(); + RevisionFile.Close(); + } + + if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName)) + { + StreamReader EntriesFile = File.OpenText(svnFileName); + inputLine = EntriesFile.ReadLine(); + while (inputLine != null) + { + // using the dir svn revision at the top of entries file + strcmp = String.Compare(inputLine, "dir"); + if (strcmp == 0) + { + buildVersion = EntriesFile.ReadLine(); + break; + } + else + { + inputLine = EntriesFile.ReadLine(); + } + } + EntriesFile.Close(); + } + + m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6); + } + } + + protected string GetVersionText() + { + return String.Format("Version: {0} (interface version {1})", m_version, VersionInfo.MajorInterfaceVersion); + } + /// /// Console output is only possible if a console has been established. /// That is something that cannot be determined within this class. So -- cgit v1.1 From 4c4379b50f22a40f6178e37259afc2689a0f2dd1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Nov 2012 04:50:09 +0000 Subject: Make "set log level" command available across all servers --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 31 -------------------------- OpenSim/Framework/Servers/ServerBase.cs | 31 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 9560171..5e898ef 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -102,10 +102,6 @@ namespace OpenSim.Framework.Servers "shutdown", "Quit the application", HandleQuit); - m_console.Commands.AddCommand("General", false, "set log level", - "set log level ", - "Set the console logging level", HandleLogLevel); - m_console.Commands.AddCommand("General", false, "show threads", "show threads", "Show thread status", HandleShow); @@ -254,33 +250,6 @@ namespace OpenSim.Framework.Servers Shutdown(); } - private void HandleLogLevel(string module, string[] cmd) - { - if (null == m_consoleAppender) - { - Notice("No appender named Console found (see the log4net config file for this executable)!"); - return; - } - - if (cmd.Length > 3) - { - string rawLevel = cmd[3]; - - ILoggerRepository repository = LogManager.GetRepository(); - Level consoleLevel = repository.LevelMap[rawLevel]; - - if (consoleLevel != null) - m_consoleAppender.Threshold = consoleLevel; - else - Notice( - String.Format( - "{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF", - rawLevel)); - } - - Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); - } - /// /// Show help information /// diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 129b5fa..feffe6d 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -126,6 +126,10 @@ namespace OpenSim.Framework.Servers m_console.Commands.AddCommand( "General", false, "show uptime", "show uptime", "Show server uptime", HandleShow); + + m_console.Commands.AddCommand( + "General", false, "set log level", "set log level ", "Set the console logging level", + HandleLogLevel); } public virtual void HandleShow(string module, string[] cmd) @@ -148,6 +152,33 @@ namespace OpenSim.Framework.Servers } } + private void HandleLogLevel(string module, string[] cmd) + { + if (null == m_consoleAppender) + { + Notice("No appender named Console found (see the log4net config file for this executable)!"); + return; + } + + if (cmd.Length > 3) + { + string rawLevel = cmd[3]; + + ILoggerRepository repository = LogManager.GetRepository(); + Level consoleLevel = repository.LevelMap[rawLevel]; + + if (consoleLevel != null) + m_consoleAppender.Threshold = consoleLevel; + else + Notice( + String.Format( + "{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF", + rawLevel)); + } + + Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); + } + /// /// Return a report about the uptime of this server /// -- cgit v1.1 From 34ff96a1196e8680fe3bbb60b870ab149979dd90 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Nov 2012 04:52:29 +0000 Subject: Remove unused BaseOpenSimServer.ShowHelp() --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 5e898ef..8bdda29 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -250,27 +250,6 @@ namespace OpenSim.Framework.Servers Shutdown(); } - /// - /// Show help information - /// - /// - protected virtual void ShowHelp(string[] helpArgs) - { - Notice(""); - - if (helpArgs.Length == 0) - { - Notice("set log level [level] - change the console logging level only. For example, off or debug."); - Notice("show info - show server information (e.g. startup path)."); - Notice("show threads - list tracked threads"); - Notice("show uptime - show server startup time and uptime."); - Notice("show version - show server version."); - Notice(""); - - return; - } - } - public override void HandleShow(string module, string[] cmd) { base.HandleShow(module, cmd); -- cgit v1.1 From 42e87a6582c5880caf7bdee49450e6f27ddf82bf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Nov 2012 04:57:45 +0000 Subject: Add "get log level" command - this returns the current server session console logging level. This supersedes getting information by calling "set log level" without a 4th argument, which is confusing. --- OpenSim/Framework/Servers/ServerBase.cs | 50 ++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index feffe6d..9973a2d 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -128,8 +128,12 @@ namespace OpenSim.Framework.Servers "General", false, "show uptime", "show uptime", "Show server uptime", HandleShow); m_console.Commands.AddCommand( - "General", false, "set log level", "set log level ", "Set the console logging level", - HandleLogLevel); + "General", false, "get log level", "get log level", "Get the current console logging level", + (mod, cmd) => ShowLogLevel()); + + m_console.Commands.AddCommand( + "General", false, "set log level", "set log level ", + "Set the console logging level for this session.", HandleSetLogLevel); } public virtual void HandleShow(string module, string[] cmd) @@ -152,30 +156,38 @@ namespace OpenSim.Framework.Servers } } - private void HandleLogLevel(string module, string[] cmd) + private void HandleSetLogLevel(string module, string[] cmd) { - if (null == m_consoleAppender) + if (cmd.Length != 4) { - Notice("No appender named Console found (see the log4net config file for this executable)!"); + Notice("Usage: set log level "); return; } - - if (cmd.Length > 3) + + if (null == m_consoleAppender) { - string rawLevel = cmd[3]; - - ILoggerRepository repository = LogManager.GetRepository(); - Level consoleLevel = repository.LevelMap[rawLevel]; - - if (consoleLevel != null) - m_consoleAppender.Threshold = consoleLevel; - else - Notice( - String.Format( - "{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF", - rawLevel)); + Notice("No appender named Console found (see the log4net config file for this executable)!"); + return; } + string rawLevel = cmd[3]; + + ILoggerRepository repository = LogManager.GetRepository(); + Level consoleLevel = repository.LevelMap[rawLevel]; + + if (consoleLevel != null) + m_consoleAppender.Threshold = consoleLevel; + else + Notice( + String.Format( + "{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF", + rawLevel)); + + ShowLogLevel(); + } + + private void ShowLogLevel() + { Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); } -- cgit v1.1 From 8269d2b893af47ad44e66a7918d472086adaddbb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Nov 2012 05:14:08 +0000 Subject: Factor out common pid file creation and removal code. Log path at which pid file is created or reason for failure to create. --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 36 +----------------- OpenSim/Framework/Servers/ServerBase.cs | 51 +++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 40 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 8bdda29..89d3507 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -61,8 +61,6 @@ namespace OpenSim.Framework.Servers /// server. /// private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000); - - protected string m_pidFile = String.Empty; /// /// Random uuid for private data @@ -293,23 +291,6 @@ namespace OpenSim.Framework.Servers MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId); } - protected void CreatePIDFile(string path) - { - try - { - string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); - FileStream fs = File.Create(path); - - Byte[] buf = Encoding.ASCII.GetBytes(pidstring); - fs.Write(buf, 0, buf.Length); - fs.Close(); - m_pidFile = path; - } - catch (Exception) - { - } - } - public string osSecret { // Secret uuid for the simulator get { return m_osSecret; } @@ -327,20 +308,5 @@ namespace OpenSim.Framework.Servers return StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version); } } - - protected void RemovePIDFile() - { - if (m_pidFile != String.Empty) - { - try - { - File.Delete(m_pidFile); - m_pidFile = String.Empty; - } - catch (Exception) - { - } - } - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 9973a2d..645b43a 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -55,6 +55,8 @@ namespace OpenSim.Framework.Servers protected DateTime m_startuptime; protected string m_startupDirectory = Environment.CurrentDirectory; + protected string m_pidFile = String.Empty; + /// /// Server version information. Usually VersionInfo + information about git commit, operating system, etc. /// @@ -67,6 +69,45 @@ namespace OpenSim.Framework.Servers EnhanceVersionInformation(); } + protected void CreatePIDFile(string path) + { + try + { + string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); + + using (FileStream fs = File.Create(path)) + { + Byte[] buf = Encoding.ASCII.GetBytes(pidstring); + fs.Write(buf, 0, buf.Length); + } + + m_pidFile = path; + + m_log.InfoFormat("[SERVER BASE]: Created pid file {0}", m_pidFile); + } + catch (Exception e) + { + m_log.Warn(string.Format("[SERVER BASE]: Could not create PID file at {0} ", path), e); + } + } + + protected void RemovePIDFile() + { + if (m_pidFile != String.Empty) + { + try + { + File.Delete(m_pidFile); + } + catch (Exception e) + { + m_log.Error(string.Format("[SERVER BASE]: Error whilst removing {0} ", m_pidFile), e); + } + + m_pidFile = String.Empty; + } + } + public void RegisterCommonAppenders(IConfig startupConfig) { ILoggerRepository repository = LogManager.GetRepository(); @@ -109,7 +150,7 @@ namespace OpenSim.Framework.Servers m_logFileAppender.ActivateOptions(); } - m_log.InfoFormat("[LOGGING]: Logging started to file {0}", m_logFileAppender.File); + m_log.InfoFormat("[SERVER BASE]: Logging started to file {0}", m_logFileAppender.File); } } @@ -243,26 +284,26 @@ namespace OpenSim.Framework.Servers } else if (File.Exists(gitRefPointerPath)) { -// m_log.DebugFormat("[OPENSIM]: Found {0}", gitRefPointerPath); +// m_log.DebugFormat("[SERVER BASE]: Found {0}", gitRefPointerPath); string rawPointer = ""; using (StreamReader pointerFile = File.OpenText(gitRefPointerPath)) rawPointer = pointerFile.ReadLine(); -// m_log.DebugFormat("[OPENSIM]: rawPointer [{0}]", rawPointer); +// m_log.DebugFormat("[SERVER BASE]: rawPointer [{0}]", rawPointer); Match m = Regex.Match(rawPointer, "^ref: (.+)$"); if (m.Success) { -// m_log.DebugFormat("[OPENSIM]: Matched [{0}]", m.Groups[1].Value); +// m_log.DebugFormat("[SERVER BASE]: Matched [{0}]", m.Groups[1].Value); string gitRef = m.Groups[1].Value; string gitRefPath = gitDir + gitRef; if (File.Exists(gitRefPath)) { -// m_log.DebugFormat("[OPENSIM]: Found gitRefPath [{0}]", gitRefPath); +// m_log.DebugFormat("[SERVER BASE]: Found gitRefPath [{0}]", gitRefPath); using (StreamReader refFile = File.OpenText(gitRefPath)) { -- cgit v1.1 From 9fcf3f1a3f3457debf0f59ba7659492b44172b99 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Nov 2012 05:48:41 +0000 Subject: Make "config show/set/get/save" console commands available on all servers --- OpenSim/Framework/Servers/ServerBase.cs | 140 +++++++++++++++++++++++++++++++- 1 file changed, 137 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 645b43a..27cfc9b 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -44,6 +44,8 @@ namespace OpenSim.Framework.Servers { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public IConfigSource Config { get; protected set; } + /// /// Console to be used for any command line output. Can be null, in which case there should be no output. /// @@ -175,6 +177,30 @@ namespace OpenSim.Framework.Servers m_console.Commands.AddCommand( "General", false, "set log level", "set log level ", "Set the console logging level for this session.", HandleSetLogLevel); + + m_console.Commands.AddCommand( + "General", false, "config set", + "config set
", + "Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig); + + m_console.Commands.AddCommand( + "General", false, "config get", + "config get [
] []", + "Synonym for config show", + HandleConfig); + + m_console.Commands.AddCommand( + "General", false, "config show", + "config show [
] []", + "Show config information", + "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine + + "If a section is given but not a field, then all fields in that section are printed.", + HandleConfig); + + m_console.Commands.AddCommand( + "General", false, "config save", + "config save ", + "Save current configuration to a file at the given path", HandleConfig); } public virtual void HandleShow(string module, string[] cmd) @@ -197,6 +223,115 @@ namespace OpenSim.Framework.Servers } } + /// + /// Change and load configuration file data. + /// + /// + /// + private void HandleConfig(string module, string[] cmd) + { + List args = new List(cmd); + args.RemoveAt(0); + string[] cmdparams = args.ToArray(); + + if (cmdparams.Length > 0) + { + string firstParam = cmdparams[0].ToLower(); + + switch (firstParam) + { + case "set": + if (cmdparams.Length < 4) + { + Notice("Syntax: config set
"); + Notice("Example: config set ScriptEngine.DotNetEngine NumberOfScriptThreads 5"); + } + else + { + IConfig c; + IConfigSource source = new IniConfigSource(); + c = source.AddConfig(cmdparams[1]); + if (c != null) + { + string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3); + c.Set(cmdparams[2], _value); + Config.Merge(source); + + Notice("In section [{0}], set {1} = {2}", c.Name, cmdparams[2], _value); + } + } + break; + + case "get": + case "show": + if (cmdparams.Length == 1) + { + foreach (IConfig config in Config.Configs) + { + Notice("[{0}]", config.Name); + string[] keys = config.GetKeys(); + foreach (string key in keys) + Notice(" {0} = {1}", key, config.GetString(key)); + } + } + else if (cmdparams.Length == 2 || cmdparams.Length == 3) + { + IConfig config = Config.Configs[cmdparams[1]]; + if (config == null) + { + Notice("Section \"{0}\" does not exist.",cmdparams[1]); + break; + } + else + { + if (cmdparams.Length == 2) + { + Notice("[{0}]", config.Name); + foreach (string key in config.GetKeys()) + Notice(" {0} = {1}", key, config.GetString(key)); + } + else + { + Notice( + "config get {0} {1} : {2}", + cmdparams[1], cmdparams[2], config.GetString(cmdparams[2])); + } + } + } + else + { + Notice("Syntax: config {0} [
] []", firstParam); + Notice("Example: config {0} ScriptEngine.DotNetEngine NumberOfScriptThreads", firstParam); + } + + break; + + case "save": + if (cmdparams.Length < 2) + { + Notice("Syntax: config save "); + return; + } + + string path = cmdparams[1]; + Notice("Saving configuration file: {0}", path); + + if (Config is IniConfigSource) + { + IniConfigSource iniCon = (IniConfigSource)Config; + iniCon.Save(path); + } + else if (Config is XmlConfigSource) + { + XmlConfigSource xmlCon = (XmlConfigSource)Config; + xmlCon.Save(path); + } + + break; + } + } + } + private void HandleSetLogLevel(string module, string[] cmd) { if (cmd.Length != 4) @@ -220,9 +355,8 @@ namespace OpenSim.Framework.Servers m_consoleAppender.Threshold = consoleLevel; else Notice( - String.Format( - "{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF", - rawLevel)); + "{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF", + rawLevel); ShowLogLevel(); } -- cgit v1.1 From 3ce00e97cc6a7801738e72af8b8033fd81d09d12 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Nov 2012 05:57:20 +0000 Subject: Factor out command script code. This also allows comments in command scripts (lines starting with ;, # or //) to be used across all servers --- OpenSim/Framework/Servers/ServerBase.cs | 52 +++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 27cfc9b..c182a3a 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -201,6 +201,11 @@ namespace OpenSim.Framework.Servers "General", false, "config save", "config save ", "Save current configuration to a file at the given path", HandleConfig); + + m_console.Commands.AddCommand( + "General", false, "command-script", + "command-script