diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index f9cd90fc8c..131febd154 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -200,7 +200,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #region IGridService - public bool RegisterRegion(UUID scopeID, GridRegion regionInfo) + public string RegisterRegion(UUID scopeID, GridRegion regionInfo) { // Region doesn't exist here. Trying to link remote region if (regionInfo.RegionID.Equals(UUID.Zero)) @@ -215,12 +215,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // Try get the map image m_HypergridServiceConnector.GetMapImage(regionInfo); - return true; + return String.Empty; } else { m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")"); - return false; + return "No such region"; } // Note that these remote regions aren't registered in localBackend, so return null, no local listeners } @@ -469,7 +469,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } // Finally, link it - if (!RegisterRegion(UUID.Zero, regInfo)) + if (RegisterRegion(UUID.Zero, regInfo) != String.Empty) { m_log.Warn("[HGrid]: Unable to link region"); return false; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 1c72488bbc..144b5a4b46 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -169,7 +169,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #region IGridService - public bool RegisterRegion(UUID scopeID, GridRegion regionInfo) + public string RegisterRegion(UUID scopeID, GridRegion regionInfo) { return m_GridService.RegisterRegion(scopeID, regionInfo); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 72c00fc02d..391e7c84f5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -135,12 +135,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #region IGridService - public override bool RegisterRegion(UUID scopeID, GridRegion regionInfo) + public override string RegisterRegion(UUID scopeID, GridRegion regionInfo) { - if (m_LocalGridService.RegisterRegion(scopeID, regionInfo)) + string msg = m_LocalGridService.RegisterRegion(scopeID, regionInfo); + + if (msg == String.Empty) return base.RegisterRegion(scopeID, regionInfo); - return false; + return msg; } public override bool DeregisterRegion(UUID regionID) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index bc9301b8b9..234554ee4d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1562,9 +1562,9 @@ namespace OpenSim.Region.Framework.Scenes //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo); GridRegion region = new GridRegion(RegionInfo); - bool success = GridService.RegisterRegion(RegionInfo.ScopeID, region); - if (!success) - throw new Exception("Can't register with grid"); + string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); + if (error != String.Empty) + throw new Exception(error); m_sceneGridService.SetScene(this); m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface(), RegionInfo); diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index d99b791a1b..85a8738c4e 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -156,14 +156,14 @@ namespace OpenSim.Server.Handlers.Grid m_log.DebugFormat("[GRID HANDLER]: exception unpacking region data: {0}", e); } - bool result = false; + string result = "Error communicating with grid service"; if (rinfo != null) result = m_GridService.RegisterRegion(scopeID, rinfo); - if (result) + if (result == String.Empty) return SuccessResult(); else - return FailureResult(); + return FailureResult(result); } byte[] Deregister(Dictionary request) @@ -431,6 +431,11 @@ namespace OpenSim.Server.Handlers.Grid } private byte[] FailureResult() + { + return FailureResult(String.Empty); + } + + private byte[] FailureResult(string msg) { XmlDocument doc = new XmlDocument(); @@ -449,6 +454,11 @@ namespace OpenSim.Server.Handlers.Grid rootElement.AppendChild(result); + XmlElement message = doc.CreateElement("", "Message", ""); + message.AppendChild(doc.CreateTextNode(msg)); + + rootElement.AppendChild(message); + return DocToBytes(doc); } diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 99aa3fb15c..1ba734488d 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -86,7 +86,7 @@ namespace OpenSim.Services.Connectors #region IGridService - public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo) + public virtual string RegisterRegion(UUID scopeID, GridRegion regionInfo) { Dictionary rinfo = regionInfo.ToKeyValuePairs(); Dictionary sendData = new Dictionary(); @@ -110,11 +110,23 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success")) - return true; - else if (!replyData.ContainsKey("Result")) - m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field"); - else + { + return String.Empty; + } + else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure")) + { m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString()); + return replyData["Message"].ToString(); + } + else if (!replyData.ContainsKey("Result")) + { + m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field"); + } + else + { + m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString()); + return "Unexpected result "+replyData["Result"].ToString(); + } } else @@ -125,7 +137,7 @@ namespace OpenSim.Services.Connectors m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); } - return false; + return "Error communicating with grid service"; } public virtual bool DeregisterRegion(UUID regionID) diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index a500593855..7749c37384 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -62,7 +62,7 @@ namespace OpenSim.Services.GridService #region IGridService - public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) + public string RegisterRegion(UUID scopeID, GridRegion regionInfos) { // This needs better sanity testing. What if regionInfo is registering in // overlapping coords? @@ -71,7 +71,7 @@ namespace OpenSim.Services.GridService { 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; + return "Region overlaps another region"; } if ((region != null) && (region.RegionID == regionInfos.RegionID) && ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) @@ -101,7 +101,7 @@ namespace OpenSim.Services.GridService { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.", regionInfos.RegionName, regionInfos.RegionID); - return false; + return "Duplicate region name"; } } } @@ -122,7 +122,7 @@ namespace OpenSim.Services.GridService m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}", regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); - return true; + return String.Empty; } public bool DeregisterRegion(UUID regionID) diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index e69e4cd1dd..5135f6dad8 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -42,7 +42,7 @@ namespace OpenSim.Services.Interfaces /// /// /// Thrown if region registration failed - bool RegisterRegion(UUID scopeID, GridRegion regionInfos); + string RegisterRegion(UUID scopeID, GridRegion regionInfos); /// /// Deregister a region with the grid service. diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs index 972c0aa3bf..8e3337319b 100644 --- a/OpenSim/Tests/Clients/Grid/GridClient.cs +++ b/OpenSim/Tests/Clients/Grid/GridClient.cs @@ -63,27 +63,28 @@ namespace OpenSim.Tests.Clients.GridClient GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000); Console.WriteLine("[GRID CLIENT]: *** Registering region 1"); - bool success = m_Connector.RegisterRegion(UUID.Zero, r1); - if (success) + string msg = m_Connector.RegisterRegion(UUID.Zero, r1); + if (msg == String.Empty) Console.WriteLine("[GRID CLIENT]: Successfully registered region 1"); else Console.WriteLine("[GRID CLIENT]: region 1 failed to register"); Console.WriteLine("[GRID CLIENT]: *** Registering region 2"); - success = m_Connector.RegisterRegion(UUID.Zero, r2); - if (success) + msg = m_Connector.RegisterRegion(UUID.Zero, r2); + if (msg == String.Empty) Console.WriteLine("[GRID CLIENT]: Successfully registered region 2"); else Console.WriteLine("[GRID CLIENT]: region 2 failed to register"); Console.WriteLine("[GRID CLIENT]: *** Registering region 3"); - success = m_Connector.RegisterRegion(UUID.Zero, r3); - if (success) + msg = m_Connector.RegisterRegion(UUID.Zero, r3); + if (msg == String.Empty) Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); else Console.WriteLine("[GRID CLIENT]: region 3 failed to register"); + bool success; Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3"); success = m_Connector.DeregisterRegion(r3.RegionID); if (success) @@ -91,8 +92,8 @@ namespace OpenSim.Tests.Clients.GridClient else Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister"); Console.WriteLine("[GRID CLIENT]: *** Registering region 3 again"); - success = m_Connector.RegisterRegion(UUID.Zero, r3); - if (success) + msg = m_Connector.RegisterRegion(UUID.Zero, r3); + if (msg == String.Empty) Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); else Console.WriteLine("[GRID CLIENT]: region 3 failed to register");