aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorBlueWall2012-10-09 06:44:14 -0400
committerBlueWall2012-10-09 06:44:14 -0400
commit252af020b05f386f88174cdd28191e0efbeba626 (patch)
treef425499b4338fa3a15f51b7621f4d37dec1d5ce7 /OpenSim/Framework
parentAdded parts to manage repositories and plugin management (diff)
parentFix build break (diff)
downloadopensim-SC_OLD-252af020b05f386f88174cdd28191e0efbeba626.zip
opensim-SC_OLD-252af020b05f386f88174cdd28191e0efbeba626.tar.gz
opensim-SC_OLD-252af020b05f386f88174cdd28191e0efbeba626.tar.bz2
opensim-SC_OLD-252af020b05f386f88174cdd28191e0efbeba626.tar.xz
Merge branch 'master' into connector_plugin
Conflicts: OpenSim/Server/ServerMain.cs
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Console/ConsoleUtil.cs114
-rw-r--r--OpenSim/Framework/GridInstantMessage.cs9
-rw-r--r--OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs13
-rw-r--r--OpenSim/Framework/Monitoring/StatsManager.cs145
-rw-r--r--OpenSim/Framework/Util.cs13
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs (renamed from OpenSim/Framework/PacketPool.cs)8
6 files changed, 293 insertions, 9 deletions
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
new file mode 100644
index 0000000..2612a50
--- /dev/null
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -0,0 +1,114 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Linq;
31using System.Reflection;
32using log4net;
33using OpenMetaverse;
34
35public class ConsoleUtil
36{
37 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
38
39 public const string MinRawConsoleVectorValue = "-~";
40 public const string MaxRawConsoleVectorValue = "~";
41
42 public const string VectorSeparator = ",";
43 public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
44
45 /// <summary>
46 /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
47 /// </summary>
48 /// <param name='rawConsoleVector'>/param>
49 /// <param name='vector'></param>
50 /// <returns></returns>
51 public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector)
52 {
53 return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector);
54 }
55
56 /// <summary>
57 /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3
58 /// </summary>
59 /// <param name='rawConsoleVector'>/param>
60 /// <param name='vector'></param>
61 /// <returns></returns>
62 public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector)
63 {
64 return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector);
65 }
66
67 /// <summary>
68 /// Convert a vector input from the console to an OpenMetaverse.Vector3
69 /// </summary>
70 /// <param name='rawConsoleVector'>
71 /// A string in the form <x>,<y>,<z> where there is no space between values.
72 /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value
73 /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40)
74 /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue
75 /// Other than that, component values must be numeric.
76 /// </param>
77 /// <param name='blankComponentFunc'></param>
78 /// <param name='vector'></param>
79 /// <returns></returns>
80 public static bool TryParseConsoleVector(
81 string rawConsoleVector, Func<string, string> blankComponentFunc, out Vector3 vector)
82 {
83 List<string> components = rawConsoleVector.Split(VectorSeparatorChars).ToList();
84
85 if (components.Count < 1 || components.Count > 3)
86 {
87 vector = Vector3.Zero;
88 return false;
89 }
90
91 for (int i = components.Count; i < 3; i++)
92 components.Add("");
93
94 List<string> semiDigestedComponents
95 = components.ConvertAll<string>(
96 c =>
97 {
98 if (c == "")
99 return blankComponentFunc.Invoke(c);
100 else if (c == MaxRawConsoleVectorValue)
101 return float.MaxValue.ToString();
102 else if (c == MinRawConsoleVectorValue)
103 return float.MinValue.ToString();
104 else
105 return c;
106 });
107
108 string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray());
109
110 m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector);
111
112 return Vector3.TryParse(semiDigestedConsoleVector, out vector);
113 }
114} \ No newline at end of file
diff --git a/OpenSim/Framework/GridInstantMessage.cs b/OpenSim/Framework/GridInstantMessage.cs
index a6bf6e3..6ae0488 100644
--- a/OpenSim/Framework/GridInstantMessage.cs
+++ b/OpenSim/Framework/GridInstantMessage.cs
@@ -44,7 +44,6 @@ namespace OpenSim.Framework
44 public Vector3 Position; 44 public Vector3 Position;
45 public byte[] binaryBucket; 45 public byte[] binaryBucket;
46 46
47
48 public uint ParentEstateID; 47 public uint ParentEstateID;
49 public Guid RegionID; 48 public Guid RegionID;
50 public uint timestamp; 49 public uint timestamp;
@@ -58,7 +57,7 @@ namespace OpenSim.Framework
58 string _fromAgentName, UUID _toAgentID, 57 string _fromAgentName, UUID _toAgentID,
59 byte _dialog, bool _fromGroup, string _message, 58 byte _dialog, bool _fromGroup, string _message,
60 UUID _imSessionID, bool _offline, Vector3 _position, 59 UUID _imSessionID, bool _offline, Vector3 _position,
61 byte[] _binaryBucket) 60 byte[] _binaryBucket, bool addTimestamp)
62 { 61 {
63 fromAgentID = _fromAgentID.Guid; 62 fromAgentID = _fromAgentID.Guid;
64 fromAgentName = _fromAgentName; 63 fromAgentName = _fromAgentName;
@@ -79,7 +78,9 @@ namespace OpenSim.Framework
79 ParentEstateID = scene.RegionInfo.EstateSettings.ParentEstateID; 78 ParentEstateID = scene.RegionInfo.EstateSettings.ParentEstateID;
80 RegionID = scene.RegionInfo.RegionSettings.RegionUUID.Guid; 79 RegionID = scene.RegionInfo.RegionSettings.RegionUUID.Guid;
81 } 80 }
82 timestamp = (uint)Util.UnixTimeSinceEpoch(); 81
82 if (addTimestamp)
83 timestamp = (uint)Util.UnixTimeSinceEpoch();
83 } 84 }
84 85
85 public GridInstantMessage(IScene scene, UUID _fromAgentID, 86 public GridInstantMessage(IScene scene, UUID _fromAgentID,
@@ -87,7 +88,7 @@ namespace OpenSim.Framework
87 string _message, bool _offline, 88 string _message, bool _offline,
88 Vector3 _position) : this(scene, _fromAgentID, _fromAgentName, 89 Vector3 _position) : this(scene, _fromAgentID, _fromAgentName,
89 _toAgentID, _dialog, false, _message, 90 _toAgentID, _dialog, false, _message,
90 _fromAgentID ^ _toAgentID, _offline, _position, new byte[0]) 91 _fromAgentID ^ _toAgentID, _offline, _position, new byte[0], true)
91 { 92 {
92 } 93 }
93 } 94 }
diff --git a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
index cdd7cc7..8ac9090 100644
--- a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
+++ b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
@@ -355,10 +355,19 @@ Asset service request failures: {3}" + Environment.NewLine,
355 sb.Append(Environment.NewLine); 355 sb.Append(Environment.NewLine);
356 sb.Append( 356 sb.Append(
357 string.Format( 357 string.Format(
358 "{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}", 358 "{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}\n\n",
359 inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime, 359 inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime,
360 netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime)); 360 netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime));
361 sb.Append(Environment.NewLine); 361
362 foreach (KeyValuePair<string, Stat> kvp in StatsManager.RegisteredStats)
363 {
364 Stat stat = kvp.Value;
365
366 if (stat.Category == "scene" && stat.Verbosity == StatVerbosity.Info)
367 {
368 sb.AppendFormat("Slow frames ({0}): {1}\n", stat.Container, stat.Value);
369 }
370 }
362 371
363 /* 372 /*
364 sb.Append(Environment.NewLine); 373 sb.Append(Environment.NewLine);
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs
index d78fa6a..b5dc24f 100644
--- a/OpenSim/Framework/Monitoring/StatsManager.cs
+++ b/OpenSim/Framework/Monitoring/StatsManager.cs
@@ -25,6 +25,9 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
29using System.Collections.Generic;
30
28namespace OpenSim.Framework.Monitoring 31namespace OpenSim.Framework.Monitoring
29{ 32{
30 /// <summary> 33 /// <summary>
@@ -32,6 +35,14 @@ namespace OpenSim.Framework.Monitoring
32 /// </summary> 35 /// </summary>
33 public class StatsManager 36 public class StatsManager
34 { 37 {
38 /// <summary>
39 /// Registered stats.
40 /// </summary>
41 /// <remarks>
42 /// Do not add or remove from this dictionary.
43 /// </remarks>
44 public static Dictionary<string, Stat> RegisteredStats = new Dictionary<string, Stat>();
45
35 private static AssetStatsCollector assetStats; 46 private static AssetStatsCollector assetStats;
36 private static UserStatsCollector userStats; 47 private static UserStatsCollector userStats;
37 private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector(); 48 private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector();
@@ -61,5 +72,139 @@ namespace OpenSim.Framework.Monitoring
61 72
62 return userStats; 73 return userStats;
63 } 74 }
75
76 public static bool RegisterStat(Stat stat)
77 {
78 lock (RegisteredStats)
79 {
80 if (RegisteredStats.ContainsKey(stat.UniqueName))
81 {
82 // XXX: For now just return false. This is to avoid problems in regression tests where all tests
83 // in a class are run in the same instance of the VM.
84 return false;
85
86// throw new Exception(
87// "StatsManager already contains stat with ShortName {0} in Category {1}", stat.ShortName, stat.Category);
88 }
89
90 // We take a replace-on-write approach here so that we don't need to generate a new Dictionary
91 Dictionary<string, Stat> newRegisteredStats = new Dictionary<string, Stat>(RegisteredStats);
92 newRegisteredStats[stat.UniqueName] = stat;
93 RegisteredStats = newRegisteredStats;
94 }
95
96 return true;
97 }
98
99 public static bool DeregisterStat(Stat stat)
100 {
101 lock (RegisteredStats)
102 {
103 if (!RegisteredStats.ContainsKey(stat.UniqueName))
104 return false;
105
106 Dictionary<string, Stat> newRegisteredStats = new Dictionary<string, Stat>(RegisteredStats);
107 newRegisteredStats.Remove(stat.UniqueName);
108 RegisteredStats = newRegisteredStats;
109
110 return true;
111 }
112 }
113 }
114
115 /// <summary>
116 /// Verbosity of stat.
117 /// </summary>
118 /// <remarks>
119 /// Info will always be displayed.
120 /// </remarks>
121 public enum StatVerbosity
122 {
123 Debug,
124 Info
125 }
126
127 /// <summary>
128 /// Holds individual static details
129 /// </summary>
130 public class Stat
131 {
132 /// <summary>
133 /// Unique stat name used for indexing. Each ShortName in a Category must be unique.
134 /// </summary>
135 public string UniqueName { get; private set; }
136
137 /// <summary>
138 /// Category of this stat (e.g. cache, scene, etc).
139 /// </summary>
140 public string Category { get; private set; }
141
142 /// <summary>
143 /// Containing name for this stat.
144 /// FIXME: In the case of a scene, this is currently the scene name (though this leaves
145 /// us with a to-be-resolved problem of non-unique region names).
146 /// </summary>
147 /// <value>
148 /// The container.
149 /// </value>
150 public string Container { get; private set; }
151
152 public StatVerbosity Verbosity { get; private set; }
153 public string ShortName { get; private set; }
154 public string Name { get; private set; }
155 public string Description { get; private set; }
156 public virtual string UnitName { get; private set; }
157
158 public virtual double Value { get; set; }
159
160 public Stat(
161 string shortName, string name, string unitName, string category, string container, StatVerbosity verbosity, string description)
162 {
163 ShortName = shortName;
164 Name = name;
165 UnitName = unitName;
166 Category = category;
167 Container = container;
168 Verbosity = verbosity;
169 Description = description;
170
171 UniqueName = GenUniqueName(Container, Category, ShortName);
172 }
173
174 public static string GenUniqueName(string container, string category, string shortName)
175 {
176 return string.Format("{0}+{1}+{2}", container, category, shortName);
177 }
178 }
179
180 public class PercentageStat : Stat
181 {
182 public int Antecedent { get; set; }
183 public int Consequent { get; set; }
184
185 public override double Value
186 {
187 get
188 {
189 int c = Consequent;
190
191 // Avoid any chance of a multi-threaded divide-by-zero
192 if (c == 0)
193 return 0;
194
195 return (double)Antecedent / c;
196 }
197
198 set
199 {
200 throw new Exception("Cannot set value on a PercentageStat");
201 }
202 }
203
204 public PercentageStat(
205 string shortName, string name, string category, string container, StatVerbosity verbosity, string description)
206 : base(shortName, name, " %", category, container, verbosity, description)
207 {
208 }
64 } 209 }
65} \ No newline at end of file 210} \ No newline at end of file
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 1b9777f..5c7797a 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -534,6 +534,19 @@ namespace OpenSim.Framework
534 } 534 }
535 535
536 /// <summary> 536 /// <summary>
537 /// Determines whether a point is inside a bounding box.
538 /// </summary>
539 /// <param name='v'>/param>
540 /// <param name='min'></param>
541 /// <param name='max'></param>
542 /// <returns></returns>
543 public static bool IsInsideBox(Vector3 v, Vector3 min, Vector3 max)
544 {
545 return v.X >= min.X & v.Y >= min.Y && v.Z >= min.Z
546 && v.X <= max.X && v.Y <= max.Y && v.Z <= max.Z;
547 }
548
549 /// <summary>
537 /// Are the co-ordinates of the new region visible from the old region? 550 /// Are the co-ordinates of the new region visible from the old region?
538 /// </summary> 551 /// </summary>
539 /// <param name="oldx">Old region x-coord</param> 552 /// <param name="oldx">Old region x-coord</param>
diff --git a/OpenSim/Framework/PacketPool.cs b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs
index 41d17c5..fc9406b 100644
--- a/OpenSim/Framework/PacketPool.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs
@@ -32,9 +32,8 @@ using OpenMetaverse;
32using OpenMetaverse.Packets; 32using OpenMetaverse.Packets;
33using log4net; 33using log4net;
34 34
35namespace OpenSim.Framework 35namespace OpenSim.Region.ClientStack.LindenUDP
36{ 36{
37
38 public sealed class PacketPool 37 public sealed class PacketPool
39 { 38 {
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 39 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -44,6 +43,9 @@ namespace OpenSim.Framework
44 private bool packetPoolEnabled = true; 43 private bool packetPoolEnabled = true;
45 private bool dataBlockPoolEnabled = true; 44 private bool dataBlockPoolEnabled = true;
46 45
46 /// <summary>
47 /// Pool of packets available for reuse.
48 /// </summary>
47 private readonly Dictionary<PacketType, Stack<Packet>> pool = new Dictionary<PacketType, Stack<Packet>>(); 49 private readonly Dictionary<PacketType, Stack<Packet>> pool = new Dictionary<PacketType, Stack<Packet>>();
48 50
49 private static Dictionary<Type, Stack<Object>> DataBlocks = 51 private static Dictionary<Type, Stack<Object>> DataBlocks =
@@ -244,4 +246,4 @@ namespace OpenSim.Framework
244 } 246 }
245 } 247 }
246 } 248 }
247} 249} \ No newline at end of file