If calls to UserAgentServiceConnector fail then throw an exception. This lets the caller decide whether to discard the error or not.

This is Oren Hurvitz's 0001 patch from http://opensimulator.org/mantis/view.php?id=6956 but I ended up doing some tweaking to resolve patch application issues.
justincc-master
Justin Clark-Casey (justincc) 2014-02-13 23:55:38 +00:00
parent e10012a7a6
commit fc35b45e21
8 changed files with 204 additions and 311 deletions

View File

@ -282,7 +282,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
string uasURL = circuit.ServiceURLs["HomeURI"].ToString(); string uasURL = circuit.ServiceURLs["HomeURI"].ToString();
m_log.DebugFormat("[HG MESSAGE TRANSFER]: getting UUI of user {0} from {1}", toAgent, uasURL); m_log.DebugFormat("[HG MESSAGE TRANSFER]: getting UUI of user {0} from {1}", toAgent, uasURL);
UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uasURL); UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uasURL);
return uasConn.GetUUI(fromAgent, toAgent);
string agentUUI = string.Empty;
try
{
agentUUI = uasConn.GetUUI(fromAgent, toAgent);
}
catch (Exception e) {
m_log.Warn("[HG MESSAGE TRANSFER]: GetUUI call failed ", e);
}
return agentUUI;
} }
} }
} }

View File

@ -1164,7 +1164,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
UserAgentServiceConnector uConn = new UserAgentServiceConnector(home_url); UserAgentServiceConnector uConn = new UserAgentServiceConnector(home_url);
Dictionary<string, object> account = uConn.GetUserInfo(userID); Dictionary<string, object> account;
try
{
account = uConn.GetUserInfo(userID);
}
catch (Exception e)
{
m_log.Warn("[PROFILES]: GetUserInfo call failed ", e);
account = new Dictionary<string, object>();
}
if (account.Count > 0) if (account.Count > 0)
{ {

View File

@ -1,4 +1,4 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
@ -462,7 +462,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString()); IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString());
Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
GridRegion finalDestination = userAgentService.GetHomeRegion(aCircuit.AgentID, out position, out lookAt);
GridRegion finalDestination = null;
try
{
finalDestination = userAgentService.GetHomeRegion(aCircuit.AgentID, out position, out lookAt);
}
catch (Exception e)
{
m_log.Warn("[HG ENTITY TRANSFER MODULE]: GetHomeRegion call failed ", e);
}
if (finalDestination == null) if (finalDestination == null)
{ {
client.SendTeleportFailed("Your home region could not be found"); client.SendTeleportFailed("Your home region could not be found");

View File

@ -130,7 +130,17 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
} }
UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr); UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr);
UUID userID = uasConn.GetUUID(names[0], names[1]);
UUID userID = UUID.Zero;
try
{
userID = uasConn.GetUUID(names[0], names[1]);
}
catch (Exception e)
{
m_log.Warn("[USER MANAGEMENT MODULE]: GetUUID call failed ", e);
}
if (!userID.Equals(UUID.Zero)) if (!userID.Equals(UUID.Zero))
{ {
UserData ud = new UserData(); UserData ud = new UserData();

View File

@ -473,7 +473,16 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
// serverType, userdata.HomeURL, userID); // serverType, userdata.HomeURL, userID);
UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL); UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL);
try
{
userdata.ServerURLs = uConn.GetServerURLs(userID); userdata.ServerURLs = uConn.GetServerURLs(userID);
}
catch (Exception e)
{
m_log.Warn("[USER MANAGEMENT MODULE]: GetServerURLs call failed ", e);
userdata.ServerURLs = new Dictionary<string, object>();
}
if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null) if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
return userdata.ServerURLs[serverType].ToString(); return userdata.ServerURLs[serverType].ToString();
} }

View File

