diff options
author | Diva Canto | 2012-03-09 12:59:24 -0800 |
---|---|---|
committer | Diva Canto | 2012-03-09 12:59:24 -0800 |
commit | a58152bd2af64493e655d6f559bc366c38433187 (patch) | |
tree | 786bbae51662a948511f9d81d9211d2984676986 /OpenSim | |
parent | More on HG inventory transfers. Move the FireAndForget higher up. (diff) | |
download | opensim-SC_OLD-a58152bd2af64493e655d6f559bc366c38433187.zip opensim-SC_OLD-a58152bd2af64493e655d6f559bc366c38433187.tar.gz opensim-SC_OLD-a58152bd2af64493e655d6f559bc366c38433187.tar.bz2 opensim-SC_OLD-a58152bd2af64493e655d6f559bc366c38433187.tar.xz |
More on inventory transfer hold ups:
- Added an inventory cache for caching root and system folders
- Synchronized the remote inventory connector, so that all the remote inventory calls are serialized
This will not make much difference in the hold ups. We'd have to move the FireAndForget high up to AddInventoryItem, but that opens up a can of worms regarding the notification of the recipient... the recipient would be notified of the offer before the items are effectively in his inventory, which could lead to surprises.
Diffstat (limited to 'OpenSim')
3 files changed, 84 insertions, 5 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index b5c0af6..4be3804 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs | |||
@@ -58,6 +58,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
58 | 58 | ||
59 | private List<Scene> m_Scenes = new List<Scene>(); | 59 | private List<Scene> m_Scenes = new List<Scene>(); |
60 | 60 | ||
61 | private InventoryCache m_Cache = new InventoryCache(); | ||
62 | |||
61 | protected IUserManagement m_UserManagement; | 63 | protected IUserManagement m_UserManagement; |
62 | protected IUserManagement UserManagementModule | 64 | protected IUserManagement UserManagementModule |
63 | { | 65 | { |
@@ -312,6 +314,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
312 | public InventoryFolderBase GetRootFolder(UUID userID) | 314 | public InventoryFolderBase GetRootFolder(UUID userID) |
313 | { | 315 | { |
314 | //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID); | 316 | //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID); |
317 | InventoryFolderBase root = m_Cache.GetRootFolder(userID); | ||
318 | if (root != null) | ||
319 | return root; | ||
315 | 320 | ||
316 | string invURL = GetInventoryServiceURL(userID); | 321 | string invURL = GetInventoryServiceURL(userID); |
317 | 322 | ||
@@ -320,12 +325,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
320 | 325 | ||
321 | IInventoryService connector = GetConnector(invURL); | 326 | IInventoryService connector = GetConnector(invURL); |
322 | 327 | ||
323 | return connector.GetRootFolder(userID); | 328 | root = connector.GetRootFolder(userID); |
329 | |||
330 | m_Cache.Cache(userID, root); | ||
331 | |||
332 | return root; | ||
324 | } | 333 | } |
325 | 334 | ||
326 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | 335 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) |
327 | { | 336 | { |
328 | //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetFolderForType {0} type {1}", userID, type); | 337 | //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetFolderForType {0} type {1}", userID, type); |
338 | InventoryFolderBase f = m_Cache.GetFolderForType(userID, type); | ||
339 | if (f != null) | ||
340 | return f; | ||
329 | 341 | ||
330 | string invURL = GetInventoryServiceURL(userID); | 342 | string invURL = GetInventoryServiceURL(userID); |
331 | 343 | ||
@@ -334,7 +346,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
334 | 346 | ||
335 | IInventoryService connector = GetConnector(invURL); | 347 | IInventoryService connector = GetConnector(invURL); |
336 | 348 | ||
337 | return connector.GetFolderForType(userID, type); | 349 | f = connector.GetFolderForType(userID, type); |
350 | |||
351 | m_Cache.Cache(userID, type, f); | ||
352 | |||
353 | return f; | ||
338 | } | 354 | } |
339 | 355 | ||
340 | public InventoryCollection GetFolderContent(UUID userID, UUID folderID) | 356 | public InventoryCollection GetFolderContent(UUID userID, UUID folderID) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs new file mode 100644 index 0000000..0fe778d --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs | |||
@@ -0,0 +1,59 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | |||
4 | using OpenSim.Framework; | ||
5 | using OpenMetaverse; | ||
6 | |||
7 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | ||
8 | { | ||
9 | public class InventoryCache | ||
10 | { | ||
11 | private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour | ||
12 | |||
13 | 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>>(); | ||
15 | |||
16 | public void Cache(UUID userID, InventoryFolderBase root) | ||
17 | { | ||
18 | lock (m_RootFolders) | ||
19 | m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS); | ||
20 | } | ||
21 | |||
22 | public InventoryFolderBase GetRootFolder(UUID userID) | ||
23 | { | ||
24 | InventoryFolderBase root = null; | ||
25 | if (m_RootFolders.TryGetValue(userID, out root)) | ||
26 | return root; | ||
27 | |||
28 | return null; | ||
29 | } | ||
30 | |||
31 | public void Cache(UUID userID, AssetType type, InventoryFolderBase folder) | ||
32 | { | ||
33 | lock (m_FolderTypes) | ||
34 | { | ||
35 | Dictionary<AssetType, InventoryFolderBase> ff = null; | ||
36 | if (!m_FolderTypes.TryGetValue(userID, out ff)) | ||
37 | { | ||
38 | ff = new Dictionary<AssetType, InventoryFolderBase>(); | ||
39 | m_FolderTypes.Add(userID, ff, CACHE_EXPIRATION_SECONDS); | ||
40 | } | ||
41 | if (!ff.ContainsKey(type)) | ||
42 | ff.Add(type, folder); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | ||
47 | { | ||
48 | Dictionary<AssetType, InventoryFolderBase> ff = null; | ||
49 | if (m_FolderTypes.TryGetValue(userID, out ff)) | ||
50 | { | ||
51 | InventoryFolderBase f = null; | ||
52 | if (ff.TryGetValue(type, out f)) | ||
53 | return f; | ||
54 | } | ||
55 | |||
56 | return null; | ||
57 | } | ||
58 | } | ||
59 | } | ||
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs index a662abb..39e983b 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs | |||
@@ -48,6 +48,8 @@ namespace OpenSim.Services.Connectors | |||
48 | 48 | ||
49 | private string m_ServerURI = String.Empty; | 49 | private string m_ServerURI = String.Empty; |
50 | 50 | ||
51 | private object m_Lock = new object(); | ||
52 | |||
51 | public XInventoryServicesConnector() | 53 | public XInventoryServicesConnector() |
52 | { | 54 | { |
53 | } | 55 | } |
@@ -514,9 +516,11 @@ namespace OpenSim.Services.Connectors | |||
514 | { | 516 | { |
515 | sendData["METHOD"] = method; | 517 | sendData["METHOD"] = method; |
516 | 518 | ||
517 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | 519 | string reply = string.Empty; |
518 | m_ServerURI + "/xinventory", | 520 | lock (m_Lock) |
519 | ServerUtils.BuildQueryString(sendData)); | 521 | reply = SynchronousRestFormsRequester.MakeRequest("POST", |
522 | m_ServerURI + "/xinventory", | ||
523 | ServerUtils.BuildQueryString(sendData)); | ||
520 | 524 | ||
521 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( | 525 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( |
522 | reply); | 526 | reply); |