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 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