From ae07b220c61cc92453c67e602907f0b3c8fcc707 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 21 Sep 2009 17:16:30 -0700 Subject: Changed position methods so that they assume the input params are in meters. --- OpenSim/Services/GridService/GridService.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 2229421..dd529f5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -95,7 +95,9 @@ namespace OpenSim.Services.GridService if (region != null) { // Not really? Maybe? - List rdatas = m_Database.Get(region.posX - 1, region.posY - 1, region.posX + 1, region.posY + 1, scopeID); + List rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize, region.posY - (int)Constants.RegionSize, + region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); + foreach (RegionData rdata in rdatas) rinfos.Add(RegionData2RegionInfo(rdata)); @@ -114,7 +116,9 @@ namespace OpenSim.Services.GridService public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) { - RegionData rdata = m_Database.Get(x, y, scopeID); + int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; + int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; + RegionData rdata = m_Database.Get(snapX, snapY, scopeID); if (rdata != null) return RegionData2RegionInfo(rdata); @@ -151,7 +155,12 @@ namespace OpenSim.Services.GridService public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { - List rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); + int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; + int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; + int yminSnap = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; + int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; + + List rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); List rinfos = new List(); foreach (RegionData rdata in rdatas) rinfos.Add(RegionData2RegionInfo(rdata)); -- cgit v1.1 From 34f4738159300ab6370e3db47df5187b6cea8771 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 11:58:40 -0700 Subject: Added HGGridConnector and related code. --- .../Connectors/Grid/HypergridServiceConnector.cs | 155 +++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs new file mode 100644 index 0000000..f68c10a --- /dev/null +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -0,0 +1,155 @@ +/* + * 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 System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Drawing; +using System.Net; +using System.Reflection; +using OpenSim.Services.Interfaces; + +using OpenSim.Framework; + +using OpenMetaverse; +using OpenMetaverse.Imaging; +using log4net; +using Nwc.XmlRpc; + +namespace OpenSim.Services.Connectors.Grid +{ + public class HypergridServiceConnector + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private IAssetService m_AssetService; + + public HypergridServiceConnector(IAssetService assService) + { + m_AssetService = assService; + } + + public UUID LinkRegion(SimpleRegionInfo info) + { + UUID uuid = UUID.Zero; + + //Hashtable hash = new Hashtable(); + //hash["region_name"] = info.RegionName; + + //IList paramList = new ArrayList(); + //paramList.Add(hash); + + //XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); + //string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; + //m_log.Debug("[HGrid]: Linking to " + uri); + //XmlRpcResponse response = request.Send(uri, 10000); + //if (response.IsFault) + //{ + // m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); + //} + //else + //{ + // hash = (Hashtable)response.Value; + // //foreach (Object o in hash) + // // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); + // try + // { + // UUID.TryParse((string)hash["uuid"], out uuid); + // info.RegionID = uuid; + // if ((string)hash["handle"] != null) + // { + // info.regionSecret = (string)hash["handle"]; + // //m_log.Debug(">> HERE: " + info.regionSecret); + // } + // if (hash["region_image"] != null) + // { + // UUID img = UUID.Zero; + // UUID.TryParse((string)hash["region_image"], out img); + // info.RegionSettings.TerrainImageID = img; + // } + // if (hash["region_name"] != null) + // { + // info.RegionName = (string)hash["region_name"]; + // //m_log.Debug(">> " + info.RegionName); + // } + // if (hash["internal_port"] != null) + // { + // int port = Convert.ToInt32((string)hash["internal_port"]); + // info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); + // //m_log.Debug(">> " + info.InternalEndPoint.ToString()); + // } + // if (hash["remoting_port"] != null) + // { + // info.RemotingPort = Convert.ToUInt32(hash["remoting_port"]); + // //m_log.Debug(">> " + info.RemotingPort); + // } + + // } + // catch (Exception e) + // { + // m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); + // } + //} + return uuid; + } + + public void GetMapImage(SimpleRegionInfo info) + { + try + { + string regionimage = "regionImage" + info.RegionID.ToString(); + regionimage = regionimage.Replace("-", ""); + + WebClient c = new WebClient(); + string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage; + //m_log.Debug("JPEG: " + uri); + c.DownloadFile(uri, info.RegionID.ToString() + ".jpg"); + Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); + //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); + byte[] imageData = OpenJPEG.EncodeFromImage(m, true); + AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString()); + + // !!! for now + //info.RegionSettings.TerrainImageID = ass.FullID; + + ass.Type = (int)AssetType.Texture; + ass.Temporary = true; + ass.Local = true; + ass.Data = imageData; + + m_AssetService.Store(ass); + + } + catch // LEGIT: Catching problems caused by OpenJPEG p/invoke + { + m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache"); + } + } + + } +} -- cgit v1.1 From ffd30b8ac31bc408316079ba86076bf9e984a8be Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 14:46:05 -0700 Subject: Moved RegionName from RegionInfo to SimpleRegionInfo. --- .../Connectors/Grid/HypergridServiceConnector.cs | 112 ++++++++++----------- OpenSim/Services/GridService/GridService.cs | 4 +- 2 files changed, 56 insertions(+), 60 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index f68c10a..6b0518c 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -54,67 +54,63 @@ namespace OpenSim.Services.Connectors.Grid m_AssetService = assService; } - public UUID LinkRegion(SimpleRegionInfo info) + public UUID LinkRegion(SimpleRegionInfo info, out ulong realHandle) { UUID uuid = UUID.Zero; + realHandle = 0; - //Hashtable hash = new Hashtable(); - //hash["region_name"] = info.RegionName; - - //IList paramList = new ArrayList(); - //paramList.Add(hash); - - //XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); - //string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; - //m_log.Debug("[HGrid]: Linking to " + uri); - //XmlRpcResponse response = request.Send(uri, 10000); - //if (response.IsFault) - //{ - // m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); - //} - //else - //{ - // hash = (Hashtable)response.Value; - // //foreach (Object o in hash) - // // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); - // try - // { - // UUID.TryParse((string)hash["uuid"], out uuid); - // info.RegionID = uuid; - // if ((string)hash["handle"] != null) - // { - // info.regionSecret = (string)hash["handle"]; - // //m_log.Debug(">> HERE: " + info.regionSecret); - // } - // if (hash["region_image"] != null) - // { - // UUID img = UUID.Zero; - // UUID.TryParse((string)hash["region_image"], out img); - // info.RegionSettings.TerrainImageID = img; - // } - // if (hash["region_name"] != null) - // { - // info.RegionName = (string)hash["region_name"]; - // //m_log.Debug(">> " + info.RegionName); - // } - // if (hash["internal_port"] != null) - // { - // int port = Convert.ToInt32((string)hash["internal_port"]); - // info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); - // //m_log.Debug(">> " + info.InternalEndPoint.ToString()); - // } - // if (hash["remoting_port"] != null) - // { - // info.RemotingPort = Convert.ToUInt32(hash["remoting_port"]); - // //m_log.Debug(">> " + info.RemotingPort); - // } - - // } - // catch (Exception e) - // { - // m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); - // } - //} + Hashtable hash = new Hashtable(); + hash["region_name"] = info.RegionName; + + IList paramList = new ArrayList(); + paramList.Add(hash); + + XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); + string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; + m_log.Debug("[HGrid]: Linking to " + uri); + XmlRpcResponse response = request.Send(uri, 10000); + if (response.IsFault) + { + m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); + } + else + { + hash = (Hashtable)response.Value; + //foreach (Object o in hash) + // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); + try + { + UUID.TryParse((string)hash["uuid"], out uuid); + info.RegionID = uuid; + if ((string)hash["handle"] != null) + { + realHandle = Convert.ToUInt64((string)hash["handle"]); + m_log.Debug(">> HERE, realHandle: " + realHandle); + } + //if (hash["region_image"] != null) + //{ + // UUID img = UUID.Zero; + // UUID.TryParse((string)hash["region_image"], out img); + // info.RegionSettings.TerrainImageID = img; + //} + if (hash["region_name"] != null) + { + info.RegionName = (string)hash["region_name"]; + //m_log.Debug(">> " + info.RegionName); + } + if (hash["internal_port"] != null) + { + int port = Convert.ToInt32((string)hash["internal_port"]); + info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); + //m_log.Debug(">> " + info.InternalEndPoint.ToString()); + } + + } + catch (Exception e) + { + m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); + } + } return uuid; } diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index dd529f5..b37a51b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -179,7 +179,7 @@ namespace OpenSim.Services.GridService rdata.posY = (int)rinfo.RegionLocY; rdata.RegionID = rinfo.RegionID; rdata.Data = rinfo.ToKeyValuePairs(); - //rdata.RegionName = rinfo.RegionName; + rdata.RegionName = rinfo.RegionName; return rdata; } @@ -190,7 +190,7 @@ namespace OpenSim.Services.GridService rinfo.RegionLocX = (uint)rdata.posX; rinfo.RegionLocY = (uint)rdata.posY; rinfo.RegionID = rdata.RegionID; - //rinfo.RegionName = rdata.RegionName; + rinfo.RegionName = rdata.RegionName; return rinfo; } -- 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') 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 ++-- .../Connectors/Grid/HypergridServiceConnector.cs | 5 +- OpenSim/Services/GridService/GridService.cs | 32 +-- OpenSim/Services/GridService/GridServiceBase.cs | 2 +- OpenSim/Services/Interfaces/IGridService.cs | 249 ++++++++++++++++++++- 5 files changed, 281 insertions(+), 46 deletions(-) (limited to 'OpenSim/Services') 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 diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index 6b0518c..616c2c1 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -33,6 +33,7 @@ using System.Drawing; using System.Net; using System.Reflection; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Framework; @@ -54,7 +55,7 @@ namespace OpenSim.Services.Connectors.Grid m_AssetService = assService; } - public UUID LinkRegion(SimpleRegionInfo info, out ulong realHandle) + public UUID LinkRegion(GridRegion info, out ulong realHandle) { UUID uuid = UUID.Zero; realHandle = 0; @@ -114,7 +115,7 @@ namespace OpenSim.Services.Connectors.Grid return uuid; } - public void GetMapImage(SimpleRegionInfo info) + public void GetMapImage(GridRegion info) { try { diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index b37a51b..cd462ab 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -35,6 +35,7 @@ using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Data; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenMetaverse; namespace OpenSim.Services.GridService @@ -48,6 +49,7 @@ namespace OpenSim.Services.GridService public GridService(IConfigSource config) : base(config) { + m_log.DebugFormat("[GRID SERVICE]: Starting..."); MainConsole.Instance.Commands.AddCommand("kfs", false, "show digest", "show digest ", @@ -62,7 +64,7 @@ namespace OpenSim.Services.GridService #region IGridService - public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) + public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) { if (m_Database.Get(regionInfos.RegionID, scopeID) != null) { @@ -88,9 +90,9 @@ namespace OpenSim.Services.GridService return m_Database.Delete(regionID); } - public List GetNeighbours(UUID scopeID, UUID regionID) + public List GetNeighbours(UUID scopeID, UUID regionID) { - List rinfos = new List(); + List rinfos = new List(); RegionData region = m_Database.Get(regionID, scopeID); if (region != null) { @@ -105,7 +107,7 @@ namespace OpenSim.Services.GridService return rinfos; } - public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { RegionData rdata = m_Database.Get(regionID, scopeID); if (rdata != null) @@ -114,7 +116,7 @@ namespace OpenSim.Services.GridService return null; } - public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; @@ -125,7 +127,7 @@ namespace OpenSim.Services.GridService return null; } - public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public GridRegion GetRegionByName(UUID scopeID, string regionName) { List rdatas = m_Database.Get(regionName + "%", scopeID); if ((rdatas != null) && (rdatas.Count > 0)) @@ -134,12 +136,12 @@ namespace OpenSim.Services.GridService return null; } - public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { List rdatas = m_Database.Get("%" + name + "%", scopeID); int count = 0; - List rinfos = new List(); + List rinfos = new List(); if (rdatas != null) { @@ -153,7 +155,7 @@ namespace OpenSim.Services.GridService return rinfos; } - public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; @@ -161,7 +163,7 @@ namespace OpenSim.Services.GridService int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; List rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); - List rinfos = new List(); + List rinfos = new List(); foreach (RegionData rdata in rdatas) rinfos.Add(RegionData2RegionInfo(rdata)); @@ -172,7 +174,7 @@ namespace OpenSim.Services.GridService #region Data structure conversions - protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) + protected RegionData RegionInfo2RegionData(GridRegion rinfo) { RegionData rdata = new RegionData(); rdata.posX = (int)rinfo.RegionLocX; @@ -184,11 +186,11 @@ namespace OpenSim.Services.GridService return rdata; } - protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) + protected GridRegion RegionData2RegionInfo(RegionData rdata) { - SimpleRegionInfo rinfo = new SimpleRegionInfo(rdata.Data); - rinfo.RegionLocX = (uint)rdata.posX; - rinfo.RegionLocY = (uint)rdata.posY; + GridRegion rinfo = new GridRegion(rdata.Data); + rinfo.RegionLocX = rdata.posX; + rinfo.RegionLocY = rdata.posY; rinfo.RegionID = rdata.RegionID; rinfo.RegionName = rdata.RegionName; diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs index 7522e64..444f79b 100644 --- a/OpenSim/Services/GridService/GridServiceBase.cs +++ b/OpenSim/Services/GridService/GridServiceBase.cs @@ -68,7 +68,7 @@ namespace OpenSim.Services.GridService connString = gridConfig.GetString("ConnectionString", connString); realm = gridConfig.GetString("Realm", realm); } - + // // We tried, but this doesn't exist. We can't proceed. // diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 8f6c524..a188f7e 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -25,8 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using OpenSim.Framework; +using System; using System.Collections.Generic; +using System.Net; +using System.Net.Sockets; +using OpenSim.Framework; using OpenMetaverse; namespace OpenSim.Services.Interfaces @@ -39,7 +42,7 @@ namespace OpenSim.Services.Interfaces /// /// /// Thrown if region registration failed - bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos); + bool RegisterRegion(UUID scopeID, GridRegion regionInfos); /// /// Deregister a region with the grid service. @@ -55,9 +58,9 @@ namespace OpenSim.Services.Interfaces /// /// /// - List GetNeighbours(UUID scopeID, UUID regionID); + List GetNeighbours(UUID scopeID, UUID regionID); - SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); + GridRegion GetRegionByUUID(UUID scopeID, UUID regionID); /// /// Get the region at the given position (in meters) @@ -66,9 +69,9 @@ namespace OpenSim.Services.Interfaces /// /// /// - SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); - - SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName); + GridRegion GetRegionByPosition(UUID scopeID, int x, int y); + + GridRegion GetRegionByName(UUID scopeID, string regionName); /// /// Get information about regions starting with the provided name. @@ -83,9 +86,237 @@ namespace OpenSim.Services.Interfaces /// A list of s of regions with matching name. If the /// grid-server couldn't be contacted or returned an error, return null. /// - List GetRegionsByName(UUID scopeID, string name, int maxNumber); + List GetRegionsByName(UUID scopeID, string name, int maxNumber); - List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); + List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); } + + public class GridRegion + { + + /// + /// The port by which http communication occurs with the region + /// + public uint HttpPort + { + get { return m_httpPort; } + set { m_httpPort = value; } + } + protected uint m_httpPort; + + /// + /// A well-formed URI for the host region server (namely "http://" + ExternalHostName) + /// + public string ServerURI + { + get { return m_serverURI; } + set { m_serverURI = value; } + } + protected string m_serverURI; + + public string RegionName + { + get { return m_regionName; } + set { m_regionName = value; } + } + protected string m_regionName = String.Empty; + + protected bool Allow_Alternate_Ports; + public bool m_allow_alternate_ports; + + protected string m_externalHostName; + + protected IPEndPoint m_internalEndPoint; + + public int RegionLocX + { + get { return m_regionLocX; } + set { m_regionLocX = value; } + } + protected int m_regionLocX; + + public int RegionLocY + { + get { return m_regionLocY; } + set { m_regionLocY = value; } + } + protected int m_regionLocY; + + public UUID RegionID = UUID.Zero; + public UUID ScopeID = UUID.Zero; + + public GridRegion() + { + } + + public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri) + { + m_regionLocX = regionLocX; + m_regionLocY = regionLocY; + + m_internalEndPoint = internalEndPoint; + m_externalHostName = externalUri; + } + + public GridRegion(int regionLocX, int regionLocY, string externalUri, uint port) + { + m_regionLocX = regionLocX; + m_regionLocY = regionLocY; + + m_externalHostName = externalUri; + + m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port); + } + + public GridRegion(uint xcell, uint ycell) + { + m_regionLocX = (int)(xcell * Constants.RegionSize); + m_regionLocY = (int)(ycell * Constants.RegionSize); + } + + public GridRegion(RegionInfo ConvertFrom) + { + m_regionName = ConvertFrom.RegionName; + m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize); + m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize); + m_internalEndPoint = ConvertFrom.InternalEndPoint; + m_externalHostName = ConvertFrom.ExternalHostName; + m_httpPort = ConvertFrom.HttpPort; + m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; + RegionID = UUID.Zero; + ServerURI = ConvertFrom.ServerURI; + } + + + /// + /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. + /// + /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method? + /// + public IPEndPoint ExternalEndPoint + { + get + { + // Old one defaults to IPv6 + //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port); + + IPAddress ia = null; + // If it is already an IP, don't resolve it - just return directly + if (IPAddress.TryParse(m_externalHostName, out ia)) + return new IPEndPoint(ia, m_internalEndPoint.Port); + + // Reset for next check + ia = null; + try + { + foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName)) + { + if (ia == null) + ia = Adr; + + if (Adr.AddressFamily == AddressFamily.InterNetwork) + { + ia = Adr; + break; + } + } + } + catch (SocketException e) + { + throw new Exception( + "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + + e + "' attached to this exception", e); + } + + return new IPEndPoint(ia, m_internalEndPoint.Port); + } + + set { m_externalHostName = value.ToString(); } + } + + public string ExternalHostName + { + get { return m_externalHostName; } + set { m_externalHostName = value; } + } + + public IPEndPoint InternalEndPoint + { + get { return m_internalEndPoint; } + set { m_internalEndPoint = value; } + } + + public ulong RegionHandle + { + get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); } + } + + public int getInternalEndPointPort() + { + return m_internalEndPoint.Port; + } + + public Dictionary ToKeyValuePairs() + { + Dictionary kvp = new Dictionary(); + kvp["uuid"] = RegionID.ToString(); + kvp["locX"] = RegionLocX.ToString(); + kvp["locY"] = RegionLocY.ToString(); + kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); + kvp["external_port"] = ExternalEndPoint.Port.ToString(); + kvp["external_host_name"] = ExternalHostName; + kvp["http_port"] = HttpPort.ToString(); + kvp["internal_ip_address"] = InternalEndPoint.Address.ToString(); + kvp["internal_port"] = InternalEndPoint.Port.ToString(); + kvp["alternate_ports"] = m_allow_alternate_ports.ToString(); + kvp["server_uri"] = ServerURI; + + return kvp; + } + + public GridRegion(Dictionary kvp) + { + if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) + { + int port = 0; + Int32.TryParse((string)kvp["external_port"], out port); + IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port); + ExternalEndPoint = ep; + } + else + ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); + + if (kvp["external_host_name"] != null) + ExternalHostName = (string)kvp["external_host_name"]; + + if (kvp["http_port"] != null) + { + UInt32 port = 0; + UInt32.TryParse((string)kvp["http_port"], out port); + HttpPort = port; + } + + if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null)) + { + int port = 0; + Int32.TryParse((string)kvp["internal_port"], out port); + IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port); + InternalEndPoint = ep; + } + else + InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); + + if (kvp["alternate_ports"] != null) + { + bool alts = false; + Boolean.TryParse((string)kvp["alternate_ports"], out alts); + m_allow_alternate_ports = alts; + } + + if (kvp["server_uri"] != null) + ServerURI = (string)kvp["server_uri"]; + } + } + } -- cgit v1.1 From fd8fb7735b0eb6150679ccad84b2a32fd5315a38 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 20:39:25 -0700 Subject: First test passes -- regions being registered and retrieved correctly in Data.Null. --- OpenSim/Services/GridService/GridService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index cd462ab..1b297dc 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -101,7 +101,8 @@ namespace OpenSim.Services.GridService region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); foreach (RegionData rdata in rdatas) - rinfos.Add(RegionData2RegionInfo(rdata)); + if (rdata.RegionID != regionID) + rinfos.Add(RegionData2RegionInfo(rdata)); } return rinfos; -- cgit v1.1 From 2824bbc47b30ab6fb9a12bce3201bb5b79b20bd5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 05:48:35 -0700 Subject: Changed name of the hyperlink XMLRPC method to linkk-region, so that it doesn't conflict with the existing one. --- OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs | 2 +- OpenSim/Services/GridService/GridService.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index 616c2c1..b5e8743 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -66,7 +66,7 @@ namespace OpenSim.Services.Connectors.Grid IList paramList = new ArrayList(); paramList.Add(hash); - XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); + XmlRpcRequest request = new XmlRpcRequest("linkk_region", paramList); string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; m_log.Debug("[HGrid]: Linking to " + uri); XmlRpcResponse response = request.Send(uri, 10000); diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 1b297dc..01ffa1d 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -71,7 +71,9 @@ namespace OpenSim.Services.GridService m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); return false; } - if (m_Database.Get((int)regionInfos.RegionLocX, (int)regionInfos.RegionLocY, scopeID) != null) + // This needs better sanity testing. What if regionInfo is registering in + // overlapping coords? + if (m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID) != null) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); -- 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 ++++++++---- OpenSim/Services/Interfaces/IGridService.cs | 9 +++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services') 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 diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index a188f7e..d12276f 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -277,6 +277,15 @@ namespace OpenSim.Services.Interfaces public GridRegion(Dictionary kvp) { + if (kvp["uuid"] != null) + RegionID = new UUID((string)kvp["uuid"]); + + if (kvp["locX"] != null) + RegionLocX = Convert.ToInt32((string)kvp["locX"]); + + if (kvp["locY"] != null) + RegionLocY = Convert.ToInt32((string)kvp["locY"]); + if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) { int port = 0; -- 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 +++++++++++++-------- OpenSim/Services/Interfaces/IGridService.cs | 4 + 2 files changed, 96 insertions(+), 59 deletions(-) (limited to 'OpenSim/Services') 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; } diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index d12276f..4bdcde2 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -263,6 +263,7 @@ namespace OpenSim.Services.Interfaces kvp["uuid"] = RegionID.ToString(); kvp["locX"] = RegionLocX.ToString(); kvp["locY"] = RegionLocY.ToString(); + kvp["name"] = RegionName; kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); kvp["external_port"] = ExternalEndPoint.Port.ToString(); kvp["external_host_name"] = ExternalHostName; @@ -286,6 +287,9 @@ namespace OpenSim.Services.Interfaces if (kvp["locY"] != null) RegionLocY = Convert.ToInt32((string)kvp["locY"]); + if (kvp["name"] != null) + RegionName = (string)kvp["name"]; + if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) { int port = 0; -- cgit v1.1 From 6a5d7650d02979c74abcbbb3595729a4a6b55411 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 18:23:55 -0700 Subject: All tests pass for MySQL/MySQLRegionData. Added OpenSim.GridServer.ini.example that I have been using for testing the ROBUST grid service with the GridClient. --- OpenSim/Services/GridService/GridService.cs | 5 ++- OpenSim/Services/Interfaces/IGridService.cs | 61 +++++++++-------------------- 2 files changed, 21 insertions(+), 45 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 01ffa1d..41344ad 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -183,9 +183,9 @@ namespace OpenSim.Services.GridService rdata.posX = (int)rinfo.RegionLocX; rdata.posY = (int)rinfo.RegionLocY; rdata.RegionID = rinfo.RegionID; - rdata.Data = rinfo.ToKeyValuePairs(); rdata.RegionName = rinfo.RegionName; - + rdata.Data = rinfo.ToKeyValuePairs(); + rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY); return rdata; } @@ -196,6 +196,7 @@ namespace OpenSim.Services.GridService rinfo.RegionLocY = rdata.posY; rinfo.RegionID = rdata.RegionID; rinfo.RegionName = rdata.RegionName; + rinfo.ScopeID = rdata.ScopeID; return rinfo; } diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 4bdcde2..513b1b0 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -263,72 +263,47 @@ namespace OpenSim.Services.Interfaces kvp["uuid"] = RegionID.ToString(); kvp["locX"] = RegionLocX.ToString(); kvp["locY"] = RegionLocY.ToString(); - kvp["name"] = RegionName; - kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); - kvp["external_port"] = ExternalEndPoint.Port.ToString(); - kvp["external_host_name"] = ExternalHostName; - kvp["http_port"] = HttpPort.ToString(); - kvp["internal_ip_address"] = InternalEndPoint.Address.ToString(); - kvp["internal_port"] = InternalEndPoint.Port.ToString(); - kvp["alternate_ports"] = m_allow_alternate_ports.ToString(); - kvp["server_uri"] = ServerURI; + kvp["regionName"] = RegionName; + kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString(); + kvp["serverHttpPort"] = HttpPort.ToString(); + kvp["serverURI"] = ServerURI; return kvp; } public GridRegion(Dictionary kvp) { - if (kvp["uuid"] != null) + if (kvp.ContainsKey("uuid")) RegionID = new UUID((string)kvp["uuid"]); - if (kvp["locX"] != null) + if (kvp.ContainsKey("locX")) RegionLocX = Convert.ToInt32((string)kvp["locX"]); - if (kvp["locY"] != null) + if (kvp.ContainsKey("locY")) RegionLocY = Convert.ToInt32((string)kvp["locY"]); - if (kvp["name"] != null) - RegionName = (string)kvp["name"]; + if (kvp.ContainsKey("regionName")) + RegionName = (string)kvp["regionName"]; - if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) + if (kvp.ContainsKey("serverIP")) { int port = 0; - Int32.TryParse((string)kvp["external_port"], out port); - IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port); - ExternalEndPoint = ep; + //Int32.TryParse((string)kvp["serverPort"], out port); + //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port); + ExternalHostName = (string)kvp["serverIP"]; } else - ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); + ExternalHostName = "127.0.0.1"; - if (kvp["external_host_name"] != null) - ExternalHostName = (string)kvp["external_host_name"]; - - if (kvp["http_port"] != null) + if (kvp.ContainsKey("serverHttpPort")) { UInt32 port = 0; - UInt32.TryParse((string)kvp["http_port"], out port); + UInt32.TryParse((string)kvp["serverHttpPort"], out port); HttpPort = port; } - if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null)) - { - int port = 0; - Int32.TryParse((string)kvp["internal_port"], out port); - IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port); - InternalEndPoint = ep; - } - else - InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); - - if (kvp["alternate_ports"] != null) - { - bool alts = false; - Boolean.TryParse((string)kvp["alternate_ports"], out alts); - m_allow_alternate_ports = alts; - } - - if (kvp["server_uri"] != null) - ServerURI = (string)kvp["server_uri"]; + if (kvp.ContainsKey("serverURI")) + ServerURI = (string)kvp["serverURI"]; } } -- cgit v1.1 From b6824c495cb04ca79c681143be2d1b8f9b5b228d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 18:28:38 -0700 Subject: Deleted the meaningless console commands on the GridService. Will need to add meaningful ones. --- OpenSim/Services/GridService/GridService.cs | 72 ----------------------------- 1 file changed, 72 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 41344ad..68b7cdf 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -50,16 +50,6 @@ namespace OpenSim.Services.GridService : base(config) { m_log.DebugFormat("[GRID SERVICE]: Starting..."); - MainConsole.Instance.Commands.AddCommand("kfs", false, - "show digest", - "show digest ", - "Show asset digest", HandleShowDigest); - - MainConsole.Instance.Commands.AddCommand("kfs", false, - "delete asset", - "delete asset ", - "Delete asset from database", HandleDeleteAsset); - } #region IGridService @@ -203,67 +193,5 @@ namespace OpenSim.Services.GridService #endregion - void HandleShowDigest(string module, string[] args) - { - //if (args.Length < 3) - //{ - // MainConsole.Instance.Output("Syntax: show digest "); - // return; - //} - - //AssetBase asset = Get(args[2]); - - //if (asset == null || asset.Data.Length == 0) - //{ - // MainConsole.Instance.Output("Asset not found"); - // return; - //} - - //int i; - - //MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name)); - //MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description)); - //MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type)); - //MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType)); - - //for (i = 0 ; i < 5 ; i++) - //{ - // int off = i * 16; - // if (asset.Data.Length <= off) - // break; - // int len = 16; - // if (asset.Data.Length < off + len) - // len = asset.Data.Length - off; - - // byte[] line = new byte[len]; - // Array.Copy(asset.Data, off, line, 0, len); - - // string text = BitConverter.ToString(line); - // MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); - //} - } - - void HandleDeleteAsset(string module, string[] args) - { - //if (args.Length < 3) - //{ - // MainConsole.Instance.Output("Syntax: delete asset "); - // return; - //} - - //AssetBase asset = Get(args[2]); - - //if (asset == null || asset.Data.Length == 0) - // MainConsole.Instance.Output("Asset not found"); - // return; - //} - - //Delete(args[2]); - - ////MainConsole.Instance.Output("Asset deleted"); - //// TODO: Implement this - - //MainConsole.Instance.Output("Asset deletion not supported by database"); - } } } -- cgit v1.1 From 52e477b41f137ff2a0775722dcbaaa64fa5f3bc3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 25 Sep 2009 06:02:41 -0700 Subject: Better guards on RegisterRegion in GridService. Added serverPort to the fields that get stored (I think this is the UDP port). --- OpenSim/Services/GridService/GridService.cs | 14 ++++++++------ OpenSim/Services/Interfaces/IGridService.cs | 10 +++++++++- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 68b7cdf..991acf2 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -56,19 +56,21 @@ namespace OpenSim.Services.GridService public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) { - if (m_Database.Get(regionInfos.RegionID, scopeID) != null) - { - m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); - return false; - } // This needs better sanity testing. What if regionInfo is registering in // overlapping coords? - if (m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID) != null) + RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); + if ((region != null) && (region.RegionID != regionInfos.RegionID)) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); return false; } + if ((region != null) && (region.RegionID == regionInfos.RegionID) && + ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) + { + // Region reregistering in other coordinates. Delete the old entry + m_Database.Delete(regionInfos.RegionID); + } // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 513b1b0..ce432ab 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -267,6 +267,7 @@ namespace OpenSim.Services.Interfaces kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString(); kvp["serverHttpPort"] = HttpPort.ToString(); kvp["serverURI"] = ServerURI; + kvp["serverPort"] = InternalEndPoint.Port.ToString(); return kvp; } @@ -287,7 +288,7 @@ namespace OpenSim.Services.Interfaces if (kvp.ContainsKey("serverIP")) { - int port = 0; + //int port = 0; //Int32.TryParse((string)kvp["serverPort"], out port); //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port); ExternalHostName = (string)kvp["serverIP"]; @@ -295,6 +296,13 @@ namespace OpenSim.Services.Interfaces else ExternalHostName = "127.0.0.1"; + if (kvp.ContainsKey("serverPort")) + { + Int32 port = 0; + Int32.TryParse((string)kvp["serverPort"], out port); + InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); + } + if (kvp.ContainsKey("serverHttpPort")) { UInt32 port = 0; -- cgit v1.1 From 730458be1f8c74da1c112df36ec54233b30caed0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Sep 2009 14:31:29 +0100 Subject: minor: remove some mono compiler warnings --- OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs | 6 +++--- .../Services/AuthenticationService/PasswordAuthenticationService.cs | 6 +++--- .../Services/AuthenticationService/WebkeyAuthenticationService.cs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs index 8904461..dcf090e 100644 --- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs +++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs @@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService // public class AuthenticationServiceBase : ServiceBase { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = +// LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); protected IAuthenticationData m_Database; diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs index 6c99b66..d65665a 100644 --- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs @@ -47,9 +47,9 @@ namespace OpenSim.Services.AuthenticationService public class PasswordAuthenticationService : AuthenticationServiceBase, IAuthenticationService { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = +// LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); public PasswordAuthenticationService(IConfigSource config) : base(config) diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs index 8831c8a..d1a5b0f 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs @@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService public class WebkeyAuthenticationService : AuthenticationServiceBase, IAuthenticationService { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = +// LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); public WebkeyAuthenticationService(IConfigSource config) : base(config) -- 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') 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