diff options
Diffstat (limited to '')
4 files changed, 194 insertions, 109 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index e474ef6..48f228a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs | |||
@@ -62,6 +62,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
62 | 62 | ||
63 | private InventoryCache m_Cache = new InventoryCache(); | 63 | private InventoryCache m_Cache = new InventoryCache(); |
64 | 64 | ||
65 | /// <summary> | ||
66 | /// Used to serialize inventory requests. | ||
67 | /// </summary> | ||
68 | private object m_Lock = new object(); | ||
69 | |||
65 | protected IUserManagement m_UserManagement; | 70 | protected IUserManagement m_UserManagement; |
66 | protected IUserManagement UserManagementModule | 71 | protected IUserManagement UserManagementModule |
67 | { | 72 | { |
@@ -233,13 +238,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
233 | if (sp != null) | 238 | if (sp != null) |
234 | { | 239 | { |
235 | AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | 240 | AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); |
241 | if (aCircuit == null) | ||
242 | return; | ||
243 | if (aCircuit.ServiceURLs == null) | ||
244 | return; | ||
245 | |||
236 | if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI")) | 246 | if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI")) |
237 | { | 247 | { |
238 | inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString(); | 248 | inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString(); |
239 | if (inventoryURL != null && inventoryURL != string.Empty) | 249 | if (inventoryURL != null && inventoryURL != string.Empty) |
240 | { | 250 | { |
241 | inventoryURL = inventoryURL.Trim(new char[] { '/' }); | 251 | inventoryURL = inventoryURL.Trim(new char[] { '/' }); |
242 | m_InventoryURLs.Add(userID, inventoryURL); | 252 | m_InventoryURLs[userID] = inventoryURL; |
243 | m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL); | 253 | m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL); |
244 | return; | 254 | return; |
245 | } | 255 | } |
@@ -254,7 +264,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
254 | if (sp == null) | 264 | if (sp == null) |
255 | { | 265 | { |
256 | inventoryURL = UserManagementModule.GetUserServerURL(userID, "InventoryServerURI"); | 266 | inventoryURL = UserManagementModule.GetUserServerURL(userID, "InventoryServerURI"); |
257 | if (inventoryURL != null && inventoryURL != string.Empty) | 267 | if (!string.IsNullOrEmpty(inventoryURL)) |
258 | { | 268 | { |
259 | inventoryURL = inventoryURL.Trim(new char[] { '/' }); | 269 | inventoryURL = inventoryURL.Trim(new char[] { '/' }); |
260 | m_InventoryURLs.Add(userID, inventoryURL); | 270 | m_InventoryURLs.Add(userID, inventoryURL); |
@@ -296,7 +306,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
296 | 306 | ||
297 | public bool CreateUserInventory(UUID userID) | 307 | public bool CreateUserInventory(UUID userID) |
298 | { | 308 | { |
299 | return m_LocalGridInventoryService.CreateUserInventory(userID); | 309 | lock (m_Lock) |
310 | return m_LocalGridInventoryService.CreateUserInventory(userID); | ||
300 | } | 311 | } |
301 | 312 | ||
302 | public List<InventoryFolderBase> GetInventorySkeleton(UUID userID) | 313 | public List<InventoryFolderBase> GetInventorySkeleton(UUID userID) |
@@ -304,36 +315,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
304 | string invURL = GetInventoryServiceURL(userID); | 315 | string invURL = GetInventoryServiceURL(userID); |
305 | 316 | ||
306 | if (invURL == null) // not there, forward to local inventory connector to resolve | 317 | if (invURL == null) // not there, forward to local inventory connector to resolve |
307 | return m_LocalGridInventoryService.GetInventorySkeleton(userID); | 318 | lock (m_Lock) |
319 | return m_LocalGridInventoryService.GetInventorySkeleton(userID); | ||
308 | 320 | ||
309 | IInventoryService connector = GetConnector(invURL); | 321 | IInventoryService connector = GetConnector(invURL); |
310 | 322 | ||
311 | return connector.GetInventorySkeleton(userID); | 323 | return connector.GetInventorySkeleton(userID); |
312 | } | 324 | } |
313 | 325 | ||
314 | public InventoryCollection GetUserInventory(UUID userID) | ||
315 | { | ||
316 | string invURL = GetInventoryServiceURL(userID); | ||
317 | m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetUserInventory for {0} {1}", userID, invURL); | ||
318 | |||
319 | if (invURL == null) // not there, forward to local inventory connector to resolve | ||
320 | return m_LocalGridInventoryService.GetUserInventory(userID); | ||
321 | |||
322 | InventoryCollection c = m_Cache.GetUserInventory(userID); | ||
323 | if (c != null) | ||
324 | return c; | ||
325 | |||
326 | IInventoryService connector = GetConnector(invURL); | ||
327 | c = connector.GetUserInventory(userID); | ||
328 | |||
329 | m_Cache.Cache(userID, c); | ||
330 | return c; | ||
331 | } | ||
332 | |||
333 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) | ||
334 | { | ||
335 | } | ||
336 | |||
337 | public InventoryFolderBase GetRootFolder(UUID userID) | 326 | public InventoryFolderBase GetRootFolder(UUID userID) |
338 | { | 327 | { |
339 | //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID); | 328 | //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID); |
@@ -344,7 +333,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
344 | string invURL = GetInventoryServiceURL(userID); | 333 | string invURL = GetInventoryServiceURL(userID); |
345 | 334 | ||
346 | if (invURL == null) // not there, forward to local inventory connector to resolve | 335 | if (invURL == null) // not there, forward to local inventory connector to resolve |
347 | return m_LocalGridInventoryService.GetRootFolder(userID); | 336 | lock (m_Lock) |
337 | return m_LocalGridInventoryService.GetRootFolder(userID); | ||
348 | 338 | ||
349 | IInventoryService connector = GetConnector(invURL); | 339 | IInventoryService connector = GetConnector(invURL); |
350 | 340 | ||
@@ -355,7 +345,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
355 | return root; | 345 | return root; |
356 | } | 346 | } |
357 | 347 | ||
358 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | 348 | public InventoryFolderBase GetFolderForType(UUID userID, FolderType type) |
359 | { | 349 | { |
360 | //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetFolderForType {0} type {1}", userID, type); | 350 | //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetFolderForType {0} type {1}", userID, type); |
361 | InventoryFolderBase f = m_Cache.GetFolderForType(userID, type); | 351 | InventoryFolderBase f = m_Cache.GetFolderForType(userID, type); |
@@ -365,7 +355,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
365 | string invURL = GetInventoryServiceURL(userID); | 355 | string invURL = GetInventoryServiceURL(userID); |
366 | 356 | ||
367 | if (invURL == null) // not there, forward to local inventory connector to resolve | 357 | if (invURL == null) // not there, forward to local inventory connector to resolve |
368 | return m_LocalGridInventoryService.GetFolderForType(userID, type); | 358 | lock (m_Lock) |
359 | return m_LocalGridInventoryService.GetFolderForType(userID, type); | ||
369 | 360 | ||
370 | IInventoryService connector = GetConnector(invURL); | 361 | IInventoryService connector = GetConnector(invURL); |
371 | 362 | ||
@@ -383,7 +374,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
383 | string invURL = GetInventoryServiceURL(userID); | 374 | string invURL = GetInventoryServiceURL(userID); |
384 | 375 | ||
385 | if (invURL == null) // not there, forward to local inventory connector to resolve | 376 | if (invURL == null) // not there, forward to local inventory connector to resolve |
386 | return m_LocalGridInventoryService.GetFolderContent(userID, folderID); | 377 | lock (m_Lock) |
378 | return m_LocalGridInventoryService.GetFolderContent(userID, folderID); | ||
387 | 379 | ||
388 | InventoryCollection c = m_Cache.GetFolderContent(userID, folderID); | 380 | InventoryCollection c = m_Cache.GetFolderContent(userID, folderID); |
389 | if (c != null) | 381 | if (c != null) |
@@ -393,8 +385,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
393 | } | 385 | } |
394 | 386 | ||
395 | IInventoryService connector = GetConnector(invURL); | 387 | IInventoryService connector = GetConnector(invURL); |
388 | |||
396 | return connector.GetFolderContent(userID, folderID); | 389 | return connector.GetFolderContent(userID, folderID); |
390 | } | ||
397 | 391 | ||
392 | public InventoryCollection[] GetMultipleFoldersContent(UUID userID, UUID[] folderIDs) | ||
393 | { | ||
394 | string invURL = GetInventoryServiceURL(userID); | ||
395 | |||
396 | if (invURL == null) // not there, forward to local inventory connector to resolve | ||
397 | lock (m_Lock) | ||
398 | return m_LocalGridInventoryService.GetMultipleFoldersContent(userID, folderIDs); | ||
399 | |||
400 | else | ||
401 | { | ||
402 | InventoryCollection[] coll = new InventoryCollection[folderIDs.Length]; | ||
403 | int i = 0; | ||
404 | foreach (UUID fid in folderIDs) | ||
405 | coll[i++] = GetFolderContent(userID, fid); | ||
406 | |||
407 | return coll; | ||
408 | } | ||
398 | } | 409 | } |
399 | 410 | ||
400 | public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) | 411 | public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) |
@@ -404,7 +415,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
404 | string invURL = GetInventoryServiceURL(userID); | 415 | string invURL = GetInventoryServiceURL(userID); |
405 | 416 | ||
406 | if (invURL == null) // not there, forward to local inventory connector to resolve | 417 | if (invURL == null) // not there, forward to local inventory connector to resolve |
407 | return m_LocalGridInventoryService.GetFolderItems(userID, folderID); | 418 | lock (m_Lock) |
419 | return m_LocalGridInventoryService.GetFolderItems(userID, folderID); | ||
408 | 420 | ||
409 | List<InventoryItemBase> items = m_Cache.GetFolderItems(userID, folderID); | 421 | List<InventoryItemBase> items = m_Cache.GetFolderItems(userID, folderID); |
410 | if (items != null) | 422 | if (items != null) |
@@ -414,8 +426,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
414 | } | 426 | } |
415 | 427 | ||
416 | IInventoryService connector = GetConnector(invURL); | 428 | IInventoryService connector = GetConnector(invURL); |
417 | return connector.GetFolderItems(userID, folderID); | ||
418 | 429 | ||
430 | return connector.GetFolderItems(userID, folderID); | ||
419 | } | 431 | } |
420 | 432 | ||
421 | public bool AddFolder(InventoryFolderBase folder) | 433 | public bool AddFolder(InventoryFolderBase folder) |
@@ -428,7 +440,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
428 | string invURL = GetInventoryServiceURL(folder.Owner); | 440 | string invURL = GetInventoryServiceURL(folder.Owner); |
429 | 441 | ||
430 | if (invURL == null) // not there, forward to local inventory connector to resolve | 442 | if (invURL == null) // not there, forward to local inventory connector to resolve |
431 | return m_LocalGridInventoryService.AddFolder(folder); | 443 | lock (m_Lock) |
444 | return m_LocalGridInventoryService.AddFolder(folder); | ||
432 | 445 | ||
433 | IInventoryService connector = GetConnector(invURL); | 446 | IInventoryService connector = GetConnector(invURL); |
434 | 447 | ||
@@ -445,7 +458,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
445 | string invURL = GetInventoryServiceURL(folder.Owner); | 458 | string invURL = GetInventoryServiceURL(folder.Owner); |
446 | 459 | ||
447 | if (invURL == null) // not there, forward to local inventory connector to resolve | 460 | if (invURL == null) // not there, forward to local inventory connector to resolve |
448 | return m_LocalGridInventoryService.UpdateFolder(folder); | 461 | lock (m_Lock) |
462 | return m_LocalGridInventoryService.UpdateFolder(folder); | ||
449 | 463 | ||
450 | IInventoryService connector = GetConnector(invURL); | 464 | IInventoryService connector = GetConnector(invURL); |
451 | 465 | ||
@@ -464,7 +478,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
464 | string invURL = GetInventoryServiceURL(ownerID); | 478 | string invURL = GetInventoryServiceURL(ownerID); |
465 | 479 | ||
466 | if (invURL == null) // not there, forward to local inventory connector to resolve | 480 | if (invURL == null) // not there, forward to local inventory connector to resolve |
467 | return m_LocalGridInventoryService.DeleteFolders(ownerID, folderIDs); | 481 | lock (m_Lock) |
482 | return m_LocalGridInventoryService.DeleteFolders(ownerID, folderIDs); | ||
468 | 483 | ||
469 | IInventoryService connector = GetConnector(invURL); | 484 | IInventoryService connector = GetConnector(invURL); |
470 | 485 | ||
@@ -481,7 +496,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
481 | string invURL = GetInventoryServiceURL(folder.Owner); | 496 | string invURL = GetInventoryServiceURL(folder.Owner); |
482 | 497 | ||
483 | if (invURL == null) // not there, forward to local inventory connector to resolve | 498 | if (invURL == null) // not there, forward to local inventory connector to resolve |
484 | return m_LocalGridInventoryService.MoveFolder(folder); | 499 | lock (m_Lock) |
500 | return m_LocalGridInventoryService.MoveFolder(folder); | ||
485 | 501 | ||
486 | IInventoryService connector = GetConnector(invURL); | 502 | IInventoryService connector = GetConnector(invURL); |
487 | 503 | ||
@@ -498,7 +514,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
498 | string invURL = GetInventoryServiceURL(folder.Owner); | 514 | string invURL = GetInventoryServiceURL(folder.Owner); |
499 | 515 | ||
500 | if (invURL == null) // not there, forward to local inventory connector to resolve | 516 | if (invURL == null) // not there, forward to local inventory connector to resolve |
501 | return m_LocalGridInventoryService.PurgeFolder(folder); | 517 | lock (m_Lock) |
518 | return m_LocalGridInventoryService.PurgeFolder(folder); | ||
502 | 519 | ||
503 | IInventoryService connector = GetConnector(invURL); | 520 | IInventoryService connector = GetConnector(invURL); |
504 | 521 | ||
@@ -515,7 +532,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
515 | string invURL = GetInventoryServiceURL(item.Owner); | 532 | string invURL = GetInventoryServiceURL(item.Owner); |
516 | 533 | ||
517 | if (invURL == null) // not there, forward to local inventory connector to resolve | 534 | if (invURL == null) // not there, forward to local inventory connector to resolve |
518 | return m_LocalGridInventoryService.AddItem(item); | 535 | lock (m_Lock) |
536 | return m_LocalGridInventoryService.AddItem(item); | ||
519 | 537 | ||
520 | IInventoryService connector = GetConnector(invURL); | 538 | IInventoryService connector = GetConnector(invURL); |
521 | 539 | ||
@@ -532,7 +550,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
532 | string invURL = GetInventoryServiceURL(item.Owner); | 550 | string invURL = GetInventoryServiceURL(item.Owner); |
533 | 551 | ||
534 | if (invURL == null) // not there, forward to local inventory connector to resolve | 552 | if (invURL == null) // not there, forward to local inventory connector to resolve |
535 | return m_LocalGridInventoryService.UpdateItem(item); | 553 | lock (m_Lock) |
554 | return m_LocalGridInventoryService.UpdateItem(item); | ||
536 | 555 | ||
537 | IInventoryService connector = GetConnector(invURL); | 556 | IInventoryService connector = GetConnector(invURL); |
538 | 557 | ||
@@ -551,7 +570,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
551 | string invURL = GetInventoryServiceURL(ownerID); | 570 | string invURL = GetInventoryServiceURL(ownerID); |
552 | 571 | ||
553 | if (invURL == null) // not there, forward to local inventory connector to resolve | 572 | if (invURL == null) // not there, forward to local inventory connector to resolve |
554 | return m_LocalGridInventoryService.MoveItems(ownerID, items); | 573 | lock (m_Lock) |
574 | return m_LocalGridInventoryService.MoveItems(ownerID, items); | ||
555 | 575 | ||
556 | IInventoryService connector = GetConnector(invURL); | 576 | IInventoryService connector = GetConnector(invURL); |
557 | 577 | ||
@@ -570,7 +590,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
570 | string invURL = GetInventoryServiceURL(ownerID); | 590 | string invURL = GetInventoryServiceURL(ownerID); |
571 | 591 | ||
572 | if (invURL == null) // not there, forward to local inventory connector to resolve | 592 | if (invURL == null) // not there, forward to local inventory connector to resolve |
573 | return m_LocalGridInventoryService.DeleteItems(ownerID, itemIDs); | 593 | lock (m_Lock) |
594 | return m_LocalGridInventoryService.DeleteItems(ownerID, itemIDs); | ||
574 | 595 | ||
575 | IInventoryService connector = GetConnector(invURL); | 596 | IInventoryService connector = GetConnector(invURL); |
576 | 597 | ||
@@ -586,13 +607,31 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
586 | string invURL = GetInventoryServiceURL(item.Owner); | 607 | string invURL = GetInventoryServiceURL(item.Owner); |
587 | 608 | ||
588 | if (invURL == null) // not there, forward to local inventory connector to resolve | 609 | if (invURL == null) // not there, forward to local inventory connector to resolve |
589 | return m_LocalGridInventoryService.GetItem(item); | 610 | lock (m_Lock) |
611 | return m_LocalGridInventoryService.GetItem(item); | ||
590 | 612 | ||
591 | IInventoryService connector = GetConnector(invURL); | 613 | IInventoryService connector = GetConnector(invURL); |
592 | 614 | ||
593 | return connector.GetItem(item); | 615 | return connector.GetItem(item); |
594 | } | 616 | } |
595 | 617 | ||
618 | public InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] itemIDs) | ||
619 | { | ||
620 | if (itemIDs == null) | ||
621 | return new InventoryItemBase[0]; | ||
622 | //m_log.Debug("[HG INVENTORY CONNECTOR]: GetItem " + item.ID); | ||
623 | |||
624 | string invURL = GetInventoryServiceURL(userID); | ||
625 | |||
626 | if (invURL == null) // not there, forward to local inventory connector to resolve | ||
627 | lock (m_Lock) | ||
628 | return m_LocalGridInventoryService.GetMultipleItems(userID, itemIDs); | ||
629 | |||
630 | IInventoryService connector = GetConnector(invURL); | ||
631 | |||
632 | return connector.GetMultipleItems(userID, itemIDs); | ||
633 | } | ||
634 | |||
596 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) | 635 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) |
597 | { | 636 | { |
598 | if (folder == null) | 637 | if (folder == null) |
@@ -603,7 +642,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
603 | string invURL = GetInventoryServiceURL(folder.Owner); | 642 | string invURL = GetInventoryServiceURL(folder.Owner); |
604 | 643 | ||
605 | if (invURL == null) // not there, forward to local inventory connector to resolve | 644 | if (invURL == null) // not there, forward to local inventory connector to resolve |
606 | return m_LocalGridInventoryService.GetFolder(folder); | 645 | lock (m_Lock) |
646 | return m_LocalGridInventoryService.GetFolder(folder); | ||
607 | 647 | ||
608 | IInventoryService connector = GetConnector(invURL); | 648 | IInventoryService connector = GetConnector(invURL); |
609 | 649 | ||
@@ -627,7 +667,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
627 | string invURL = GetInventoryServiceURL(userID); | 667 | string invURL = GetInventoryServiceURL(userID); |
628 | 668 | ||
629 | if (invURL == null) // not there, forward to local inventory connector to resolve | 669 | if (invURL == null) // not there, forward to local inventory connector to resolve |
630 | return m_LocalGridInventoryService.GetAssetPermissions(userID, assetID); | 670 | lock (m_Lock) |
671 | return m_LocalGridInventoryService.GetAssetPermissions(userID, assetID); | ||
631 | 672 | ||
632 | IInventoryService connector = GetConnector(invURL); | 673 | IInventoryService connector = GetConnector(invURL); |
633 | 674 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs index 1e434b9..3195e6b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs | |||
@@ -1,23 +1,52 @@ | |||
1 | using System; | 1 | /* |
2 | using System.Collections.Generic; | 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 | */ | ||
3 | 27 | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Threading; | ||
4 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
5 | using OpenMetaverse; | 32 | using OpenMetaverse; |
6 | 33 | ||
7 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | 34 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory |
8 | { | 35 | { |
36 | /// <summary> | ||
37 | /// Cache root and system inventory folders to reduce number of potentially remote inventory calls and associated holdups. | ||
38 | /// </summary> | ||
9 | public class InventoryCache | 39 | public class InventoryCache |
10 | { | 40 | { |
11 | private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour | 41 | private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour |
12 | 42 | ||
13 | private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>(); | 43 | private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>(); |
14 | private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>(); | 44 | private static ExpiringCache<UUID, Dictionary<FolderType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<FolderType, InventoryFolderBase>>(); |
15 | private static ExpiringCache<UUID, InventoryCollection> m_Inventories = new ExpiringCache<UUID, InventoryCollection>(); | 45 | private static ExpiringCache<UUID, InventoryCollection> m_Inventories = new ExpiringCache<UUID, InventoryCollection>(); |
16 | 46 | ||
17 | public void Cache(UUID userID, InventoryFolderBase root) | 47 | public void Cache(UUID userID, InventoryFolderBase root) |
18 | { | 48 | { |
19 | lock (m_RootFolders) | 49 | m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS); |
20 | m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS); | ||
21 | } | 50 | } |
22 | 51 | ||
23 | public InventoryFolderBase GetRootFolder(UUID userID) | 52 | public InventoryFolderBase GetRootFolder(UUID userID) |
@@ -29,29 +58,37 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
29 | return null; | 58 | return null; |
30 | } | 59 | } |
31 | 60 | ||
32 | public void Cache(UUID userID, AssetType type, InventoryFolderBase folder) | 61 | public void Cache(UUID userID, FolderType type, InventoryFolderBase folder) |
33 | { | 62 | { |
34 | lock (m_FolderTypes) | 63 | Dictionary<FolderType, InventoryFolderBase> ff = null; |
64 | if (!m_FolderTypes.TryGetValue(userID, out ff)) | ||
65 | { | ||
66 | ff = new Dictionary<FolderType, InventoryFolderBase>(); | ||
67 | m_FolderTypes.Add(userID, ff, CACHE_EXPIRATION_SECONDS); | ||
68 | } | ||
69 | |||
70 | // We need to lock here since two threads could potentially retrieve the same dictionary | ||
71 | // and try to add a folder for that type simultaneously. Dictionary<>.Add() is not described as thread-safe in the SDK | ||
72 | // even if the folders are identical. | ||
73 | lock (ff) | ||
35 | { | 74 | { |
36 | Dictionary<AssetType, InventoryFolderBase> ff = null; | ||
37 | if (!m_FolderTypes.TryGetValue(userID, out ff)) | ||
38 | { | ||
39 | ff = new Dictionary<AssetType, InventoryFolderBase>(); | ||
40 | m_FolderTypes.Add(userID, ff, CACHE_EXPIRATION_SECONDS); | ||
41 | } | ||
42 | if (!ff.ContainsKey(type)) | 75 | if (!ff.ContainsKey(type)) |
43 | ff.Add(type, folder); | 76 | ff.Add(type, folder); |
44 | } | 77 | } |
45 | } | 78 | } |
46 | 79 | ||
47 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | 80 | public InventoryFolderBase GetFolderForType(UUID userID, FolderType type) |
48 | { | 81 | { |
49 | Dictionary<AssetType, InventoryFolderBase> ff = null; | 82 | Dictionary<FolderType, InventoryFolderBase> ff = null; |
50 | if (m_FolderTypes.TryGetValue(userID, out ff)) | 83 | if (m_FolderTypes.TryGetValue(userID, out ff)) |
51 | { | 84 | { |
52 | InventoryFolderBase f = null; | 85 | InventoryFolderBase f = null; |
53 | if (ff.TryGetValue(type, out f)) | 86 | |
54 | return f; | 87 | lock (ff) |
88 | { | ||
89 | if (ff.TryGetValue(type, out f)) | ||
90 | return f; | ||
91 | } | ||
55 | } | 92 | } |
56 | 93 | ||
57 | return null; | 94 | return null; |
@@ -59,16 +96,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
59 | 96 | ||
60 | public void Cache(UUID userID, InventoryCollection inv) | 97 | public void Cache(UUID userID, InventoryCollection inv) |
61 | { | 98 | { |
62 | lock (m_Inventories) | 99 | m_Inventories.AddOrUpdate(userID, inv, 120); |
63 | m_Inventories.AddOrUpdate(userID, inv, 120); | ||
64 | } | ||
65 | |||
66 | public InventoryCollection GetUserInventory(UUID userID) | ||
67 | { | ||
68 | InventoryCollection inv = null; | ||
69 | if (m_Inventories.TryGetValue(userID, out inv)) | ||
70 | return inv; | ||
71 | return null; | ||
72 | } | 100 | } |
73 | 101 | ||
74 | public InventoryCollection GetFolderContent(UUID userID, UUID folderID) | 102 | public InventoryCollection GetFolderContent(UUID userID, UUID folderID) |
@@ -78,7 +106,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
78 | if (m_Inventories.TryGetValue(userID, out inv)) | 106 | if (m_Inventories.TryGetValue(userID, out inv)) |
79 | { | 107 | { |
80 | c = new InventoryCollection(); | 108 | c = new InventoryCollection(); |
81 | c.UserID = userID; | 109 | c.OwnerID = userID; |
82 | 110 | ||
83 | c.Folders = inv.Folders.FindAll(delegate(InventoryFolderBase f) | 111 | c.Folders = inv.Folders.FindAll(delegate(InventoryFolderBase f) |
84 | { | 112 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index ec5751d..20d4e02 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs | |||
@@ -33,6 +33,7 @@ using System; | |||
33 | using System.Collections.Generic; | 33 | using System.Collections.Generic; |
34 | using System.Reflection; | 34 | using System.Reflection; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Monitoring; | ||
36 | using OpenSim.Data; | 37 | using OpenSim.Data; |
37 | using OpenSim.Server.Base; | 38 | using OpenSim.Server.Base; |
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
@@ -164,22 +165,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
164 | return m_InventoryService.GetInventorySkeleton(userId); | 165 | return m_InventoryService.GetInventorySkeleton(userId); |
165 | } | 166 | } |
166 | 167 | ||
167 | public InventoryCollection GetUserInventory(UUID id) | ||
168 | { | ||
169 | return m_InventoryService.GetUserInventory(id); | ||
170 | } | ||
171 | |||
172 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) | ||
173 | { | ||
174 | m_InventoryService.GetUserInventory(userID, callback); | ||
175 | } | ||
176 | |||
177 | public InventoryFolderBase GetRootFolder(UUID userID) | 168 | public InventoryFolderBase GetRootFolder(UUID userID) |
178 | { | 169 | { |
179 | return m_InventoryService.GetRootFolder(userID); | 170 | return m_InventoryService.GetRootFolder(userID); |
180 | } | 171 | } |
181 | 172 | ||
182 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | 173 | public InventoryFolderBase GetFolderForType(UUID userID, FolderType type) |
183 | { | 174 | { |
184 | return m_InventoryService.GetFolderForType(userID, type); | 175 | return m_InventoryService.GetFolderForType(userID, type); |
185 | } | 176 | } |
@@ -193,16 +184,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
193 | // Protect ourselves against the caller subsequently modifying the items list | 184 | // Protect ourselves against the caller subsequently modifying the items list |
194 | List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items); | 185 | List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items); |
195 | 186 | ||
196 | Util.FireAndForget(delegate | 187 | WorkManager.RunInThread(delegate |
197 | { | 188 | { |
198 | foreach (InventoryItemBase item in items) | 189 | foreach (InventoryItemBase item in items) |
199 | UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); | 190 | if (!string.IsNullOrEmpty(item.CreatorData)) |
200 | }); | 191 | UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); |
192 | }, null, string.Format("GetFolderContent (user {0}, folder {1})", userID, folderID)); | ||
201 | } | 193 | } |
202 | 194 | ||
203 | return invCol; | 195 | return invCol; |
204 | } | 196 | } |
205 | 197 | ||
198 | public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs) | ||
199 | { | ||
200 | InventoryCollection[] invColl = new InventoryCollection[folderIDs.Length]; | ||
201 | int i = 0; | ||
202 | foreach (UUID fid in folderIDs) | ||
203 | { | ||
204 | invColl[i++] = GetFolderContent(principalID, fid); | ||
205 | } | ||
206 | |||
207 | return invColl; | ||
208 | |||
209 | } | ||
210 | |||
206 | public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) | 211 | public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) |
207 | { | 212 | { |
208 | return m_InventoryService.GetFolderItems(userID, folderID); | 213 | return m_InventoryService.GetFolderItems(userID, folderID); |
@@ -302,6 +307,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
302 | return item; | 307 | return item; |
303 | } | 308 | } |
304 | 309 | ||
310 | public InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] itemIDs) | ||
311 | { | ||
312 | return m_InventoryService.GetMultipleItems(userID, itemIDs); | ||
313 | } | ||
314 | |||
305 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) | 315 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) |
306 | { | 316 | { |
307 | return m_InventoryService.GetFolder(folder); | 317 | return m_InventoryService.GetFolder(folder); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs index 2d3ba82..978b9d9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs | |||
@@ -172,21 +172,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
172 | return m_RemoteConnector.GetInventorySkeleton(userId); | 172 | return m_RemoteConnector.GetInventorySkeleton(userId); |
173 | } | 173 | } |
174 | 174 | ||
175 | public InventoryCollection GetUserInventory(UUID userID) | ||
176 | { | ||
177 | return m_RemoteConnector.GetUserInventory(userID); | ||
178 | } | ||
179 | |||
180 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) | ||
181 | { | ||
182 | } | ||
183 | |||
184 | public InventoryFolderBase GetRootFolder(UUID userID) | 175 | public InventoryFolderBase GetRootFolder(UUID userID) |
185 | { | 176 | { |
186 | return m_RemoteConnector.GetRootFolder(userID); | 177 | return m_RemoteConnector.GetRootFolder(userID); |
187 | } | 178 | } |
188 | 179 | ||
189 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | 180 | public InventoryFolderBase GetFolderForType(UUID userID, FolderType type) |
190 | { | 181 | { |
191 | return m_RemoteConnector.GetFolderForType(userID, type); | 182 | return m_RemoteConnector.GetFolderForType(userID, type); |
192 | } | 183 | } |
@@ -195,22 +186,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
195 | { | 186 | { |
196 | InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID); | 187 | InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID); |
197 | 188 | ||
198 | if (invCol != null && UserManager != null) | 189 | // Commenting this for now, because it's causing more grief than good |
199 | { | 190 | //if (invCol != null && UserManager != null) |
200 | // Protect ourselves against the caller subsequently modifying the items list | 191 | //{ |
201 | List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items); | 192 | // // Protect ourselves against the caller subsequently modifying the items list |
202 | 193 | // List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items); | |
203 | if (items != null && items.Count > 0) | 194 | |
204 | Util.FireAndForget(delegate | 195 | // if (items != null && items.Count > 0) |
205 | { | 196 | // //Util.FireAndForget(delegate |
206 | foreach (InventoryItemBase item in items) | 197 | // //{ |
207 | UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); | 198 | // foreach (InventoryItemBase item in items) |
208 | }); | 199 | // if (!string.IsNullOrEmpty(item.CreatorData)) |
209 | } | 200 | // UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); |
201 | // //}); | ||
202 | //} | ||
210 | 203 | ||
211 | return invCol; | 204 | return invCol; |
212 | } | 205 | } |
213 | 206 | ||
207 | public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs) | ||
208 | { | ||
209 | return m_RemoteConnector.GetMultipleFoldersContent(principalID, folderIDs); | ||
210 | } | ||
211 | |||
214 | public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) | 212 | public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) |
215 | { | 213 | { |
216 | return m_RemoteConnector.GetFolderItems(userID, folderID); | 214 | return m_RemoteConnector.GetFolderItems(userID, folderID); |
@@ -305,6 +303,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
305 | return m_RemoteConnector.GetItem(item); | 303 | return m_RemoteConnector.GetItem(item); |
306 | } | 304 | } |
307 | 305 | ||
306 | public InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] itemIDs) | ||
307 | { | ||
308 | if (itemIDs == null) | ||
309 | return new InventoryItemBase[0]; | ||
310 | |||
311 | return m_RemoteConnector.GetMultipleItems(userID, itemIDs); | ||
312 | } | ||
313 | |||
308 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) | 314 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) |
309 | { | 315 | { |
310 | //m_log.DebugFormat("[XINVENTORY CONNECTOR]: GetFolder {0}", folder.ID); | 316 | //m_log.DebugFormat("[XINVENTORY CONNECTOR]: GetFolder {0}", folder.ID); |