aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework/Caps
diff options
context:
space:
mode:
authorMelanie2013-07-13 00:47:58 +0100
committerMelanie2013-07-13 00:47:58 +0100
commita53a10ad270ea02e57aca7787d0b8278989eea68 (patch)
tree7ff1b6d170e828e8b9628ef13078b2cd0ecbd8b6 /OpenSim/Region/CoreModules/Framework/Caps
parentMerge branch 'master' into careminster (diff)
parentCentralize duplicated code in SceneObjectPart for subscribing to (diff)
downloadopensim-SC_OLD-a53a10ad270ea02e57aca7787d0b8278989eea68.zip
opensim-SC_OLD-a53a10ad270ea02e57aca7787d0b8278989eea68.tar.gz
opensim-SC_OLD-a53a10ad270ea02e57aca7787d0b8278989eea68.tar.bz2
opensim-SC_OLD-a53a10ad270ea02e57aca7787d0b8278989eea68.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs OpenSim/Region/Framework/Scenes/Scene.cs OpenSim/Region/Framework/Scenes/SceneObjectPart.cs OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/Caps')
-rw-r--r--OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs337
1 files changed, 301 insertions, 36 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
index fff86d5..2fc3b1c 100644
--- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Linq;
31using System.Reflection; 32using System.Reflection;
32using System.Text; 33using System.Text;
33using log4net; 34using log4net;
@@ -37,6 +38,7 @@ using OpenMetaverse;
37using OpenSim.Framework; 38using OpenSim.Framework;
38using OpenSim.Framework.Console; 39using OpenSim.Framework.Console;
39using OpenSim.Framework.Servers; 40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
42using Caps=OpenSim.Framework.Capabilities.Caps; 44using 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 [<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,6 +124,7 @@ 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 if (m_capsObjects.ContainsKey(circuitCode))
@@ -121,7 +140,7 @@ namespace OpenSim.Region.CoreModules.Framework
121 //return; 140 //return;
122 } 141 }
123 142
124 Caps caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName, 143 caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName,
125 (MainServer.Instance == null) ? 0: MainServer.Instance.Port, 144 (MainServer.Instance == null) ? 0: MainServer.Instance.Port,
126 capsObjectPath, agentId, m_scene.RegionInfo.RegionName); 145 capsObjectPath, agentId, m_scene.RegionInfo.RegionName);
127 146
@@ -132,9 +151,12 @@ namespace OpenSim.Region.CoreModules.Framework
132 151
133 public void RemoveCaps(UUID agentId, uint circuitCode) 152 public void RemoveCaps(UUID agentId, uint circuitCode)
134 { 153 {
135 if (childrenSeeds.ContainsKey(agentId)) 154 lock (m_childrenSeeds)
136 { 155 {
137 childrenSeeds.Remove(agentId); 156 if (m_childrenSeeds.ContainsKey(agentId))
157 {
158 m_childrenSeeds.Remove(agentId);
159 }
138 } 160 }
139 161
140 lock (m_capsObjects) 162 lock (m_capsObjects)
@@ -180,16 +202,22 @@ namespace OpenSim.Region.CoreModules.Framework
180 202
181 public void SetAgentCapsSeeds(AgentCircuitData agent) 203 public void SetAgentCapsSeeds(AgentCircuitData agent)
182 { 204 {
183 capsPaths[agent.AgentID] = agent.CapsPath; 205 lock (m_capsPaths)
184 childrenSeeds[agent.AgentID] 206 m_capsPaths[agent.AgentID] = agent.CapsPath;
185 = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds); 207
208 lock (m_childrenSeeds)
209 m_childrenSeeds[agent.AgentID]
210 = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds);
186 } 211 }
187 212
188 public string GetCapsPath(UUID agentId) 213 public string GetCapsPath(UUID agentId)
189 { 214 {
190 if (capsPaths.ContainsKey(agentId)) 215 lock (m_capsPaths)
191 { 216 {
192 return capsPaths[agentId]; 217 if (m_capsPaths.ContainsKey(agentId))
218 {
219 return m_capsPaths[agentId];
220 }
193 } 221 }
194 222
195 return null; 223 return null;
@@ -198,17 +226,24 @@ namespace OpenSim.Region.CoreModules.Framework
198 public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID) 226 public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID)
199 { 227 {
200 Dictionary<ulong, string> seeds = null; 228 Dictionary<ulong, string> seeds = null;
201 if (childrenSeeds.TryGetValue(agentID, out seeds)) 229
202 return seeds; 230 lock (m_childrenSeeds)
231 if (m_childrenSeeds.TryGetValue(agentID, out seeds))
232 return seeds;
233
203 return new Dictionary<ulong, string>(); 234 return new Dictionary<ulong, string>();
204 } 235 }
205 236
206 public void DropChildSeed(UUID agentID, ulong handle) 237 public void DropChildSeed(UUID agentID, ulong handle)
207 { 238 {
208 Dictionary<ulong, string> seeds; 239 Dictionary<ulong, string> seeds;
209 if (childrenSeeds.TryGetValue(agentID, out seeds)) 240
241 lock (m_childrenSeeds)
210 { 242 {
211 seeds.Remove(handle); 243 if (m_childrenSeeds.TryGetValue(agentID, out seeds))
244 {
245 seeds.Remove(handle);
246 }
212 } 247 }
213 } 248 }
214 249
@@ -216,53 +251,283 @@ namespace OpenSim.Region.CoreModules.Framework
216 { 251 {
217 Dictionary<ulong, string> seeds; 252 Dictionary<ulong, string> seeds;
218 string returnval; 253 string returnval;
219 if (childrenSeeds.TryGetValue(agentID, out seeds)) 254
255 lock (m_childrenSeeds)
220 { 256 {
221 if (seeds.TryGetValue(handle, out returnval)) 257 if (m_childrenSeeds.TryGetValue(agentID, out seeds))
222 return returnval; 258 {
259 if (seeds.TryGetValue(handle, out returnval))
260 return returnval;
261 }
223 } 262 }
263
224 return null; 264 return null;
225 } 265 }
226 266
227 public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds) 267 public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds)
228 { 268 {
229 //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count); 269 //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count);
230 childrenSeeds[agentID] = seeds; 270
271 lock (m_childrenSeeds)
272 m_childrenSeeds[agentID] = seeds;
231 } 273 }
232 274
233 public void DumpChildrenSeeds(UUID agentID) 275 public void DumpChildrenSeeds(UUID agentID)
234 { 276 {
235 m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================"); 277 m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================");
236 foreach (KeyValuePair<ulong, string> kvp in childrenSeeds[agentID]) 278
279 lock (m_childrenSeeds)
237 { 280 {
238 uint x, y; 281 foreach (KeyValuePair<ulong, string> kvp in m_childrenSeeds[agentID])
239 Utils.LongToUInts(kvp.Key, out x, out y); 282 {
240 x = x / Constants.RegionSize; 283 uint x, y;
241 y = y / Constants.RegionSize; 284 Utils.LongToUInts(kvp.Key, out x, out y);
242 m_log.Info(" >> "+x+", "+y+": "+kvp.Value); 285 x = x / Constants.RegionSize;
286 y = y / Constants.RegionSize;
287 m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
288 }
243 } 289 }
244 } 290 }
245 291
246 private void HandleShowCapsCommand(string module, string[] cmdparams) 292 private void HandleShowCapsListCommand(string module, string[] cmdParams)
247 { 293 {
294 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
295 return;
296
248 StringBuilder caps = new StringBuilder(); 297 StringBuilder caps = new StringBuilder();
249 caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); 298 caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName);
250 299
251 foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects) 300 lock (m_capsObjects)
252 { 301 {
253 caps.AppendFormat("** Circuit {0}:\n", kvp.Key); 302 foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects)
303 {
304 caps.AppendFormat("** User {0}:\n", kvp.Key);
254 305
255 for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) 306 for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); )
307 {
308 Uri uri = new Uri(kvp2.Value.ToString());
309 caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery);
310 }
311
312 foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers)
313 caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value);
314 }
315 }
316
317 MainConsole.Instance.Output(caps.ToString());
318 }
319
320 private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams)
321 {
322 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
323 return;
324
325 if (cmdParams.Length != 5 && cmdParams.Length != 6)
326 {
327 MainConsole.Instance.Output("Usage: show caps stats by cap [<cap-name>]");
328 return;
329 }
330
331 StringBuilder sb = new StringBuilder();
332 sb.AppendFormat("Region {0}:\n", m_scene.Name);
333
334 if (cmdParams.Length == 5)
335 {
336 BuildSummaryStatsByCapReport(sb);
337 }
338 else if (cmdParams.Length == 6)
339 {
340 BuildDetailedStatsByCapReport(sb, cmdParams[5]);
341 }
342
343 MainConsole.Instance.Output(sb.ToString());
344 }
345
346 private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName)
347 {
348 /*
349 sb.AppendFormat("Capability name {0}\n", capName);
350
351 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
352 cdt.AddColumn("User Name", 34);
353 cdt.AddColumn("Req Received", 12);
354 cdt.AddColumn("Req Handled", 12);
355 cdt.Indent = 2;
356
357 Dictionary<string, int> receivedStats = new Dictionary<string, int>();
358 Dictionary<string, int> handledStats = new Dictionary<string, int>();
359
360 m_scene.ForEachScenePresence(
361 sp =>
256 { 362 {
257 Uri uri = new Uri(kvp2.Value.ToString()); 363 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
258 caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); 364
365 if (caps == null)
366 return;
367
368 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
369
370 IRequestHandler reqHandler;
371 if (capsHandlers.TryGetValue(capName, out reqHandler))
372 {
373 receivedStats[sp.Name] = reqHandler.RequestsReceived;
374 handledStats[sp.Name] = reqHandler.RequestsHandled;
375 }
259 } 376 }
377 );
260 378
261 foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers) 379 foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value))
262 caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); 380 {
381 cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]);
263 } 382 }
264 383
265 MainConsole.Instance.Output(caps.ToString()); 384 sb.Append(cdt.ToString());
385 */
386 }
387
388 private void BuildSummaryStatsByCapReport(StringBuilder sb)
389 {
390 /*
391 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
392 cdt.AddColumn("Name", 34);
393 cdt.AddColumn("Req Received", 12);
394 cdt.AddColumn("Req Handled", 12);
395 cdt.Indent = 2;
396
397 Dictionary<string, int> receivedStats = new Dictionary<string, int>();
398 Dictionary<string, int> handledStats = new Dictionary<string, int>();
399
400 m_scene.ForEachScenePresence(
401 sp =>
402 {
403 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
404
405 if (caps == null)
406 return;
407
408 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
409
410 foreach (IRequestHandler reqHandler in capsHandlers.Values)
411 {
412 string reqName = reqHandler.Name ?? "";
413
414 if (!receivedStats.ContainsKey(reqName))
415 {
416 receivedStats[reqName] = reqHandler.RequestsReceived;
417 handledStats[reqName] = reqHandler.RequestsHandled;
418 }
419 else
420 {
421 receivedStats[reqName] += reqHandler.RequestsReceived;
422 handledStats[reqName] += reqHandler.RequestsHandled;
423 }
424 }
425 }
426 );
427
428 foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value))
429 cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]);
430
431 sb.Append(cdt.ToString());
432 */
433 }
434
435 private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams)
436 {
437 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
438 return;
439
440 if (cmdParams.Length != 5 && cmdParams.Length != 7)
441 {
442 MainConsole.Instance.Output("Usage: show caps stats by user [<first-name> <last-name>]");
443 return;
444 }
445
446 StringBuilder sb = new StringBuilder();
447 sb.AppendFormat("Region {0}:\n", m_scene.Name);
448
449 if (cmdParams.Length == 5)
450 {
451 BuildSummaryStatsByUserReport(sb);
452 }
453 else if (cmdParams.Length == 7)
454 {
455 string firstName = cmdParams[5];
456 string lastName = cmdParams[6];
457
458 ScenePresence sp = m_scene.GetScenePresence(firstName, lastName);
459
460 if (sp == null)
461 return;
462
463 BuildDetailedStatsByUserReport(sb, sp);
464 }
465
466 MainConsole.Instance.Output(sb.ToString());
467 }
468
469 private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp)
470 {
471 /*
472 sb.AppendFormat("Avatar name {0}, type {1}\n", sp.Name, sp.IsChildAgent ? "child" : "root");
473
474 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
475 cdt.AddColumn("Cap Name", 34);
476 cdt.AddColumn("Req Received", 12);
477 cdt.AddColumn("Req Handled", 12);
478 cdt.Indent = 2;
479
480 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
481
482 if (caps == null)
483 return;
484
485 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
486
487 foreach (IRequestHandler reqHandler in capsHandlers.Values.OrderByDescending(rh => rh.RequestsReceived))
488 {
489 cdt.AddRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled);
490 }
491
492 sb.Append(cdt.ToString());
493 */
494 }
495
496 private void BuildSummaryStatsByUserReport(StringBuilder sb)
497 {
498 /*
499 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
500 cdt.AddColumn("Name", 32);
501 cdt.AddColumn("Type", 5);
502 cdt.AddColumn("Req Received", 12);
503 cdt.AddColumn("Req Handled", 12);
504 cdt.Indent = 2;
505
506 m_scene.ForEachScenePresence(
507 sp =>
508 {
509 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
510
511 if (caps == null)
512 return;
513
514 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
515
516 int totalRequestsReceived = 0;
517 int totalRequestsHandled = 0;
518
519 foreach (IRequestHandler reqHandler in capsHandlers.Values)
520 {
521 totalRequestsReceived += reqHandler.RequestsReceived;
522 totalRequestsHandled += reqHandler.RequestsHandled;
523 }
524
525 cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled);
526 }
527 );
528
529 sb.Append(cdt.ToString());
530 */
266 } 531 }
267 } 532 }
268} 533}