@ -78,7 +78,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message); m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message);
} }
} }
m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL);
//m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL);
} }
public UserAgentServiceConnector(IConfigSource config) public UserAgentServiceConnector(IConfigSource config)
@ -190,6 +191,40 @@ namespace OpenSim.Services.Connectors.Hypergrid
// no-op // no-op
} }
private Hashtable CallServer(string methodName, Hashtable hash)
{
IList paramList = new ArrayList();
paramList.Add(hash);
XmlRpcRequest request = new XmlRpcRequest(methodName, paramList);
// Send and get reply
XmlRpcResponse response = null;
try
{
response = request.Send(m_ServerURL, 10000);
}
catch (Exception e)
{
m_log.WarnFormat("[USER AGENT CONNECTOR]: {0} call to {1} failed: {2}", methodName, m_ServerURL, e.Message);
throw;
}
if (response.IsFault)
{
throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned an error: {2}", methodName, m_ServerURL, response.FaultString));
}
hash = (Hashtable)response.Value;
if (hash == null)
{
throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned null", methodName, m_ServerURL));
}
return hash;
}
public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
{ {
position = Vector3.UnitY; lookAt = Vector3.UnitY; position = Vector3.UnitY; lookAt = Vector3.UnitY;
@ -197,34 +232,12 @@ namespace OpenSim.Services.Connectors.Hypergrid
Hashtable hash = new Hashtable(); Hashtable hash = new Hashtable();
hash["userID"] = userID.ToString(); hash["userID"] = userID.ToString();
IList paramList = new ArrayList(); hash = CallServer("get_home_region", hash);
paramList.Add(hash);
XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList); bool success;
XmlRpcResponse response = null; if (!Boolean.TryParse((string)hash["result"], out success) || !success)
try
{
response = request.Send(m_ServerURL, 10000);
}
catch (Exception)
{
return null; return null;
}
if (response.IsFault)
{
return null;
}
hash = (Hashtable)response.Value;
//foreach (Object o in hash)
// m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
try
{
bool success = false;
Boolean.TryParse((string)hash["result"], out success);
if (success)
{
GridRegion region = new GridRegion(); GridRegion region = new GridRegion();
UUID.TryParse((string)hash["uuid"], out region.RegionID); UUID.TryParse((string)hash["uuid"], out region.RegionID);
@ -273,15 +286,6 @@ namespace OpenSim.Services.Connectors.Hypergrid
return region; return region;
} }
}
catch (Exception)
{
return null;
}
return null;
}
public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName) public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName)
{ {
Hashtable hash = new Hashtable(); Hashtable hash = new Hashtable();
@ -488,39 +492,10 @@ namespace OpenSim.Services.Connectors.Hypergrid
Hashtable hash = new Hashtable(); Hashtable hash = new Hashtable();
hash["userID"] = userID.ToString(); hash["userID"] = userID.ToString();
IList paramList = new ArrayList(); hash = CallServer("get_user_info", hash);
paramList.Add(hash);
XmlRpcRequest request = new XmlRpcRequest("get_user_info", paramList);
Dictionary<string, object> info = new Dictionary<string, object>(); Dictionary<string, object> info = new Dictionary<string, object>();
XmlRpcResponse response = null;
try
{
response = request.Send(m_ServerURL, 10000);
}
catch
{
m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUserInfo", m_ServerURL);
return info;
}
if (response.IsFault)
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString);
return info;
}
hash = (Hashtable)response.Value;
try
{
if (hash == null)
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUserInfo Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
return info;
}
// Here is the actual response
foreach (object key in hash.Keys) foreach (object key in hash.Keys)
{ {
if (hash[key] != null) if (hash[key] != null)
@ -528,11 +503,6 @@ namespace OpenSim.Services.Connectors.Hypergrid
info.Add(key.ToString(), hash[key]); info.Add(key.ToString(), hash[key]);
} }
} }
}
catch
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
}
return info; return info;
} }
@ -542,46 +512,9 @@ namespace OpenSim.Services.Connectors.Hypergrid
Hashtable hash = new Hashtable(); Hashtable hash = new Hashtable();
hash["userID"] = userID.ToString(); hash["userID"] = userID.ToString();
IList paramList = new ArrayList(); hash = CallServer("get_server_urls", hash);
paramList.Add(hash);
XmlRpcRequest request = new XmlRpcRequest("get_server_urls", paramList);
// string reason = string.Empty;
// Send and get reply
Dictionary<string, object> serverURLs = new Dictionary<string, object>(); Dictionary<string, object> serverURLs = new Dictionary<string, object>();
XmlRpcResponse response = null;
try
{
response = request.Send(m_ServerURL, 10000);
}
catch
{
m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetServerURLs for user {1}", m_ServerURL, userID);
// reason = "Exception: " + e.Message;
return serverURLs;
}
if (response.IsFault)
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString);
// reason = "XMLRPC Fault";
return serverURLs;
}
hash = (Hashtable)response.Value;
//foreach (Object o in hash)
// m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
try
{
if (hash == null)
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetServerURLs Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
// reason = "Internal error 1";
return serverURLs;
}
// Here is the actual response
foreach (object key in hash.Keys) foreach (object key in hash.Keys)
{ {
if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null) if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null)
@ -591,13 +524,6 @@ namespace OpenSim.Services.Connectors.Hypergrid
} }
} }
}
catch
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
// reason = "Exception: " + e.Message;
}
return serverURLs; return serverURLs;
} }
@ -606,56 +532,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
Hashtable hash = new Hashtable(); Hashtable hash = new Hashtable();
hash["userID"] = userID.ToString(); hash["userID"] = userID.ToString();
IList paramList = new ArrayList(); hash = CallServer("locate_user", hash);
paramList.Add(hash);
XmlRpcRequest request = new XmlRpcRequest("locate_user", paramList);
// string reason = string.Empty;
// Send and get reply
string url = string.Empty; string url = string.Empty;
XmlRpcResponse response = null;
try
{
response = request.Send(m_ServerURL, 10000);
}
catch
{
m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for LocateUser", m_ServerURL);
// reason = "Exception: " + e.Message;
return url;
}
if (response.IsFault)
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for LocateUser returned an error: {1}", m_ServerURL, response.FaultString);
// reason = "XMLRPC Fault";
return url;
}
hash = (Hashtable)response.Value;
//foreach (Object o in hash)
// m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
try
{
if (hash == null)
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: LocateUser Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
// reason = "Internal error 1";
return url;
}
// Here's the actual response // Here's the actual response
if (hash.ContainsKey("URL")) if (hash.ContainsKey("URL"))
url = hash["URL"].ToString(); url = hash["URL"].ToString();
}
catch
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response.");
// reason = "Exception: " + e.Message;
}
return url; return url;
} }
@ -665,56 +549,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
hash["userID"] = userID.ToString(); hash["userID"] = userID.ToString();
hash["targetUserID"] = targetUserID.ToString(); hash["targetUserID"] = targetUserID.ToString();
IList paramList = new ArrayList(); hash = CallServer("get_uui", hash);
paramList.Add(hash);
XmlRpcRequest request = new XmlRpcRequest("get_uui", paramList);
// string reason = string.Empty;
// Send and get reply
string uui = string.Empty; string uui = string.Empty;
XmlRpcResponse response = null;
try
{
response = request.Send(m_ServerURL, 10000);
}
catch
{
m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUI", m_ServerURL);
// reason = "Exception: " + e.Message;
return uui;
}
if (response.IsFault)
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUI returned an error: {1}", m_ServerURL, response.FaultString);
// reason = "XMLRPC Fault";
return uui;
}
hash = (Hashtable)response.Value;
//foreach (Object o in hash)
// m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
try
{
if (hash == null)
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
// reason = "Internal error 1";
return uui;
}
// Here's the actual response // Here's the actual response
if (hash.ContainsKey("UUI")) if (hash.ContainsKey("UUI"))
uui = hash["UUI"].ToString(); uui = hash["UUI"].ToString();
}
catch
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetUUI response.");
// reason = "Exception: " + e.Message;
}
return uui; return uui;
} }
@ -724,54 +566,17 @@ namespace OpenSim.Services.Connectors.Hypergrid
hash["first"] = first; hash["first"] = first;
hash["last"] = last; hash["last"] = last;
IList paramList = new ArrayList(); hash = CallServer("get_uuid", hash);
paramList.Add(hash);
XmlRpcRequest request = new XmlRpcRequest("get_uuid", paramList); if (!hash.ContainsKey("UUID"))
// string reason = string.Empty;
// Send and get reply
UUID uuid = UUID.Zero;
XmlRpcResponse response = null;
try
{ {
response = request.Send(m_ServerURL, 10000); throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} didn't return a UUID", m_ServerURL));
}
catch
{
m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUID", m_ServerURL);
// reason = "Exception: " + e.Message;
return uuid;
} }
if (response.IsFault) UUID uuid;
if (!UUID.TryParse(hash["UUID"].ToString(), out uuid))
{ {
m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUID returned an error: {1}", m_ServerURL, response.FaultString); throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} returned an invalid UUID: {1}", m_ServerURL, hash["UUID"].ToString()));
// reason = "XMLRPC Fault";
return uuid;
}
hash = (Hashtable)response.Value;
//foreach (Object o in hash)
// m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
try
{
if (hash == null)
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUDI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
// reason = "Internal error 1";
return uuid;
}
// Here's the actual response
if (hash.ContainsKey("UUID"))
UUID.TryParse(hash["UUID"].ToString(), out uuid);
}
catch
{
m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on UUID response.");
// reason = "Exception: " + e.Message;
} }
return uuid; return uuid;

