diff options
author | Melanie Thielker | 2014-06-21 00:39:55 +0200 |
---|---|---|
committer | Melanie Thielker | 2014-06-21 00:39:55 +0200 |
commit | 159fcbf150b7da0e229b29aa7b94793484543d12 (patch) | |
tree | b8c0ff3b4c758a3fba8315b556c923ef4c02a185 /OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | |
parent | Merge commit '68c8633ba18f0a11cfc0ed04d1d0c7c59e6cec76' (diff) | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.zip opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.tar.gz opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.tar.bz2 opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.tar.xz |
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster
Conflicts:
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | 426 |
1 files changed, 373 insertions, 53 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs index fff86d5..de8925d 100644 --- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Linq; | ||
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using System.Text; | 33 | using System.Text; |
33 | using log4net; | 34 | using log4net; |
@@ -37,6 +38,7 @@ using OpenMetaverse; | |||
37 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Console; | 39 | using OpenSim.Framework.Console; |
39 | using OpenSim.Framework.Servers; | 40 | using OpenSim.Framework.Servers; |
41 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
42 | using Caps=OpenSim.Framework.Capabilities.Caps; | 44 | using Caps=OpenSim.Framework.Capabilities.Caps; |
@@ -57,8 +59,9 @@ namespace OpenSim.Region.CoreModules.Framework | |||
57 | /// </summary> | 59 | /// </summary> |
58 | protected Dictionary<uint, Caps> m_capsObjects = new Dictionary<uint, Caps>(); | 60 | protected Dictionary<uint, Caps> m_capsObjects = new Dictionary<uint, Caps>(); |
59 | 61 | ||
60 | protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>(); | 62 | protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>(); |
61 | protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds | 63 | |
64 | protected Dictionary<UUID, Dictionary<ulong, string>> m_childrenSeeds | ||
62 | = new Dictionary<UUID, Dictionary<ulong, string>>(); | 65 | = new Dictionary<UUID, Dictionary<ulong, string>>(); |
63 | 66 | ||
64 | public void Initialise(IConfigSource source) | 67 | public void Initialise(IConfigSource source) |
@@ -70,9 +73,24 @@ namespace OpenSim.Region.CoreModules.Framework | |||
70 | m_scene = scene; | 73 | m_scene = scene; |
71 | m_scene.RegisterModuleInterface<ICapabilitiesModule>(this); | 74 | m_scene.RegisterModuleInterface<ICapabilitiesModule>(this); |
72 | 75 | ||
73 | MainConsole.Instance.Commands.AddCommand("Comms", false, "show caps", | 76 | MainConsole.Instance.Commands.AddCommand( |
74 | "show caps", | 77 | "Comms", false, "show caps list", |
75 | "Shows all registered capabilities for users", HandleShowCapsCommand); | 78 | "show caps list", |
79 | "Shows list of registered capabilities for users.", HandleShowCapsListCommand); | ||
80 | |||
81 | MainConsole.Instance.Commands.AddCommand( | ||
82 | "Comms", false, "show caps stats by user", | ||
83 | "show caps stats by user [<first-name> <last-name>]", | ||
84 | "Shows statistics on capabilities use by user.", | ||
85 | "If a user name is given, then prints a detailed breakdown of caps use ordered by number of requests received.", | ||
86 | HandleShowCapsStatsByUserCommand); | ||
87 | |||
88 | MainConsole.Instance.Commands.AddCommand( | ||
89 | "Comms", false, "show caps stats by cap", | ||
90 | "show caps stats by cap [<cap-name>]", | ||
91 | "Shows statistics on capabilities use by capability.", | ||
92 | "If a capability name is given, then prints a detailed breakdown of use by each user.", | ||
93 | HandleShowCapsStatsByCapCommand); | ||
76 | } | 94 | } |
77 | 95 | ||
78 | public void RegionLoaded(Scene scene) | 96 | public void RegionLoaded(Scene scene) |
@@ -106,35 +124,38 @@ namespace OpenSim.Region.CoreModules.Framework | |||
106 | if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags)) | 124 | if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags)) |
107 | return; | 125 | return; |
108 | 126 | ||
127 | Caps caps; | ||
109 | String capsObjectPath = GetCapsPath(agentId); | 128 | String capsObjectPath = GetCapsPath(agentId); |
110 | 129 | ||
111 | if (m_capsObjects.ContainsKey(circuitCode)) | 130 | lock (m_capsObjects) |
112 | { | 131 | { |
113 | Caps oldCaps = m_capsObjects[circuitCode]; | 132 | if (m_capsObjects.ContainsKey(circuitCode)) |
114 | 133 | { | |
115 | m_log.DebugFormat( | 134 | Caps oldCaps = m_capsObjects[circuitCode]; |
116 | "[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ", | 135 | |
117 | agentId, oldCaps.CapsObjectPath, capsObjectPath); | 136 | //m_log.WarnFormat( |
118 | // This should not happen. The caller code is confused. We need to fix that. | 137 | // "[CAPS]: Recreating caps for agent {0} in region {1}. Old caps path {2}, new caps path {3}. ", |
119 | // CAPs can never be reregistered, or the client will be confused. | 138 | // agentId, m_scene.RegionInfo.RegionName, oldCaps.CapsObjectPath, capsObjectPath); |
120 | // Hence this return here. | 139 | } |
121 | //return; | ||
122 | } | ||
123 | |||
124 | Caps caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName, | ||
125 | (MainServer.Instance == null) ? 0: MainServer.Instance.Port, | ||
126 | capsObjectPath, agentId, m_scene.RegionInfo.RegionName); | ||
127 | 140 | ||
128 | m_capsObjects[circuitCode] = caps; | 141 | caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName, |
142 | (MainServer.Instance == null) ? 0: MainServer.Instance.Port, | ||
143 | capsObjectPath, agentId, m_scene.RegionInfo.RegionName); | ||
129 | 144 | ||
145 | m_capsObjects[circuitCode] = caps; | ||
146 | } | ||
130 | m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); | 147 | m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); |
131 | } | 148 | } |
132 | 149 | ||
133 | public void RemoveCaps(UUID agentId, uint circuitCode) | 150 | public void RemoveCaps(UUID agentId, uint circuitCode) |
134 | { | 151 | { |
135 | if (childrenSeeds.ContainsKey(agentId)) | 152 | m_log.DebugFormat("[CAPS]: Remove caps for agent {0} in region {1}", agentId, m_scene.RegionInfo.RegionName); |
153 | lock (m_childrenSeeds) | ||
136 | { | 154 | { |
137 | childrenSeeds.Remove(agentId); | 155 | if (m_childrenSeeds.ContainsKey(agentId)) |
156 | { | ||
157 | m_childrenSeeds.Remove(agentId); | ||
158 | } | ||
138 | } | 159 | } |
139 | 160 | ||
140 | lock (m_capsObjects) | 161 | lock (m_capsObjects) |
@@ -180,16 +201,22 @@ namespace OpenSim.Region.CoreModules.Framework | |||
180 | 201 | ||
181 | public void SetAgentCapsSeeds(AgentCircuitData agent) | 202 | public void SetAgentCapsSeeds(AgentCircuitData agent) |
182 | { | 203 | { |
183 | capsPaths[agent.AgentID] = agent.CapsPath; | 204 | lock (m_capsPaths) |
184 | childrenSeeds[agent.AgentID] | 205 | m_capsPaths[agent.AgentID] = agent.CapsPath; |
185 | = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds); | 206 | |
207 | lock (m_childrenSeeds) | ||
208 | m_childrenSeeds[agent.AgentID] | ||
209 | = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds); | ||
186 | } | 210 | } |
187 | 211 | ||
188 | public string GetCapsPath(UUID agentId) | 212 | public string GetCapsPath(UUID agentId) |
189 | { | 213 | { |
190 | if (capsPaths.ContainsKey(agentId)) | 214 | lock (m_capsPaths) |
191 | { | 215 | { |
192 | return capsPaths[agentId]; | 216 | if (m_capsPaths.ContainsKey(agentId)) |
217 | { | ||
218 | return m_capsPaths[agentId]; | ||
219 | } | ||
193 | } | 220 | } |
194 | 221 | ||
195 | return null; | 222 | return null; |
@@ -198,17 +225,24 @@ namespace OpenSim.Region.CoreModules.Framework | |||
198 | public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID) | 225 | public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID) |
199 | { | 226 | { |
200 | Dictionary<ulong, string> seeds = null; | 227 | Dictionary<ulong, string> seeds = null; |
201 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | 228 | |
202 | return seeds; | 229 | lock (m_childrenSeeds) |
230 | if (m_childrenSeeds.TryGetValue(agentID, out seeds)) | ||
231 | return seeds; | ||
232 | |||
203 | return new Dictionary<ulong, string>(); | 233 | return new Dictionary<ulong, string>(); |
204 | } | 234 | } |
205 | 235 | ||
206 | public void DropChildSeed(UUID agentID, ulong handle) | 236 | public void DropChildSeed(UUID agentID, ulong handle) |
207 | { | 237 | { |
208 | Dictionary<ulong, string> seeds; | 238 | Dictionary<ulong, string> seeds; |
209 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | 239 | |
240 | lock (m_childrenSeeds) | ||
210 | { | 241 | { |
211 | seeds.Remove(handle); | 242 | if (m_childrenSeeds.TryGetValue(agentID, out seeds)) |
243 | { | ||
244 | seeds.Remove(handle); | ||
245 | } | ||
212 | } | 246 | } |
213 | } | 247 | } |
214 | 248 | ||
@@ -216,53 +250,339 @@ namespace OpenSim.Region.CoreModules.Framework | |||
216 | { | 250 | { |
217 | Dictionary<ulong, string> seeds; | 251 | Dictionary<ulong, string> seeds; |
218 | string returnval; | 252 | string returnval; |
219 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | 253 | |
254 | lock (m_childrenSeeds) | ||
220 | { | 255 | { |
221 | if (seeds.TryGetValue(handle, out returnval)) | 256 | if (m_childrenSeeds.TryGetValue(agentID, out seeds)) |
222 | return returnval; | 257 | { |
258 | if (seeds.TryGetValue(handle, out returnval)) | ||
259 | return returnval; | ||
260 | } | ||
223 | } | 261 | } |
262 | |||
224 | return null; | 263 | return null; |
225 | } | 264 | } |
226 | 265 | ||
227 | public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds) | 266 | public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds) |
228 | { | 267 | { |
229 | //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count); | 268 | //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count); |
230 | childrenSeeds[agentID] = seeds; | 269 | |
270 | lock (m_childrenSeeds) | ||
271 | m_childrenSeeds[agentID] = seeds; | ||
231 | } | 272 | } |
232 | 273 | ||
233 | public void DumpChildrenSeeds(UUID agentID) | 274 | public void DumpChildrenSeeds(UUID agentID) |
234 | { | 275 | { |
235 | m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================"); | 276 | m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================"); |
236 | foreach (KeyValuePair<ulong, string> kvp in childrenSeeds[agentID]) | 277 | |
278 | lock (m_childrenSeeds) | ||
279 | { | ||
280 | foreach (KeyValuePair<ulong, string> kvp in m_childrenSeeds[agentID]) | ||
281 | { | ||
282 | uint x, y; | ||
283 | Utils.LongToUInts(kvp.Key, out x, out y); | ||
284 | x = x / Constants.RegionSize; | ||
285 | y = y / Constants.RegionSize; | ||
286 | m_log.Info(" >> "+x+", "+y+": "+kvp.Value); | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | |||
291 | private void HandleShowCapsListCommand(string module, string[] cmdParams) | ||
292 | { | ||
293 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) | ||
294 | return; | ||
295 | |||
296 | StringBuilder capsReport = new StringBuilder(); | ||
297 | capsReport.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); | ||
298 | |||
299 | lock (m_capsObjects) | ||
237 | { | 300 | { |
238 | uint x, y; | 301 | foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects) |
239 | Utils.LongToUInts(kvp.Key, out x, out y); | 302 | { |
240 | x = x / Constants.RegionSize; | 303 | capsReport.AppendFormat("** Circuit {0}:\n", kvp.Key); |
241 | y = y / Constants.RegionSize; | 304 | Caps caps = kvp.Value; |
242 | m_log.Info(" >> "+x+", "+y+": "+kvp.Value); | 305 | |
306 | for (IDictionaryEnumerator kvp2 = caps.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) | ||
307 | { | ||
308 | Uri uri = new Uri(kvp2.Value.ToString()); | ||
309 | capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); | ||
310 | } | ||
311 | |||
312 | foreach (KeyValuePair<string, PollServiceEventArgs> kvp2 in caps.GetPollHandlers()) | ||
313 | capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, kvp2.Value.Url); | ||
314 | |||
315 | foreach (KeyValuePair<string, string> kvp3 in caps.ExternalCapsHandlers) | ||
316 | capsReport.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); | ||
317 | } | ||
243 | } | 318 | } |
319 | |||
320 | MainConsole.Instance.Output(capsReport.ToString()); | ||
244 | } | 321 | } |
245 | 322 | ||
246 | private void HandleShowCapsCommand(string module, string[] cmdparams) | 323 | private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams) |
247 | { | 324 | { |
248 | StringBuilder caps = new StringBuilder(); | 325 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) |
249 | caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); | 326 | return; |
327 | |||
328 | if (cmdParams.Length != 5 && cmdParams.Length != 6) | ||
329 | { | ||
330 | MainConsole.Instance.Output("Usage: show caps stats by cap [<cap-name>]"); | ||
331 | return; | ||
332 | } | ||
333 | |||
334 | StringBuilder sb = new StringBuilder(); | ||
335 | sb.AppendFormat("Region {0}:\n", m_scene.Name); | ||
336 | |||
337 | if (cmdParams.Length == 5) | ||
338 | { | ||
339 | BuildSummaryStatsByCapReport(sb); | ||
340 | } | ||
341 | else if (cmdParams.Length == 6) | ||
342 | { | ||
343 | BuildDetailedStatsByCapReport(sb, cmdParams[5]); | ||
344 | } | ||
345 | |||
346 | MainConsole.Instance.Output(sb.ToString()); | ||
347 | } | ||
348 | |||
349 | private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName) | ||
350 | { | ||
351 | /* | ||
352 | sb.AppendFormat("Capability name {0}\n", capName); | ||
353 | |||
354 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | ||
355 | cdt.AddColumn("User Name", 34); | ||
356 | cdt.AddColumn("Req Received", 12); | ||
357 | cdt.AddColumn("Req Handled", 12); | ||
358 | cdt.Indent = 2; | ||
359 | |||
360 | Dictionary<string, int> receivedStats = new Dictionary<string, int>(); | ||
361 | Dictionary<string, int> handledStats = new Dictionary<string, int>(); | ||
362 | |||
363 | m_scene.ForEachScenePresence( | ||
364 | sp => | ||
365 | { | ||
366 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); | ||
250 | 367 | ||
251 | foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects) | 368 | if (caps == null) |
369 | return; | ||
370 | |||
371 | Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); | ||
372 | |||
373 | IRequestHandler reqHandler; | ||
374 | if (capsHandlers.TryGetValue(capName, out reqHandler)) | ||
375 | { | ||
376 | receivedStats[sp.Name] = reqHandler.RequestsReceived; | ||
377 | handledStats[sp.Name] = reqHandler.RequestsHandled; | ||
378 | } | ||
379 | else | ||
380 | { | ||
381 | PollServiceEventArgs pollHandler = null; | ||
382 | if (caps.TryGetPollHandler(capName, out pollHandler)) | ||
383 | { | ||
384 | receivedStats[sp.Name] = pollHandler.RequestsReceived; | ||
385 | handledStats[sp.Name] = pollHandler.RequestsHandled; | ||
386 | } | ||
387 | } | ||
388 | } | ||
389 | ); | ||
390 | |||
391 | foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value)) | ||
252 | { | 392 | { |
253 | caps.AppendFormat("** Circuit {0}:\n", kvp.Key); | 393 | cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]); |
394 | } | ||
395 | |||
396 | sb.Append(cdt.ToString()); | ||
397 | */ | ||
398 | } | ||
399 | |||
400 | private void BuildSummaryStatsByCapReport(StringBuilder sb) | ||
401 | { | ||
402 | /* | ||
403 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | ||
404 | cdt.AddColumn("Name", 34); | ||
405 | cdt.AddColumn("Req Received", 12); | ||
406 | cdt.AddColumn("Req Handled", 12); | ||
407 | cdt.Indent = 2; | ||
408 | |||
409 | Dictionary<string, int> receivedStats = new Dictionary<string, int>(); | ||
410 | Dictionary<string, int> handledStats = new Dictionary<string, int>(); | ||
254 | 411 | ||
255 | for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) | 412 | m_scene.ForEachScenePresence( |
413 | sp => | ||
256 | { | 414 | { |
257 | Uri uri = new Uri(kvp2.Value.ToString()); | 415 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); |
258 | caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); | 416 | |
417 | if (caps == null) | ||
418 | return; | ||
419 | |||
420 | foreach (IRequestHandler reqHandler in caps.CapsHandlers.GetCapsHandlers().Values) | ||
421 | { | ||
422 | string reqName = reqHandler.Name ?? ""; | ||
423 | |||
424 | if (!receivedStats.ContainsKey(reqName)) | ||
425 | { | ||
426 | receivedStats[reqName] = reqHandler.RequestsReceived; | ||
427 | handledStats[reqName] = reqHandler.RequestsHandled; | ||
428 | } | ||
429 | else | ||
430 | { | ||
431 | receivedStats[reqName] += reqHandler.RequestsReceived; | ||
432 | handledStats[reqName] += reqHandler.RequestsHandled; | ||
433 | } | ||
434 | } | ||
435 | |||
436 | foreach (KeyValuePair<string, PollServiceEventArgs> kvp in caps.GetPollHandlers()) | ||
437 | { | ||
438 | string name = kvp.Key; | ||
439 | PollServiceEventArgs pollHandler = kvp.Value; | ||
440 | |||
441 | if (!receivedStats.ContainsKey(name)) | ||
442 | { | ||
443 | receivedStats[name] = pollHandler.RequestsReceived; | ||
444 | handledStats[name] = pollHandler.RequestsHandled; | ||
445 | } | ||
446 | else | ||
447 | { | ||
448 | receivedStats[name] += pollHandler.RequestsReceived; | ||
449 | handledStats[name] += pollHandler.RequestsHandled; | ||
450 | } | ||
451 | } | ||
259 | } | 452 | } |
453 | ); | ||
454 | |||
455 | foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value)) | ||
456 | cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]); | ||
457 | |||
458 | sb.Append(cdt.ToString()); | ||
459 | */ | ||
460 | } | ||
461 | |||
462 | private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams) | ||
463 | { | ||
464 | /* | ||
465 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) | ||
466 | return; | ||
467 | |||
468 | if (cmdParams.Length != 5 && cmdParams.Length != 7) | ||
469 | { | ||
470 | MainConsole.Instance.Output("Usage: show caps stats by user [<first-name> <last-name>]"); | ||
471 | return; | ||
472 | } | ||
473 | |||
474 | StringBuilder sb = new StringBuilder(); | ||
475 | sb.AppendFormat("Region {0}:\n", m_scene.Name); | ||
476 | |||
477 | if (cmdParams.Length == 5) | ||
478 | { | ||
479 | BuildSummaryStatsByUserReport(sb); | ||
480 | } | ||
481 | else if (cmdParams.Length == 7) | ||
482 | { | ||
483 | string firstName = cmdParams[5]; | ||
484 | string lastName = cmdParams[6]; | ||
485 | |||
486 | ScenePresence sp = m_scene.GetScenePresence(firstName, lastName); | ||
487 | |||
488 | if (sp == null) | ||
489 | return; | ||
260 | 490 | ||
261 | foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers) | 491 | BuildDetailedStatsByUserReport(sb, sp); |
262 | caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); | ||
263 | } | 492 | } |
264 | 493 | ||
265 | MainConsole.Instance.Output(caps.ToString()); | 494 | MainConsole.Instance.Output(sb.ToString()); |
495 | */ | ||
496 | } | ||
497 | |||
498 | private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp) | ||
499 | { | ||
500 | /* | ||
501 | sb.AppendFormat("Avatar name {0}, type {1}\n", sp.Name, sp.IsChildAgent ? "child" : "root"); | ||
502 | |||
503 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | ||
504 | cdt.AddColumn("Cap Name", 34); | ||
505 | cdt.AddColumn("Req Received", 12); | ||
506 | cdt.AddColumn("Req Handled", 12); | ||
507 | cdt.Indent = 2; | ||
508 | |||
509 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); | ||
510 | |||
511 | if (caps == null) | ||
512 | return; | ||
513 | |||
514 | List<CapTableRow> capRows = new List<CapTableRow>(); | ||
515 | |||
516 | foreach (IRequestHandler reqHandler in caps.CapsHandlers.GetCapsHandlers().Values) | ||
517 | capRows.Add(new CapTableRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled)); | ||
518 | |||
519 | foreach (KeyValuePair<string, PollServiceEventArgs> kvp in caps.GetPollHandlers()) | ||
520 | capRows.Add(new CapTableRow(kvp.Key, kvp.Value.RequestsReceived, kvp.Value.RequestsHandled)); | ||
521 | |||
522 | foreach (CapTableRow ctr in capRows.OrderByDescending(ctr => ctr.RequestsReceived)) | ||
523 | cdt.AddRow(ctr.Name, ctr.RequestsReceived, ctr.RequestsHandled); | ||
524 | |||
525 | sb.Append(cdt.ToString()); | ||
526 | */ | ||
527 | } | ||
528 | |||
529 | private void BuildSummaryStatsByUserReport(StringBuilder sb) | ||
530 | { | ||
531 | /* | ||
532 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | ||
533 | cdt.AddColumn("Name", 32); | ||
534 | cdt.AddColumn("Type", 5); | ||
535 | cdt.AddColumn("Req Received", 12); | ||
536 | cdt.AddColumn("Req Handled", 12); | ||
537 | cdt.Indent = 2; | ||
538 | |||
539 | m_scene.ForEachScenePresence( | ||
540 | sp => | ||
541 | { | ||
542 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); | ||
543 | |||
544 | if (caps == null) | ||
545 | return; | ||
546 | |||
547 | Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); | ||
548 | |||
549 | int totalRequestsReceived = 0; | ||
550 | int totalRequestsHandled = 0; | ||
551 | |||
552 | foreach (IRequestHandler reqHandler in capsHandlers.Values) | ||
553 | { | ||
554 | totalRequestsReceived += reqHandler.RequestsReceived; | ||
555 | totalRequestsHandled += reqHandler.RequestsHandled; | ||
556 | } | ||
557 | |||
558 | Dictionary<string, PollServiceEventArgs> capsPollHandlers = caps.GetPollHandlers(); | ||
559 | |||
560 | foreach (PollServiceEventArgs handler in capsPollHandlers.Values) | ||
561 | { | ||
562 | totalRequestsReceived += handler.RequestsReceived; | ||
563 | totalRequestsHandled += handler.RequestsHandled; | ||
564 | } | ||
565 | |||
566 | cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled); | ||
567 | } | ||
568 | ); | ||
569 | |||
570 | sb.Append(cdt.ToString()); | ||
571 | */ | ||
572 | } | ||
573 | |||
574 | private class CapTableRow | ||
575 | { | ||
576 | public string Name { get; set; } | ||
577 | public int RequestsReceived { get; set; } | ||
578 | public int RequestsHandled { get; set; } | ||
579 | |||
580 | public CapTableRow(string name, int requestsReceived, int requestsHandled) | ||
581 | { | ||
582 | Name = name; | ||
583 | RequestsReceived = requestsReceived; | ||
584 | RequestsHandled = requestsHandled; | ||
585 | } | ||
266 | } | 586 | } |
267 | } | 587 | } |
268 | } | 588 | } |