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 --- .../SimianUserAccountServiceConnector.cs | 6 ++ .../UserAccounts/UserAccountServicesConnector.cs | 72 ++++++++++++++++++++++ .../Services/HypergridService/UserAccountCache.cs | 6 ++ OpenSim/Services/Interfaces/IUserAccountService.cs | 1 + .../UserAccountService/UserAccountService.cs | 13 ++++ 5 files changed, 98 insertions(+) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs index 563a1e7..1ef5ad2 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs @@ -201,6 +201,12 @@ namespace OpenSim.Services.Connectors.SimianGrid return null; } + public List GetUserAccounts(UUID scopeID, List IDs, out bool suported) + { + suported = false; + return null; + } + public bool StoreUserAccount(UserAccount data) { // m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name); diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs index 3de0a20..e625143 100644 --- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs +++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs @@ -191,6 +191,78 @@ namespace OpenSim.Services.Connectors return accounts; } + public virtual List GetUserAccounts(UUID scopeID, List IDs, out bool suported) + { + suported = true; + Dictionary sendData = new Dictionary(); + //sendData["SCOPEID"] = scopeID.ToString(); + sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); + sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); + sendData["METHOD"] = "getmultiaccounts"; + + sendData["ScopeID"] = scopeID.ToString(); + sendData["IDS"] = new List(IDs); + + string reply = string.Empty; + string reqString = ServerUtils.BuildQueryString(sendData); + string uri = m_ServerURI + "/accounts"; + // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString); + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + uri, + reqString, + m_Auth); + if (reply == null || (reply != null && reply == string.Empty)) + { + m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetMultiUserAccounts received null or empty reply"); + return null; + } + } + catch (Exception e) + { + m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting user accounts server at {0}: {1}", uri, e.Message); + } + + List accounts = new List(); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if (replyData != null) + { + if (replyData.ContainsKey("result")) + { + if(replyData["result"].ToString() == "null") + return accounts; + + if(replyData["result"].ToString() == "Failure") + { + suported = false; + return accounts; + } + } + + Dictionary.ValueCollection accountList = replyData.Values; + //m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count); + foreach (object acc in accountList) + { + if (acc is Dictionary) + { + UserAccount pinfo = new UserAccount((Dictionary)acc); + accounts.Add(pinfo); + } + else + m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetMultiUserAccounts received invalid response type {0}", + acc.GetType()); + } + } + else + m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetMultiUserAccounts received null response"); + + return accounts; + } + + public void InvalidateCache(UUID userID) { } diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs index 6c3c655..618bd97 100644 --- a/OpenSim/Services/HypergridService/UserAccountCache.cs +++ b/OpenSim/Services/HypergridService/UserAccountCache.cs @@ -100,6 +100,12 @@ namespace OpenSim.Services.HypergridService return null; } + public List GetUserAccounts(UUID scopeID, List IDs, out bool suported) + { + suported = false; + return null; + } + public void InvalidateCache(UUID userID) { m_UUIDCache.Remove(userID); diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs index 1814699..1914040 100644 --- a/OpenSim/Services/Interfaces/IUserAccountService.cs +++ b/OpenSim/Services/Interfaces/IUserAccountService.cs @@ -187,6 +187,7 @@ namespace OpenSim.Services.Interfaces /// List GetUserAccounts(UUID scopeID, string query); List GetUserAccountsWhere(UUID scopeID, string where); + List GetUserAccounts(UUID scopeID, List IDs, out bool suported); /// /// Store the data given, wich replaces the stored data, therefore must be complete. diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 6010f0c..fbe5e3b 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -265,6 +265,19 @@ namespace OpenSim.Services.UserAccountService return MakeUserAccount(d[0]); } + public List GetUserAccounts(UUID scopeID, List IDs, out bool suported) + { + suported = true; + List accs = new List(); + UUID uuid = UUID.Zero; + foreach(string id in IDs) + { + if (UUID.TryParse(id, out uuid) && uuid != UUID.Zero) + accs.Add(GetUserAccount(scopeID, uuid)); + } + return accs; + } + public void InvalidateCache(UUID userID) { } -- 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. --- .../SimianUserAccountServiceConnector.cs | 3 +-- .../UserAccounts/UserAccountServicesConnector.cs | 22 +++++++++++++++++++++- .../Services/HypergridService/UserAccountCache.cs | 3 +-- OpenSim/Services/Interfaces/IUserAccountService.cs | 2 +- .../UserAccountService/UserAccountService.cs | 4 ++-- 5 files changed, 26 insertions(+), 8 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs index 1ef5ad2..6f613c1 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs @@ -201,9 +201,8 @@ namespace OpenSim.Services.Connectors.SimianGrid return null; } - public List GetUserAccounts(UUID scopeID, List IDs, out bool suported) + public List GetUserAccounts(UUID scopeID, List IDs) { - suported = false; return null; } diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs index e625143..5bc7a1c 100644 --- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs +++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs @@ -191,7 +191,27 @@ namespace OpenSim.Services.Connectors return accounts; } - public virtual List GetUserAccounts(UUID scopeID, List IDs, out bool suported) + public virtual List GetUserAccounts(UUID scopeID, List IDs) + { + List accs = new List(); + bool multisuported = true; + accs = doGetMultiUserAccounts(scopeID, IDs, out multisuported); + if(multisuported) + return accs; + + // service does not do multi accounts so need to do it one by one + + UUID uuid = UUID.Zero; + foreach(string id in IDs) + { + if(UUID.TryParse(id, out uuid) && uuid != UUID.Zero) + accs.Add(GetUserAccount(scopeID,uuid)); + } + + return accs; + } + + private List doGetMultiUserAccounts(UUID scopeID, List IDs, out bool suported) { suported = true; Dictionary sendData = new Dictionary(); diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs index 618bd97..25ffb63 100644 --- a/OpenSim/Services/HypergridService/UserAccountCache.cs +++ b/OpenSim/Services/HypergridService/UserAccountCache.cs @@ -100,9 +100,8 @@ namespace OpenSim.Services.HypergridService return null; } - public List GetUserAccounts(UUID scopeID, List IDs, out bool suported) + public List GetUserAccounts(UUID scopeID, List IDs) { - suported = false; return null; } diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs index 1914040..c6f3ef3 100644 --- a/OpenSim/Services/Interfaces/IUserAccountService.cs +++ b/OpenSim/Services/Interfaces/IUserAccountService.cs @@ -187,7 +187,7 @@ namespace OpenSim.Services.Interfaces /// List GetUserAccounts(UUID scopeID, string query); List GetUserAccountsWhere(UUID scopeID, string where); - List GetUserAccounts(UUID scopeID, List IDs, out bool suported); + List GetUserAccounts(UUID scopeID, List IDs); /// /// Store the data given, wich replaces the stored data, therefore must be complete. diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index fbe5e3b..668fe53 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -265,9 +265,9 @@ namespace OpenSim.Services.UserAccountService return MakeUserAccount(d[0]); } - public List GetUserAccounts(UUID scopeID, List IDs, out bool suported) + public List GetUserAccounts(UUID scopeID, List IDs) { - suported = true; + // do it one at a time db access should be fast, so no need to break its api List accs = new List(); UUID uuid = UUID.Zero; foreach(string id in IDs) -- 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 --- OpenSim/Services/Interfaces/IUserManagement.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Interfaces/IUserManagement.cs b/OpenSim/Services/Interfaces/IUserManagement.cs index 9e560d5..225560e 100644 --- a/OpenSim/Services/Interfaces/IUserManagement.cs +++ b/OpenSim/Services/Interfaces/IUserManagement.cs @@ -42,6 +42,7 @@ namespace OpenSim.Services.Interfaces string GetUserUUI(UUID uuid); bool GetUserUUI(UUID userID, out string uui); string GetUserServerURL(UUID uuid, string serverType); + Dictionary GetUsersNames(string[] ids); /// /// Get user ID by the given name. -- cgit v1.1