aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-07-15 23:22:39 +0100
committerJustin Clark-Casey (justincc)2013-07-15 23:27:46 +0100
commit1b7b664c8696531fec26378d1386362d8a3da55e (patch)
tree1bdf9c56b647c7d5fa47289ec8323c4d35ae09ca /OpenSim/Region
parentReinsert PhysicsActor variable back into SOP.SubscribeForCollisionEvents() in... (diff)
downloadopensim-SC_OLD-1b7b664c8696531fec26378d1386362d8a3da55e.zip
opensim-SC_OLD-1b7b664c8696531fec26378d1386362d8a3da55e.tar.gz
opensim-SC_OLD-1b7b664c8696531fec26378d1386362d8a3da55e.tar.bz2
opensim-SC_OLD-1b7b664c8696531fec26378d1386362d8a3da55e.tar.xz
Add request received/handling stats for caps which are served by http poll handlers.
This adds explicit cap poll handler supporting to the Caps classes rather than relying on callers to do the complicated coding. Other refactoring was required to get logic into the right places to support this.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs13
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs66
-rw-r--r--OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs92
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs6
5 files changed, 110 insertions, 69 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index 5c6bc1c..1d4c7f0 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -285,18 +285,7 @@ namespace OpenSim.Region.ClientStack.Linden
285 foreach (OSD c in capsRequested) 285 foreach (OSD c in capsRequested)
286 validCaps.Add(c.AsString()); 286 validCaps.Add(c.AsString());
287 287
288 Hashtable caps = m_HostCapsObj.CapsHandlers.GetCapsDetails(true, validCaps); 288 string result = LLSDHelpers.SerialiseLLSDReply(m_HostCapsObj.GetCapsDetails(true, validCaps));
289
290 // Add the external too
291 foreach (KeyValuePair<string, string> kvp in m_HostCapsObj.ExternalCapsHandlers)
292 {
293 if (!validCaps.Contains(kvp.Key))
294 continue;
295
296 caps[kvp.Key] = kvp.Value;
297 }
298
299 string result = LLSDHelpers.SerialiseLLSDReply(caps);
300 289
301 //m_log.DebugFormat("[CAPS] CapsRequest {0}", result); 290 //m_log.DebugFormat("[CAPS] CapsRequest {0}", result);
302 291
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index 50bfda1..ca38a97 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -377,7 +377,7 @@ namespace OpenSim.Region.ClientStack.Linden
377 // TODO: Add EventQueueGet name/description for diagnostics 377 // TODO: Add EventQueueGet name/description for diagnostics
378 MainServer.Instance.AddPollServiceHTTPHandler( 378 MainServer.Instance.AddPollServiceHTTPHandler(
379 eventQueueGetPath, 379 eventQueueGetPath,
380 new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID, 40000)); 380 new PollServiceEventArgs(null, eventQueueGetPath, HasEvents, GetEvents, NoEvents, agentID, 40000));
381 381
382// m_log.DebugFormat( 382// m_log.DebugFormat(
383// "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", 383// "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}",
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
index b90df17..86a0298 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
@@ -77,7 +77,6 @@ namespace OpenSim.Region.ClientStack.Linden
77 77
78 private static WebFetchInvDescHandler m_webFetchHandler; 78 private static WebFetchInvDescHandler m_webFetchHandler;
79 79
80 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>();
81 private static Thread[] m_workerThreads = null; 80 private static Thread[] m_workerThreads = null;
82 81
83 private static DoubleQueue<aPollRequest> m_queue = 82 private static DoubleQueue<aPollRequest> m_queue =
@@ -114,7 +113,6 @@ namespace OpenSim.Region.ClientStack.Linden
114 return; 113 return;
115 114
116 m_scene.EventManager.OnRegisterCaps -= RegisterCaps; 115 m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
117 m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps;
118 116
119 foreach (Thread t in m_workerThreads) 117 foreach (Thread t in m_workerThreads)
120 Watchdog.AbortThread(t.ManagedThreadId); 118 Watchdog.AbortThread(t.ManagedThreadId);
@@ -134,7 +132,6 @@ namespace OpenSim.Region.ClientStack.Linden
134 m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService); 132 m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService);
135 133
136 m_scene.EventManager.OnRegisterCaps += RegisterCaps; 134 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
137 m_scene.EventManager.OnDeregisterCaps += DeregisterCaps;
138 135
139 if (m_workerThreads == null) 136 if (m_workerThreads == null)
140 { 137 {
@@ -177,8 +174,8 @@ namespace OpenSim.Region.ClientStack.Linden
177 174
178 private Scene m_scene; 175 private Scene m_scene;
179 176
180 public PollServiceInventoryEventArgs(Scene scene, UUID pId) : 177 public PollServiceInventoryEventArgs(Scene scene, string url, UUID pId) :
181 base(null, null, null, null, pId, int.MaxValue) 178 base(null, url, null, null, null, pId, int.MaxValue)
182 { 179 {
183 m_scene = scene; 180 m_scene = scene;
184 181
@@ -308,40 +305,39 @@ namespace OpenSim.Region.ClientStack.Linden
308 if (m_fetchInventoryDescendents2Url == "") 305 if (m_fetchInventoryDescendents2Url == "")
309 return; 306 return;
310 307
311 string capUrl = "/CAPS/" + UUID.Random() + "/";
312
313 // Register this as a poll service 308 // Register this as a poll service
314 PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(m_scene, agentID); 309 PollServiceInventoryEventArgs args
315 310 = new PollServiceInventoryEventArgs(m_scene, "/CAPS/" + UUID.Random() + "/", agentID);
316 args.Type = PollServiceEventArgs.EventType.Inventory; 311 args.Type = PollServiceEventArgs.EventType.Inventory;
317 MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args);
318
319 string hostName = m_scene.RegionInfo.ExternalHostName;
320 uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port;
321 string protocol = "http";
322
323 if (MainServer.Instance.UseSSL)
324 {
325 hostName = MainServer.Instance.SSLCommonName;
326 port = MainServer.Instance.SSLPort;
327 protocol = "https";
328 }
329
330 caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl));
331 312
332 m_capsDict[agentID] = capUrl; 313 caps.RegisterPollHandler("FetchInventoryDescendents2", args);
314
315// MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args);
316//
317// string hostName = m_scene.RegionInfo.ExternalHostName;
318// uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port;
319// string protocol = "http";
320//
321// if (MainServer.Instance.UseSSL)
322// {
323// hostName = MainServer.Instance.SSLCommonName;
324// port = MainServer.Instance.SSLPort;
325// protocol = "https";
326// }
327//
328// caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl));
333 } 329 }
334 330
335 private void DeregisterCaps(UUID agentID, Caps caps) 331// private void DeregisterCaps(UUID agentID, Caps caps)
336 { 332// {
337 string capUrl; 333// string capUrl;
338 334//
339 if (m_capsDict.TryGetValue(agentID, out capUrl)) 335// if (m_capsDict.TryGetValue(agentID, out capUrl))
340 { 336// {
341 MainServer.Instance.RemoveHTTPHandler("", capUrl); 337// MainServer.Instance.RemoveHTTPHandler("", capUrl);
342 m_capsDict.Remove(agentID); 338// m_capsDict.Remove(agentID);
343 } 339// }
344 } 340// }
345 341
346 private void DoInventoryRequests() 342 private void DoInventoryRequests()
347 { 343 {
@@ -355,4 +351,4 @@ namespace OpenSim.Region.ClientStack.Linden
355 } 351 }
356 } 352 }
357 } 353 }
358} 354} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
index bd60611..ad1c4ce 100644
--- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.Framework
80 80
81 MainConsole.Instance.Commands.AddCommand( 81 MainConsole.Instance.Commands.AddCommand(
82 "Comms", false, "show caps stats by user", 82 "Comms", false, "show caps stats by user",
83 "show caps stats [<first-name> <last-name>]", 83 "show caps stats by user [<first-name> <last-name>]",
84 "Shows statistics on capabilities use by user.", 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.", 85 "If a user name is given, then prints a detailed breakdown of caps use ordered by number of requests received.",
86 HandleShowCapsStatsByUserCommand); 86 HandleShowCapsStatsByUserCommand);
@@ -285,27 +285,31 @@ namespace OpenSim.Region.CoreModules.Framework
285 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) 285 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
286 return; 286 return;
287 287
288 StringBuilder caps = new StringBuilder(); 288 StringBuilder capsReport = new StringBuilder();
289 caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); 289 capsReport.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName);
290 290
291 lock (m_capsObjects) 291 lock (m_capsObjects)
292 { 292 {
293 foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects) 293 foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects)
294 { 294 {
295 caps.AppendFormat("** User {0}:\n", kvp.Key); 295 capsReport.AppendFormat("** User {0}:\n", kvp.Key);
296 Caps caps = kvp.Value;
296 297
297 for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) 298 for (IDictionaryEnumerator kvp2 = caps.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); )
298 { 299 {
299 Uri uri = new Uri(kvp2.Value.ToString()); 300 Uri uri = new Uri(kvp2.Value.ToString());
300 caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); 301 capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery);
301 } 302 }
302 303
303 foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers) 304 foreach (KeyValuePair<string, PollServiceEventArgs> kvp2 in caps.GetPollHandlers())
304 caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); 305 capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, kvp2.Value.Url);
306
307 foreach (KeyValuePair<string, string> kvp3 in caps.ExternalCapsHandlers)
308 capsReport.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value);
305 } 309 }
306 } 310 }
307 311
308 MainConsole.Instance.Output(caps.ToString()); 312 MainConsole.Instance.Output(capsReport.ToString());
309 } 313 }
310 314
311 private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams) 315 private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams)
@@ -362,7 +366,16 @@ namespace OpenSim.Region.CoreModules.Framework
362 { 366 {
363 receivedStats[sp.Name] = reqHandler.RequestsReceived; 367 receivedStats[sp.Name] = reqHandler.RequestsReceived;
364 handledStats[sp.Name] = reqHandler.RequestsHandled; 368 handledStats[sp.Name] = reqHandler.RequestsHandled;
365 } 369 }
370 else
371 {
372 PollServiceEventArgs pollHandler = null;
373 if (caps.TryGetPollHandler(capName, out pollHandler))
374 {
375 receivedStats[sp.Name] = pollHandler.RequestsReceived;
376 handledStats[sp.Name] = pollHandler.RequestsHandled;
377 }
378 }
366 } 379 }
367 ); 380 );
368 381
@@ -391,11 +404,9 @@ namespace OpenSim.Region.CoreModules.Framework
391 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); 404 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
392 405
393 if (caps == null) 406 if (caps == null)
394 return; 407 return;
395
396 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
397 408
398 foreach (IRequestHandler reqHandler in capsHandlers.Values) 409 foreach (IRequestHandler reqHandler in caps.CapsHandlers.GetCapsHandlers().Values)
399 { 410 {
400 string reqName = reqHandler.Name ?? ""; 411 string reqName = reqHandler.Name ?? "";
401 412
@@ -410,6 +421,23 @@ namespace OpenSim.Region.CoreModules.Framework
410 handledStats[reqName] += reqHandler.RequestsHandled; 421 handledStats[reqName] += reqHandler.RequestsHandled;
411 } 422 }
412 } 423 }
424
425 foreach (KeyValuePair<string, PollServiceEventArgs> kvp in caps.GetPollHandlers())
426 {
427 string name = kvp.Key;
428 PollServiceEventArgs pollHandler = kvp.Value;
429
430 if (!receivedStats.ContainsKey(name))
431 {
432 receivedStats[name] = pollHandler.RequestsReceived;
433 handledStats[name] = pollHandler.RequestsHandled;
434 }
435 else
436 {
437 receivedStats[name] += pollHandler.RequestsReceived;
438 handledStats[name] += pollHandler.RequestsHandled;
439 }
440 }
413 } 441 }
414 ); 442 );
415 443
@@ -468,12 +496,16 @@ namespace OpenSim.Region.CoreModules.Framework
468 if (caps == null) 496 if (caps == null)
469 return; 497 return;
470 498
471 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); 499 List<CapTableRow> capRows = new List<CapTableRow>();
472 500
473 foreach (IRequestHandler reqHandler in capsHandlers.Values.OrderByDescending(rh => rh.RequestsReceived)) 501 foreach (IRequestHandler reqHandler in caps.CapsHandlers.GetCapsHandlers().Values)
474 { 502 capRows.Add(new CapTableRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled));
475 cdt.AddRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled); 503
476 } 504 foreach (KeyValuePair<string, PollServiceEventArgs> kvp in caps.GetPollHandlers())
505 capRows.Add(new CapTableRow(kvp.Key, kvp.Value.RequestsReceived, kvp.Value.RequestsHandled));
506
507 foreach (CapTableRow ctr in capRows.OrderByDescending(ctr => ctr.RequestsReceived))
508 cdt.AddRow(ctr.Name, ctr.RequestsReceived, ctr.RequestsHandled);
477 509
478 sb.Append(cdt.ToString()); 510 sb.Append(cdt.ToString());
479 } 511 }
@@ -505,6 +537,14 @@ namespace OpenSim.Region.CoreModules.Framework
505 totalRequestsReceived += reqHandler.RequestsReceived; 537 totalRequestsReceived += reqHandler.RequestsReceived;
506 totalRequestsHandled += reqHandler.RequestsHandled; 538 totalRequestsHandled += reqHandler.RequestsHandled;
507 } 539 }
540
541 Dictionary<string, PollServiceEventArgs> capsPollHandlers = caps.GetPollHandlers();
542
543 foreach (PollServiceEventArgs handler in capsPollHandlers.Values)
544 {
545 totalRequestsReceived += handler.RequestsReceived;
546 totalRequestsHandled += handler.RequestsHandled;
547 }
508 548
509 cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled); 549 cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled);
510 } 550 }
@@ -512,5 +552,19 @@ namespace OpenSim.Region.CoreModules.Framework
512 552
513 sb.Append(cdt.ToString()); 553 sb.Append(cdt.ToString());
514 } 554 }
555
556 private class CapTableRow
557 {
558 public string Name { get; set; }
559 public int RequestsReceived { get; set; }
560 public int RequestsHandled { get; set; }
561
562 public CapTableRow(string name, int requestsReceived, int requestsHandled)
563 {
564 Name = name;
565 RequestsReceived = requestsReceived;
566 RequestsHandled = requestsHandled;
567 }
568 }
515 } 569 }
516} \ No newline at end of file 570} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index def8162..99a3122 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -235,7 +235,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
235 235
236 string uri = "/lslhttp/" + urlcode.ToString() + "/"; 236 string uri = "/lslhttp/" + urlcode.ToString() + "/";
237 237
238 PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); 238 PollServiceEventArgs args
239 = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000);
239 args.Type = PollServiceEventArgs.EventType.LslHttp; 240 args.Type = PollServiceEventArgs.EventType.LslHttp;
240 m_HttpServer.AddPollServiceHTTPHandler(uri, args); 241 m_HttpServer.AddPollServiceHTTPHandler(uri, args);
241 242
@@ -280,7 +281,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
280 281
281 string uri = "/lslhttps/" + urlcode.ToString() + "/"; 282 string uri = "/lslhttps/" + urlcode.ToString() + "/";
282 283
283 PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); 284 PollServiceEventArgs args
285 = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000);
284 args.Type = PollServiceEventArgs.EventType.LslHttp; 286 args.Type = PollServiceEventArgs.EventType.LslHttp;
285 m_HttpsServer.AddPollServiceHTTPHandler(uri, args); 287 m_HttpsServer.AddPollServiceHTTPHandler(uri, args);
286 288