From 7c1b2a5dde3b61dae4cca6bff7d2fe560be96fae Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 13 Aug 2016 05:22:29 +0100 Subject: add some wiring to have GetUserAccounts for multiple IDs on a single request to grid services. Unfinished, untested --- .../LocalUserAccountServiceConnector.cs | 6 ++++ .../RemoteUserAccountServiceConnector.cs | 35 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index cf9a7b4..1002b85 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -182,6 +182,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts return UserAccountService.GetUserAccount(scopeID, Email); } + public List GetUserAccounts(UUID scopeID, List IDs, out bool suported) + { + return UserAccountService.GetUserAccounts(scopeID, IDs, out suported); + } + + public List GetUserAccountsWhere(UUID scopeID, string query) { return null; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index afbba30..fb5fae1 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs @@ -26,6 +26,8 @@ */ using System; +using System.Collections; +using System.Collections.Generic; using Nini.Config; using log4net; using Mono.Addins; @@ -158,6 +160,39 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts return account; } + public override List GetUserAccounts(UUID scopeID, List IDs, out bool suported) + { + suported = true; + List accs = new List(); + List missing = new List(); + + UUID uuid = UUID.Zero;; + UserAccount account; + bool inCache = false; + + foreach(string id in IDs) + { + if(UUID.TryParse(id, out uuid)) + { + account = m_Cache.Get(uuid, out inCache); + if (inCache) + accs.Add(account); + else + missing.Add(id); + } + } + + if(missing.Count > 0) + { + List ext = base.GetUserAccounts(scopeID, missing, out suported); + if(suported && ext != null) + accs.AddRange(ext); + } + + return accs; + } + + public override bool StoreUserAccount(UserAccount data) { // This remote connector refuses to serve this method -- cgit v1.1 From 1337f5f26e628dc7c5d038ffee5e957d95a72566 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 13 Aug 2016 23:41:57 +0100 Subject: remove a parameter for detection of grid fail to suport getting multiple user accounts per call and handle it where needed. --- .../UserAccounts/LocalUserAccountServiceConnector.cs | 4 ++-- .../UserAccounts/RemoteUserAccountServiceConnector.cs | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index 1002b85..1bb4704 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -182,9 +182,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts return UserAccountService.GetUserAccount(scopeID, Email); } - public List GetUserAccounts(UUID scopeID, List IDs, out bool suported) + public List GetUserAccounts(UUID scopeID, List IDs) { - return UserAccountService.GetUserAccounts(scopeID, IDs, out suported); + return UserAccountService.GetUserAccounts(scopeID, IDs); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index fb5fae1..ce1754f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs @@ -160,9 +160,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts return account; } - public override List GetUserAccounts(UUID scopeID, List IDs, out bool suported) + public override List GetUserAccounts(UUID scopeID, List IDs) { - suported = true; List accs = new List(); List missing = new List(); @@ -184,15 +183,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts if(missing.Count > 0) { - List ext = base.GetUserAccounts(scopeID, missing, out suported); - if(suported && ext != null) + List ext = base.GetUserAccounts(scopeID, missing); + if(ext != null) accs.AddRange(ext); } return accs; } - public override bool StoreUserAccount(UserAccount data) { // This remote connector refuses to serve this method -- cgit v1.1 From 72876fc68385861e06fd900707c3a7c28d040a7d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 16 Aug 2016 23:11:01 +0100 Subject: drasticly reduce HG inventory caches Expire times, Remove them all onClientClose. This to avoid potencial desyncs with inventory service --- .../Inventory/HGInventoryBroker.cs | 19 ++++++++++--------- .../ServiceConnectorsOut/Inventory/InventoryCache.cs | 13 ++++++++++++- 2 files changed, 22 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 863560b..c48186f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -203,21 +203,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory void OnClientClosed(UUID clientID, Scene scene) { - if (m_InventoryURLs.ContainsKey(clientID)) // if it's in cache + ScenePresence sp = null; + foreach (Scene s in m_Scenes) { - ScenePresence sp = null; - foreach (Scene s in m_Scenes) + s.TryGetScenePresence(clientID, out sp); + if ((sp != null) && !sp.IsChildAgent && (s != scene)) { - s.TryGetScenePresence(clientID, out sp); - if ((sp != null) && !sp.IsChildAgent && (s != scene)) - { - m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping inventoryURL in cache", + m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping inventoryURL in cache", scene.RegionInfo.RegionName, clientID); return; - } } - DropInventoryServiceURL(clientID); } + + if (m_InventoryURLs.ContainsKey(clientID)) // if it's in cache + DropInventoryServiceURL(clientID); + + m_Cache.RemoveAll(clientID); } /// diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs index 3195e6b..f7ef2ea 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs @@ -38,12 +38,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// public class InventoryCache { - private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour + private const double CACHE_EXPIRATION_SECONDS = 60.0; // 1 minute private static ExpiringCache m_RootFolders = new ExpiringCache(); private static ExpiringCache> m_FolderTypes = new ExpiringCache>(); private static ExpiringCache m_Inventories = new ExpiringCache(); + + public void RemoveAll(UUID userID) + { + if(m_RootFolders.Contains(userID)) + m_RootFolders.Remove(userID); + if(m_FolderTypes.Contains(userID)) + m_FolderTypes.Remove(userID); + if(m_Inventories.Contains(userID)) + m_Inventories.Remove(userID); + } + public void Cache(UUID userID, InventoryFolderBase root) { m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS); -- cgit v1.1 From 04ea34f379a1839e618ef1a7ba05a1be19f8e43c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 17 Aug 2016 06:00:42 +0100 Subject: add GetUsersNames(string[] ids) to UserManagement. Make GetDisplayNames cap use it so several IDs are handle on a single call. Since there is no grid side suport, no much gain still --- .../UserAccounts/RemoteUserAccountServiceConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index ce1754f..90c90d6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs @@ -165,7 +165,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts List accs = new List(); List missing = new List(); - UUID uuid = UUID.Zero;; + UUID uuid = UUID.Zero; UserAccount account; bool inCache = false; -- cgit v1.1 From c53d74274d1fa9e76621206185ee4e1ff3c57f16 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 19 Aug 2016 00:14:46 +0100 Subject: missed another UserAccounts cache, add a few locks --- .../LocalUserAccountServiceConnector.cs | 51 +++++++++++++++++++--- .../RemoteUserAccountServiceConnector.cs | 31 ++++++++++--- 2 files changed, 69 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index 1bb4704..3127199 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -153,12 +153,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts public UserAccount GetUserAccount(UUID scopeID, UUID userID) { bool inCache = false; - UserAccount account = m_Cache.Get(userID, out inCache); + UserAccount account; + lock(m_Cache) + account = m_Cache.Get(userID, out inCache); if (inCache) return account; account = UserAccountService.GetUserAccount(scopeID, userID); - m_Cache.Cache(userID, account); + lock(m_Cache) + m_Cache.Cache(userID, account); return account; } @@ -166,13 +169,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) { bool inCache = false; - UserAccount account = m_Cache.Get(firstName + " " + lastName, out inCache); + UserAccount account; + lock(m_Cache) + account = m_Cache.Get(firstName + " " + lastName, out inCache); if (inCache) return account; account = UserAccountService.GetUserAccount(scopeID, firstName, lastName); if (account != null) - m_Cache.Cache(account.PrincipalID, account); + lock(m_Cache) + m_Cache.Cache(account.PrincipalID, account); return account; } @@ -184,9 +190,42 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts public List GetUserAccounts(UUID scopeID, List IDs) { - return UserAccountService.GetUserAccounts(scopeID, IDs); - } + List ret = new List(); + List missing = new List(); + + // still another cache.. + bool inCache = false; + UUID uuid = UUID.Zero; + UserAccount account; + foreach(string id in IDs) + { + if(UUID.TryParse(id, out uuid)) + { + lock(m_Cache) + account = m_Cache.Get(uuid, out inCache); + if (inCache) + ret.Add(account); + else + missing.Add(id); + } + } + if(missing.Count == 0) + return ret; + + List ext = UserAccountService.GetUserAccounts(scopeID, missing); + if(ext != null && ext.Count > 0) + { + ret.AddRange(ext); + foreach(UserAccount acc in ext) + { + if(acc != null) + lock(m_Cache) + m_Cache.Cache(acc.PrincipalID, acc); + } + } + return ret; + } public List GetUserAccountsWhere(UUID scopeID, string query) { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index 90c90d6..eead05d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs @@ -128,7 +128,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts // flags, title, etc. And country, don't forget country! private void OnNewClient(IClientAPI client) { - m_Cache.Remove(client.Name); + lock(m_Cache) + m_Cache.Remove(client.Name); } #region Overwritten methods from IUserAccountService @@ -136,12 +137,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts public override UserAccount GetUserAccount(UUID scopeID, UUID userID) { bool inCache = false; - UserAccount account = m_Cache.Get(userID, out inCache); + UserAccount account; + lock(m_Cache) + account = m_Cache.Get(userID, out inCache); if (inCache) return account; account = base.GetUserAccount(scopeID, userID); - m_Cache.Cache(userID, account); + lock(m_Cache) + if(account != null) + m_Cache.Cache(userID, account); return account; } @@ -149,13 +154,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts public override UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) { bool inCache = false; - UserAccount account = m_Cache.Get(firstName + " " + lastName, out inCache); + UserAccount account; + lock(m_Cache) + account = m_Cache.Get(firstName + " " + lastName, out inCache); if (inCache) return account; account = base.GetUserAccount(scopeID, firstName, lastName); if (account != null) - m_Cache.Cache(account.PrincipalID, account); + lock(m_Cache) + m_Cache.Cache(account.PrincipalID, account); return account; } @@ -173,7 +181,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { if(UUID.TryParse(id, out uuid)) { - account = m_Cache.Get(uuid, out inCache); + lock(m_Cache) + account = m_Cache.Get(uuid, out inCache); if (inCache) accs.Add(account); else @@ -184,8 +193,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts if(missing.Count > 0) { List ext = base.GetUserAccounts(scopeID, missing); - if(ext != null) + if(ext != null && ext.Count >0 ) + { accs.AddRange(ext); + foreach(UserAccount acc in ext) + { + if(acc != null) + lock(m_Cache) + m_Cache.Cache(acc.PrincipalID, acc); + } + } } return accs; -- cgit v1.1