aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2015-06-03 17:42:41 -0700
committerDiva Canto2015-06-03 17:42:41 -0700
commitbac53387a9868f3765175179aecd3b97981d54a0 (patch)
tree68856ca9441d200d5ef83d7d616fdb9a94b91473
parentI suspect the viewer doesn't need the target of linked items inside linked fo... (diff)
downloadopensim-SC_OLD-bac53387a9868f3765175179aecd3b97981d54a0.zip
opensim-SC_OLD-bac53387a9868f3765175179aecd3b97981d54a0.tar.gz
opensim-SC_OLD-bac53387a9868f3765175179aecd3b97981d54a0.tar.bz2
opensim-SC_OLD-bac53387a9868f3765175179aecd3b97981d54a0.tar.xz
Mantis #7567: added an 8-sec expiring item cache to the inventory network connector. This fixed the problem on my local test grid and generally made things faster. This cache has been needed for a while... there are many parts in the code where the sim gets an item multiple times in a short amount of time (rezzing attachs and objects, for example).
Other minor changes: - added the scene as a parameter to the constructor od FetchInvDescHandler, so that I could see in which scene the handler was being called - brought linked items in linked folders back to being prefetched
-rw-r--r--OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs35
-rw-r--r--OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescServerConnector.cs2
-rw-r--r--OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs2
-rw-r--r--OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs8
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs2
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs37
6 files changed, 57 insertions, 29 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs
index 1b7d3f5..62ca8a3 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs
@@ -50,18 +50,21 @@ namespace OpenSim.Capabilities.Handlers
50 50
51 private IInventoryService m_InventoryService; 51 private IInventoryService m_InventoryService;
52 private ILibraryService m_LibraryService; 52 private ILibraryService m_LibraryService;
53 private IScene m_Scene;
53// private object m_fetchLock = new Object(); 54// private object m_fetchLock = new Object();
54 55
55 public FetchInvDescHandler(IInventoryService invService, ILibraryService libService) 56 public FetchInvDescHandler(IInventoryService invService, ILibraryService libService, IScene s)
56 { 57 {
57 m_InventoryService = invService; 58 m_InventoryService = invService;
58 m_LibraryService = libService; 59 m_LibraryService = libService;
60 m_Scene = s;
59 } 61 }
60 62
61 63
62 public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 64 public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
63 { 65 {
64 66 //m_log.DebugFormat("[XXX]: FetchInventoryDescendentsRequest in {0}, {1}", (m_Scene == null) ? "none" : m_Scene.Name, request);
67
65 // nasty temporary hack here, the linden client falsely 68 // nasty temporary hack here, the linden client falsely
66 // identifies the uuid 00000000-0000-0000-0000-000000000000 69 // identifies the uuid 00000000-0000-0000-0000-000000000000
67 // as a string which breaks us 70 // as a string which breaks us
@@ -725,20 +728,20 @@ namespace OpenSim.Capabilities.Handlers
725 728
726 itemsToReturn.InsertRange(0, links); 729 itemsToReturn.InsertRange(0, links);
727 730
728 //foreach (InventoryItemBase link in linkedFolderContents.Items) 731 foreach (InventoryItemBase link in linkedFolderContents.Items)
729 //{ 732 {
730 // // Take care of genuinely broken links where the target doesn't exist 733 // Take care of genuinely broken links where the target doesn't exist
731 // // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, 734 // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate,
732 // // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles 735 // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles
733 // // rather than having to keep track of every folder requested in the recursion. 736 // rather than having to keep track of every folder requested in the recursion.
734 // if (link != null && link.AssetType == (int)AssetType.Link) 737 if (link != null && link.AssetType == (int)AssetType.Link)
735 // { 738 {
736 // //m_log.DebugFormat( 739 //m_log.DebugFormat(
737 // // "[WEB FETCH INV DESC HANDLER]: Adding item {0} {1} from folder {2} linked from {3} ({4} {5})", 740 // "[WEB FETCH INV DESC HANDLER]: Adding item {0} {1} from folder {2} linked from {3} ({4} {5})",
738 // // link.Name, (AssetType)link.AssetType, linkedFolderContents.FolderID, contents.FolderID, link.ID, link.AssetID); 741 // link.Name, (AssetType)link.AssetType, linkedFolderContents.FolderID, contents.FolderID, link.ID, link.AssetID);
739 // itemIDs.Add(link.AssetID); 742 itemIDs.Add(link.AssetID);
740 // } 743 }
741 //} 744 }
742 } 745 }
743 } 746 }
744 747
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescServerConnector.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescServerConnector.cs
index 6fbe173..9dcfaa4 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescServerConnector.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescServerConnector.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Capabilities.Handlers
67 m_LibraryService = 67 m_LibraryService =
68 ServerUtils.LoadPlugin<ILibraryService>(libService, args); 68 ServerUtils.LoadPlugin<ILibraryService>(libService, args);
69 69
70 FetchInvDescHandler webFetchHandler = new FetchInvDescHandler(m_InventoryService, m_LibraryService); 70 FetchInvDescHandler webFetchHandler = new FetchInvDescHandler(m_InventoryService, m_LibraryService, null);
71 IRequestHandler reqHandler 71 IRequestHandler reqHandler
72 = new RestStreamHandler( 72 = new RestStreamHandler(
73 "POST", 73 "POST",
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
index 0832b02..c904392 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Capabilities.Handlers
54 54
55 public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 55 public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
56 { 56 {
57// m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capabilty request"); 57 //m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request);
58 58
59 OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request)); 59 OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
60 OSDArray itemsRequested = (OSDArray)requestmap["items"]; 60 OSDArray itemsRequested = (OSDArray)requestmap["items"];
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs b/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs
index 056b4db..380c54a 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs
@@ -133,7 +133,7 @@ namespace OpenSim.Capabilities.Handlers.FetchInventory.Tests
133 133
134 Init(); 134 Init();
135 135
136 FetchInvDescHandler handler = new FetchInvDescHandler(m_scene.InventoryService, null); 136 FetchInvDescHandler handler = new FetchInvDescHandler(m_scene.InventoryService, null, m_scene);
137 TestOSHttpRequest req = new TestOSHttpRequest(); 137 TestOSHttpRequest req = new TestOSHttpRequest();
138 TestOSHttpResponse resp = new TestOSHttpResponse(); 138 TestOSHttpResponse resp = new TestOSHttpResponse();
139 139
@@ -157,7 +157,7 @@ namespace OpenSim.Capabilities.Handlers.FetchInventory.Tests
157 { 157 {
158 TestHelpers.InMethod(); 158 TestHelpers.InMethod();
159 159
160 FetchInvDescHandler handler = new FetchInvDescHandler(m_scene.InventoryService, null); 160 FetchInvDescHandler handler = new FetchInvDescHandler(m_scene.InventoryService, null, m_scene);
161 TestOSHttpRequest req = new TestOSHttpRequest(); 161 TestOSHttpRequest req = new TestOSHttpRequest();
162 TestOSHttpResponse resp = new TestOSHttpResponse(); 162 TestOSHttpResponse resp = new TestOSHttpResponse();
163 163
@@ -187,7 +187,7 @@ namespace OpenSim.Capabilities.Handlers.FetchInventory.Tests
187 { 187 {
188 TestHelpers.InMethod(); 188 TestHelpers.InMethod();
189 189
190 FetchInvDescHandler handler = new FetchInvDescHandler(m_scene.InventoryService, null); 190 FetchInvDescHandler handler = new FetchInvDescHandler(m_scene.InventoryService, null, m_scene);
191 TestOSHttpRequest req = new TestOSHttpRequest(); 191 TestOSHttpRequest req = new TestOSHttpRequest();
192 TestOSHttpResponse resp = new TestOSHttpResponse(); 192 TestOSHttpResponse resp = new TestOSHttpResponse();
193 193
@@ -230,7 +230,7 @@ namespace OpenSim.Capabilities.Handlers.FetchInventory.Tests
230 { 230 {
231 TestHelpers.InMethod(); 231 TestHelpers.InMethod();
232 232
233 FetchInvDescHandler handler = new FetchInvDescHandler(m_scene.InventoryService, null); 233 FetchInvDescHandler handler = new FetchInvDescHandler(m_scene.InventoryService, null, m_scene);
234 TestOSHttpRequest req = new TestOSHttpRequest(); 234 TestOSHttpRequest req = new TestOSHttpRequest();
235 TestOSHttpResponse resp = new TestOSHttpResponse(); 235 TestOSHttpResponse resp = new TestOSHttpResponse();
236 236
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
index 30d1921..299b4f6 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
@@ -197,7 +197,7 @@ namespace OpenSim.Region.ClientStack.Linden
197 m_LibraryService = Scene.LibraryService; 197 m_LibraryService = Scene.LibraryService;
198 198
199 // We'll reuse the same handler for all requests. 199 // We'll reuse the same handler for all requests.
200 m_webFetchHandler = new FetchInvDescHandler(m_InventoryService, m_LibraryService); 200 m_webFetchHandler = new FetchInvDescHandler(m_InventoryService, m_LibraryService, Scene);
201 201
202 Scene.EventManager.OnRegisterCaps += RegisterCaps; 202 Scene.EventManager.OnRegisterCaps += RegisterCaps;
203 203
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
index db3c857..b123e9d 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
@@ -62,6 +62,9 @@ namespace OpenSim.Services.Connectors
62 /// </remarks> 62 /// </remarks>
63 private int m_requestTimeoutSecs = -1; 63 private int m_requestTimeoutSecs = -1;
64 64
65 private const double CACHE_EXPIRATION_SECONDS = 8.0;
66 private ExpiringCache<UUID, InventoryItemBase> m_ItemCache = new ExpiringCache<UUID,InventoryItemBase>();
67
65 public XInventoryServicesConnector() 68 public XInventoryServicesConnector()
66 { 69 {
67 } 70 }
@@ -511,6 +514,10 @@ namespace OpenSim.Services.Connectors
511 514
512 public InventoryItemBase GetItem(InventoryItemBase item) 515 public InventoryItemBase GetItem(InventoryItemBase item)
513 { 516 {
517 InventoryItemBase retrieved = null;
518 if (m_ItemCache.TryGetValue(item.ID, out retrieved))
519 return retrieved;
520
514 try 521 try
515 { 522 {
516 Dictionary<string, object> ret = MakeRequest("GETITEM", 523 Dictionary<string, object> ret = MakeRequest("GETITEM",
@@ -521,39 +528,57 @@ namespace OpenSim.Services.Connectors
521 if (!CheckReturn(ret)) 528 if (!CheckReturn(ret))
522 return null; 529 return null;
523 530
524 return BuildItem((Dictionary<string, object>)ret["item"]); 531 retrieved = BuildItem((Dictionary<string, object>)ret["item"]);
525 } 532 }
526 catch (Exception e) 533 catch (Exception e)
527 { 534 {
528 m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception in GetItem: ", e); 535 m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception in GetItem: ", e);
529 } 536 }
530 537
531 return null; 538 m_ItemCache.AddOrUpdate(item.ID, retrieved, CACHE_EXPIRATION_SECONDS);
539
540 return retrieved;
532 } 541 }
533 542
534 public virtual InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs) 543 public virtual InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs)
535 { 544 {
536 InventoryItemBase[] itemArr = new InventoryItemBase[itemIDs.Length]; 545 InventoryItemBase[] itemArr = new InventoryItemBase[itemIDs.Length];
546 // Try to get them from the cache
547 List<UUID> pending = new List<UUID>();
548 InventoryItemBase item = null;
549 int i = 0;
550 foreach (UUID id in itemIDs)
551 {
552 if (m_ItemCache.TryGetValue(id, out item))
553 itemArr[i++] = item;
554 else
555 pending.Add(id);
556 }
557
537 try 558 try
538 { 559 {
539 Dictionary<string, object> resultSet = MakeRequest("GETMULTIPLEITEMS", 560 Dictionary<string, object> resultSet = MakeRequest("GETMULTIPLEITEMS",
540 new Dictionary<string, object> { 561 new Dictionary<string, object> {
541 { "PRINCIPAL", principalID.ToString() }, 562 { "PRINCIPAL", principalID.ToString() },
542 { "ITEMS", String.Join(",", itemIDs) }, 563 { "ITEMS", String.Join(",", pending.ToArray()) },
543 { "COUNT", itemIDs.Length.ToString() } 564 { "COUNT", pending.Count.ToString() }
544 }); 565 });
545 566
546 if (!CheckReturn(resultSet)) 567 if (!CheckReturn(resultSet))
547 return null; 568 return null;
548 569
549 int i = 0; 570 // carry over index i where we left above
550 foreach (KeyValuePair<string, object> kvp in resultSet) 571 foreach (KeyValuePair<string, object> kvp in resultSet)
551 { 572 {
552 InventoryCollection inventory = new InventoryCollection(); 573 InventoryCollection inventory = new InventoryCollection();
553 if (kvp.Key.StartsWith("item_")) 574 if (kvp.Key.StartsWith("item_"))
554 { 575 {
555 if (kvp.Value is Dictionary<string, object>) 576 if (kvp.Value is Dictionary<string, object>)
556 itemArr[i++] = BuildItem((Dictionary<string, object>)kvp.Value); 577 {
578 item = BuildItem((Dictionary<string, object>)kvp.Value);
579 m_ItemCache.AddOrUpdate(item.ID, item, CACHE_EXPIRATION_SECONDS);
580 itemArr[i++] = item;
581 }
557 else 582 else
558 itemArr[i++] = null; 583 itemArr[i++] = null;
559 } 584 }