View File

@ -215,8 +215,16 @@ namespace OpenSim.Services.HypergridService
{ {
// Let's check with the UAS if the user is elsewhere // Let's check with the UAS if the user is elsewhere
m_log.DebugFormat("[HG IM SERVICE]: User is not present. Checking location with User Agent service"); m_log.DebugFormat("[HG IM SERVICE]: User is not present. Checking location with User Agent service");
try
{
url = m_UserAgentService.LocateUser(toAgentID); url = m_UserAgentService.LocateUser(toAgentID);
} }
catch (Exception e)
{
m_log.Warn("[HG IM SERVICE]: LocateUser call failed ", e);
url = string.Empty;
}
}
// check if we've tried this before.. // check if we've tried this before..
// This is one way to end the recursive loop // This is one way to end the recursive loop

View File

@ -1,4 +1,4 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
@ -47,15 +47,47 @@ namespace OpenSim.Services.Interfaces
{ {
bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason); bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason);
void LogoutAgent(UUID userID, UUID sessionID); void LogoutAgent(UUID userID, UUID sessionID);
/// <summary>
/// Returns the home region of a remote user.
/// </summary>
/// <returns>On success: the user's home region. If the user doesn't exist: null.</returns>
/// <remarks>Throws an exception if an error occurs (e.g., can't contact the server).</remarks>
GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt); GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt);
/// <summary>
/// Returns the Server URLs of a remote user.
/// </summary>
/// <returns>On success: the user's Server URLs. If the user doesn't exist: an empty dictionary.</returns>
/// <remarks>Throws an exception if an error occurs (e.g., can't contact the server).</remarks>
Dictionary<string, object> GetServerURLs(UUID userID); Dictionary<string, object> GetServerURLs(UUID userID);
/// <summary>
/// Returns the UserInfo of a remote user.
/// </summary>
/// <returns>On success: the user's UserInfo. If the user doesn't exist: an empty dictionary.</returns>
/// <remarks>Throws an exception if an error occurs (e.g., can't contact the server).</remarks>
Dictionary<string, object> GetUserInfo(UUID userID); Dictionary<string, object> GetUserInfo(UUID userID);
/// <summary>
/// Returns the current location of a remote user.
/// </summary>
/// <returns>On success: the user's Server URLs. If the user doesn't exist: "".</returns>
/// <remarks>Throws an exception if an error occurs (e.g., can't contact the server).</remarks>
string LocateUser(UUID userID); string LocateUser(UUID userID);
// Tries to get the universal user identifier for the targetUserId
// on behalf of the userID /// <summary>
/// Returns the Universal User Identifier for 'targetUserID' on behalf of 'userID'.
/// </summary>
/// <returns>On success: the user's UUI. If the user doesn't exist: "".</returns>
/// <remarks>Throws an exception if an error occurs (e.g., can't contact the server).</remarks>
string GetUUI(UUID userID, UUID targetUserID); string GetUUI(UUID userID, UUID targetUserID);
/// <summary>
/// Returns the remote user that has the given name.
/// </summary>
/// <returns>On success: the user's UUID. If the user doesn't exist: UUID.Zero.</returns>
/// <remarks>Throws an exception if an error occurs (e.g., can't contact the server).</remarks>
UUID GetUUID(String first, String last); UUID GetUUID(String first, String last);
// Returns the local friends online // Returns the local friends online