add some wiring to have GetUserAccounts for multiple IDs on a single request to grid services. Unfinished, untested

LSLKeyTest
UbitUmarov 2016-08-13 05:22:29 +01:00
parent b64f25e631
commit 7c1b2a5dde
7 changed files with 139 additions and 0 deletions

View File

@ -182,6 +182,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
return UserAccountService.GetUserAccount(scopeID, Email);
}
public List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs, out bool suported)
{
return UserAccountService.GetUserAccounts(scopeID, IDs, out suported);
}
public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query)
{
return null;

View File

@ -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<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs, out bool suported)
{
suported = true;
List<UserAccount> accs = new List<UserAccount>();
List<string> missing = new List<string>();
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<UserAccount> 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

View File

@ -201,6 +201,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
return null;
}
public List<UserAccount> GetUserAccounts(UUID scopeID, List<string> 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);

View File

@ -191,6 +191,78 @@ namespace OpenSim.Services.Connectors
return accounts;
}
public virtual List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs, out bool suported)
{
suported = true;
Dictionary<string, object> sendData = new Dictionary<string, object>();
//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<string>(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<UserAccount> accounts = new List<UserAccount>();
Dictionary<string, object> 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<string, object>.ValueCollection accountList = replyData.Values;
//m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count);
foreach (object acc in accountList)
{
if (acc is Dictionary<string, object>)
{
UserAccount pinfo = new UserAccount((Dictionary<string, object>)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)
{
}

View File

@ -100,6 +100,12 @@ namespace OpenSim.Services.HypergridService
return null;
}
public List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs, out bool suported)
{
suported = false;
return null;
}
public void InvalidateCache(UUID userID)
{
m_UUIDCache.Remove(userID);

View File

@ -187,6 +187,7 @@ namespace OpenSim.Services.Interfaces
/// <returns></returns>
List<UserAccount> GetUserAccounts(UUID scopeID, string query);
List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where);
List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs, out bool suported);
/// <summary>
/// Store the data given, wich replaces the stored data, therefore must be complete.

View File

@ -265,6 +265,19 @@ namespace OpenSim.Services.UserAccountService
return MakeUserAccount(d[0]);
}
public List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs, out bool suported)
{
suported = true;
List<UserAccount> accs = new List<UserAccount>();
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)
{
}