Better error handling on the client-side grid connector.

remotes/origin/0.6.7-post-fixes
Diva Canto 2009-09-25 07:47:58 -07:00
parent b2772b3a2d
commit 295868033f
1 changed files with 108 additions and 44 deletions

View File

@ -99,18 +99,25 @@ namespace OpenSim.Services.Connectors
string reqString = ServerUtils.BuildQueryString(sendData); string reqString = ServerUtils.BuildQueryString(sendData);
//m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); //m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
string reply = SynchronousRestFormsRequester.MakeRequest("POST", try
m_ServerURI + "/grid",
reqString);
if (reply != string.Empty)
{ {
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); string reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
reqString);
if (reply != string.Empty)
{
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
return true; return true;
}
else
m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
} }
else
m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
return false; return false;
} }
@ -123,19 +130,26 @@ namespace OpenSim.Services.Connectors
sendData["METHOD"] = "deregister"; sendData["METHOD"] = "deregister";
string reply = SynchronousRestFormsRequester.MakeRequest("POST", try
m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
if (reply != string.Empty)
{ {
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); string reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) if (reply != string.Empty)
return true; {
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
return true;
}
else
m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply");
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
} }
else
m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply");
return false; return false;
} }
@ -149,14 +163,24 @@ namespace OpenSim.Services.Connectors
sendData["METHOD"] = "get_neighbours"; sendData["METHOD"] = "get_neighbours";
List<GridRegion> rinfos = new List<GridRegion>();
string reqString = ServerUtils.BuildQueryString(sendData); string reqString = ServerUtils.BuildQueryString(sendData);
string reply = SynchronousRestFormsRequester.MakeRequest("POST", string reply = string.Empty;
m_ServerURI + "/grid", try
reqString); {
reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
reqString);
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
return rinfos;
}
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
List<GridRegion> rinfos = new List<GridRegion>();
if (replyData != null) if (replyData != null)
{ {
Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
@ -189,9 +213,18 @@ namespace OpenSim.Services.Connectors
sendData["METHOD"] = "get_region_by_uuid"; sendData["METHOD"] = "get_region_by_uuid";
string reply = SynchronousRestFormsRequester.MakeRequest("POST", string reply = string.Empty;
m_ServerURI + "/grid", try
ServerUtils.BuildQueryString(sendData)); {
reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
return null;
}
GridRegion rinfo = null; GridRegion rinfo = null;
@ -226,10 +259,18 @@ namespace OpenSim.Services.Connectors
sendData["Y"] = y.ToString(); sendData["Y"] = y.ToString();
sendData["METHOD"] = "get_region_by_position"; sendData["METHOD"] = "get_region_by_position";
string reply = string.Empty;
string reply = SynchronousRestFormsRequester.MakeRequest("POST", try
m_ServerURI + "/grid", {
ServerUtils.BuildQueryString(sendData)); reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
return null;
}
GridRegion rinfo = null; GridRegion rinfo = null;
if (reply != string.Empty) if (reply != string.Empty)
@ -262,10 +303,18 @@ namespace OpenSim.Services.Connectors
sendData["NAME"] = regionName; sendData["NAME"] = regionName;
sendData["METHOD"] = "get_region_by_name"; sendData["METHOD"] = "get_region_by_name";
string reply = string.Empty;
string reply = SynchronousRestFormsRequester.MakeRequest("POST", try
m_ServerURI + "/grid", {
ServerUtils.BuildQueryString(sendData)); reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
return null;
}
GridRegion rinfo = null; GridRegion rinfo = null;
if (reply != string.Empty) if (reply != string.Empty)
@ -296,12 +345,19 @@ namespace OpenSim.Services.Connectors
sendData["MAX"] = maxNumber.ToString(); sendData["MAX"] = maxNumber.ToString();
sendData["METHOD"] = "get_regions_by_name"; sendData["METHOD"] = "get_regions_by_name";
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
List<GridRegion> rinfos = new List<GridRegion>(); List<GridRegion> rinfos = new List<GridRegion>();
string reply = string.Empty;
try
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
return rinfos;
}
if (reply != string.Empty) if (reply != string.Empty)
{ {
@ -345,12 +401,20 @@ namespace OpenSim.Services.Connectors
sendData["METHOD"] = "get_region_range"; sendData["METHOD"] = "get_region_range";
List<GridRegion> rinfos = new List<GridRegion>(); List<GridRegion> rinfos = new List<GridRegion>();
string reply = string.Empty;
try
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
string reply = SynchronousRestFormsRequester.MakeRequest("POST", //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
m_ServerURI + "/grid", }
ServerUtils.BuildQueryString(sendData)); catch (Exception e)
{
//m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
return rinfos;
}
if (reply != string.Empty) if (reply != string.Empty)
{ {