diff options
Diffstat (limited to 'OpenSim/Framework')
43 files changed, 1602 insertions, 408 deletions
diff --git a/OpenSim/Framework/Animation.cs b/OpenSim/Framework/Animation.cs index 232f5a1..3425505 100644 --- a/OpenSim/Framework/Animation.cs +++ b/OpenSim/Framework/Animation.cs | |||
@@ -120,5 +120,24 @@ namespace OpenSim.Framework | |||
120 | sequenceNum = args["seq_num"].AsInteger(); | 120 | sequenceNum = args["seq_num"].AsInteger(); |
121 | } | 121 | } |
122 | 122 | ||
123 | public override bool Equals(object obj) | ||
124 | { | ||
125 | Animation other = obj as Animation; | ||
126 | if (other != null) | ||
127 | { | ||
128 | return (other.AnimID.Equals(this.AnimID) | ||
129 | && other.SequenceNum == this.SequenceNum | ||
130 | && other.ObjectID.Equals(this.ObjectID) ); | ||
131 | } | ||
132 | return base.Equals(obj); | ||
133 | } | ||
134 | |||
135 | public override string ToString() | ||
136 | { | ||
137 | return "AnimID=" + AnimID.ToString() | ||
138 | + "/seq=" + SequenceNum.ToString() | ||
139 | + "/objID=" + ObjectID.ToString(); | ||
140 | } | ||
141 | |||
123 | } | 142 | } |
124 | } | 143 | } |
diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs index 3658161..3e90fac 100644 --- a/OpenSim/Framework/BlockingQueue.cs +++ b/OpenSim/Framework/BlockingQueue.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Framework | |||
58 | { | 58 | { |
59 | lock (m_queueSync) | 59 | lock (m_queueSync) |
60 | { | 60 | { |
61 | if (m_queue.Count < 1 && m_pqueue.Count < 1) | 61 | while (m_queue.Count < 1 && m_pqueue.Count < 1) |
62 | { | 62 | { |
63 | Monitor.Wait(m_queueSync); | 63 | Monitor.Wait(m_queueSync); |
64 | } | 64 | } |
@@ -76,9 +76,10 @@ namespace OpenSim.Framework | |||
76 | { | 76 | { |
77 | lock (m_queueSync) | 77 | lock (m_queueSync) |
78 | { | 78 | { |
79 | if (m_queue.Count < 1 && m_pqueue.Count < 1) | 79 | bool success = true; |
80 | while (m_queue.Count < 1 && m_pqueue.Count < 1 && success) | ||
80 | { | 81 | { |
81 | Monitor.Wait(m_queueSync, msTimeout); | 82 | success = Monitor.Wait(m_queueSync, msTimeout); |
82 | } | 83 | } |
83 | 84 | ||
84 | if (m_pqueue.Count > 0) | 85 | if (m_pqueue.Count > 0) |
@@ -89,8 +90,17 @@ namespace OpenSim.Framework | |||
89 | } | 90 | } |
90 | } | 91 | } |
91 | 92 | ||
93 | /// <summary> | ||
94 | /// Indicate whether this queue contains the given item. | ||
95 | /// </summary> | ||
96 | /// <remarks> | ||
97 | /// This method is not thread-safe. Do not rely on the result without consistent external locking. | ||
98 | /// </remarks> | ||
92 | public bool Contains(T item) | 99 | public bool Contains(T item) |
93 | { | 100 | { |
101 | if (m_queue.Count < 1 && m_pqueue.Count < 1) | ||
102 | return false; | ||
103 | |||
94 | lock (m_queueSync) | 104 | lock (m_queueSync) |
95 | { | 105 | { |
96 | if (m_pqueue.Contains(item)) | 106 | if (m_pqueue.Contains(item)) |
@@ -99,16 +109,28 @@ namespace OpenSim.Framework | |||
99 | } | 109 | } |
100 | } | 110 | } |
101 | 111 | ||
112 | /// <summary> | ||
113 | /// Return a count of the number of requests on this queue. | ||
114 | /// </summary> | ||
115 | /// <remarks> | ||
116 | /// This method is not thread-safe. Do not rely on the result without consistent external locking. | ||
117 | /// </remarks> | ||
102 | public int Count() | 118 | public int Count() |
103 | { | 119 | { |
104 | lock (m_queueSync) | 120 | return m_queue.Count + m_pqueue.Count; |
105 | { | ||
106 | return m_queue.Count+m_pqueue.Count; | ||
107 | } | ||
108 | } | 121 | } |
109 | 122 | ||
123 | /// <summary> | ||
124 | /// Return the array of items on this queue. | ||
125 | /// </summary> | ||
126 | /// <remarks> | ||
127 | /// This method is not thread-safe. Do not rely on the result without consistent external locking. | ||
128 | /// </remarks> | ||
110 | public T[] GetQueueArray() | 129 | public T[] GetQueueArray() |
111 | { | 130 | { |
131 | if (m_queue.Count < 1 && m_pqueue.Count < 1) | ||
132 | return new T[0]; | ||
133 | |||
112 | lock (m_queueSync) | 134 | lock (m_queueSync) |
113 | { | 135 | { |
114 | return m_queue.ToArray(); | 136 | return m_queue.ToArray(); |
diff --git a/OpenSim/Framework/CachedTextureEventArg.cs b/OpenSim/Framework/CachedTextureEventArg.cs new file mode 100644 index 0000000..239fc56 --- /dev/null +++ b/OpenSim/Framework/CachedTextureEventArg.cs | |||
@@ -0,0 +1,46 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Text; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Framework | ||
33 | { | ||
34 | public class CachedTextureRequestArg | ||
35 | { | ||
36 | public int BakedTextureIndex; | ||
37 | public UUID WearableHashID; | ||
38 | } | ||
39 | |||
40 | public class CachedTextureResponseArg | ||
41 | { | ||
42 | public int BakedTextureIndex; | ||
43 | public UUID BakedTextureID; | ||
44 | public String HostName; | ||
45 | } | ||
46 | } | ||
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index 8c32734..4962629 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs | |||
@@ -171,9 +171,10 @@ namespace OpenSim.Framework | |||
171 | /// Soon to be decommissioned | 171 | /// Soon to be decommissioned |
172 | /// </summary> | 172 | /// </summary> |
173 | /// <param name="cAgent"></param> | 173 | /// <param name="cAgent"></param> |
174 | public void CopyFrom(ChildAgentDataUpdate cAgent) | 174 | public void CopyFrom(ChildAgentDataUpdate cAgent, UUID sid) |
175 | { | 175 | { |
176 | AgentID = new UUID(cAgent.AgentID); | 176 | AgentID = new UUID(cAgent.AgentID); |
177 | SessionID = sid; | ||
177 | 178 | ||
178 | // next: ??? | 179 | // next: ??? |
179 | Size = new Vector3(); | 180 | Size = new Vector3(); |
@@ -291,7 +292,7 @@ namespace OpenSim.Framework | |||
291 | public Vector3 AtAxis; | 292 | public Vector3 AtAxis; |
292 | public Vector3 LeftAxis; | 293 | public Vector3 LeftAxis; |
293 | public Vector3 UpAxis; | 294 | public Vector3 UpAxis; |
294 | public bool ChangedGrid; | 295 | public bool SenderWantsToWaitForRoot; |
295 | 296 | ||
296 | public float Far; | 297 | public float Far; |
297 | public float Aspect; | 298 | public float Aspect; |
@@ -362,8 +363,9 @@ namespace OpenSim.Framework | |||
362 | args["left_axis"] = OSD.FromString(LeftAxis.ToString()); | 363 | args["left_axis"] = OSD.FromString(LeftAxis.ToString()); |
363 | args["up_axis"] = OSD.FromString(UpAxis.ToString()); | 364 | args["up_axis"] = OSD.FromString(UpAxis.ToString()); |
364 | 365 | ||
365 | 366 | //backwards compatibility | |
366 | args["changed_grid"] = OSD.FromBoolean(ChangedGrid); | 367 | args["changed_grid"] = OSD.FromBoolean(SenderWantsToWaitForRoot); |
368 | args["wait_for_root"] = OSD.FromBoolean(SenderWantsToWaitForRoot); | ||
367 | args["far"] = OSD.FromReal(Far); | 369 | args["far"] = OSD.FromReal(Far); |
368 | args["aspect"] = OSD.FromReal(Aspect); | 370 | args["aspect"] = OSD.FromReal(Aspect); |
369 | 371 | ||
@@ -536,8 +538,8 @@ namespace OpenSim.Framework | |||
536 | if (args["up_axis"] != null) | 538 | if (args["up_axis"] != null) |
537 | Vector3.TryParse(args["up_axis"].AsString(), out AtAxis); | 539 | Vector3.TryParse(args["up_axis"].AsString(), out AtAxis); |
538 | 540 | ||
539 | if (args["changed_grid"] != null) | 541 | if (args.ContainsKey("wait_for_root") && args["wait_for_root"] != null) |
540 | ChangedGrid = args["changed_grid"].AsBoolean(); | 542 | SenderWantsToWaitForRoot = args["wait_for_root"].AsBoolean(); |
541 | 543 | ||
542 | if (args["far"] != null) | 544 | if (args["far"] != null) |
543 | Far = (float)(args["far"].AsReal()); | 545 | Far = (float)(args["far"].AsReal()); |
diff --git a/OpenSim/Framework/ClientInfo.cs b/OpenSim/Framework/ClientInfo.cs index 62acb70..9021315 100644 --- a/OpenSim/Framework/ClientInfo.cs +++ b/OpenSim/Framework/ClientInfo.cs | |||
@@ -33,12 +33,13 @@ namespace OpenSim.Framework | |||
33 | { | 33 | { |
34 | public class ClientInfo | 34 | public class ClientInfo |
35 | { | 35 | { |
36 | public AgentCircuitData agentcircuit; | 36 | public readonly DateTime StartedTime = DateTime.Now; |
37 | public AgentCircuitData agentcircuit = null; | ||
37 | 38 | ||
38 | public Dictionary<uint, byte[]> needAck; | 39 | public Dictionary<uint, byte[]> needAck; |
39 | 40 | ||
40 | public List<byte[]> out_packets; | 41 | public List<byte[]> out_packets = new List<byte[]>(); |
41 | public Dictionary<uint, uint> pendingAcks; | 42 | public Dictionary<uint, uint> pendingAcks = new Dictionary<uint,uint>(); |
42 | public EndPoint proxyEP; | 43 | public EndPoint proxyEP; |
43 | 44 | ||
44 | public uint sequence; | 45 | public uint sequence; |
@@ -53,5 +54,9 @@ namespace OpenSim.Framework | |||
53 | public int assetThrottle; | 54 | public int assetThrottle; |
54 | public int textureThrottle; | 55 | public int textureThrottle; |
55 | public int totalThrottle; | 56 | public int totalThrottle; |
57 | |||
58 | public Dictionary<string, int> SyncRequests = new Dictionary<string,int>(); | ||
59 | public Dictionary<string, int> AsyncRequests = new Dictionary<string,int>(); | ||
60 | public Dictionary<string, int> GenericRequests = new Dictionary<string,int>(); | ||
56 | } | 61 | } |
57 | } | 62 | } |
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index d41481f..a967db6 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs | |||
@@ -426,6 +426,21 @@ namespace OpenSim.Framework.Console | |||
426 | System.Console.Write("{0}", prompt); | 426 | System.Console.Write("{0}", prompt); |
427 | 427 | ||
428 | break; | 428 | break; |
429 | case ConsoleKey.Delete: | ||
430 | if (m_cursorXPosition == m_commandLine.Length) | ||
431 | break; | ||
432 | |||
433 | m_commandLine.Remove(m_cursorXPosition, 1); | ||
434 | |||
435 | SetCursorLeft(0); | ||
436 | m_cursorYPosition = SetCursorTop(m_cursorYPosition); | ||
437 | |||
438 | if (m_echo) | ||
439 | System.Console.Write("{0}{1} ", prompt, m_commandLine); | ||
440 | else | ||
441 | System.Console.Write("{0}", prompt); | ||
442 | |||
443 | break; | ||
429 | case ConsoleKey.End: | 444 | case ConsoleKey.End: |
430 | m_cursorXPosition = m_commandLine.Length; | 445 | m_cursorXPosition = m_commandLine.Length; |
431 | break; | 446 | break; |
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 3e3c2b3..8ad7b0d 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -234,7 +234,7 @@ namespace OpenSim.Framework.Console | |||
234 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; | 234 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; |
235 | 235 | ||
236 | m_Server.AddPollServiceHTTPHandler( | 236 | m_Server.AddPollServiceHTTPHandler( |
237 | uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout | 237 | uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout |
238 | 238 | ||
239 | XmlDocument xmldoc = new XmlDocument(); | 239 | XmlDocument xmldoc = new XmlDocument(); |
240 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, | 240 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, |
diff --git a/OpenSim/Framework/DAMap.cs b/OpenSim/Framework/DAMap.cs index df4a6bc..4995a92 100644 --- a/OpenSim/Framework/DAMap.cs +++ b/OpenSim/Framework/DAMap.cs | |||
@@ -29,10 +29,12 @@ using System; | |||
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Reflection; | ||
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Xml; | 34 | using System.Xml; |
34 | using System.Xml.Schema; | 35 | using System.Xml.Schema; |
35 | using System.Xml.Serialization; | 36 | using System.Xml.Serialization; |
37 | using log4net; | ||
36 | using OpenMetaverse; | 38 | using OpenMetaverse; |
37 | using OpenMetaverse.StructuredData; | 39 | using OpenMetaverse.StructuredData; |
38 | 40 | ||
@@ -48,13 +50,20 @@ namespace OpenSim.Framework | |||
48 | /// within their data store. However, avoid storing large amounts of data because that | 50 | /// within their data store. However, avoid storing large amounts of data because that |
49 | /// would slow down database access. | 51 | /// would slow down database access. |
50 | /// </remarks> | 52 | /// </remarks> |
51 | public class DAMap : IDictionary<string, OSDMap>, IXmlSerializable | 53 | public class DAMap : IXmlSerializable |
52 | { | 54 | { |
53 | private static readonly int MIN_STORE_NAME_LENGTH = 4; | 55 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
54 | 56 | ||
55 | protected OSDMap m_map; | 57 | private static readonly int MIN_NAMESPACE_LENGTH = 4; |
56 | 58 | ||
57 | public DAMap() { m_map = new OSDMap(); } | 59 | private OSDMap m_map = new OSDMap(); |
60 | |||
61 | // WARNING: this is temporary for experimentation only, it will be removed!!!! | ||
62 | public OSDMap TopLevelMap | ||
63 | { | ||
64 | get { return m_map; } | ||
65 | set { m_map = value; } | ||
66 | } | ||
58 | 67 | ||
59 | public XmlSchema GetSchema() { return null; } | 68 | public XmlSchema GetSchema() { return null; } |
60 | 69 | ||
@@ -64,39 +73,34 @@ namespace OpenSim.Framework | |||
64 | map.ReadXml(rawXml); | 73 | map.ReadXml(rawXml); |
65 | return map; | 74 | return map; |
66 | } | 75 | } |
67 | 76 | ||
77 | public void ReadXml(XmlReader reader) | ||
78 | { | ||
79 | ReadXml(reader.ReadInnerXml()); | ||
80 | } | ||
81 | |||
68 | public void ReadXml(string rawXml) | 82 | public void ReadXml(string rawXml) |
69 | { | 83 | { |
70 | // System.Console.WriteLine("Trying to deserialize [{0}]", rawXml); | 84 | // System.Console.WriteLine("Trying to deserialize [{0}]", rawXml); |
71 | 85 | ||
72 | lock (this) | 86 | lock (this) |
87 | { | ||
73 | m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml); | 88 | m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml); |
89 | SanitiseMap(this); | ||
90 | } | ||
74 | } | 91 | } |
75 | 92 | ||
76 | // WARNING: this is temporary for experimentation only, it will be removed!!!! | 93 | public void WriteXml(XmlWriter writer) |
77 | public OSDMap TopLevelMap | ||
78 | { | 94 | { |
79 | get { return m_map; } | 95 | writer.WriteRaw(ToXml()); |
80 | set { m_map = value; } | ||
81 | } | 96 | } |
82 | |||
83 | 97 | ||
84 | public void ReadXml(XmlReader reader) | ||
85 | { | ||
86 | ReadXml(reader.ReadInnerXml()); | ||
87 | } | ||
88 | |||
89 | public string ToXml() | 98 | public string ToXml() |
90 | { | 99 | { |
91 | lock (this) | 100 | lock (this) |
92 | return OSDParser.SerializeLLSDXmlString(m_map); | 101 | return OSDParser.SerializeLLSDXmlString(m_map); |
93 | } | 102 | } |
94 | 103 | ||
95 | public void WriteXml(XmlWriter writer) | ||
96 | { | ||
97 | writer.WriteRaw(ToXml()); | ||
98 | } | ||
99 | |||
100 | public void CopyFrom(DAMap other) | 104 | public void CopyFrom(DAMap other) |
101 | { | 105 | { |
102 | // Deep copy | 106 | // Deep copy |
@@ -104,7 +108,7 @@ namespace OpenSim.Framework | |||
104 | string data = null; | 108 | string data = null; |
105 | lock (other) | 109 | lock (other) |
106 | { | 110 | { |
107 | if (other.Count > 0) | 111 | if (other.CountNamespaces > 0) |
108 | { | 112 | { |
109 | data = OSDParser.SerializeLLSDXmlString(other.m_map); | 113 | data = OSDParser.SerializeLLSDXmlString(other.m_map); |
110 | } | 114 | } |
@@ -120,59 +124,132 @@ namespace OpenSim.Framework | |||
120 | } | 124 | } |
121 | 125 | ||
122 | /// <summary> | 126 | /// <summary> |
123 | /// Returns the number of data stores. | 127 | /// Sanitise the map to remove any namespaces or stores that are not OSDMap. |
124 | /// </summary> | 128 | /// </summary> |
125 | public int Count { get { lock (this) { return m_map.Count; } } } | 129 | /// <param name='map'> |
126 | 130 | /// </param> | |
127 | public bool IsReadOnly { get { return false; } } | 131 | public static void SanitiseMap(DAMap daMap) |
128 | 132 | { | |
133 | List<string> keysToRemove = null; | ||
134 | |||
135 | OSDMap namespacesMap = daMap.m_map; | ||
136 | |||
137 | foreach (string key in namespacesMap.Keys) | ||
138 | { | ||
139 | // Console.WriteLine("Processing ns {0}", key); | ||
140 | if (!(namespacesMap[key] is OSDMap)) | ||
141 | { | ||
142 | if (keysToRemove == null) | ||
143 | keysToRemove = new List<string>(); | ||
144 | |||
145 | keysToRemove.Add(key); | ||
146 | } | ||
147 | } | ||
148 | |||
149 | if (keysToRemove != null) | ||
150 | { | ||
151 | foreach (string key in keysToRemove) | ||
152 | { | ||
153 | // Console.WriteLine ("Removing bad ns {0}", key); | ||
154 | namespacesMap.Remove(key); | ||
155 | } | ||
156 | } | ||
157 | |||
158 | foreach (OSD nsOsd in namespacesMap.Values) | ||
159 | { | ||
160 | OSDMap nsOsdMap = (OSDMap)nsOsd; | ||
161 | keysToRemove = null; | ||
162 | |||
163 | foreach (string key in nsOsdMap.Keys) | ||
164 | { | ||
165 | if (!(nsOsdMap[key] is OSDMap)) | ||
166 | { | ||
167 | if (keysToRemove == null) | ||
168 | keysToRemove = new List<string>(); | ||
169 | |||
170 | keysToRemove.Add(key); | ||
171 | } | ||
172 | } | ||
173 | |||
174 | if (keysToRemove != null) | ||
175 | foreach (string key in keysToRemove) | ||
176 | nsOsdMap.Remove(key); | ||
177 | } | ||
178 | } | ||
179 | |||
129 | /// <summary> | 180 | /// <summary> |
130 | /// Returns the names of the data stores. | 181 | /// Get the number of namespaces |
131 | /// </summary> | 182 | /// </summary> |
132 | public ICollection<string> Keys { get { lock (this) { return m_map.Keys; } } } | 183 | public int CountNamespaces { get { lock (this) { return m_map.Count; } } } |
133 | 184 | ||
134 | /// <summary> | 185 | /// <summary> |
135 | /// Returns all the data stores. | 186 | /// Get the number of stores. |
136 | /// </summary> | 187 | /// </summary> |
137 | public ICollection<OSDMap> Values | 188 | public int CountStores |
138 | { | 189 | { |
139 | get | 190 | get |
140 | { | 191 | { |
192 | int count = 0; | ||
193 | |||
141 | lock (this) | 194 | lock (this) |
142 | { | 195 | { |
143 | List<OSDMap> stores = new List<OSDMap>(m_map.Count); | 196 | foreach (OSD osdNamespace in m_map) |
144 | foreach (OSD llsd in m_map.Values) | 197 | { |
145 | stores.Add((OSDMap)llsd); | 198 | count += ((OSDMap)osdNamespace).Count; |
146 | return stores; | 199 | } |
147 | } | 200 | } |
201 | |||
202 | return count; | ||
148 | } | 203 | } |
149 | } | 204 | } |
150 | 205 | ||
151 | /// <summary> | 206 | /// <summary> |
152 | /// Gets or sets one data store. | 207 | /// Retrieve a Dynamic Attribute store |
153 | /// </summary> | 208 | /// </summary> |
154 | /// <param name="key">Store name</param> | 209 | /// <param name="ns">namespace for the store - use "OpenSim" for in-core modules</param> |
155 | /// <returns></returns> | 210 | /// <param name="storeName">name of the store within the namespace</param> |
156 | public OSDMap this[string key] | 211 | /// <returns>an OSDMap representing the stored data, or null if not found</returns> |
157 | { | 212 | public OSDMap GetStore(string ns, string storeName) |
158 | get | 213 | { |
159 | { | 214 | OSD namespaceOsd; |
160 | OSD llsd; | 215 | |
161 | 216 | lock (this) | |
162 | lock (this) | 217 | { |
218 | if (m_map.TryGetValue(ns, out namespaceOsd)) | ||
163 | { | 219 | { |
164 | if (m_map.TryGetValue(key, out llsd)) | 220 | OSD store; |
165 | return (OSDMap)llsd; | 221 | |
166 | else | 222 | if (((OSDMap)namespaceOsd).TryGetValue(storeName, out store)) |
167 | return null; | 223 | return (OSDMap)store; |
168 | } | 224 | } |
169 | } | 225 | } |
170 | 226 | ||
171 | set | 227 | return null; |
228 | } | ||
229 | |||
230 | /// <summary> | ||
231 | /// Saves a Dynamic attribute store | ||
232 | /// </summary> | ||
233 | /// <param name="ns">namespace for the store - use "OpenSim" for in-core modules</param> | ||
234 | /// <param name="storeName">name of the store within the namespace</param> | ||
235 | /// <param name="store">an OSDMap representing the data to store</param> | ||
236 | public void SetStore(string ns, string storeName, OSDMap store) | ||
237 | { | ||
238 | ValidateNamespace(ns); | ||
239 | OSDMap nsMap; | ||
240 | |||
241 | lock (this) | ||
172 | { | 242 | { |
173 | ValidateKey(key); | 243 | if (!m_map.ContainsKey(ns)) |
174 | lock (this) | 244 | { |
175 | m_map[key] = value; | 245 | nsMap = new OSDMap(); |
246 | m_map[ns] = nsMap; | ||
247 | } | ||
248 | |||
249 | nsMap = (OSDMap)m_map[ns]; | ||
250 | |||
251 | // m_log.DebugFormat("[DA MAP]: Setting store to {0}:{1}", ns, storeName); | ||
252 | nsMap[storeName] = store; | ||
176 | } | 253 | } |
177 | } | 254 | } |
178 | 255 | ||
@@ -180,54 +257,46 @@ namespace OpenSim.Framework | |||
180 | /// Validate the key used for storing separate data stores. | 257 | /// Validate the key used for storing separate data stores. |
181 | /// </summary> | 258 | /// </summary> |
182 | /// <param name='key'></param> | 259 | /// <param name='key'></param> |
183 | public static void ValidateKey(string key) | 260 | public static void ValidateNamespace(string ns) |
184 | { | 261 | { |
185 | if (key.Length < MIN_STORE_NAME_LENGTH) | 262 | if (ns.Length < MIN_NAMESPACE_LENGTH) |
186 | throw new Exception("Minimum store name length is " + MIN_STORE_NAME_LENGTH); | 263 | throw new Exception("Minimum namespace length is " + MIN_NAMESPACE_LENGTH); |
187 | } | 264 | } |
188 | 265 | ||
189 | public bool ContainsKey(string key) | 266 | public bool ContainsStore(string ns, string storeName) |
190 | { | 267 | { |
191 | lock (this) | 268 | OSD namespaceOsd; |
192 | return m_map.ContainsKey(key); | ||
193 | } | ||
194 | 269 | ||
195 | public void Add(string key, OSDMap store) | ||
196 | { | ||
197 | ValidateKey(key); | ||
198 | lock (this) | ||
199 | m_map.Add(key, store); | ||
200 | } | ||
201 | |||
202 | public void Add(KeyValuePair<string, OSDMap> kvp) | ||
203 | { | ||
204 | ValidateKey(kvp.Key); | ||
205 | lock (this) | 270 | lock (this) |
206 | m_map.Add(kvp.Key, kvp.Value); | 271 | { |
207 | } | 272 | if (m_map.TryGetValue(ns, out namespaceOsd)) |
273 | { | ||
274 | return ((OSDMap)namespaceOsd).ContainsKey(storeName); | ||
275 | } | ||
276 | } | ||
208 | 277 | ||
209 | public bool Remove(string key) | 278 | return false; |
210 | { | 279 | } |
211 | lock (this) | ||
212 | return m_map.Remove(key); | ||
213 | } | ||
214 | 280 | ||
215 | public bool TryGetValue(string key, out OSDMap store) | 281 | public bool TryGetStore(string ns, string storeName, out OSDMap store) |
216 | { | 282 | { |
283 | OSD namespaceOsd; | ||
284 | |||
217 | lock (this) | 285 | lock (this) |
218 | { | 286 | { |
219 | OSD llsd; | 287 | if (m_map.TryGetValue(ns, out namespaceOsd)) |
220 | if (m_map.TryGetValue(key, out llsd)) | ||
221 | { | ||
222 | store = (OSDMap)llsd; | ||
223 | return true; | ||
224 | } | ||
225 | else | ||
226 | { | 288 | { |
227 | store = null; | 289 | OSD storeOsd; |
228 | return false; | 290 | |
291 | bool result = ((OSDMap)namespaceOsd).TryGetValue(storeName, out storeOsd); | ||
292 | store = (OSDMap)storeOsd; | ||
293 | |||
294 | return result; | ||
229 | } | 295 | } |
230 | } | 296 | } |
297 | |||
298 | store = null; | ||
299 | return false; | ||
231 | } | 300 | } |
232 | 301 | ||
233 | public void Clear() | 302 | public void Clear() |
@@ -235,39 +304,25 @@ namespace OpenSim.Framework | |||
235 | lock (this) | 304 | lock (this) |
236 | m_map.Clear(); | 305 | m_map.Clear(); |
237 | } | 306 | } |
238 | |||
239 | public bool Contains(KeyValuePair<string, OSDMap> kvp) | ||
240 | { | ||
241 | lock (this) | ||
242 | return m_map.ContainsKey(kvp.Key); | ||
243 | } | ||
244 | |||
245 | public void CopyTo(KeyValuePair<string, OSDMap>[] array, int index) | ||
246 | { | ||
247 | throw new NotImplementedException(); | ||
248 | } | ||
249 | 307 | ||
250 | public bool Remove(KeyValuePair<string, OSDMap> kvp) | 308 | public bool RemoveStore(string ns, string storeName) |
251 | { | 309 | { |
252 | lock (this) | 310 | OSD namespaceOsd; |
253 | return m_map.Remove(kvp.Key); | ||
254 | } | ||
255 | 311 | ||
256 | public System.Collections.IDictionaryEnumerator GetEnumerator() | ||
257 | { | ||
258 | lock (this) | 312 | lock (this) |
259 | return m_map.GetEnumerator(); | 313 | { |
260 | } | 314 | if (m_map.TryGetValue(ns, out namespaceOsd)) |
315 | { | ||
316 | OSDMap namespaceOsdMap = (OSDMap)namespaceOsd; | ||
317 | namespaceOsdMap.Remove(storeName); | ||
261 | 318 | ||
262 | IEnumerator<KeyValuePair<string, OSDMap>> IEnumerable<KeyValuePair<string, OSDMap>>.GetEnumerator() | 319 | // Don't keep empty namespaces around |
263 | { | 320 | if (namespaceOsdMap.Count <= 0) |
264 | return null; | 321 | m_map.Remove(ns); |
265 | } | 322 | } |
323 | } | ||
266 | 324 | ||
267 | IEnumerator IEnumerable.GetEnumerator() | 325 | return false; |
268 | { | 326 | } |
269 | lock (this) | ||
270 | return m_map.GetEnumerator(); | ||
271 | } | ||
272 | } | 327 | } |
273 | } \ No newline at end of file | 328 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/DOMap.cs b/OpenSim/Framework/DOMap.cs index 755e129..f5b650b 100644 --- a/OpenSim/Framework/DOMap.cs +++ b/OpenSim/Framework/DOMap.cs | |||
@@ -42,22 +42,22 @@ namespace OpenSim.Framework | |||
42 | /// This class stores and retrieves dynamic objects. | 42 | /// This class stores and retrieves dynamic objects. |
43 | /// </summary> | 43 | /// </summary> |
44 | /// <remarks> | 44 | /// <remarks> |
45 | /// Experimental - DO NOT USE. | 45 | /// Experimental - DO NOT USE. Does not yet have namespace support. |
46 | /// </remarks> | 46 | /// </remarks> |
47 | public class DOMap | 47 | public class DOMap |
48 | { | 48 | { |
49 | private IDictionary<string, object> m_map; | 49 | private IDictionary<string, object> m_map; |
50 | 50 | ||
51 | public void Add(string key, object dynObj) | 51 | public void Add(string ns, string objName, object dynObj) |
52 | { | 52 | { |
53 | DAMap.ValidateKey(key); | 53 | DAMap.ValidateNamespace(ns); |
54 | 54 | ||
55 | lock (this) | 55 | lock (this) |
56 | { | 56 | { |
57 | if (m_map == null) | 57 | if (m_map == null) |
58 | m_map = new Dictionary<string, object>(); | 58 | m_map = new Dictionary<string, object>(); |
59 | 59 | ||
60 | m_map.Add(key, dynObj); | 60 | m_map.Add(objName, dynObj); |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index e03750b..5ddbd61 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs | |||
@@ -430,6 +430,5 @@ namespace OpenSim.Framework | |||
430 | { | 430 | { |
431 | return l_EstateGroups.Contains(groupID); | 431 | return l_EstateGroups.Contains(groupID); |
432 | } | 432 | } |
433 | |||
434 | } | 433 | } |
435 | } | 434 | } |
diff --git a/OpenSim/Framework/GridInstantMessage.cs b/OpenSim/Framework/GridInstantMessage.cs index 6ae0488..da3690c 100644 --- a/OpenSim/Framework/GridInstantMessage.cs +++ b/OpenSim/Framework/GridInstantMessage.cs | |||
@@ -53,6 +53,24 @@ namespace OpenSim.Framework | |||
53 | binaryBucket = new byte[0]; | 53 | binaryBucket = new byte[0]; |
54 | } | 54 | } |
55 | 55 | ||
56 | public GridInstantMessage(GridInstantMessage im, bool addTimestamp) | ||
57 | { | ||
58 | fromAgentID = im.fromAgentID; | ||
59 | fromAgentName = im.fromAgentName; | ||
60 | toAgentID = im.toAgentID; | ||
61 | dialog = im.dialog; | ||
62 | fromGroup = im.fromGroup; | ||
63 | message = im.message; | ||
64 | imSessionID = im.imSessionID; | ||
65 | offline = im.offline; | ||
66 | Position = im.Position; | ||
67 | binaryBucket = im.binaryBucket; | ||
68 | RegionID = im.RegionID; | ||
69 | |||
70 | if (addTimestamp) | ||
71 | timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
72 | } | ||
73 | |||
56 | public GridInstantMessage(IScene scene, UUID _fromAgentID, | 74 | public GridInstantMessage(IScene scene, UUID _fromAgentID, |
57 | string _fromAgentName, UUID _toAgentID, | 75 | string _fromAgentName, UUID _toAgentID, |
58 | byte _dialog, bool _fromGroup, string _message, | 76 | byte _dialog, bool _fromGroup, string _message, |
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index ad3471a..22cc79d 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs | |||
@@ -65,6 +65,7 @@ namespace OpenSim.Framework | |||
65 | public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); | 65 | public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); |
66 | 66 | ||
67 | public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 AvSize, WearableCacheItem[] CacheItems); | 67 | public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 AvSize, WearableCacheItem[] CacheItems); |
68 | public delegate void CachedTextureRequest(IClientAPI remoteClient, int serial, List<CachedTextureRequestArg> cachedTextureRequest); | ||
68 | 69 | ||
69 | public delegate void StartAnim(IClientAPI remoteClient, UUID animID); | 70 | public delegate void StartAnim(IClientAPI remoteClient, UUID animID); |
70 | 71 | ||
@@ -789,6 +790,7 @@ namespace OpenSim.Framework | |||
789 | event EstateChangeInfo OnEstateChangeInfo; | 790 | event EstateChangeInfo OnEstateChangeInfo; |
790 | event EstateManageTelehub OnEstateManageTelehub; | 791 | event EstateManageTelehub OnEstateManageTelehub; |
791 | // [Obsolete("LLClientView Specific.")] | 792 | // [Obsolete("LLClientView Specific.")] |
793 | event CachedTextureRequest OnCachedTextureRequest; | ||
792 | event SetAppearance OnSetAppearance; | 794 | event SetAppearance OnSetAppearance; |
793 | // [Obsolete("LLClientView Specific - Replace and rename OnAvatarUpdate. Difference from SetAppearance?")] | 795 | // [Obsolete("LLClientView Specific - Replace and rename OnAvatarUpdate. Difference from SetAppearance?")] |
794 | event AvatarNowWearing OnAvatarNowWearing; | 796 | event AvatarNowWearing OnAvatarNowWearing; |
@@ -832,6 +834,8 @@ namespace OpenSim.Framework | |||
832 | /// </remarks> | 834 | /// </remarks> |
833 | event UpdateAgent OnAgentUpdate; | 835 | event UpdateAgent OnAgentUpdate; |
834 | 836 | ||
837 | event UpdateAgent OnAgentCameraUpdate; | ||
838 | |||
835 | event AgentRequestSit OnAgentRequestSit; | 839 | event AgentRequestSit OnAgentRequestSit; |
836 | event AgentSit OnAgentSit; | 840 | event AgentSit OnAgentSit; |
837 | event AvatarPickerRequest OnAvatarPickerRequest; | 841 | event AvatarPickerRequest OnAvatarPickerRequest; |
@@ -1100,14 +1104,15 @@ namespace OpenSim.Framework | |||
1100 | /// <param name="textureEntry"></param> | 1104 | /// <param name="textureEntry"></param> |
1101 | void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry); | 1105 | void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry); |
1102 | 1106 | ||
1107 | void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures); | ||
1108 | |||
1103 | void SendStartPingCheck(byte seq); | 1109 | void SendStartPingCheck(byte seq); |
1104 | 1110 | ||
1105 | /// <summary> | 1111 | /// <summary> |
1106 | /// Tell the client that an object has been deleted | 1112 | /// Tell the client that an object has been deleted |
1107 | /// </summary> | 1113 | /// </summary> |
1108 | /// <param name="regionHandle"></param> | ||
1109 | /// <param name="localID"></param> | 1114 | /// <param name="localID"></param> |
1110 | void SendKillObject(ulong regionHandle, List<uint> localID); | 1115 | void SendKillObject(List<uint> localID); |
1111 | 1116 | ||
1112 | void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs); | 1117 | void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs); |
1113 | void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args); | 1118 | void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args); |
@@ -1486,7 +1491,7 @@ namespace OpenSim.Framework | |||
1486 | void SendChangeUserRights(UUID agentID, UUID friendID, int rights); | 1491 | void SendChangeUserRights(UUID agentID, UUID friendID, int rights); |
1487 | void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId); | 1492 | void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId); |
1488 | 1493 | ||
1489 | void StopFlying(ISceneEntity presence); | 1494 | void SendAgentTerseUpdate(ISceneEntity presence); |
1490 | 1495 | ||
1491 | void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data); | 1496 | void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data); |
1492 | } | 1497 | } |
diff --git a/OpenSim/Framework/IPeople.cs b/OpenSim/Framework/IPeople.cs new file mode 100644 index 0000000..b88e103 --- /dev/null +++ b/OpenSim/Framework/IPeople.cs | |||
@@ -0,0 +1,47 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Framework | ||
33 | { | ||
34 | public class UserData | ||
35 | { | ||
36 | public UUID Id { get; set; } | ||
37 | public string FirstName { get; set; } | ||
38 | public string LastName { get; set; } | ||
39 | public string HomeURL { get; set; } | ||
40 | public Dictionary<string, object> ServerURLs { get; set; } | ||
41 | } | ||
42 | |||
43 | public interface IPeople | ||
44 | { | ||
45 | List<UserData> GetUserData(string query, int page_size, int page_number); | ||
46 | } | ||
47 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index 87ec99e..8164f41 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs | |||
@@ -136,5 +136,10 @@ namespace OpenSim.Framework | |||
136 | ISceneObject DeserializeObject(string representation); | 136 | ISceneObject DeserializeObject(string representation); |
137 | 137 | ||
138 | bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); | 138 | bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); |
139 | |||
140 | /// <summary> | ||
141 | /// Start the scene and associated scripts within it. | ||
142 | /// </summary> | ||
143 | void Start(); | ||
139 | } | 144 | } |
140 | } | 145 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Location.cs b/OpenSim/Framework/Location.cs index 9504e03..0b88834 100644 --- a/OpenSim/Framework/Location.cs +++ b/OpenSim/Framework/Location.cs | |||
@@ -33,10 +33,10 @@ namespace OpenSim.Framework | |||
33 | [Serializable] | 33 | [Serializable] |
34 | public class Location : ICloneable | 34 | public class Location : ICloneable |
35 | { | 35 | { |
36 | private readonly int m_x; | 36 | private readonly uint m_x; |
37 | private readonly int m_y; | 37 | private readonly uint m_y; |
38 | 38 | ||
39 | public Location(int x, int y) | 39 | public Location(uint x, uint y) |
40 | { | 40 | { |
41 | m_x = x; | 41 | m_x = x; |
42 | m_y = y; | 42 | m_y = y; |
@@ -44,21 +44,21 @@ namespace OpenSim.Framework | |||
44 | 44 | ||
45 | public Location(ulong regionHandle) | 45 | public Location(ulong regionHandle) |
46 | { | 46 | { |
47 | m_x = (int) regionHandle; | 47 | m_x = (uint)(regionHandle >> 32); |
48 | m_y = (int) (regionHandle >> 32); | 48 | m_y = (uint)(regionHandle & (ulong)uint.MaxValue); |
49 | } | 49 | } |
50 | 50 | ||
51 | public ulong RegionHandle | 51 | public ulong RegionHandle |
52 | { | 52 | { |
53 | get { return Utils.UIntsToLong((uint)m_x, (uint)m_y); } | 53 | get { return Utils.UIntsToLong(m_x, m_y); } |
54 | } | 54 | } |
55 | 55 | ||
56 | public int X | 56 | public uint X |
57 | { | 57 | { |
58 | get { return m_x; } | 58 | get { return m_x; } |
59 | } | 59 | } |
60 | 60 | ||
61 | public int Y | 61 | public uint Y |
62 | { | 62 | { |
63 | get { return m_y; } | 63 | get { return m_y; } |
64 | } | 64 | } |
diff --git a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs index 23dba09..96536e8 100644 --- a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -44,16 +44,16 @@ namespace OpenSim.Framework.Monitoring | |||
44 | sb.Append("MEMORY STATISTICS"); | 44 | sb.Append("MEMORY STATISTICS"); |
45 | sb.Append(Environment.NewLine); | 45 | sb.Append(Environment.NewLine); |
46 | sb.AppendFormat( | 46 | sb.AppendFormat( |
47 | "Allocated to OpenSim objects: {0} MB\n", | 47 | "Heap allocated to OpenSim : {0} MB\n", |
48 | Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)); | 48 | Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)); |
49 | 49 | ||
50 | sb.AppendFormat( | 50 | sb.AppendFormat( |
51 | "OpenSim last object memory churn : {0} MB/s\n", | 51 | "Last heap allocation rate : {0} MB/s\n", |
52 | Math.Round((MemoryWatchdog.LastMemoryChurn * 1000) / 1024.0 / 1024, 3)); | 52 | Math.Round((MemoryWatchdog.LastHeapAllocationRate * 1000) / 1024.0 / 1024, 3)); |
53 | 53 | ||
54 | sb.AppendFormat( | 54 | sb.AppendFormat( |
55 | "OpenSim average object memory churn : {0} MB/s\n", | 55 | "Average heap allocation rate: {0} MB/s\n", |
56 | Math.Round((MemoryWatchdog.AverageMemoryChurn * 1000) / 1024.0 / 1024, 3)); | 56 | Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1024.0 / 1024, 3)); |
57 | 57 | ||
58 | Process myprocess = Process.GetCurrentProcess(); | 58 | Process myprocess = Process.GetCurrentProcess(); |
59 | if (!myprocess.HasExited) | 59 | if (!myprocess.HasExited) |
diff --git a/OpenSim/Framework/Monitoring/MemoryWatchdog.cs b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs index c6010cd..c474622 100644 --- a/OpenSim/Framework/Monitoring/MemoryWatchdog.cs +++ b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs | |||
@@ -60,17 +60,17 @@ namespace OpenSim.Framework.Monitoring | |||
60 | private static bool m_enabled; | 60 | private static bool m_enabled; |
61 | 61 | ||
62 | /// <summary> | 62 | /// <summary> |
63 | /// Last memory churn in bytes per millisecond. | 63 | /// Average heap allocation rate in bytes per millisecond. |
64 | /// </summary> | 64 | /// </summary> |
65 | public static double AverageMemoryChurn | 65 | public static double AverageHeapAllocationRate |
66 | { | 66 | { |
67 | get { if (m_samples.Count > 0) return m_samples.Average(); else return 0; } | 67 | get { if (m_samples.Count > 0) return m_samples.Average(); else return 0; } |
68 | } | 68 | } |
69 | 69 | ||
70 | /// <summary> | 70 | /// <summary> |
71 | /// Average memory churn in bytes per millisecond. | 71 | /// Last heap allocation in bytes |
72 | /// </summary> | 72 | /// </summary> |
73 | public static double LastMemoryChurn | 73 | public static double LastHeapAllocationRate |
74 | { | 74 | { |
75 | get { if (m_samples.Count > 0) return m_samples.Last(); else return 0; } | 75 | get { if (m_samples.Count > 0) return m_samples.Last(); else return 0; } |
76 | } | 76 | } |
diff --git a/OpenSim/Framework/Monitoring/ServerStatsCollector.cs b/OpenSim/Framework/Monitoring/ServerStatsCollector.cs new file mode 100644 index 0000000..ac0f0bc --- /dev/null +++ b/OpenSim/Framework/Monitoring/ServerStatsCollector.cs | |||
@@ -0,0 +1,349 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Diagnostics; | ||
31 | using System.Linq; | ||
32 | using System.Net.NetworkInformation; | ||
33 | using System.Text; | ||
34 | using System.Threading; | ||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | |||
40 | namespace OpenSim.Framework.Monitoring | ||
41 | { | ||
42 | public class ServerStatsCollector | ||
43 | { | ||
44 | private readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | private readonly string LogHeader = "[SERVER STATS]"; | ||
46 | |||
47 | public bool Enabled = false; | ||
48 | private static Dictionary<string, Stat> RegisteredStats = new Dictionary<string, Stat>(); | ||
49 | |||
50 | public readonly string CategoryServer = "server"; | ||
51 | |||
52 | public readonly string ContainerThreadpool = "threadpool"; | ||
53 | public readonly string ContainerProcessor = "processor"; | ||
54 | public readonly string ContainerMemory = "memory"; | ||
55 | public readonly string ContainerNetwork = "network"; | ||
56 | public readonly string ContainerProcess = "process"; | ||
57 | |||
58 | public string NetworkInterfaceTypes = "Ethernet"; | ||
59 | |||
60 | readonly int performanceCounterSampleInterval = 500; | ||
61 | // int lastperformanceCounterSampleTime = 0; | ||
62 | |||
63 | private class PerfCounterControl | ||
64 | { | ||
65 | public PerformanceCounter perfCounter; | ||
66 | public int lastFetch; | ||
67 | public string name; | ||
68 | public PerfCounterControl(PerformanceCounter pPc) | ||
69 | : this(pPc, String.Empty) | ||
70 | { | ||
71 | } | ||
72 | public PerfCounterControl(PerformanceCounter pPc, string pName) | ||
73 | { | ||
74 | perfCounter = pPc; | ||
75 | lastFetch = 0; | ||
76 | name = pName; | ||
77 | } | ||
78 | } | ||
79 | |||
80 | PerfCounterControl processorPercentPerfCounter = null; | ||
81 | |||
82 | // IRegionModuleBase.Initialize | ||
83 | public void Initialise(IConfigSource source) | ||
84 | { | ||
85 | IConfig cfg = source.Configs["Monitoring"]; | ||
86 | |||
87 | if (cfg != null) | ||
88 | Enabled = cfg.GetBoolean("ServerStatsEnabled", true); | ||
89 | |||
90 | if (Enabled) | ||
91 | { | ||
92 | NetworkInterfaceTypes = cfg.GetString("NetworkInterfaceTypes", "Ethernet"); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public void Start() | ||
97 | { | ||
98 | if (RegisteredStats.Count == 0) | ||
99 | RegisterServerStats(); | ||
100 | } | ||
101 | |||
102 | public void Close() | ||
103 | { | ||
104 | if (RegisteredStats.Count > 0) | ||
105 | { | ||
106 | foreach (Stat stat in RegisteredStats.Values) | ||
107 | { | ||
108 | StatsManager.DeregisterStat(stat); | ||
109 | stat.Dispose(); | ||
110 | } | ||
111 | RegisteredStats.Clear(); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | private void MakeStat(string pName, string pDesc, string pUnit, string pContainer, Action<Stat> act) | ||
116 | { | ||
117 | MakeStat(pName, pDesc, pUnit, pContainer, act, MeasuresOfInterest.None); | ||
118 | } | ||
119 | |||
120 | private void MakeStat(string pName, string pDesc, string pUnit, string pContainer, Action<Stat> act, MeasuresOfInterest moi) | ||
121 | { | ||
122 | string desc = pDesc; | ||
123 | if (desc == null) | ||
124 | desc = pName; | ||
125 | Stat stat = new Stat(pName, pName, desc, pUnit, CategoryServer, pContainer, StatType.Pull, moi, act, StatVerbosity.Debug); | ||
126 | StatsManager.RegisterStat(stat); | ||
127 | RegisteredStats.Add(pName, stat); | ||
128 | } | ||
129 | |||
130 | public void RegisterServerStats() | ||
131 | { | ||
132 | // lastperformanceCounterSampleTime = Util.EnvironmentTickCount(); | ||
133 | PerformanceCounter tempPC; | ||
134 | Stat tempStat; | ||
135 | string tempName; | ||
136 | |||
137 | try | ||
138 | { | ||
139 | tempName = "CPUPercent"; | ||
140 | tempPC = new PerformanceCounter("Processor", "% Processor Time", "_Total"); | ||
141 | processorPercentPerfCounter = new PerfCounterControl(tempPC); | ||
142 | // A long time bug in mono is that CPU percent is reported as CPU percent idle. Windows reports CPU percent busy. | ||
143 | tempStat = new Stat(tempName, tempName, "", "percent", CategoryServer, ContainerProcessor, | ||
144 | StatType.Pull, (s) => { GetNextValue(s, processorPercentPerfCounter, Util.IsWindows() ? 1 : -1); }, | ||
145 | StatVerbosity.Info); | ||
146 | StatsManager.RegisterStat(tempStat); | ||
147 | RegisteredStats.Add(tempName, tempStat); | ||
148 | |||
149 | MakeStat("TotalProcessorTime", null, "sec", ContainerProcessor, | ||
150 | (s) => { s.Value = Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds; }); | ||
151 | |||
152 | MakeStat("UserProcessorTime", null, "sec", ContainerProcessor, | ||
153 | (s) => { s.Value = Process.GetCurrentProcess().UserProcessorTime.TotalSeconds; }); | ||
154 | |||
155 | MakeStat("PrivilegedProcessorTime", null, "sec", ContainerProcessor, | ||
156 | (s) => { s.Value = Process.GetCurrentProcess().PrivilegedProcessorTime.TotalSeconds; }); | ||
157 | |||
158 | MakeStat("Threads", null, "threads", ContainerProcessor, | ||
159 | (s) => { s.Value = Process.GetCurrentProcess().Threads.Count; }); | ||
160 | } | ||
161 | catch (Exception e) | ||
162 | { | ||
163 | m_log.ErrorFormat("{0} Exception creating 'Process': {1}", LogHeader, e); | ||
164 | } | ||
165 | |||
166 | MakeStat("BuiltinThreadpoolWorkerThreadsAvailable", null, "threads", ContainerThreadpool, | ||
167 | s => | ||
168 | { | ||
169 | int workerThreads, iocpThreads; | ||
170 | ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads); | ||
171 | s.Value = workerThreads; | ||
172 | }); | ||
173 | |||
174 | MakeStat("BuiltinThreadpoolIOCPThreadsAvailable", null, "threads", ContainerThreadpool, | ||
175 | s => | ||
176 | { | ||
177 | int workerThreads, iocpThreads; | ||
178 | ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads); | ||
179 | s.Value = iocpThreads; | ||
180 | }); | ||
181 | |||
182 | if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool && Util.GetSmartThreadPoolInfo() != null) | ||
183 | { | ||
184 | MakeStat("STPMaxThreads", null, "threads", ContainerThreadpool, s => s.Value = Util.GetSmartThreadPoolInfo().MaxThreads); | ||
185 | MakeStat("STPMinThreads", null, "threads", ContainerThreadpool, s => s.Value = Util.GetSmartThreadPoolInfo().MinThreads); | ||
186 | MakeStat("STPConcurrency", null, "threads", ContainerThreadpool, s => s.Value = Util.GetSmartThreadPoolInfo().MaxConcurrentWorkItems); | ||
187 | MakeStat("STPActiveThreads", null, "threads", ContainerThreadpool, s => s.Value = Util.GetSmartThreadPoolInfo().ActiveThreads); | ||
188 | MakeStat("STPInUseThreads", null, "threads", ContainerThreadpool, s => s.Value = Util.GetSmartThreadPoolInfo().InUseThreads); | ||
189 | MakeStat("STPWorkItemsWaiting", null, "threads", ContainerThreadpool, s => s.Value = Util.GetSmartThreadPoolInfo().WaitingCallbacks); | ||
190 | } | ||
191 | |||
192 | MakeStat( | ||
193 | "HTTPRequestsMade", | ||
194 | "Number of outbound HTTP requests made", | ||
195 | "requests", | ||
196 | ContainerNetwork, | ||
197 | s => s.Value = WebUtil.RequestNumber, | ||
198 | MeasuresOfInterest.AverageChangeOverTime); | ||
199 | |||
200 | try | ||
201 | { | ||
202 | List<string> okInterfaceTypes = new List<string>(NetworkInterfaceTypes.Split(',')); | ||
203 | |||
204 | IEnumerable<NetworkInterface> nics = NetworkInterface.GetAllNetworkInterfaces(); | ||
205 | foreach (NetworkInterface nic in nics) | ||
206 | { | ||
207 | if (nic.OperationalStatus != OperationalStatus.Up) | ||
208 | continue; | ||
209 | |||
210 | string nicInterfaceType = nic.NetworkInterfaceType.ToString(); | ||
211 | if (!okInterfaceTypes.Contains(nicInterfaceType)) | ||
212 | { | ||
213 | m_log.DebugFormat("{0} Not including stats for network interface '{1}' of type '{2}'.", | ||
214 | LogHeader, nic.Name, nicInterfaceType); | ||
215 | m_log.DebugFormat("{0} To include, add to comma separated list in [Monitoring]NetworkInterfaceTypes={1}", | ||
216 | LogHeader, NetworkInterfaceTypes); | ||
217 | continue; | ||
218 | } | ||
219 | |||
220 | if (nic.Supports(NetworkInterfaceComponent.IPv4)) | ||
221 | { | ||
222 | IPv4InterfaceStatistics nicStats = nic.GetIPv4Statistics(); | ||
223 | if (nicStats != null) | ||
224 | { | ||
225 | MakeStat("BytesRcvd/" + nic.Name, nic.Name, "KB", ContainerNetwork, | ||
226 | (s) => { LookupNic(s, (ns) => { return ns.BytesReceived; }, 1024.0); }); | ||
227 | MakeStat("BytesSent/" + nic.Name, nic.Name, "KB", ContainerNetwork, | ||
228 | (s) => { LookupNic(s, (ns) => { return ns.BytesSent; }, 1024.0); }); | ||
229 | MakeStat("TotalBytes/" + nic.Name, nic.Name, "KB", ContainerNetwork, | ||
230 | (s) => { LookupNic(s, (ns) => { return ns.BytesSent + ns.BytesReceived; }, 1024.0); }); | ||
231 | } | ||
232 | } | ||
233 | // TODO: add IPv6 (it may actually happen someday) | ||
234 | } | ||
235 | } | ||
236 | catch (Exception e) | ||
237 | { | ||
238 | m_log.ErrorFormat("{0} Exception creating 'Network Interface': {1}", LogHeader, e); | ||
239 | } | ||
240 | |||
241 | MakeStat("ProcessMemory", null, "MB", ContainerMemory, | ||
242 | (s) => { s.Value = Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024d / 1024d, 3); }); | ||
243 | MakeStat("HeapMemory", null, "MB", ContainerMemory, | ||
244 | (s) => { s.Value = Math.Round(GC.GetTotalMemory(false) / 1024d / 1024d, 3); }); | ||
245 | MakeStat("LastHeapAllocationRate", null, "MB/sec", ContainerMemory, | ||
246 | (s) => { s.Value = Math.Round(MemoryWatchdog.LastHeapAllocationRate * 1000d / 1024d / 1024d, 3); }); | ||
247 | MakeStat("AverageHeapAllocationRate", null, "MB/sec", ContainerMemory, | ||
248 | (s) => { s.Value = Math.Round(MemoryWatchdog.AverageHeapAllocationRate * 1000d / 1024d / 1024d, 3); }); | ||
249 | } | ||
250 | |||
251 | // Notes on performance counters: | ||
252 | // "How To Read Performance Counters": http://blogs.msdn.com/b/bclteam/archive/2006/06/02/618156.aspx | ||
253 | // "How to get the CPU Usage in C#": http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-in-c | ||
254 | // "Mono Performance Counters": http://www.mono-project.com/Mono_Performance_Counters | ||
255 | private delegate double PerfCounterNextValue(); | ||
256 | private void GetNextValue(Stat stat, PerfCounterControl perfControl) | ||
257 | { | ||
258 | GetNextValue(stat, perfControl, 1.0); | ||
259 | } | ||
260 | private void GetNextValue(Stat stat, PerfCounterControl perfControl, double factor) | ||
261 | { | ||
262 | if (Util.EnvironmentTickCountSubtract(perfControl.lastFetch) > performanceCounterSampleInterval) | ||
263 | { | ||
264 | if (perfControl != null && perfControl.perfCounter != null) | ||
265 | { | ||
266 | try | ||
267 | { | ||
268 | // Kludge for factor to run double duty. If -1, subtract the value from one | ||
269 | if (factor == -1) | ||
270 | stat.Value = 1 - perfControl.perfCounter.NextValue(); | ||
271 | else | ||
272 | stat.Value = perfControl.perfCounter.NextValue() / factor; | ||
273 | } | ||
274 | catch (Exception e) | ||
275 | { | ||
276 | m_log.ErrorFormat("{0} Exception on NextValue fetching {1}: {2}", LogHeader, stat.Name, e); | ||
277 | } | ||
278 | perfControl.lastFetch = Util.EnvironmentTickCount(); | ||
279 | } | ||
280 | } | ||
281 | } | ||
282 | |||
283 | // Lookup the nic that goes with this stat and set the value by using a fetch action. | ||
284 | // Not sure about closure with delegates inside delegates. | ||
285 | private delegate double GetIPv4StatValue(IPv4InterfaceStatistics interfaceStat); | ||
286 | private void LookupNic(Stat stat, GetIPv4StatValue getter, double factor) | ||
287 | { | ||
288 | // Get the one nic that has the name of this stat | ||
289 | IEnumerable<NetworkInterface> nics = NetworkInterface.GetAllNetworkInterfaces().Where( | ||
290 | (network) => network.Name == stat.Description); | ||
291 | try | ||
292 | { | ||
293 | foreach (NetworkInterface nic in nics) | ||
294 | { | ||
295 | IPv4InterfaceStatistics intrStats = nic.GetIPv4Statistics(); | ||
296 | if (intrStats != null) | ||
297 | { | ||
298 | double newVal = Math.Round(getter(intrStats) / factor, 3); | ||
299 | stat.Value = newVal; | ||
300 | } | ||
301 | break; | ||
302 | } | ||
303 | } | ||
304 | catch | ||
305 | { | ||
306 | // There are times interfaces go away so we just won't update the stat for this | ||
307 | m_log.ErrorFormat("{0} Exception fetching stat on interface '{1}'", LogHeader, stat.Description); | ||
308 | } | ||
309 | } | ||
310 | } | ||
311 | |||
312 | public class ServerStatsAggregator : Stat | ||
313 | { | ||
314 | public ServerStatsAggregator( | ||
315 | string shortName, | ||
316 | string name, | ||
317 | string description, | ||
318 | string unitName, | ||
319 | string category, | ||
320 | string container | ||
321 | ) | ||
322 | : base( | ||
323 | shortName, | ||
324 | name, | ||
325 | description, | ||
326 | unitName, | ||
327 | category, | ||
328 | container, | ||
329 | StatType.Push, | ||
330 | MeasuresOfInterest.None, | ||
331 | null, | ||
332 | StatVerbosity.Info) | ||
333 | { | ||
334 | } | ||
335 | public override string ToConsoleString() | ||
336 | { | ||
337 | StringBuilder sb = new StringBuilder(); | ||
338 | |||
339 | return sb.ToString(); | ||
340 | } | ||
341 | |||
342 | public override OSDMap ToOSDMap() | ||
343 | { | ||
344 | OSDMap ret = new OSDMap(); | ||
345 | |||
346 | return ret; | ||
347 | } | ||
348 | } | ||
349 | } | ||
diff --git a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs index 6a68322..f6f458d 100644 --- a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Linq; | ||
30 | using System.Text; | 31 | using System.Text; |
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
32 | using OpenMetaverse.StructuredData; | 33 | using OpenMetaverse.StructuredData; |
@@ -39,8 +40,6 @@ namespace OpenSim.Framework.Monitoring | |||
39 | /// </summary> | 40 | /// </summary> |
40 | public class SimExtraStatsCollector : BaseStatsCollector | 41 | public class SimExtraStatsCollector : BaseStatsCollector |
41 | { | 42 | { |
42 | private long abnormalClientThreadTerminations; | ||
43 | |||
44 | // private long assetsInCache; | 43 | // private long assetsInCache; |
45 | // private long texturesInCache; | 44 | // private long texturesInCache; |
46 | // private long assetCacheMemoryUsage; | 45 | // private long assetCacheMemoryUsage; |
@@ -73,11 +72,6 @@ namespace OpenSim.Framework.Monitoring | |||
73 | private volatile float activeScripts; | 72 | private volatile float activeScripts; |
74 | private volatile float scriptLinesPerSecond; | 73 | private volatile float scriptLinesPerSecond; |
75 | 74 | ||
76 | /// <summary> | ||
77 | /// Number of times that a client thread terminated because of an exception | ||
78 | /// </summary> | ||
79 | public long AbnormalClientThreadTerminations { get { return abnormalClientThreadTerminations; } } | ||
80 | |||
81 | // /// <summary> | 75 | // /// <summary> |
82 | // /// These statistics are being collected by push rather than pull. Pull would be simpler, but I had the | 76 | // /// These statistics are being collected by push rather than pull. Pull would be simpler, but I had the |
83 | // /// notion of providing some flow statistics (which pull wouldn't give us). Though admittedly these | 77 | // /// notion of providing some flow statistics (which pull wouldn't give us). Though admittedly these |
@@ -166,11 +160,6 @@ namespace OpenSim.Framework.Monitoring | |||
166 | private IDictionary<UUID, PacketQueueStatsCollector> packetQueueStatsCollectors | 160 | private IDictionary<UUID, PacketQueueStatsCollector> packetQueueStatsCollectors |
167 | = new Dictionary<UUID, PacketQueueStatsCollector>(); | 161 | = new Dictionary<UUID, PacketQueueStatsCollector>(); |
168 | 162 | ||
169 | public void AddAbnormalClientThreadTermination() | ||
170 | { | ||
171 | abnormalClientThreadTerminations++; | ||
172 | } | ||
173 | |||
174 | // public void AddAsset(AssetBase asset) | 163 | // public void AddAsset(AssetBase asset) |
175 | // { | 164 | // { |
176 | // assetsInCache++; | 165 | // assetsInCache++; |
@@ -324,10 +313,12 @@ Asset service request failures: {3}" + Environment.NewLine, | |||
324 | sb.Append(Environment.NewLine); | 313 | sb.Append(Environment.NewLine); |
325 | sb.Append("CONNECTION STATISTICS"); | 314 | sb.Append("CONNECTION STATISTICS"); |
326 | sb.Append(Environment.NewLine); | 315 | sb.Append(Environment.NewLine); |
327 | sb.Append( | 316 | |
328 | string.Format( | 317 | List<Stat> stats = StatsManager.GetStatsFromEachContainer("clientstack", "ClientLogoutsDueToNoReceives"); |
329 | "Abnormal client thread terminations: {0}" + Environment.NewLine, | 318 | |
330 | abnormalClientThreadTerminations)); | 319 | sb.AppendFormat( |
320 | "Client logouts due to no data receive timeout: {0}\n\n", | ||
321 | stats != null ? stats.Sum(s => s.Value).ToString() : "unknown"); | ||
331 | 322 | ||
332 | // sb.Append(Environment.NewLine); | 323 | // sb.Append(Environment.NewLine); |
333 | // sb.Append("INVENTORY STATISTICS"); | 324 | // sb.Append("INVENTORY STATISTICS"); |
@@ -338,7 +329,7 @@ Asset service request failures: {3}" + Environment.NewLine, | |||
338 | // InventoryServiceRetrievalFailures)); | 329 | // InventoryServiceRetrievalFailures)); |
339 | 330 | ||
340 | sb.Append(Environment.NewLine); | 331 | sb.Append(Environment.NewLine); |
341 | sb.Append("FRAME STATISTICS"); | 332 | sb.Append("SAMPLE FRAME STATISTICS"); |
342 | sb.Append(Environment.NewLine); | 333 | sb.Append(Environment.NewLine); |
343 | sb.Append("Dilatn SimFPS PhyFPS AgntUp RootAg ChldAg Prims AtvPrm AtvScr ScrLPS"); | 334 | sb.Append("Dilatn SimFPS PhyFPS AgntUp RootAg ChldAg Prims AtvPrm AtvScr ScrLPS"); |
344 | sb.Append(Environment.NewLine); | 335 | sb.Append(Environment.NewLine); |
diff --git a/OpenSim/Framework/Monitoring/Stats/CounterStat.cs b/OpenSim/Framework/Monitoring/Stats/CounterStat.cs index caea30d..04442c3 100755 --- a/OpenSim/Framework/Monitoring/Stats/CounterStat.cs +++ b/OpenSim/Framework/Monitoring/Stats/CounterStat.cs | |||
@@ -224,5 +224,26 @@ public class CounterStat : Stat | |||
224 | } | 224 | } |
225 | } | 225 | } |
226 | } | 226 | } |
227 | |||
228 | // CounterStat is a basic stat plus histograms | ||
229 | public override OSDMap ToOSDMap() | ||
230 | { | ||
231 | // Get the foundational instance | ||
232 | OSDMap map = base.ToOSDMap(); | ||
233 | |||
234 | map["StatType"] = "CounterStat"; | ||
235 | |||
236 | // If there are any histograms, add a new field that is an array of histograms as OSDMaps | ||
237 | if (m_histograms.Count > 0) | ||
238 | { | ||
239 | OSDArray histos = new OSDArray(); | ||
240 | foreach (EventHistogram histo in m_histograms.Values) | ||
241 | { | ||
242 | histos.Add(histo.GetHistogramAsOSDMap()); | ||
243 | } | ||
244 | map.Add("Histograms", histos); | ||
245 | } | ||
246 | return map; | ||
247 | } | ||
227 | } | 248 | } |
228 | } | 249 | } |
diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs index 2e7665f..ffd5132 100644 --- a/OpenSim/Framework/Monitoring/Stats/Stat.cs +++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs | |||
@@ -27,8 +27,10 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Linq; | ||
31 | using System.Reflection; | ||
30 | using System.Text; | 32 | using System.Text; |
31 | 33 | using log4net; | |
32 | using OpenMetaverse.StructuredData; | 34 | using OpenMetaverse.StructuredData; |
33 | 35 | ||
34 | namespace OpenSim.Framework.Monitoring | 36 | namespace OpenSim.Framework.Monitoring |
@@ -38,6 +40,10 @@ namespace OpenSim.Framework.Monitoring | |||
38 | /// </summary> | 40 | /// </summary> |
39 | public class Stat : IDisposable | 41 | public class Stat : IDisposable |
40 | { | 42 | { |
43 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | public static readonly char[] DisallowedShortNameCharacters = { '.' }; | ||
46 | |||
41 | /// <summary> | 47 | /// <summary> |
42 | /// Category of this stat (e.g. cache, scene, etc). | 48 | /// Category of this stat (e.g. cache, scene, etc). |
43 | /// </summary> | 49 | /// </summary> |
@@ -95,7 +101,7 @@ namespace OpenSim.Framework.Monitoring | |||
95 | /// <remarks> | 101 | /// <remarks> |
96 | /// Will be null if no measures of interest require samples. | 102 | /// Will be null if no measures of interest require samples. |
97 | /// </remarks> | 103 | /// </remarks> |
98 | private static Queue<double> m_samples; | 104 | private Queue<double> m_samples; |
99 | 105 | ||
100 | /// <summary> | 106 | /// <summary> |
101 | /// Maximum number of statistical samples. | 107 | /// Maximum number of statistical samples. |
@@ -162,6 +168,12 @@ namespace OpenSim.Framework.Monitoring | |||
162 | throw new Exception( | 168 | throw new Exception( |
163 | string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category)); | 169 | string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category)); |
164 | 170 | ||
171 | foreach (char c in DisallowedShortNameCharacters) | ||
172 | { | ||
173 | if (shortName.IndexOf(c) != -1) | ||
174 | throw new Exception(string.Format("Stat name {0} cannot contain character {1}", shortName, c)); | ||
175 | } | ||
176 | |||
165 | ShortName = shortName; | 177 | ShortName = shortName; |
166 | Name = name; | 178 | Name = name; |
167 | Description = description; | 179 | Description = description; |
@@ -204,6 +216,8 @@ namespace OpenSim.Framework.Monitoring | |||
204 | if (m_samples.Count >= m_maxSamples) | 216 | if (m_samples.Count >= m_maxSamples) |
205 | m_samples.Dequeue(); | 217 | m_samples.Dequeue(); |
206 | 218 | ||
219 | // m_log.DebugFormat("[STAT]: Recording value {0} for {1}", newValue, Name); | ||
220 | |||
207 | m_samples.Enqueue(newValue); | 221 | m_samples.Enqueue(newValue); |
208 | } | 222 | } |
209 | } | 223 | } |
@@ -211,7 +225,13 @@ namespace OpenSim.Framework.Monitoring | |||
211 | public virtual string ToConsoleString() | 225 | public virtual string ToConsoleString() |
212 | { | 226 | { |
213 | StringBuilder sb = new StringBuilder(); | 227 | StringBuilder sb = new StringBuilder(); |
214 | sb.AppendFormat("{0}.{1}.{2} : {3} {4}", Category, Container, ShortName, Value, UnitName); | 228 | sb.AppendFormat( |
229 | "{0}.{1}.{2} : {3}{4}", | ||
230 | Category, | ||
231 | Container, | ||
232 | ShortName, | ||
233 | Value, | ||
234 | UnitName == null || UnitName == "" ? "" : string.Format(" {0}", UnitName)); | ||
215 | 235 | ||
216 | AppendMeasuresOfInterest(sb); | 236 | AppendMeasuresOfInterest(sb); |
217 | 237 | ||
@@ -228,6 +248,7 @@ namespace OpenSim.Framework.Monitoring | |||
228 | ret.Add("Description", OSD.FromString(Description)); | 248 | ret.Add("Description", OSD.FromString(Description)); |
229 | ret.Add("UnitName", OSD.FromString(UnitName)); | 249 | ret.Add("UnitName", OSD.FromString(UnitName)); |
230 | ret.Add("Value", OSD.FromReal(Value)); | 250 | ret.Add("Value", OSD.FromReal(Value)); |
251 | ret.Add("StatType", "Stat"); // used by overloading classes to denote type of stat | ||
231 | 252 | ||
232 | return ret; | 253 | return ret; |
233 | } | 254 | } |
@@ -238,22 +259,40 @@ namespace OpenSim.Framework.Monitoring | |||
238 | == MeasuresOfInterest.AverageChangeOverTime) | 259 | == MeasuresOfInterest.AverageChangeOverTime) |
239 | { | 260 | { |
240 | double totalChange = 0; | 261 | double totalChange = 0; |
262 | double lastChangeOverTime = 0; | ||
263 | double? penultimateSample = null; | ||
241 | double? lastSample = null; | 264 | double? lastSample = null; |
242 | 265 | ||
243 | lock (m_samples) | 266 | lock (m_samples) |
244 | { | 267 | { |
268 | // m_log.DebugFormat( | ||
269 | // "[STAT]: Samples for {0} are {1}", | ||
270 | // Name, string.Join(",", m_samples.Select(s => s.ToString()).ToArray())); | ||
271 | |||
245 | foreach (double s in m_samples) | 272 | foreach (double s in m_samples) |
246 | { | 273 | { |
247 | if (lastSample != null) | 274 | if (lastSample != null) |
248 | totalChange += s - (double)lastSample; | 275 | totalChange += s - (double)lastSample; |
249 | 276 | ||
277 | penultimateSample = lastSample; | ||
250 | lastSample = s; | 278 | lastSample = s; |
251 | } | 279 | } |
252 | } | 280 | } |
253 | 281 | ||
282 | if (lastSample != null && penultimateSample != null) | ||
283 | lastChangeOverTime | ||
284 | = ((double)lastSample - (double)penultimateSample) / (Watchdog.WATCHDOG_INTERVAL_MS / 1000); | ||
285 | |||
254 | int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1; | 286 | int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1; |
255 | 287 | ||
256 | sb.AppendFormat(", {0:0.##}{1}/s", totalChange / divisor / (Watchdog.WATCHDOG_INTERVAL_MS / 1000), UnitName); | 288 | double averageChangeOverTime = totalChange / divisor / (Watchdog.WATCHDOG_INTERVAL_MS / 1000); |
289 | |||
290 | sb.AppendFormat( | ||
291 | ", {0:0.##}{1}/s, {2:0.##}{3}/s", | ||
292 | lastChangeOverTime, | ||
293 | UnitName == null || UnitName == "" ? "" : string.Format(" {0}", UnitName), | ||
294 | averageChangeOverTime, | ||
295 | UnitName == null || UnitName == "" ? "" : string.Format(" {0}", UnitName)); | ||
257 | } | 296 | } |
258 | } | 297 | } |
259 | } | 298 | } |
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 24db6d4..e6a2304 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs | |||
@@ -27,8 +27,11 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Linq; | ||
30 | using System.Text; | 31 | using System.Text; |
31 | 32 | ||
33 | using OpenMetaverse.StructuredData; | ||
34 | |||
32 | namespace OpenSim.Framework.Monitoring | 35 | namespace OpenSim.Framework.Monitoring |
33 | { | 36 | { |
34 | /// <summary> | 37 | /// <summary> |
@@ -54,13 +57,13 @@ namespace OpenSim.Framework.Monitoring | |||
54 | public static SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Stat>>> RegisteredStats | 57 | public static SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Stat>>> RegisteredStats |
55 | = new SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Stat>>>(); | 58 | = new SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Stat>>>(); |
56 | 59 | ||
57 | private static AssetStatsCollector assetStats; | 60 | // private static AssetStatsCollector assetStats; |
58 | private static UserStatsCollector userStats; | 61 | // private static UserStatsCollector userStats; |
59 | private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector(); | 62 | // private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector(); |
60 | 63 | ||
61 | public static AssetStatsCollector AssetStats { get { return assetStats; } } | 64 | // public static AssetStatsCollector AssetStats { get { return assetStats; } } |
62 | public static UserStatsCollector UserStats { get { return userStats; } } | 65 | // public static UserStatsCollector UserStats { get { return userStats; } } |
63 | public static SimExtraStatsCollector SimExtraStats { get { return simExtraStats; } } | 66 | public static SimExtraStatsCollector SimExtraStats { get; set; } |
64 | 67 | ||
65 | public static void RegisterConsoleCommands(ICommandConsole console) | 68 | public static void RegisterConsoleCommands(ICommandConsole console) |
66 | { | 69 | { |
@@ -68,12 +71,14 @@ namespace OpenSim.Framework.Monitoring | |||
68 | "General", | 71 | "General", |
69 | false, | 72 | false, |
70 | "show stats", | 73 | "show stats", |
71 | "show stats [list|all|<category>]", | 74 | "show stats [list|all|(<category>[.<container>])+", |
72 | "Show statistical information for this server", | 75 | "Show statistical information for this server", |
73 | "If no final argument is specified then legacy statistics information is currently shown.\n" | 76 | "If no final argument is specified then legacy statistics information is currently shown.\n" |
74 | + "If list is specified then statistic categories are shown.\n" | 77 | + "'list' argument will show statistic categories.\n" |
75 | + "If all is specified then all registered statistics are shown.\n" | 78 | + "'all' will show all statistics.\n" |
76 | + "If a category name is specified then only statistics from that category are shown.\n" | 79 | + "A <category> name will show statistics from that category.\n" |
80 | + "A <category>.<container> name will show statistics from that category in that container.\n" | ||
81 | + "More than one name can be given separated by spaces.\n" | ||
77 | + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS", | 82 | + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS", |
78 | HandleShowStatsCommand); | 83 | HandleShowStatsCommand); |
79 | } | 84 | } |
@@ -84,43 +89,47 @@ namespace OpenSim.Framework.Monitoring | |||
84 | 89 | ||
85 | if (cmd.Length > 2) | 90 | if (cmd.Length > 2) |
86 | { | 91 | { |
87 | var categoryName = cmd[2]; | 92 | foreach (string name in cmd.Skip(2)) |
88 | var containerName = cmd.Length > 3 ? cmd[3] : String.Empty; | ||
89 | |||
90 | if (categoryName == AllSubCommand) | ||
91 | { | 93 | { |
92 | foreach (var category in RegisteredStats.Values) | 94 | string[] components = name.Split('.'); |
95 | |||
96 | string categoryName = components[0]; | ||
97 | string containerName = components.Length > 1 ? components[1] : null; | ||
98 | |||
99 | if (categoryName == AllSubCommand) | ||
93 | { | 100 | { |
94 | OutputCategoryStatsToConsole(con, category); | 101 | OutputAllStatsToConsole(con); |
95 | } | 102 | } |
96 | } | 103 | else if (categoryName == ListSubCommand) |
97 | else if (categoryName == ListSubCommand) | ||
98 | { | ||
99 | con.Output("Statistic categories available are:"); | ||
100 | foreach (string category in RegisteredStats.Keys) | ||
101 | con.OutputFormat(" {0}", category); | ||
102 | } | ||
103 | else | ||
104 | { | ||
105 | SortedDictionary<string, SortedDictionary<string, Stat>> category; | ||
106 | if (!RegisteredStats.TryGetValue(categoryName, out category)) | ||
107 | { | 104 | { |
108 | con.OutputFormat("No such category as {0}", categoryName); | 105 | con.Output("Statistic categories available are:"); |
106 | foreach (string category in RegisteredStats.Keys) | ||
107 | con.OutputFormat(" {0}", category); | ||
109 | } | 108 | } |
110 | else | 109 | else |
111 | { | 110 | { |
112 | if (String.IsNullOrEmpty(containerName)) | 111 | SortedDictionary<string, SortedDictionary<string, Stat>> category; |
113 | OutputCategoryStatsToConsole(con, category); | 112 | if (!RegisteredStats.TryGetValue(categoryName, out category)) |
113 | { | ||
114 | con.OutputFormat("No such category as {0}", categoryName); | ||
115 | } | ||
114 | else | 116 | else |
115 | { | 117 | { |
116 | SortedDictionary<string, Stat> container; | 118 | if (String.IsNullOrEmpty(containerName)) |
117 | if (category.TryGetValue(containerName, out container)) | ||
118 | { | 119 | { |
119 | OutputContainerStatsToConsole(con, container); | 120 | OutputCategoryStatsToConsole(con, category); |
120 | } | 121 | } |
121 | else | 122 | else |
122 | { | 123 | { |
123 | con.OutputFormat("No such container {0} in category {1}", containerName, categoryName); | 124 | SortedDictionary<string, Stat> container; |
125 | if (category.TryGetValue(containerName, out container)) | ||
126 | { | ||
127 | OutputContainerStatsToConsole(con, container); | ||
128 | } | ||
129 | else | ||
130 | { | ||
131 | con.OutputFormat("No such container {0} in category {1}", containerName, categoryName); | ||
132 | } | ||
124 | } | 133 | } |
125 | } | 134 | } |
126 | } | 135 | } |
@@ -129,7 +138,18 @@ namespace OpenSim.Framework.Monitoring | |||
129 | else | 138 | else |
130 | { | 139 | { |
131 | // Legacy | 140 | // Legacy |
132 | con.Output(SimExtraStats.Report()); | 141 | if (SimExtraStats != null) |
142 | con.Output(SimExtraStats.Report()); | ||
143 | else | ||
144 | OutputAllStatsToConsole(con); | ||
145 | } | ||
146 | } | ||
147 | |||
148 | private static void OutputAllStatsToConsole(ICommandConsole con) | ||
149 | { | ||
150 | foreach (var category in RegisteredStats.Values) | ||
151 | { | ||
152 | OutputCategoryStatsToConsole(con, category); | ||
133 | } | 153 | } |
134 | } | 154 | } |
135 | 155 | ||
@@ -150,28 +170,92 @@ namespace OpenSim.Framework.Monitoring | |||
150 | } | 170 | } |
151 | } | 171 | } |
152 | 172 | ||
153 | /// <summary> | 173 | // Creates an OSDMap of the format: |
154 | /// Start collecting statistics related to assets. | 174 | // { categoryName: { |
155 | /// Should only be called once. | 175 | // containerName: { |
156 | /// </summary> | 176 | // statName: { |
157 | public static AssetStatsCollector StartCollectingAssetStats() | 177 | // "Name": name, |
178 | // "ShortName": shortName, | ||
179 | // ... | ||
180 | // }, | ||
181 | // statName: { | ||
182 | // "Name": name, | ||
183 | // "ShortName": shortName, | ||
184 | // ... | ||
185 | // }, | ||
186 | // ... | ||
187 | // }, | ||
188 | // containerName: { | ||
189 | // ... | ||
190 | // }, | ||
191 | // ... | ||
192 | // }, | ||
193 | // categoryName: { | ||
194 | // ... | ||
195 | // }, | ||
196 | // ... | ||
197 | // } | ||
198 | // The passed in parameters will filter the categories, containers and stats returned. If any of the | ||
199 | // parameters are either EmptyOrNull or the AllSubCommand value, all of that type will be returned. | ||
200 | // Case matters. | ||
201 | public static OSDMap GetStatsAsOSDMap(string pCategoryName, string pContainerName, string pStatName) | ||
158 | { | 202 | { |
159 | assetStats = new AssetStatsCollector(); | 203 | OSDMap map = new OSDMap(); |
160 | 204 | ||
161 | return assetStats; | 205 | foreach (string catName in RegisteredStats.Keys) |
162 | } | 206 | { |
207 | // Do this category if null spec, "all" subcommand or category name matches passed parameter. | ||
208 | // Skip category if none of the above. | ||
209 | if (!(String.IsNullOrEmpty(pCategoryName) || pCategoryName == AllSubCommand || pCategoryName == catName)) | ||
210 | continue; | ||
163 | 211 | ||
164 | /// <summary> | 212 | OSDMap contMap = new OSDMap(); |
165 | /// Start collecting statistics related to users. | 213 | foreach (string contName in RegisteredStats[catName].Keys) |
166 | /// Should only be called once. | 214 | { |
167 | /// </summary> | 215 | if (!(string.IsNullOrEmpty(pContainerName) || pContainerName == AllSubCommand || pContainerName == contName)) |
168 | public static UserStatsCollector StartCollectingUserStats() | 216 | continue; |
169 | { | 217 | |
170 | userStats = new UserStatsCollector(); | 218 | OSDMap statMap = new OSDMap(); |
219 | |||
220 | SortedDictionary<string, Stat> theStats = RegisteredStats[catName][contName]; | ||
221 | foreach (string statName in theStats.Keys) | ||
222 | { | ||
223 | if (!(String.IsNullOrEmpty(pStatName) || pStatName == AllSubCommand || pStatName == statName)) | ||
224 | continue; | ||
225 | |||
226 | statMap.Add(statName, theStats[statName].ToOSDMap()); | ||
227 | } | ||
228 | |||
229 | contMap.Add(contName, statMap); | ||
230 | } | ||
231 | map.Add(catName, contMap); | ||
232 | } | ||
171 | 233 | ||
172 | return userStats; | 234 | return map; |
173 | } | 235 | } |
174 | 236 | ||
237 | // /// <summary> | ||
238 | // /// Start collecting statistics related to assets. | ||
239 | // /// Should only be called once. | ||
240 | // /// </summary> | ||
241 | // public static AssetStatsCollector StartCollectingAssetStats() | ||
242 | // { | ||
243 | // assetStats = new AssetStatsCollector(); | ||
244 | // | ||
245 | // return assetStats; | ||
246 | // } | ||
247 | // | ||
248 | // /// <summary> | ||
249 | // /// Start collecting statistics related to users. | ||
250 | // /// Should only be called once. | ||
251 | // /// </summary> | ||
252 | // public static UserStatsCollector StartCollectingUserStats() | ||
253 | // { | ||
254 | // userStats = new UserStatsCollector(); | ||
255 | // | ||
256 | // return userStats; | ||
257 | // } | ||
258 | |||
175 | /// <summary> | 259 | /// <summary> |
176 | /// Registers a statistic. | 260 | /// Registers a statistic. |
177 | /// </summary> | 261 | /// </summary> |
@@ -187,7 +271,7 @@ namespace OpenSim.Framework.Monitoring | |||
187 | // Stat name is not unique across category/container/shortname key. | 271 | // Stat name is not unique across category/container/shortname key. |
188 | // XXX: For now just return false. This is to avoid problems in regression tests where all tests | 272 | // XXX: For now just return false. This is to avoid problems in regression tests where all tests |
189 | // in a class are run in the same instance of the VM. | 273 | // in a class are run in the same instance of the VM. |
190 | if (TryGetStat(stat, out category, out container)) | 274 | if (TryGetStatParents(stat, out category, out container)) |
191 | return false; | 275 | return false; |
192 | 276 | ||
193 | // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed. | 277 | // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed. |
@@ -223,7 +307,7 @@ namespace OpenSim.Framework.Monitoring | |||
223 | 307 | ||
224 | lock (RegisteredStats) | 308 | lock (RegisteredStats) |
225 | { | 309 | { |
226 | if (!TryGetStat(stat, out category, out container)) | 310 | if (!TryGetStatParents(stat, out category, out container)) |
227 | return false; | 311 | return false; |
228 | 312 | ||
229 | newContainer = new SortedDictionary<string, Stat>(container); | 313 | newContainer = new SortedDictionary<string, Stat>(container); |
@@ -239,12 +323,67 @@ namespace OpenSim.Framework.Monitoring | |||
239 | } | 323 | } |
240 | } | 324 | } |
241 | 325 | ||
242 | public static bool TryGetStats(string category, out SortedDictionary<string, SortedDictionary<string, Stat>> stats) | 326 | public static bool TryGetStat(string category, string container, string statShortName, out Stat stat) |
327 | { | ||
328 | stat = null; | ||
329 | SortedDictionary<string, SortedDictionary<string, Stat>> categoryStats; | ||
330 | |||
331 | lock (RegisteredStats) | ||
332 | { | ||
333 | if (!TryGetStatsForCategory(category, out categoryStats)) | ||
334 | return false; | ||
335 | |||
336 | SortedDictionary<string, Stat> containerStats; | ||
337 | |||
338 | if (!categoryStats.TryGetValue(container, out containerStats)) | ||
339 | return false; | ||
340 | |||
341 | return containerStats.TryGetValue(statShortName, out stat); | ||
342 | } | ||
343 | } | ||
344 | |||
345 | public static bool TryGetStatsForCategory( | ||
346 | string category, out SortedDictionary<string, SortedDictionary<string, Stat>> stats) | ||
243 | { | 347 | { |
244 | return RegisteredStats.TryGetValue(category, out stats); | 348 | lock (RegisteredStats) |
349 | return RegisteredStats.TryGetValue(category, out stats); | ||
350 | } | ||
351 | |||
352 | /// <summary> | ||
353 | /// Get the same stat for each container in a given category. | ||
354 | /// </summary> | ||
355 | /// <returns> | ||
356 | /// The stats if there were any to fetch. Otherwise null. | ||
357 | /// </returns> | ||
358 | /// <param name='category'></param> | ||
359 | /// <param name='statShortName'></param> | ||
360 | public static List<Stat> GetStatsFromEachContainer(string category, string statShortName) | ||
361 | { | ||
362 | SortedDictionary<string, SortedDictionary<string, Stat>> categoryStats; | ||
363 | |||
364 | lock (RegisteredStats) | ||
365 | { | ||
366 | if (!RegisteredStats.TryGetValue(category, out categoryStats)) | ||
367 | return null; | ||
368 | |||
369 | List<Stat> stats = null; | ||
370 | |||
371 | foreach (SortedDictionary<string, Stat> containerStats in categoryStats.Values) | ||
372 | { | ||
373 | if (containerStats.ContainsKey(statShortName)) | ||
374 | { | ||
375 | if (stats == null) | ||
376 | stats = new List<Stat>(); | ||
377 | |||
378 | stats.Add(containerStats[statShortName]); | ||
379 | } | ||
380 | } | ||
381 | |||
382 | return stats; | ||
383 | } | ||
245 | } | 384 | } |
246 | 385 | ||
247 | public static bool TryGetStat( | 386 | public static bool TryGetStatParents( |
248 | Stat stat, | 387 | Stat stat, |
249 | out SortedDictionary<string, SortedDictionary<string, Stat>> category, | 388 | out SortedDictionary<string, SortedDictionary<string, Stat>> category, |
250 | out SortedDictionary<string, Stat> container) | 389 | out SortedDictionary<string, Stat> container) |
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 6c04c69..bfd67c7 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -86,26 +86,23 @@ namespace OpenSim.Framework.Servers | |||
86 | /// </summary> | 86 | /// </summary> |
87 | protected virtual void StartupSpecific() | 87 | protected virtual void StartupSpecific() |
88 | { | 88 | { |
89 | if (m_console == null) | 89 | StatsManager.SimExtraStats = new SimExtraStatsCollector(); |
90 | return; | ||
91 | |||
92 | RegisterCommonCommands(); | 90 | RegisterCommonCommands(); |
93 | 91 | RegisterCommonComponents(Config); | |
94 | m_console.Commands.AddCommand("General", false, "quit", | 92 | } |
95 | "quit", | 93 | |
96 | "Quit the application", HandleQuit); | 94 | protected override void ShutdownSpecific() |
95 | { | ||
96 | m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting..."); | ||
97 | |||
98 | RemovePIDFile(); | ||
97 | 99 | ||
98 | m_console.Commands.AddCommand("General", false, "shutdown", | 100 | base.ShutdownSpecific(); |
99 | "shutdown", | 101 | |
100 | "Quit the application", HandleQuit); | 102 | Environment.Exit(0); |
101 | } | 103 | } |
102 | 104 | ||
103 | /// <summary> | 105 | /// <summary> |
104 | /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing | ||
105 | /// </summary> | ||
106 | public virtual void ShutdownSpecific() {} | ||
107 | |||
108 | /// <summary> | ||
109 | /// Provides a list of help topics that are available. Overriding classes should append their topics to the | 106 | /// Provides a list of help topics that are available. Overriding classes should append their topics to the |
110 | /// information returned when the base method is called. | 107 | /// information returned when the base method is called. |
111 | /// </summary> | 108 | /// </summary> |
@@ -153,25 +150,8 @@ namespace OpenSim.Framework.Servers | |||
153 | timeTaken.Minutes, timeTaken.Seconds); | 150 | timeTaken.Minutes, timeTaken.Seconds); |
154 | } | 151 | } |
155 | 152 | ||
156 | /// <summary> | 153 | public string osSecret |
157 | /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing | ||
158 | /// </summary> | ||
159 | public virtual void Shutdown() | ||
160 | { | 154 | { |
161 | ShutdownSpecific(); | ||
162 | |||
163 | m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting..."); | ||
164 | RemovePIDFile(); | ||
165 | |||
166 | Environment.Exit(0); | ||
167 | } | ||
168 | |||
169 | private void HandleQuit(string module, string[] args) | ||
170 | { | ||
171 | Shutdown(); | ||
172 | } | ||
173 | |||
174 | public string osSecret { | ||
175 | // Secret uuid for the simulator | 155 | // Secret uuid for the simulator |
176 | get { return m_osSecret; } | 156 | get { return m_osSecret; } |
177 | } | 157 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 97035e3..f4b4156 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -54,7 +54,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); | 55 | private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); |
56 | 56 | ||
57 | |||
58 | /// <summary> | 57 | /// <summary> |
59 | /// This is a pending websocket request before it got an sucessful upgrade response. | 58 | /// This is a pending websocket request before it got an sucessful upgrade response. |
60 | /// The consumer must call handler.HandshakeAndUpgrade() to signal to the handler to | 59 | /// The consumer must call handler.HandshakeAndUpgrade() to signal to the handler to |
@@ -81,6 +80,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
81 | /// </remarks> | 80 | /// </remarks> |
82 | public int RequestNumber { get; private set; } | 81 | public int RequestNumber { get; private set; } |
83 | 82 | ||
83 | /// <summary> | ||
84 | /// Statistic for holding number of requests processed. | ||
85 | /// </summary> | ||
86 | private Stat m_requestsProcessedStat; | ||
87 | |||
84 | private volatile int NotSocketErrors = 0; | 88 | private volatile int NotSocketErrors = 0; |
85 | public volatile bool HTTPDRunning = false; | 89 | public volatile bool HTTPDRunning = false; |
86 | 90 | ||
@@ -383,6 +387,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
383 | 387 | ||
384 | if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) | 388 | if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) |
385 | { | 389 | { |
390 | psEvArgs.RequestsReceived++; | ||
391 | |||
386 | PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); | 392 | PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); |
387 | 393 | ||
388 | if (psEvArgs.Request != null) | 394 | if (psEvArgs.Request != null) |
@@ -437,9 +443,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
437 | } | 443 | } |
438 | } | 444 | } |
439 | 445 | ||
440 | public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request) | 446 | private void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request) |
441 | { | 447 | { |
442 | |||
443 | OSHttpRequest req = new OSHttpRequest(context, request); | 448 | OSHttpRequest req = new OSHttpRequest(context, request); |
444 | WebSocketRequestDelegate dWebSocketRequestDelegate = null; | 449 | WebSocketRequestDelegate dWebSocketRequestDelegate = null; |
445 | lock (m_WebSocketHandlers) | 450 | lock (m_WebSocketHandlers) |
@@ -454,9 +459,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
454 | } | 459 | } |
455 | 460 | ||
456 | OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); | 461 | OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); |
457 | 462 | resp.ReuseContext = true; | |
458 | HandleRequest(req, resp); | 463 | HandleRequest(req, resp); |
459 | |||
460 | 464 | ||
461 | // !!!HACK ALERT!!! | 465 | // !!!HACK ALERT!!! |
462 | // There seems to be a bug in the underlying http code that makes subsequent requests | 466 | // There seems to be a bug in the underlying http code that makes subsequent requests |
@@ -687,7 +691,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
687 | 691 | ||
688 | if (buffer != null) | 692 | if (buffer != null) |
689 | { | 693 | { |
690 | if (!response.SendChunked) | 694 | if (!response.SendChunked && response.ContentLength64 <= 0) |
691 | response.ContentLength64 = buffer.LongLength; | 695 | response.ContentLength64 = buffer.LongLength; |
692 | 696 | ||
693 | response.OutputStream.Write(buffer, 0, buffer.Length); | 697 | response.OutputStream.Write(buffer, 0, buffer.Length); |
@@ -1850,8 +1854,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1850 | m_httpListener2.Start(64); | 1854 | m_httpListener2.Start(64); |
1851 | 1855 | ||
1852 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events | 1856 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events |
1853 | // m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); | ||
1854 | m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000); | 1857 | m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000); |
1858 | m_PollServiceManager.Start(); | ||
1855 | HTTPDRunning = true; | 1859 | HTTPDRunning = true; |
1856 | 1860 | ||
1857 | //HttpListenerContext context; | 1861 | //HttpListenerContext context; |
@@ -1870,6 +1874,21 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1870 | // useful without inbound HTTP. | 1874 | // useful without inbound HTTP. |
1871 | throw e; | 1875 | throw e; |
1872 | } | 1876 | } |
1877 | |||
1878 | m_requestsProcessedStat | ||
1879 | = new Stat( | ||
1880 | "HTTPRequestsServed", | ||
1881 | "Number of inbound HTTP requests processed", | ||
1882 | "", | ||
1883 | "requests", | ||
1884 | "httpserver", | ||
1885 | Port.ToString(), | ||
1886 | StatType.Pull, | ||
1887 | MeasuresOfInterest.AverageChangeOverTime, | ||
1888 | stat => stat.Value = RequestNumber, | ||
1889 | StatVerbosity.Debug); | ||
1890 | |||
1891 | StatsManager.RegisterStat(m_requestsProcessedStat); | ||
1873 | } | 1892 | } |
1874 | 1893 | ||
1875 | public void httpServerDisconnectMonitor(IHttpClientContext source, SocketError err) | 1894 | public void httpServerDisconnectMonitor(IHttpClientContext source, SocketError err) |
@@ -1902,9 +1921,12 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1902 | public void Stop() | 1921 | public void Stop() |
1903 | { | 1922 | { |
1904 | HTTPDRunning = false; | 1923 | HTTPDRunning = false; |
1924 | |||
1925 | StatsManager.DeregisterStat(m_requestsProcessedStat); | ||
1926 | |||
1905 | try | 1927 | try |
1906 | { | 1928 | { |
1907 | // m_PollServiceManager.Stop(); | 1929 | m_PollServiceManager.Stop(); |
1908 | 1930 | ||
1909 | m_httpListener2.ExceptionThrown -= httpServerException; | 1931 | m_httpListener2.ExceptionThrown -= httpServerException; |
1910 | //m_httpListener2.DisconnectHandler = null; | 1932 | //m_httpListener2.DisconnectHandler = null; |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseOutputStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseOutputStreamHandler.cs new file mode 100644 index 0000000..72b3065 --- /dev/null +++ b/OpenSim/Framework/Servers/HttpServer/BaseOutputStreamHandler.cs | |||
@@ -0,0 +1,60 @@ | |||
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 | |||
28 | using System.IO; | ||
29 | |||
30 | namespace OpenSim.Framework.Servers.HttpServer | ||
31 | { | ||
32 | /// <summary> | ||
33 | /// Base handler for writing to an output stream | ||
34 | /// </summary> | ||
35 | /// <remarks> | ||
36 | /// Inheriting classes should override ProcessRequest() rather than Handle() | ||
37 | /// </remarks> | ||
38 | public abstract class BaseOutputStreamHandler : BaseRequestHandler, IRequestHandler | ||
39 | { | ||
40 | protected BaseOutputStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} | ||
41 | |||
42 | protected BaseOutputStreamHandler(string httpMethod, string path, string name, string description) | ||
43 | : base(httpMethod, path, name, description) {} | ||
44 | |||
45 | public virtual void Handle( | ||
46 | string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
47 | { | ||
48 | RequestsReceived++; | ||
49 | |||
50 | ProcessRequest(path, request, response, httpRequest, httpResponse); | ||
51 | |||
52 | RequestsHandled++; | ||
53 | } | ||
54 | |||
55 | protected virtual void ProcessRequest( | ||
56 | string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
57 | { | ||
58 | } | ||
59 | } | ||
60 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs index ae7aaf2..bbac699 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs | |||
@@ -31,6 +31,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
31 | { | 31 | { |
32 | public abstract class BaseRequestHandler | 32 | public abstract class BaseRequestHandler |
33 | { | 33 | { |
34 | public int RequestsReceived { get; protected set; } | ||
35 | |||
36 | public int RequestsHandled { get; protected set; } | ||
37 | |||
34 | public virtual string ContentType | 38 | public virtual string ContentType |
35 | { | 39 | { |
36 | get { return "application/xml"; } | 40 | get { return "application/xml"; } |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs index 6342983..252cc2a 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs | |||
@@ -29,14 +29,35 @@ using System.IO; | |||
29 | 29 | ||
30 | namespace OpenSim.Framework.Servers.HttpServer | 30 | namespace OpenSim.Framework.Servers.HttpServer |
31 | { | 31 | { |
32 | /// <summary> | ||
33 | /// Base streamed request handler. | ||
34 | /// </summary> | ||
35 | /// <remarks> | ||
36 | /// Inheriting classes should override ProcessRequest() rather than Handle() | ||
37 | /// </remarks> | ||
32 | public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler | 38 | public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler |
33 | { | 39 | { |
34 | public abstract byte[] Handle(string path, Stream request, | ||
35 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse); | ||
36 | |||
37 | protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} | 40 | protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} |
38 | 41 | ||
39 | protected BaseStreamHandler(string httpMethod, string path, string name, string description) | 42 | protected BaseStreamHandler(string httpMethod, string path, string name, string description) |
40 | : base(httpMethod, path, name, description) {} | 43 | : base(httpMethod, path, name, description) {} |
44 | |||
45 | public virtual byte[] Handle( | ||
46 | string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
47 | { | ||
48 | RequestsReceived++; | ||
49 | |||
50 | byte[] result = ProcessRequest(path, request, httpRequest, httpResponse); | ||
51 | |||
52 | RequestsHandled++; | ||
53 | |||
54 | return result; | ||
55 | } | ||
56 | |||
57 | protected virtual byte[] ProcessRequest( | ||
58 | string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
59 | { | ||
60 | return null; | ||
61 | } | ||
41 | } | 62 | } |
42 | } \ No newline at end of file | 63 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs index b94bfb4..1b03f54 100644 --- a/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs | |||
@@ -45,7 +45,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
45 | m_method = binaryMethod; | 45 | m_method = binaryMethod; |
46 | } | 46 | } |
47 | 47 | ||
48 | public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 48 | protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
49 | { | 49 | { |
50 | byte[] data = ReadFully(request); | 50 | byte[] data = ReadFully(request); |
51 | string param = GetParam(path); | 51 | string param = GetParam(path); |
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs index cb5cce5..b8541cb 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs | |||
@@ -32,7 +32,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
32 | { | 32 | { |
33 | public interface IRequestHandler | 33 | public interface IRequestHandler |
34 | { | 34 | { |
35 | |||
36 | /// <summary> | 35 | /// <summary> |
37 | /// Name for this handler. | 36 | /// Name for this handler. |
38 | /// </summary> | 37 | /// </summary> |
@@ -59,6 +58,19 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
59 | 58 | ||
60 | // Return path | 59 | // Return path |
61 | string Path { get; } | 60 | string Path { get; } |
61 | |||
62 | /// <summary> | ||
63 | /// Number of requests received by this handler | ||
64 | /// </summary> | ||
65 | int RequestsReceived { get; } | ||
66 | |||
67 | /// <summary> | ||
68 | /// Number of requests handled. | ||
69 | /// </summary> | ||
70 | /// <remarks> | ||
71 | /// Should be equal to RequestsReceived unless requested are being handled slowly or there is deadlock. | ||
72 | /// </remarks> | ||
73 | int RequestsHandled { get; } | ||
62 | } | 74 | } |
63 | 75 | ||
64 | public interface IStreamedRequestHandler : IRequestHandler | 76 | public interface IStreamedRequestHandler : IRequestHandler |
@@ -69,7 +81,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
69 | 81 | ||
70 | public interface IStreamHandler : IRequestHandler | 82 | public interface IStreamHandler : IRequestHandler |
71 | { | 83 | { |
72 | // Handle request stream, return byte array | ||
73 | void Handle(string path, Stream request, Stream response, IOSHttpRequest httpReqbuest, IOSHttpResponse httpResponse); | 84 | void Handle(string path, Stream request, Stream response, IOSHttpRequest httpReqbuest, IOSHttpResponse httpResponse); |
74 | } | 85 | } |
75 | 86 | ||
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index c19ac32..3fd3bf7 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs | |||
@@ -50,25 +50,39 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
50 | 50 | ||
51 | public enum EventType : int | 51 | public enum EventType : int |
52 | { | 52 | { |
53 | Normal = 0, | 53 | LongPoll = 0, |
54 | LslHttp = 1, | 54 | LslHttp = 1, |
55 | Inventory = 2, | 55 | Inventory = 2, |
56 | Texture = 3, | 56 | Texture = 3, |
57 | Mesh = 4 | 57 | Mesh = 4 |
58 | } | 58 | } |
59 | 59 | ||
60 | public string Url { get; set; } | ||
61 | |||
62 | /// <summary> | ||
63 | /// Number of requests received for this poll service. | ||
64 | /// </summary> | ||
65 | public int RequestsReceived { get; set; } | ||
66 | |||
67 | /// <summary> | ||
68 | /// Number of requests handled by this poll service. | ||
69 | /// </summary> | ||
70 | public int RequestsHandled { get; set; } | ||
71 | |||
60 | public PollServiceEventArgs( | 72 | public PollServiceEventArgs( |
61 | RequestMethod pRequest, | 73 | RequestMethod pRequest, |
74 | string pUrl, | ||
62 | HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, | 75 | HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, |
63 | UUID pId, int pTimeOutms) | 76 | UUID pId, int pTimeOutms) |
64 | { | 77 | { |
65 | Request = pRequest; | 78 | Request = pRequest; |
79 | Url = pUrl; | ||
66 | HasEvents = pHasEvents; | 80 | HasEvents = pHasEvents; |
67 | GetEvents = pGetEvents; | 81 | GetEvents = pGetEvents; |
68 | NoEvents = pNoEvents; | 82 | NoEvents = pNoEvents; |
69 | Id = pId; | 83 | Id = pId; |
70 | TimeOutms = pTimeOutms; | 84 | TimeOutms = pTimeOutms; |
71 | Type = EventType.Normal; | 85 | Type = EventType.LongPoll; |
72 | } | 86 | } |
73 | } | 87 | } |
74 | } | 88 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs index 723530a..6aa9479 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs | |||
@@ -26,13 +26,19 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
29 | using HttpServer; | 32 | using HttpServer; |
33 | using log4net; | ||
30 | using OpenMetaverse; | 34 | using OpenMetaverse; |
31 | 35 | ||
32 | namespace OpenSim.Framework.Servers.HttpServer | 36 | namespace OpenSim.Framework.Servers.HttpServer |
33 | { | 37 | { |
34 | public class PollServiceHttpRequest | 38 | public class PollServiceHttpRequest |
35 | { | 39 | { |
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
41 | |||
36 | public readonly PollServiceEventArgs PollServiceArgs; | 42 | public readonly PollServiceEventArgs PollServiceArgs; |
37 | public readonly IHttpClientContext HttpContext; | 43 | public readonly IHttpClientContext HttpContext; |
38 | public readonly IHttpRequest Request; | 44 | public readonly IHttpRequest Request; |
@@ -48,5 +54,44 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
48 | RequestTime = System.Environment.TickCount; | 54 | RequestTime = System.Environment.TickCount; |
49 | RequestID = UUID.Random(); | 55 | RequestID = UUID.Random(); |
50 | } | 56 | } |
57 | |||
58 | internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata) | ||
59 | { | ||
60 | OSHttpResponse response | ||
61 | = new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext); | ||
62 | |||
63 | byte[] buffer = server.DoHTTPGruntWork(responsedata, response); | ||
64 | |||
65 | response.SendChunked = false; | ||
66 | response.ContentLength64 = buffer.Length; | ||
67 | response.ContentEncoding = Encoding.UTF8; | ||
68 | |||
69 | try | ||
70 | { | ||
71 | response.OutputStream.Write(buffer, 0, buffer.Length); | ||
72 | } | ||
73 | catch (Exception ex) | ||
74 | { | ||
75 | m_log.Warn(string.Format("[POLL SERVICE WORKER THREAD]: Error ", ex)); | ||
76 | } | ||
77 | finally | ||
78 | { | ||
79 | //response.OutputStream.Close(); | ||
80 | try | ||
81 | { | ||
82 | response.OutputStream.Flush(); | ||
83 | response.Send(); | ||
84 | |||
85 | //if (!response.KeepAlive && response.ReuseContext) | ||
86 | // response.FreeContext(); | ||
87 | } | ||
88 | catch (Exception e) | ||
89 | { | ||
90 | m_log.Warn(String.Format("[POLL SERVICE WORKER THREAD]: Error ", e)); | ||
91 | } | ||
92 | |||
93 | PollServiceArgs.RequestsHandled++; | ||
94 | } | ||
95 | } | ||
51 | } | 96 | } |
52 | } \ No newline at end of file | 97 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 5406f00..44f7045 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | |||
@@ -64,14 +64,17 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
64 | m_server = pSrv; | 64 | m_server = pSrv; |
65 | m_WorkerThreadCount = pWorkerThreadCount; | 65 | m_WorkerThreadCount = pWorkerThreadCount; |
66 | m_workerThreads = new Thread[m_WorkerThreadCount]; | 66 | m_workerThreads = new Thread[m_WorkerThreadCount]; |
67 | } | ||
67 | 68 | ||
69 | public void Start() | ||
70 | { | ||
68 | //startup worker threads | 71 | //startup worker threads |
69 | for (uint i = 0; i < m_WorkerThreadCount; i++) | 72 | for (uint i = 0; i < m_WorkerThreadCount; i++) |
70 | { | 73 | { |
71 | m_workerThreads[i] | 74 | m_workerThreads[i] |
72 | = Watchdog.StartThread( | 75 | = Watchdog.StartThread( |
73 | PoolWorkerJob, | 76 | PoolWorkerJob, |
74 | String.Format("PollServiceWorkerThread{0}", i), | 77 | string.Format("PollServiceWorkerThread{0}:{1}", i, m_server.Port), |
75 | ThreadPriority.Normal, | 78 | ThreadPriority.Normal, |
76 | false, | 79 | false, |
77 | false, | 80 | false, |
@@ -81,7 +84,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
81 | 84 | ||
82 | m_retrysThread = Watchdog.StartThread( | 85 | m_retrysThread = Watchdog.StartThread( |
83 | this.CheckRetries, | 86 | this.CheckRetries, |
84 | "PollServiceWatcherThread", | 87 | string.Format("PollServiceWatcherThread:{0}", m_server.Port), |
85 | ThreadPriority.Normal, | 88 | ThreadPriority.Normal, |
86 | false, | 89 | false, |
87 | true, | 90 | true, |
@@ -89,7 +92,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
89 | 1000 * 60 * 10); | 92 | 1000 * 60 * 10); |
90 | } | 93 | } |
91 | 94 | ||
92 | |||
93 | private void ReQueueEvent(PollServiceHttpRequest req) | 95 | private void ReQueueEvent(PollServiceHttpRequest req) |
94 | { | 96 | { |
95 | if (m_running) | 97 | if (m_running) |
@@ -103,7 +105,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
103 | { | 105 | { |
104 | if (m_running) | 106 | if (m_running) |
105 | { | 107 | { |
106 | if (req.PollServiceArgs.Type != PollServiceEventArgs.EventType.Normal) | 108 | if (req.PollServiceArgs.Type != PollServiceEventArgs.EventType.LongPoll) |
107 | { | 109 | { |
108 | m_requests.Enqueue(req); | 110 | m_requests.Enqueue(req); |
109 | } | 111 | } |
@@ -140,13 +142,13 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
140 | } | 142 | } |
141 | } | 143 | } |
142 | 144 | ||
143 | ~PollServiceRequestManager() | 145 | public void Stop() |
144 | { | 146 | { |
145 | m_running = false; | 147 | m_running = false; |
146 | Thread.Sleep(1000); // let the world move | 148 | Thread.Sleep(1000); // let the world move |
147 | 149 | ||
148 | foreach (Thread t in m_workerThreads) | 150 | foreach (Thread t in m_workerThreads) |
149 | Watchdog.AbortThread(t.ManagedThreadId); | 151 | Watchdog.AbortThread(t.ManagedThreadId); |
150 | 152 | ||
151 | try | 153 | try |
152 | { | 154 | { |
@@ -205,7 +207,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
205 | if (responsedata == null) | 207 | if (responsedata == null) |
206 | continue; | 208 | continue; |
207 | 209 | ||
208 | if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Normal) // This is the event queue | 210 | if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) // This is the event queue |
209 | { | 211 | { |
210 | try | 212 | try |
211 | { | 213 | { |
diff --git a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs index 07082a8..bd55657 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs | |||
@@ -33,7 +33,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
33 | { | 33 | { |
34 | public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request); | 34 | public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request); |
35 | 35 | ||
36 | public class RestDeserialiseHandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler | 36 | public class RestDeserialiseHandler<TRequest, TResponse> : BaseOutputStreamHandler, IStreamHandler |
37 | where TRequest : new() | 37 | where TRequest : new() |
38 | { | 38 | { |
39 | private RestDeserialiseMethod<TRequest, TResponse> m_method; | 39 | private RestDeserialiseMethod<TRequest, TResponse> m_method; |
@@ -48,7 +48,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
48 | m_method = method; | 48 | m_method = method; |
49 | } | 49 | } |
50 | 50 | ||
51 | public void Handle(string path, Stream request, Stream responseStream, | 51 | protected override void ProcessRequest(string path, Stream request, Stream responseStream, |
52 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 52 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
53 | { | 53 | { |
54 | TRequest deserial; | 54 | TRequest deserial; |
diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs index edcd134..83c9848 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs | |||
@@ -183,7 +183,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
183 | 183 | ||
184 | public delegate bool CheckIdentityMethod(string sid, string aid); | 184 | public delegate bool CheckIdentityMethod(string sid, string aid); |
185 | 185 | ||
186 | public class RestDeserialiseSecureHandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler | 186 | public class RestDeserialiseSecureHandler<TRequest, TResponse> : BaseOutputStreamHandler, IStreamHandler |
187 | where TRequest : new() | 187 | where TRequest : new() |
188 | { | 188 | { |
189 | private static readonly ILog m_log | 189 | private static readonly ILog m_log |
@@ -201,7 +201,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
201 | m_method = method; | 201 | m_method = method; |
202 | } | 202 | } |
203 | 203 | ||
204 | public void Handle(string path, Stream request, Stream responseStream, | 204 | protected override void ProcessRequest(string path, Stream request, Stream responseStream, |
205 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 205 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
206 | { | 206 | { |
207 | RestSessionObject<TRequest> deserial = default(RestSessionObject<TRequest>); | 207 | RestSessionObject<TRequest> deserial = default(RestSessionObject<TRequest>); |
@@ -237,7 +237,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
237 | 237 | ||
238 | public delegate bool CheckTrustedSourceMethod(IPEndPoint peer); | 238 | public delegate bool CheckTrustedSourceMethod(IPEndPoint peer); |
239 | 239 | ||
240 | public class RestDeserialiseTrustedHandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler | 240 | public class RestDeserialiseTrustedHandler<TRequest, TResponse> : BaseOutputStreamHandler, IStreamHandler |
241 | where TRequest : new() | 241 | where TRequest : new() |
242 | { | 242 | { |
243 | private static readonly ILog m_log | 243 | private static readonly ILog m_log |
@@ -260,7 +260,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
260 | m_method = method; | 260 | m_method = method; |
261 | } | 261 | } |
262 | 262 | ||
263 | public void Handle(string path, Stream request, Stream responseStream, | 263 | protected override void ProcessRequest(string path, Stream request, Stream responseStream, |
264 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 264 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
265 | { | 265 | { |
266 | TRequest deserial = default(TRequest); | 266 | TRequest deserial = default(TRequest); |
@@ -292,6 +292,5 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
292 | serializer.Serialize(xmlWriter, response); | 292 | serializer.Serialize(xmlWriter, response); |
293 | } | 293 | } |
294 | } | 294 | } |
295 | } | 295 | } |
296 | 296 | } \ No newline at end of file | |
297 | } | ||
diff --git a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs index 1f17fee..0305dee 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs | |||
@@ -48,7 +48,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
48 | m_restMethod = restMethod; | 48 | m_restMethod = restMethod; |
49 | } | 49 | } |
50 | 50 | ||
51 | public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 51 | protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
52 | { | 52 | { |
53 | Encoding encoding = Encoding.UTF8; | 53 | Encoding encoding = Encoding.UTF8; |
54 | StreamReader streamReader = new StreamReader(request, encoding); | 54 | StreamReader streamReader = new StreamReader(request, encoding); |
diff --git a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs index ee96b47..de89e2e 100644 --- a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs | |||
@@ -75,7 +75,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
75 | /// <summary> | 75 | /// <summary> |
76 | /// This is a regular HTTP Request... This may be removed in the future. | 76 | /// This is a regular HTTP Request... This may be removed in the future. |
77 | /// </summary> | 77 | /// </summary> |
78 | public event RegularHttpRequestDelegate OnRegularHttpRequest; | 78 | // public event RegularHttpRequestDelegate OnRegularHttpRequest; |
79 | 79 | ||
80 | /// <summary> | 80 | /// <summary> |
81 | /// When the upgrade from a HTTP request to a Websocket is completed, this will be fired | 81 | /// When the upgrade from a HTTP request to a Websocket is completed, this will be fired |
@@ -304,15 +304,14 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
304 | if (d != null) | 304 | if (d != null) |
305 | d(this, new UpgradeCompletedEventArgs()); | 305 | d(this, new UpgradeCompletedEventArgs()); |
306 | } | 306 | } |
307 | catch (IOException fail) | 307 | catch (IOException) |
308 | { | 308 | { |
309 | Close(string.Empty); | 309 | Close(string.Empty); |
310 | } | 310 | } |
311 | catch (ObjectDisposedException fail) | 311 | catch (ObjectDisposedException) |
312 | { | 312 | { |
313 | Close(string.Empty); | 313 | Close(string.Empty); |
314 | } | 314 | } |
315 | |||
316 | } | 315 | } |
317 | 316 | ||
318 | /// <summary> | 317 | /// <summary> |
@@ -414,8 +413,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
414 | _socketState.Header = pheader; | 413 | _socketState.Header = pheader; |
415 | } | 414 | } |
416 | 415 | ||
417 | |||
418 | |||
419 | if (_socketState.FrameComplete) | 416 | if (_socketState.FrameComplete) |
420 | { | 417 | { |
421 | ProcessFrame(_socketState); | 418 | ProcessFrame(_socketState); |
@@ -424,7 +421,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
424 | _socketState.ExpectedBytes = 0; | 421 | _socketState.ExpectedBytes = 0; |
425 | 422 | ||
426 | } | 423 | } |
427 | |||
428 | } | 424 | } |
429 | } | 425 | } |
430 | else | 426 | else |
@@ -457,8 +453,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
457 | _socketState.ReceivedBytes.Clear(); | 453 | _socketState.ReceivedBytes.Clear(); |
458 | _socketState.ExpectedBytes = 0; | 454 | _socketState.ExpectedBytes = 0; |
459 | // do some processing | 455 | // do some processing |
460 | } | 456 | } |
461 | |||
462 | } | 457 | } |
463 | } | 458 | } |
464 | if (offset > 0) | 459 | if (offset > 0) |
@@ -477,13 +472,12 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
477 | { | 472 | { |
478 | // We can't read the stream anymore... | 473 | // We can't read the stream anymore... |
479 | } | 474 | } |
480 | |||
481 | } | 475 | } |
482 | catch (IOException fail) | 476 | catch (IOException) |
483 | { | 477 | { |
484 | Close(string.Empty); | 478 | Close(string.Empty); |
485 | } | 479 | } |
486 | catch (ObjectDisposedException fail) | 480 | catch (ObjectDisposedException) |
487 | { | 481 | { |
488 | Close(string.Empty); | 482 | Close(string.Empty); |
489 | } | 483 | } |
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index cfd34bb..57931d4 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs | |||
@@ -121,12 +121,14 @@ namespace OpenSim.Framework.Servers | |||
121 | + " level >= 2 then long warnings are logged when receiving bad input data.\n" | 121 | + " level >= 2 then long warnings are logged when receiving bad input data.\n" |
122 | + " level >= 3 then short notices about all incoming non-poll HTTP requests are logged.\n" | 122 | + " level >= 3 then short notices about all incoming non-poll HTTP requests are logged.\n" |
123 | + " level >= 4 then the time taken to fulfill the request is logged.\n" | 123 | + " level >= 4 then the time taken to fulfill the request is logged.\n" |
124 | + " level >= 5 then a sample from the beginning of the incoming data is logged.\n" | 124 | + " level >= 5 then a sample from the beginning of the data is logged.\n" |
125 | + " level >= 6 then the entire incoming data is logged.\n" | 125 | + " level >= 6 then the entire data is logged.\n" |
126 | + " no level is specified then the current level is returned.\n\n" | 126 | + " no level is specified then the current level is returned.\n\n" |
127 | + "If out or all and\n" | 127 | + "If out or all and\n" |
128 | + " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\n" | 128 | + " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\n" |
129 | + " level >= 4 then the time taken to fulfill the request is logged.\n", | 129 | + " level >= 4 then the time taken to fulfill the request is logged.\n" |
130 | + " level >= 5 then a sample from the beginning of the data is logged.\n" | ||
131 | + " level >= 6 then the entire data is logged.\n", | ||
130 | HandleDebugHttpCommand); | 132 | HandleDebugHttpCommand); |
131 | } | 133 | } |
132 | 134 | ||
@@ -283,7 +285,12 @@ namespace OpenSim.Framework.Servers | |||
283 | public static bool RemoveHttpServer(uint port) | 285 | public static bool RemoveHttpServer(uint port) |
284 | { | 286 | { |
285 | lock (m_Servers) | 287 | lock (m_Servers) |
288 | { | ||
289 | if (instance != null && instance.Port == port) | ||
290 | instance = null; | ||
291 | |||
286 | return m_Servers.Remove(port); | 292 | return m_Servers.Remove(port); |
293 | } | ||
287 | } | 294 | } |
288 | 295 | ||
289 | /// <summary> | 296 | /// <summary> |
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 1ff8aca..eb8c9f8 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs | |||
@@ -62,6 +62,8 @@ namespace OpenSim.Framework.Servers | |||
62 | 62 | ||
63 | protected string m_pidFile = String.Empty; | 63 | protected string m_pidFile = String.Empty; |
64 | 64 | ||
65 | protected ServerStatsCollector m_serverStatsCollector; | ||
66 | |||
65 | /// <summary> | 67 | /// <summary> |
66 | /// Server version information. Usually VersionInfo + information about git commit, operating system, etc. | 68 | /// Server version information. Usually VersionInfo + information about git commit, operating system, etc. |
67 | /// </summary> | 69 | /// </summary> |
@@ -76,6 +78,11 @@ namespace OpenSim.Framework.Servers | |||
76 | 78 | ||
77 | protected void CreatePIDFile(string path) | 79 | protected void CreatePIDFile(string path) |
78 | { | 80 | { |
81 | if (File.Exists(path)) | ||
82 | m_log.ErrorFormat( | ||
83 | "[SERVER BASE]: Previous pid file {0} still exists on startup. Possibly previously unclean shutdown.", | ||
84 | path); | ||
85 | |||
79 | try | 86 | try |
80 | { | 87 | { |
81 | string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); | 88 | string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); |
@@ -254,6 +261,25 @@ namespace OpenSim.Framework.Servers | |||
254 | "force gc", | 261 | "force gc", |
255 | "Manually invoke runtime garbage collection. For debugging purposes", | 262 | "Manually invoke runtime garbage collection. For debugging purposes", |
256 | HandleForceGc); | 263 | HandleForceGc); |
264 | |||
265 | m_console.Commands.AddCommand( | ||
266 | "General", false, "quit", | ||
267 | "quit", | ||
268 | "Quit the application", (mod, args) => Shutdown()); | ||
269 | |||
270 | m_console.Commands.AddCommand( | ||
271 | "General", false, "shutdown", | ||
272 | "shutdown", | ||
273 | "Quit the application", (mod, args) => Shutdown()); | ||
274 | |||
275 | StatsManager.RegisterConsoleCommands(m_console); | ||
276 | } | ||
277 | |||
278 | public void RegisterCommonComponents(IConfigSource configSource) | ||
279 | { | ||
280 | m_serverStatsCollector = new ServerStatsCollector(); | ||
281 | m_serverStatsCollector.Initialise(configSource); | ||
282 | m_serverStatsCollector.Start(); | ||
257 | } | 283 | } |
258 | 284 | ||
259 | private void HandleForceGc(string module, string[] args) | 285 | private void HandleForceGc(string module, string[] args) |
@@ -641,7 +667,68 @@ namespace OpenSim.Framework.Servers | |||
641 | sb.AppendFormat("Total threads active: {0}\n\n", totalThreads); | 667 | sb.AppendFormat("Total threads active: {0}\n\n", totalThreads); |
642 | 668 | ||
643 | sb.Append("Main threadpool (excluding script engine pools)\n"); | 669 | sb.Append("Main threadpool (excluding script engine pools)\n"); |
644 | sb.Append(Util.GetThreadPoolReport()); | 670 | sb.Append(GetThreadPoolReport()); |
671 | |||
672 | return sb.ToString(); | ||
673 | } | ||
674 | |||
675 | /// <summary> | ||
676 | /// Get a thread pool report. | ||
677 | /// </summary> | ||
678 | /// <returns></returns> | ||
679 | public static string GetThreadPoolReport() | ||
680 | { | ||
681 | string threadPoolUsed = null; | ||
682 | int maxThreads = 0; | ||
683 | int minThreads = 0; | ||
684 | int allocatedThreads = 0; | ||
685 | int inUseThreads = 0; | ||
686 | int waitingCallbacks = 0; | ||
687 | int completionPortThreads = 0; | ||
688 | |||
689 | StringBuilder sb = new StringBuilder(); | ||
690 | if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool) | ||
691 | { | ||
692 | STPInfo stpi = Util.GetSmartThreadPoolInfo(); | ||
693 | |||
694 | // ROBUST currently leaves this the FireAndForgetMethod but never actually initializes the threadpool. | ||
695 | if (stpi != null) | ||
696 | { | ||
697 | threadPoolUsed = "SmartThreadPool"; | ||
698 | maxThreads = stpi.MaxThreads; | ||
699 | minThreads = stpi.MinThreads; | ||
700 | inUseThreads = stpi.InUseThreads; | ||
701 | allocatedThreads = stpi.ActiveThreads; | ||
702 | waitingCallbacks = stpi.WaitingCallbacks; | ||
703 | } | ||
704 | } | ||
705 | else if ( | ||
706 | Util.FireAndForgetMethod == FireAndForgetMethod.QueueUserWorkItem | ||
707 | || Util.FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem) | ||
708 | { | ||
709 | threadPoolUsed = "BuiltInThreadPool"; | ||
710 | ThreadPool.GetMaxThreads(out maxThreads, out completionPortThreads); | ||
711 | ThreadPool.GetMinThreads(out minThreads, out completionPortThreads); | ||
712 | int availableThreads; | ||
713 | ThreadPool.GetAvailableThreads(out availableThreads, out completionPortThreads); | ||
714 | inUseThreads = maxThreads - availableThreads; | ||
715 | allocatedThreads = -1; | ||
716 | waitingCallbacks = -1; | ||
717 | } | ||
718 | |||
719 | if (threadPoolUsed != null) | ||
720 | { | ||
721 | sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed); | ||
722 | sb.AppendFormat("Max threads : {0}\n", maxThreads); | ||
723 | sb.AppendFormat("Min threads : {0}\n", minThreads); | ||
724 | sb.AppendFormat("Allocated threads : {0}\n", allocatedThreads < 0 ? "not applicable" : allocatedThreads.ToString()); | ||
725 | sb.AppendFormat("In use threads : {0}\n", inUseThreads); | ||
726 | sb.AppendFormat("Work items waiting : {0}\n", waitingCallbacks < 0 ? "not available" : waitingCallbacks.ToString()); | ||
727 | } | ||
728 | else | ||
729 | { | ||
730 | sb.AppendFormat("Thread pool not used\n"); | ||
731 | } | ||
645 | 732 | ||
646 | return sb.ToString(); | 733 | return sb.ToString(); |
647 | } | 734 | } |
@@ -693,5 +780,16 @@ namespace OpenSim.Framework.Servers | |||
693 | if (m_console != null) | 780 | if (m_console != null) |
694 | m_console.OutputFormat(format, components); | 781 | m_console.OutputFormat(format, components); |
695 | } | 782 | } |
783 | |||
784 | public virtual void Shutdown() | ||
785 | { | ||
786 | m_serverStatsCollector.Close(); | ||
787 | ShutdownSpecific(); | ||
788 | } | ||
789 | |||
790 | /// <summary> | ||
791 | /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing | ||
792 | /// </summary> | ||
793 | protected virtual void ShutdownSpecific() {} | ||
696 | } | 794 | } |
697 | } | 795 | } |
diff --git a/OpenSim/Framework/Tests/LocationTest.cs b/OpenSim/Framework/Tests/LocationTest.cs index a56ecb4..af5f164 100644 --- a/OpenSim/Framework/Tests/LocationTest.cs +++ b/OpenSim/Framework/Tests/LocationTest.cs | |||
@@ -51,21 +51,21 @@ namespace OpenSim.Framework.Tests | |||
51 | [Test] | 51 | [Test] |
52 | public void locationXYRegionHandle() | 52 | public void locationXYRegionHandle() |
53 | { | 53 | { |
54 | Location TestLocation1 = new Location(256000,256000); | 54 | Location TestLocation1 = new Location(255000,256000); |
55 | Location TestLocation2 = new Location(1099511628032000); | 55 | Location TestLocation2 = new Location(1095216660736000); |
56 | Assert.That(TestLocation1 == TestLocation2); | 56 | Assert.That(TestLocation1 == TestLocation2); |
57 | 57 | ||
58 | Assert.That(TestLocation2.X == 256000 && TestLocation2.Y == 256000, "Test xy location doesn't match regionhandle provided"); | 58 | Assert.That(TestLocation2.X == 255000 && TestLocation2.Y == 256000, "Test xy location doesn't match regionhandle provided"); |
59 | 59 | ||
60 | Assert.That(TestLocation2.RegionHandle == 1099511628032000, | 60 | Assert.That(TestLocation2.RegionHandle == 1095216660736000, |
61 | "Location RegionHandle Property didn't match regionhandle provided in constructor"); | 61 | "Location RegionHandle Property didn't match regionhandle provided in constructor"); |
62 | 62 | ||
63 | 63 | ||
64 | TestLocation1 = new Location(256001, 256001); | 64 | TestLocation1 = new Location(255001, 256001); |
65 | TestLocation2 = new Location(1099511628032000); | 65 | TestLocation2 = new Location(1095216660736000); |
66 | Assert.That(TestLocation1 != TestLocation2); | 66 | Assert.That(TestLocation1 != TestLocation2); |
67 | 67 | ||
68 | Assert.That(TestLocation1.Equals(256001, 256001), "Equals(x,y) failed to match the position in the constructor"); | 68 | Assert.That(TestLocation1.Equals(255001, 256001), "Equals(x,y) failed to match the position in the constructor"); |
69 | 69 | ||
70 | Assert.That(TestLocation2.GetHashCode() == (TestLocation2.X.GetHashCode() ^ TestLocation2.Y.GetHashCode()), "GetHashCode failed to produce the expected hashcode"); | 70 | Assert.That(TestLocation2.GetHashCode() == (TestLocation2.X.GetHashCode() ^ TestLocation2.Y.GetHashCode()), "GetHashCode failed to produce the expected hashcode"); |
71 | 71 | ||
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs index 0fbdaf3..08f2af5 100644 --- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs +++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs | |||
@@ -100,7 +100,7 @@ namespace OpenSim.Framework.Tests | |||
100 | cadu.AVHeight = Size1.Z; | 100 | cadu.AVHeight = Size1.Z; |
101 | 101 | ||
102 | AgentPosition position2 = new AgentPosition(); | 102 | AgentPosition position2 = new AgentPosition(); |
103 | position2.CopyFrom(cadu); | 103 | position2.CopyFrom(cadu, position1.SessionID); |
104 | 104 | ||
105 | Assert.IsTrue( | 105 | Assert.IsTrue( |
106 | position2.AgentID == position1.AgentID | 106 | position2.AgentID == position1.AgentID |
diff --git a/OpenSim/Framework/UserProfiles.cs b/OpenSim/Framework/UserProfiles.cs new file mode 100644 index 0000000..6133591 --- /dev/null +++ b/OpenSim/Framework/UserProfiles.cs | |||
@@ -0,0 +1,117 @@ | |||
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 | |||
28 | using System; | ||
29 | using OpenMetaverse; | ||
30 | |||
31 | namespace OpenSim.Framework | ||
32 | { | ||
33 | public class UserClassifiedAdd | ||
34 | { | ||
35 | public UUID ClassifiedId = UUID.Zero; | ||
36 | public UUID CreatorId = UUID.Zero; | ||
37 | public int CreationDate = 0; | ||
38 | public int ExpirationDate = 0; | ||
39 | public int Category = 0; | ||
40 | public string Name = string.Empty; | ||
41 | public string Description = string.Empty; | ||
42 | public UUID ParcelId = UUID.Zero; | ||
43 | public int ParentEstate = 0; | ||
44 | public UUID SnapshotId = UUID.Zero; | ||
45 | public string SimName = string.Empty; | ||
46 | public string GlobalPos = "<0,0,0>"; | ||
47 | public string ParcelName = string.Empty; | ||
48 | public byte Flags = 0; | ||
49 | public int Price = 0; | ||
50 | } | ||
51 | |||
52 | public class UserProfileProperties | ||
53 | { | ||
54 | public UUID UserId = UUID.Zero; | ||
55 | public UUID PartnerId = UUID.Zero; | ||
56 | public bool PublishProfile = false; | ||
57 | public bool PublishMature = false; | ||
58 | public string WebUrl = string.Empty; | ||
59 | public int WantToMask = 0; | ||
60 | public string WantToText = string.Empty; | ||
61 | public int SkillsMask = 0; | ||
62 | public string SkillsText = string.Empty; | ||
63 | public string Language = string.Empty; | ||
64 | public UUID ImageId = UUID.Zero; | ||
65 | public string AboutText = string.Empty; | ||
66 | public UUID FirstLifeImageId = UUID.Zero; | ||
67 | public string FirstLifeText = string.Empty; | ||
68 | } | ||
69 | |||
70 | public class UserProfilePick | ||
71 | { | ||
72 | public UUID PickId = UUID.Zero; | ||
73 | public UUID CreatorId = UUID.Zero; | ||
74 | public bool TopPick = false; | ||
75 | public string Name = string.Empty; | ||
76 | public string OriginalName = string.Empty; | ||
77 | public string Desc = string.Empty; | ||
78 | public UUID ParcelId = UUID.Zero; | ||
79 | public UUID SnapshotId = UUID.Zero; | ||
80 | public string User = string.Empty; | ||
81 | public string SimName = string.Empty; | ||
82 | public string GlobalPos = "<0,0,0>"; | ||
83 | public int SortOrder = 0; | ||
84 | public bool Enabled = false; | ||
85 | } | ||
86 | |||
87 | public class UserProfileNotes | ||
88 | { | ||
89 | public UUID UserId; | ||
90 | public UUID TargetId; | ||
91 | public string Notes; | ||
92 | } | ||
93 | |||
94 | public class UserAccountProperties | ||
95 | { | ||
96 | public string EmailAddress = string.Empty; | ||
97 | public string Firstname = string.Empty; | ||
98 | public string LastName = string.Empty; | ||
99 | public string Password = string.Empty; | ||
100 | public string UserId = string.Empty; | ||
101 | } | ||
102 | |||
103 | public class UserAccountAuth | ||
104 | { | ||
105 | public string UserId = UUID.Zero.ToString(); | ||
106 | public string Password = string.Empty; | ||
107 | } | ||
108 | |||
109 | public class UserAppData | ||
110 | { | ||
111 | public string TagId = string.Empty; | ||
112 | public string DataKey = string.Empty; | ||
113 | public string UserId = UUID.Zero.ToString(); | ||
114 | public string DataVal = string.Empty; | ||
115 | } | ||
116 | } | ||
117 | |||
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 557f38e..19d40db 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -89,9 +89,30 @@ namespace OpenSim.Framework | |||
89 | } | 89 | } |
90 | 90 | ||
91 | /// <summary> | 91 | /// <summary> |
92 | /// Class for delivering SmartThreadPool statistical information | ||
93 | /// </summary> | ||
94 | /// <remarks> | ||
95 | /// We do it this way so that we do not directly expose STP. | ||
96 | /// </remarks> | ||
97 | public class STPInfo | ||
98 | { | ||
99 | public string Name { get; set; } | ||
100 | public STPStartInfo STPStartInfo { get; set; } | ||
101 | public WIGStartInfo WIGStartInfo { get; set; } | ||
102 | public bool IsIdle { get; set; } | ||
103 | public bool IsShuttingDown { get; set; } | ||
104 | public int MaxThreads { get; set; } | ||
105 | public int MinThreads { get; set; } | ||
106 | public int InUseThreads { get; set; } | ||
107 | public int ActiveThreads { get; set; } | ||
108 | public int WaitingCallbacks { get; set; } | ||
109 | public int MaxConcurrentWorkItems { get; set; } | ||
110 | } | ||
111 | |||
112 | /// <summary> | ||
92 | /// Miscellaneous utility functions | 113 | /// Miscellaneous utility functions |
93 | /// </summary> | 114 | /// </summary> |
94 | public class Util | 115 | public static class Util |
95 | { | 116 | { |
96 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 117 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
97 | 118 | ||
@@ -120,6 +141,11 @@ namespace OpenSim.Framework | |||
120 | public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool; | 141 | public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool; |
121 | public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod; | 142 | public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod; |
122 | 143 | ||
144 | public static bool IsPlatformMono | ||
145 | { | ||
146 | get { return Type.GetType("Mono.Runtime") != null; } | ||
147 | } | ||
148 | |||
123 | /// <summary> | 149 | /// <summary> |
124 | /// Gets the name of the directory where the current running executable | 150 | /// Gets the name of the directory where the current running executable |
125 | /// is located | 151 | /// is located |
@@ -1317,7 +1343,7 @@ namespace OpenSim.Framework | |||
1317 | ru = "OSX/Mono"; | 1343 | ru = "OSX/Mono"; |
1318 | else | 1344 | else |
1319 | { | 1345 | { |
1320 | if (Type.GetType("Mono.Runtime") != null) | 1346 | if (IsPlatformMono) |
1321 | ru = "Win/Mono"; | 1347 | ru = "Win/Mono"; |
1322 | else | 1348 | else |
1323 | ru = "Win/.NET"; | 1349 | ru = "Win/.NET"; |
@@ -1765,10 +1791,12 @@ namespace OpenSim.Framework | |||
1765 | FireAndForget(callback, null); | 1791 | FireAndForget(callback, null); |
1766 | } | 1792 | } |
1767 | 1793 | ||
1768 | public static void InitThreadPool(int maxThreads) | 1794 | public static void InitThreadPool(int minThreads, int maxThreads) |
1769 | { | 1795 | { |
1770 | if (maxThreads < 2) | 1796 | if (maxThreads < 2) |
1771 | throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2"); | 1797 | throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2"); |
1798 | if (minThreads > maxThreads || minThreads < 2) | ||
1799 | throw new ArgumentOutOfRangeException("minThreads", "minThreads must be greater than 2 and less than or equal to maxThreads"); | ||
1772 | if (m_ThreadPool != null) | 1800 | if (m_ThreadPool != null) |
1773 | throw new InvalidOperationException("SmartThreadPool is already initialized"); | 1801 | throw new InvalidOperationException("SmartThreadPool is already initialized"); |
1774 | 1802 | ||
@@ -1776,7 +1804,7 @@ namespace OpenSim.Framework | |||
1776 | startInfo.ThreadPoolName = "Util"; | 1804 | startInfo.ThreadPoolName = "Util"; |
1777 | startInfo.IdleTimeout = 2000; | 1805 | startInfo.IdleTimeout = 2000; |
1778 | startInfo.MaxWorkerThreads = maxThreads; | 1806 | startInfo.MaxWorkerThreads = maxThreads; |
1779 | startInfo.MinWorkerThreads = 2; | 1807 | startInfo.MinWorkerThreads = minThreads; |
1780 | 1808 | ||
1781 | m_ThreadPool = new SmartThreadPool(startInfo); | 1809 | m_ThreadPool = new SmartThreadPool(startInfo); |
1782 | } | 1810 | } |
@@ -1851,8 +1879,8 @@ namespace OpenSim.Framework | |||
1851 | break; | 1879 | break; |
1852 | case FireAndForgetMethod.SmartThreadPool: | 1880 | case FireAndForgetMethod.SmartThreadPool: |
1853 | if (m_ThreadPool == null) | 1881 | if (m_ThreadPool == null) |
1854 | InitThreadPool(15); | 1882 | InitThreadPool(2, 15); |
1855 | m_ThreadPool.QueueWorkItem(SmartThreadPoolCallback, new object[] { realCallback, obj }); | 1883 | m_ThreadPool.QueueWorkItem((cb, o) => cb(o), realCallback, obj); |
1856 | break; | 1884 | break; |
1857 | case FireAndForgetMethod.Thread: | 1885 | case FireAndForgetMethod.Thread: |
1858 | Thread thread = new Thread(delegate(object o) { realCallback(o); }); | 1886 | Thread thread = new Thread(delegate(object o) { realCallback(o); }); |
@@ -1864,72 +1892,29 @@ namespace OpenSim.Framework | |||
1864 | } | 1892 | } |
1865 | 1893 | ||
1866 | /// <summary> | 1894 | /// <summary> |
1867 | /// Get a thread pool report. | 1895 | /// Get information about the current state of the smart thread pool. |
1868 | /// </summary> | 1896 | /// </summary> |
1869 | /// <returns></returns> | 1897 | /// <returns> |
1870 | public static string GetThreadPoolReport() | 1898 | /// null if this isn't the pool being used for non-scriptengine threads. |
1899 | /// </returns> | ||
1900 | public static STPInfo GetSmartThreadPoolInfo() | ||
1871 | { | 1901 | { |
1872 | string threadPoolUsed = null; | 1902 | if (m_ThreadPool == null) |
1873 | int maxThreads = 0; | 1903 | return null; |
1874 | int minThreads = 0; | ||
1875 | int allocatedThreads = 0; | ||
1876 | int inUseThreads = 0; | ||
1877 | int waitingCallbacks = 0; | ||
1878 | int completionPortThreads = 0; | ||
1879 | |||
1880 | StringBuilder sb = new StringBuilder(); | ||
1881 | if (FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool) | ||
1882 | { | ||
1883 | // ROBUST currently leaves this the FireAndForgetMethod but never actually initializes the threadpool. | ||
1884 | if (m_ThreadPool != null) | ||
1885 | { | ||
1886 | threadPoolUsed = "SmartThreadPool"; | ||
1887 | maxThreads = m_ThreadPool.MaxThreads; | ||
1888 | minThreads = m_ThreadPool.MinThreads; | ||
1889 | inUseThreads = m_ThreadPool.InUseThreads; | ||
1890 | allocatedThreads = m_ThreadPool.ActiveThreads; | ||
1891 | waitingCallbacks = m_ThreadPool.WaitingCallbacks; | ||
1892 | } | ||
1893 | } | ||
1894 | else if ( | ||
1895 | FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem | ||
1896 | || FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem) | ||
1897 | { | ||
1898 | threadPoolUsed = "BuiltInThreadPool"; | ||
1899 | ThreadPool.GetMaxThreads(out maxThreads, out completionPortThreads); | ||
1900 | ThreadPool.GetMinThreads(out minThreads, out completionPortThreads); | ||
1901 | int availableThreads; | ||
1902 | ThreadPool.GetAvailableThreads(out availableThreads, out completionPortThreads); | ||
1903 | inUseThreads = maxThreads - availableThreads; | ||
1904 | allocatedThreads = -1; | ||
1905 | waitingCallbacks = -1; | ||
1906 | } | ||
1907 | |||
1908 | if (threadPoolUsed != null) | ||
1909 | { | ||
1910 | sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed); | ||
1911 | sb.AppendFormat("Max threads : {0}\n", maxThreads); | ||
1912 | sb.AppendFormat("Min threads : {0}\n", minThreads); | ||
1913 | sb.AppendFormat("Allocated threads : {0}\n", allocatedThreads < 0 ? "not applicable" : allocatedThreads.ToString()); | ||
1914 | sb.AppendFormat("In use threads : {0}\n", inUseThreads); | ||
1915 | sb.AppendFormat("Work items waiting : {0}\n", waitingCallbacks < 0 ? "not available" : waitingCallbacks.ToString()); | ||
1916 | } | ||
1917 | else | ||
1918 | { | ||
1919 | sb.AppendFormat("Thread pool not used\n"); | ||
1920 | } | ||
1921 | |||
1922 | return sb.ToString(); | ||
1923 | } | ||
1924 | 1904 | ||
1925 | private static object SmartThreadPoolCallback(object o) | 1905 | STPInfo stpi = new STPInfo(); |
1926 | { | 1906 | stpi.Name = m_ThreadPool.Name; |
1927 | object[] array = (object[])o; | 1907 | stpi.STPStartInfo = m_ThreadPool.STPStartInfo; |
1928 | WaitCallback callback = (WaitCallback)array[0]; | 1908 | stpi.IsIdle = m_ThreadPool.IsIdle; |
1929 | object obj = array[1]; | 1909 | stpi.IsShuttingDown = m_ThreadPool.IsShuttingdown; |
1910 | stpi.MaxThreads = m_ThreadPool.MaxThreads; | ||
1911 | stpi.MinThreads = m_ThreadPool.MinThreads; | ||
1912 | stpi.InUseThreads = m_ThreadPool.InUseThreads; | ||
1913 | stpi.ActiveThreads = m_ThreadPool.ActiveThreads; | ||
1914 | stpi.WaitingCallbacks = m_ThreadPool.WaitingCallbacks; | ||
1915 | stpi.MaxConcurrentWorkItems = m_ThreadPool.Concurrency; | ||
1930 | 1916 | ||
1931 | callback(obj); | 1917 | return stpi; |
1932 | return null; | ||
1933 | } | 1918 | } |
1934 | 1919 | ||
1935 | #endregion FireAndForget Threading Pattern | 1920 | #endregion FireAndForget Threading Pattern |
@@ -2148,7 +2133,7 @@ namespace OpenSim.Framework | |||
2148 | /// <param name="secret">the secret part</param> | 2133 | /// <param name="secret">the secret part</param> |
2149 | public static bool ParseUniversalUserIdentifier(string value, out UUID uuid, out string url, out string firstname, out string lastname, out string secret) | 2134 | public static bool ParseUniversalUserIdentifier(string value, out UUID uuid, out string url, out string firstname, out string lastname, out string secret) |
2150 | { | 2135 | { |
2151 | uuid = UUID.Zero; url = string.Empty; firstname = "Unknown"; lastname = "User"; secret = string.Empty; | 2136 | uuid = UUID.Zero; url = string.Empty; firstname = "Unknown"; lastname = "UserUPUUI"; secret = string.Empty; |
2152 | 2137 | ||
2153 | string[] parts = value.Split(';'); | 2138 | string[] parts = value.Split(';'); |
2154 | if (parts.Length >= 1) | 2139 | if (parts.Length >= 1) |
@@ -2282,7 +2267,7 @@ namespace OpenSim.Framework | |||
2282 | { | 2267 | { |
2283 | lock (m_syncRoot) | 2268 | lock (m_syncRoot) |
2284 | { | 2269 | { |
2285 | m_lowQueue.Enqueue(data); | 2270 | q.Enqueue(data); |
2286 | m_s.WaitOne(0); | 2271 | m_s.WaitOne(0); |
2287 | m_s.Release(); | 2272 | m_s.Release(); |
2288 | } | 2273 | } |
@@ -2322,7 +2307,7 @@ namespace OpenSim.Framework | |||
2322 | { | 2307 | { |
2323 | if (m_highQueue.Count > 0) | 2308 | if (m_highQueue.Count > 0) |
2324 | res = m_highQueue.Dequeue(); | 2309 | res = m_highQueue.Dequeue(); |
2325 | else | 2310 | else if (m_lowQueue.Count > 0) |
2326 | res = m_lowQueue.Dequeue(); | 2311 | res = m_lowQueue.Dequeue(); |
2327 | 2312 | ||
2328 | if (m_highQueue.Count == 0 && m_lowQueue.Count == 0) | 2313 | if (m_highQueue.Count == 0 && m_lowQueue.Count == 0) |
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index bf57fd4..dfa37ca 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -151,6 +151,39 @@ namespace OpenSim.Framework | |||
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | public static void LogOutgoingDetail(Stream outputStream) | ||
155 | { | ||
156 | using (StreamReader reader = new StreamReader(Util.Copy(outputStream), Encoding.UTF8)) | ||
157 | { | ||
158 | string output; | ||
159 | |||
160 | if (DebugLevel == 5) | ||
161 | { | ||
162 | const int sampleLength = 80; | ||
163 | char[] sampleChars = new char[sampleLength]; | ||
164 | reader.Read(sampleChars, 0, sampleLength); | ||
165 | output = new string(sampleChars); | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | output = reader.ReadToEnd(); | ||
170 | } | ||
171 | |||
172 | LogOutgoingDetail(output); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | public static void LogOutgoingDetail(string output) | ||
177 | { | ||
178 | if (DebugLevel == 5) | ||
179 | { | ||
180 | output = output.Substring(0, 80); | ||
181 | output = output + "..."; | ||
182 | } | ||
183 | |||
184 | m_log.DebugFormat("[WEB UTIL]: {0}", output.Replace("\n", @"\n")); | ||
185 | } | ||
186 | |||
154 | private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) | 187 | private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) |
155 | { | 188 | { |
156 | int reqnum = RequestNumber++; | 189 | int reqnum = RequestNumber++; |
@@ -178,7 +211,11 @@ namespace OpenSim.Framework | |||
178 | // If there is some input, write it into the request | 211 | // If there is some input, write it into the request |
179 | if (data != null) | 212 | if (data != null) |
180 | { | 213 | { |
181 | strBuffer = OSDParser.SerializeJsonString(data); | 214 | strBuffer = OSDParser.SerializeJsonString(data); |
215 | |||
216 | if (DebugLevel >= 5) | ||
217 | LogOutgoingDetail(strBuffer); | ||
218 | |||
182 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); | 219 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); |
183 | 220 | ||
184 | if (compressed) | 221 | if (compressed) |
@@ -358,6 +395,10 @@ namespace OpenSim.Framework | |||
358 | if (data != null) | 395 | if (data != null) |
359 | { | 396 | { |
360 | queryString = BuildQueryString(data); | 397 | queryString = BuildQueryString(data); |
398 | |||
399 | if (DebugLevel >= 5) | ||
400 | LogOutgoingDetail(queryString); | ||
401 | |||
361 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString); | 402 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString); |
362 | 403 | ||
363 | request.ContentLength = buffer.Length; | 404 | request.ContentLength = buffer.Length; |
@@ -769,6 +810,9 @@ namespace OpenSim.Framework | |||
769 | int length = (int)buffer.Length; | 810 | int length = (int)buffer.Length; |
770 | request.ContentLength = length; | 811 | request.ContentLength = length; |
771 | 812 | ||
813 | if (WebUtil.DebugLevel >= 5) | ||
814 | WebUtil.LogOutgoingDetail(buffer); | ||
815 | |||
772 | request.BeginGetRequestStream(delegate(IAsyncResult res) | 816 | request.BeginGetRequestStream(delegate(IAsyncResult res) |
773 | { | 817 | { |
774 | Stream requestStream = request.EndGetRequestStream(res); | 818 | Stream requestStream = request.EndGetRequestStream(res); |
@@ -928,11 +972,12 @@ namespace OpenSim.Framework | |||
928 | /// <param name="verb"></param> | 972 | /// <param name="verb"></param> |
929 | /// <param name="requestUrl"></param> | 973 | /// <param name="requestUrl"></param> |
930 | /// <param name="obj"> </param> | 974 | /// <param name="obj"> </param> |
975 | /// <param name="timeoutsecs"> </param> | ||
931 | /// <returns></returns> | 976 | /// <returns></returns> |
932 | /// | 977 | /// |
933 | /// <exception cref="System.Net.WebException">Thrown if we encounter a network issue while posting | 978 | /// <exception cref="System.Net.WebException">Thrown if we encounter a network issue while posting |
934 | /// the request. You'll want to make sure you deal with this as they're not uncommon</exception> | 979 | /// the request. You'll want to make sure you deal with this as they're not uncommon</exception> |
935 | public static string MakeRequest(string verb, string requestUrl, string obj) | 980 | public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs) |
936 | { | 981 | { |
937 | int reqnum = WebUtil.RequestNumber++; | 982 | int reqnum = WebUtil.RequestNumber++; |
938 | 983 | ||
@@ -946,6 +991,8 @@ namespace OpenSim.Framework | |||
946 | 991 | ||
947 | WebRequest request = WebRequest.Create(requestUrl); | 992 | WebRequest request = WebRequest.Create(requestUrl); |
948 | request.Method = verb; | 993 | request.Method = verb; |
994 | if (timeoutsecs > 0) | ||
995 | request.Timeout = timeoutsecs * 1000; | ||
949 | string respstring = String.Empty; | 996 | string respstring = String.Empty; |
950 | 997 | ||
951 | int tickset = Util.EnvironmentTickCountSubtract(tickstart); | 998 | int tickset = Util.EnvironmentTickCountSubtract(tickstart); |
@@ -966,6 +1013,9 @@ namespace OpenSim.Framework | |||
966 | length = (int)obj.Length; | 1013 | length = (int)obj.Length; |
967 | request.ContentLength = length; | 1014 | request.ContentLength = length; |
968 | 1015 | ||
1016 | if (WebUtil.DebugLevel >= 5) | ||
1017 | WebUtil.LogOutgoingDetail(buffer); | ||
1018 | |||
969 | Stream requestStream = null; | 1019 | Stream requestStream = null; |
970 | try | 1020 | try |
971 | { | 1021 | { |
@@ -1039,6 +1089,11 @@ namespace OpenSim.Framework | |||
1039 | 1089 | ||
1040 | return respstring; | 1090 | return respstring; |
1041 | } | 1091 | } |
1092 | |||
1093 | public static string MakeRequest(string verb, string requestUrl, string obj) | ||
1094 | { | ||
1095 | return MakeRequest(verb, requestUrl, obj, -1); | ||
1096 | } | ||
1042 | } | 1097 | } |
1043 | 1098 | ||
1044 | public class SynchronousRestObjectRequester | 1099 | public class SynchronousRestObjectRequester |
@@ -1111,6 +1166,9 @@ namespace OpenSim.Framework | |||
1111 | int length = (int)buffer.Length; | 1166 | int length = (int)buffer.Length; |
1112 | request.ContentLength = length; | 1167 | request.ContentLength = length; |
1113 | 1168 | ||
1169 | if (WebUtil.DebugLevel >= 5) | ||
1170 | WebUtil.LogOutgoingDetail(buffer); | ||
1171 | |||
1114 | Stream requestStream = null; | 1172 | Stream requestStream = null; |
1115 | try | 1173 | try |
1116 | { | 1174 | { |
@@ -1213,4 +1271,4 @@ namespace OpenSim.Framework | |||
1213 | return deserial; | 1271 | return deserial; |
1214 | } | 1272 | } |
1215 | } | 1273 | } |
1216 | } | 1274 | } \ No newline at end of file |