From 390137d540b9ae39eba3ba9136bd49d5e992bc5f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 21 Sep 2009 11:05:01 -0700 Subject: Added grid handler and grid remote connector. --- .../Connectors/Grid/GridServiceConnector.cs | 346 +++++++++++++++++++++ 1 file changed, 346 insertions(+) create mode 100644 OpenSim/Services/Connectors/Grid/GridServiceConnector.cs (limited to 'OpenSim/Services/Connectors/Grid/GridServiceConnector.cs') diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs new file mode 100644 index 0000000..ae7db7e --- /dev/null +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -0,0 +1,346 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using log4net; +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Services.Interfaces; +using OpenSim.Server.Base; +using OpenMetaverse; + +namespace OpenSim.Services.Connectors +{ + public class GridServicesConnector : IGridService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private string m_ServerURI = String.Empty; + + public GridServicesConnector() + { + } + + public GridServicesConnector(string serverURI) + { + m_ServerURI = serverURI.TrimEnd('/'); + } + + public GridServicesConnector(IConfigSource source) + { + Initialise(source); + } + + public virtual void Initialise(IConfigSource source) + { + IConfig gridConfig = source.Configs["GridService"]; + if (gridConfig == null) + { + m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini"); + throw new Exception("Grid connector init error"); + } + + string serviceURI = gridConfig.GetString("GridServerURI", + String.Empty); + + if (serviceURI == String.Empty) + { + m_log.Error("[GRID CONNECTOR]: No Server URI named in section GridService"); + throw new Exception("Grid connector init error"); + } + m_ServerURI = serviceURI; + } + + + #region IGridService + + public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + { + Dictionary rinfo = regionInfo.ToKeyValuePairs(); + Dictionary sendData = new Dictionary(); + foreach (KeyValuePair kvp in rinfo) + sendData[kvp.Key] = (string)kvp.Value; + + sendData["SCOPEID"] = scopeID.ToString(); + + sendData["METHOD"] = "register"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) + return true; + + return false; + } + + public bool DeregisterRegion(UUID regionID) + { + Dictionary sendData = new Dictionary(); + + sendData["REGIONID"] = regionID.ToString(); + + sendData["METHOD"] = "deregister"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) + return true; + + return false; + } + + public List GetNeighbours(UUID scopeID, UUID regionID) + { + Dictionary sendData = new Dictionary(); + + sendData["SCOPEID"] = scopeID.ToString(); + sendData["REGIONID"] = regionID.ToString(); + + sendData["METHOD"] = "get_neighbours"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + List rinfos = new List(); + if (replyData != null) + { + Dictionary.ValueCollection rinfosList = replyData.Values; + foreach (object r in rinfosList) + { + if (r is Dictionary) + { + SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + rinfos.Add(rinfo); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response", + scopeID, regionID); + } + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received null response", + scopeID, regionID); + + return rinfos; + } + + public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + { + Dictionary sendData = new Dictionary(); + + sendData["SCOPEID"] = scopeID.ToString(); + sendData["REGIONID"] = regionID.ToString(); + + sendData["METHOD"] = "get_region_by_uuid"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + SimpleRegionInfo rinfo = null; + if ((replyData != null) && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", + scopeID, regionID); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", + scopeID, regionID); + + return rinfo; + } + + public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + { + Dictionary sendData = new Dictionary(); + + sendData["SCOPEID"] = scopeID.ToString(); + sendData["X"] = x.ToString(); + sendData["Y"] = y.ToString(); + + sendData["METHOD"] = "get_region_by_position"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + SimpleRegionInfo rinfo = null; + if ((replyData != null) && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", + scopeID, x, y); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", + scopeID, x, y); + + return rinfo; + } + + public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + { + Dictionary sendData = new Dictionary(); + + sendData["SCOPEID"] = scopeID.ToString(); + sendData["NAME"] = regionName; + + sendData["METHOD"] = "get_region_by_name"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + SimpleRegionInfo rinfo = null; + if ((replyData != null) && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", + scopeID, regionName); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response", + scopeID, regionName); + + return rinfo; + } + + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + { + Dictionary sendData = new Dictionary(); + + sendData["SCOPEID"] = scopeID.ToString(); + sendData["NAME"] = name; + sendData["MAX"] = maxNumber.ToString(); + + sendData["METHOD"] = "get_regions_by_name"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + List rinfos = new List(); + if (replyData != null) + { + Dictionary.ValueCollection rinfosList = replyData.Values; + foreach (object r in rinfosList) + { + if (r is Dictionary) + { + SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + rinfos.Add(rinfo); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response", + scopeID, name, maxNumber); + } + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response", + scopeID, name, maxNumber); + + return rinfos; + } + + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + { + Dictionary sendData = new Dictionary(); + + sendData["SCOPEID"] = scopeID.ToString(); + sendData["XMIN"] = xmin.ToString(); + sendData["XMAX"] = xmax.ToString(); + sendData["YMIN"] = ymin.ToString(); + sendData["YMAX"] = ymax.ToString(); + + sendData["METHOD"] = "get_region_range"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + List rinfos = new List(); + if (replyData != null) + { + Dictionary.ValueCollection rinfosList = replyData.Values; + foreach (object r in rinfosList) + { + if (r is Dictionary) + { + SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + rinfos.Add(rinfo); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received invalid response", + scopeID, xmin, xmax, ymin, ymax); + } + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response", + scopeID, xmin, xmax, ymin, ymax); + + return rinfos; + } + + #endregion + + } +} -- cgit v1.1 From 882d2c9cc399c4c7d1809702104ce94c9c2c7b17 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 20:25:00 -0700 Subject: Added hg console commands to the module. Added the IN connector module for link-region and corresponding handler to be used in the regions only. No service as such is needed. This will replace the current link-region machinery. Compiles but not tested. --- OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Services/Connectors/Grid/GridServiceConnector.cs') diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index ae7db7e..1962bcf 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -85,7 +85,7 @@ namespace OpenSim.Services.Connectors #region IGridService - public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + public virtual bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) { Dictionary rinfo = regionInfo.ToKeyValuePairs(); Dictionary sendData = new Dictionary(); @@ -108,7 +108,7 @@ namespace OpenSim.Services.Connectors return false; } - public bool DeregisterRegion(UUID regionID) + public virtual bool DeregisterRegion(UUID regionID) { Dictionary sendData = new Dictionary(); @@ -128,7 +128,7 @@ namespace OpenSim.Services.Connectors return false; } - public List GetNeighbours(UUID scopeID, UUID regionID) + public virtual List GetNeighbours(UUID scopeID, UUID regionID) { Dictionary sendData = new Dictionary(); @@ -166,7 +166,7 @@ namespace OpenSim.Services.Connectors return rinfos; } - public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public virtual SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) { Dictionary sendData = new Dictionary(); @@ -197,7 +197,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public virtual SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) { Dictionary sendData = new Dictionary(); @@ -229,7 +229,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public virtual SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) { Dictionary sendData = new Dictionary(); @@ -260,7 +260,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public virtual List GetRegionsByName(UUID scopeID, string name, int maxNumber) { Dictionary sendData = new Dictionary(); @@ -299,7 +299,7 @@ namespace OpenSim.Services.Connectors return rinfos; } - public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public virtual List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { Dictionary sendData = new Dictionary(); -- cgit v1.1 From 67276589c883fe1a74d8d52057db1431d637dade Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 17:20:07 -0700 Subject: Changed IGridService to use the new GridRegion data structure instead of old SimpleRegionInfo. Added grid configs to standalones. --- .../Connectors/Grid/GridServiceConnector.cs | 39 +++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'OpenSim/Services/Connectors/Grid/GridServiceConnector.cs') diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 1962bcf..0a867db 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -35,6 +35,7 @@ using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; using OpenMetaverse; @@ -85,7 +86,7 @@ namespace OpenSim.Services.Connectors #region IGridService - public virtual bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo) { Dictionary rinfo = regionInfo.ToKeyValuePairs(); Dictionary sendData = new Dictionary(); @@ -128,7 +129,7 @@ namespace OpenSim.Services.Connectors return false; } - public virtual List GetNeighbours(UUID scopeID, UUID regionID) + public virtual List GetNeighbours(UUID scopeID, UUID regionID) { Dictionary sendData = new Dictionary(); @@ -143,7 +144,7 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - List rinfos = new List(); + List rinfos = new List(); if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; @@ -151,7 +152,7 @@ namespace OpenSim.Services.Connectors { if (r is Dictionary) { - SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + GridRegion rinfo = new GridRegion((Dictionary)r); rinfos.Add(rinfo); } else @@ -166,7 +167,7 @@ namespace OpenSim.Services.Connectors return rinfos; } - public virtual SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { Dictionary sendData = new Dictionary(); @@ -181,11 +182,11 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - SimpleRegionInfo rinfo = null; + GridRegion rinfo = null; if ((replyData != null) && (replyData["result"] != null)) { if (replyData["result"] is Dictionary) - rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + rinfo = new GridRegion((Dictionary)replyData["result"]); else m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", scopeID, regionID); @@ -197,7 +198,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public virtual SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { Dictionary sendData = new Dictionary(); @@ -213,11 +214,11 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - SimpleRegionInfo rinfo = null; + GridRegion rinfo = null; if ((replyData != null) && (replyData["result"] != null)) { if (replyData["result"] is Dictionary) - rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + rinfo = new GridRegion((Dictionary)replyData["result"]); else m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", scopeID, x, y); @@ -229,7 +230,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public virtual SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public virtual GridRegion GetRegionByName(UUID scopeID, string regionName) { Dictionary sendData = new Dictionary(); @@ -244,11 +245,11 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - SimpleRegionInfo rinfo = null; + GridRegion rinfo = null; if ((replyData != null) && (replyData["result"] != null)) { if (replyData["result"] is Dictionary) - rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + rinfo = new GridRegion((Dictionary)replyData["result"]); else m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", scopeID, regionName); @@ -260,7 +261,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public virtual List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public virtual List GetRegionsByName(UUID scopeID, string name, int maxNumber) { Dictionary sendData = new Dictionary(); @@ -276,7 +277,7 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - List rinfos = new List(); + List rinfos = new List(); if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; @@ -284,7 +285,7 @@ namespace OpenSim.Services.Connectors { if (r is Dictionary) { - SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + GridRegion rinfo = new GridRegion((Dictionary)r); rinfos.Add(rinfo); } else @@ -299,7 +300,7 @@ namespace OpenSim.Services.Connectors return rinfos; } - public virtual List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public virtual List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { Dictionary sendData = new Dictionary(); @@ -317,7 +318,7 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - List rinfos = new List(); + List rinfos = new List(); if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; @@ -325,7 +326,7 @@ namespace OpenSim.Services.Connectors { if (r is Dictionary) { - SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + GridRegion rinfo = new GridRegion((Dictionary)r); rinfos.Add(rinfo); } else -- cgit v1.1 From dd3d52ae1faefbca85e2fe8d8cea67f7db4005ac Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 13:33:58 -0700 Subject: Added test GridClient, which allowed me to remove a few bugs out of the new code. --- OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services/Connectors/Grid/GridServiceConnector.cs') diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 0a867db..fa197c8 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -97,9 +97,11 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "register"; + string reqString = ServerUtils.BuildQueryString(sendData); + m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); + reqString); Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -138,9 +140,10 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "get_neighbours"; + string reqString = ServerUtils.BuildQueryString(sendData); string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); + reqString); Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -148,6 +151,7 @@ namespace OpenSim.Services.Connectors if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; + m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count); foreach (object r in rinfosList) { if (r is Dictionary) @@ -156,8 +160,8 @@ namespace OpenSim.Services.Connectors rinfos.Add(rinfo); } else - m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response", - scopeID, regionID); + m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response type {2}", + scopeID, regionID, r.GetType()); } } else -- cgit v1.1 From 1faaa0a43a851c44af40336336ddbe3a7dbe83af Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 15:30:00 -0700 Subject: GridServerPostHandler finished. GridClient tests all work. More guards on getting parameters and replies over the wire. --- .../Connectors/Grid/GridServiceConnector.cs | 151 +++++++++++++-------- 1 file changed, 92 insertions(+), 59 deletions(-) (limited to 'OpenSim/Services/Connectors/Grid/GridServiceConnector.cs') diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index fa197c8..ebb66a7 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -98,15 +98,19 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "register"; 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", m_ServerURI + "/grid", reqString); + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - - if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) - return true; + if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) + return true; + } + else + m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply"); return false; } @@ -123,10 +127,15 @@ namespace OpenSim.Services.Connectors m_ServerURI + "/grid", ServerUtils.BuildQueryString(sendData)); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) - return true; + if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) + return true; + } + else + m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply"); return false; } @@ -151,7 +160,7 @@ namespace OpenSim.Services.Connectors if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; - m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count); + //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count); foreach (object r in rinfosList) { if (r is Dictionary) @@ -184,20 +193,26 @@ namespace OpenSim.Services.Connectors m_ServerURI + "/grid", ServerUtils.BuildQueryString(sendData)); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - GridRegion rinfo = null; - if ((replyData != null) && (replyData["result"] != null)) + + if (reply != string.Empty) { - if (replyData["result"] is Dictionary) - rinfo = new GridRegion((Dictionary)replyData["result"]); + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if ((replyData != null) && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + rinfo = new GridRegion((Dictionary)replyData["result"]); + //else + // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", + // scopeID, regionID); + } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", scopeID, regionID); } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", - scopeID, regionID); + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply"); return rinfo; } @@ -216,20 +231,25 @@ namespace OpenSim.Services.Connectors m_ServerURI + "/grid", ServerUtils.BuildQueryString(sendData)); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - GridRegion rinfo = null; - if ((replyData != null) && (replyData["result"] != null)) + if (reply != string.Empty) { - if (replyData["result"] is Dictionary) - rinfo = new GridRegion((Dictionary)replyData["result"]); + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if ((replyData != null) && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + rinfo = new GridRegion((Dictionary)replyData["result"]); + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", + scopeID, x, y); + } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", scopeID, x, y); } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", - scopeID, x, y); + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply"); return rinfo; } @@ -247,20 +267,22 @@ namespace OpenSim.Services.Connectors m_ServerURI + "/grid", ServerUtils.BuildQueryString(sendData)); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - GridRegion rinfo = null; - if ((replyData != null) && (replyData["result"] != null)) + if (reply != string.Empty) { - if (replyData["result"] is Dictionary) - rinfo = new GridRegion((Dictionary)replyData["result"]); + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if ((replyData != null) && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + rinfo = new GridRegion((Dictionary)replyData["result"]); + } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response", scopeID, regionName); } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response", - scopeID, regionName); + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply"); return rinfo; } @@ -279,27 +301,33 @@ namespace OpenSim.Services.Connectors m_ServerURI + "/grid", ServerUtils.BuildQueryString(sendData)); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - List rinfos = new List(); - if (replyData != null) + + if (reply != string.Empty) { - Dictionary.ValueCollection rinfosList = replyData.Values; - foreach (object r in rinfosList) + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if (replyData != null) { - if (r is Dictionary) + Dictionary.ValueCollection rinfosList = replyData.Values; + foreach (object r in rinfosList) { - GridRegion rinfo = new GridRegion((Dictionary)r); - rinfos.Add(rinfo); + if (r is Dictionary) + { + GridRegion rinfo = new GridRegion((Dictionary)r); + rinfos.Add(rinfo); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response", + scopeID, name, maxNumber); } - else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response", - scopeID, name, maxNumber); } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response", + scopeID, name, maxNumber); } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response", - scopeID, name, maxNumber); + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply"); return rinfos; } @@ -316,31 +344,36 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "get_region_range"; + List rinfos = new List(); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/grid", ServerUtils.BuildQueryString(sendData)); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); - List rinfos = new List(); - if (replyData != null) + if (reply != string.Empty) { - Dictionary.ValueCollection rinfosList = replyData.Values; - foreach (object r in rinfosList) + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if (replyData != null) { - if (r is Dictionary) + Dictionary.ValueCollection rinfosList = replyData.Values; + foreach (object r in rinfosList) { - GridRegion rinfo = new GridRegion((Dictionary)r); - rinfos.Add(rinfo); + if (r is Dictionary) + { + GridRegion rinfo = new GridRegion((Dictionary)r); + rinfos.Add(rinfo); + } } - else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received invalid response", - scopeID, xmin, xmax, ymin, ymax); } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response", + scopeID, xmin, xmax, ymin, ymax); } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response", - scopeID, xmin, xmax, ymin, ymax); + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply"); return rinfos; } -- cgit v1.1 From 295868033f44edeb25230c2d4cf336c454693075 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 25 Sep 2009 07:47:58 -0700 Subject: Better error handling on the client-side grid connector. --- .../Connectors/Grid/GridServiceConnector.cs | 152 +++++++++++++++------ 1 file changed, 108 insertions(+), 44 deletions(-) (limited to 'OpenSim/Services/Connectors/Grid/GridServiceConnector.cs') diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index ebb66a7..748892a 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -99,18 +99,25 @@ namespace OpenSim.Services.Connectors string reqString = ServerUtils.BuildQueryString(sendData); //m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - reqString); - if (reply != string.Empty) + try { - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + reqString); + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) - return true; + if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) + 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; } @@ -123,19 +130,26 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "deregister"; - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); - - if (reply != string.Empty) + try { - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) - return true; + 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; } @@ -149,14 +163,24 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "get_neighbours"; + List rinfos = new List(); + string reqString = ServerUtils.BuildQueryString(sendData); - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - reqString); + string reply = string.Empty; + try + { + 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 replyData = ServerUtils.ParseXmlResponse(reply); - List rinfos = new List(); if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; @@ -189,9 +213,18 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "get_region_by_uuid"; - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); + 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 null; + } GridRegion rinfo = null; @@ -226,10 +259,18 @@ namespace OpenSim.Services.Connectors sendData["Y"] = y.ToString(); sendData["METHOD"] = "get_region_by_position"; - - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); + 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 null; + } GridRegion rinfo = null; if (reply != string.Empty) @@ -262,10 +303,18 @@ namespace OpenSim.Services.Connectors sendData["NAME"] = regionName; sendData["METHOD"] = "get_region_by_name"; - - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); + 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 null; + } GridRegion rinfo = null; if (reply != string.Empty) @@ -296,12 +345,19 @@ namespace OpenSim.Services.Connectors sendData["MAX"] = maxNumber.ToString(); sendData["METHOD"] = "get_regions_by_name"; - - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); - List rinfos = new List(); + 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) { @@ -345,12 +401,20 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "get_region_range"; List rinfos = new List(); + string reply = string.Empty; + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); - - //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); + //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); + return rinfos; + } if (reply != string.Empty) { -- cgit v1.1