From b75b8877981dc1ed07f38f55e3152cf2770911df Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 3 Oct 2009 11:55:52 -0700 Subject: Fixed interface between the Messaging server and the grid server. --- .../MessagingServer.Modules/MessageRegionModule.cs | 71 +++++++++------------- 1 file changed, 29 insertions(+), 42 deletions(-) (limited to 'OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs') diff --git a/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs b/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs index 5651a17..dedf876 100644 --- a/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs +++ b/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs @@ -39,6 +39,10 @@ using OpenSim.Data; using OpenSim.Framework; using OpenSim.Grid.Framework; using Timer = System.Timers.Timer; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + namespace OpenSim.Grid.MessagingServer.Modules { @@ -52,6 +56,8 @@ namespace OpenSim.Grid.MessagingServer.Modules private IGridServiceCore m_messageCore; + private IGridService m_GridService; + // a dictionary of all current regions this server knows about private Dictionary m_regionInfoCache = new Dictionary(); @@ -59,6 +65,8 @@ namespace OpenSim.Grid.MessagingServer.Modules { m_cfg = config; m_messageCore = messageCore; + + m_GridService = new GridServicesConnector(m_cfg.GridServerURL); } public void Initialise() @@ -134,51 +142,30 @@ namespace OpenSim.Grid.MessagingServer.Modules /// public RegionProfileData RequestRegionInfo(ulong regionHandle) { - RegionProfileData regionProfile = null; - try - { - Hashtable requestData = new Hashtable(); - requestData["region_handle"] = regionHandle.ToString(); - requestData["authkey"] = m_cfg.GridSendKey; - - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion region = m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); + if (region != null) + return GridRegionToRegionProfile(region); - XmlRpcResponse GridResp = GridReq.Send(m_cfg.GridServerURL, 3000); - - Hashtable responseData = (Hashtable)GridResp.Value; - - if (responseData.ContainsKey("error")) - { - m_log.Error("[GRID]: error received from grid server" + responseData["error"]); - return null; - } - - uint regX = Convert.ToUInt32((string)responseData["region_locx"]); - uint regY = Convert.ToUInt32((string)responseData["region_locy"]); - string internalIpStr = (string)responseData["sim_ip"]; - - regionProfile = new RegionProfileData(); - regionProfile.httpPort = (uint)Convert.ToInt32((string)responseData["http_port"]); - regionProfile.httpServerURI = "http://" + internalIpStr + ":" + regionProfile.httpPort + "/"; - regionProfile.regionHandle = Utils.UIntsToLong((regX * Constants.RegionSize), (regY * Constants.RegionSize)); - regionProfile.regionLocX = regX; - regionProfile.regionLocY = regY; - - regionProfile.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); - regionProfile.UUID = new UUID((string)responseData["region_UUID"]); - regionProfile.regionName = (string)responseData["region_name"]; - } - catch (WebException) - { - m_log.Error("[GRID]: " + - "Region lookup failed for: " + regionHandle.ToString() + - " - Is the GridServer down?"); - } + else + return null; + } - return regionProfile; + private RegionProfileData GridRegionToRegionProfile(GridRegion region) + { + RegionProfileData rprofile = new RegionProfileData(); + rprofile.httpPort = region.HttpPort; + rprofile.httpServerURI = region.ServerURI; + rprofile.regionLocX = (uint)(region.RegionLocX / Constants.RegionSize); + rprofile.regionLocY = (uint)(region.RegionLocY / Constants.RegionSize); + rprofile.RegionName = region.RegionName; + rprofile.ServerHttpPort = region.HttpPort; + rprofile.ServerIP = region.ExternalHostName; + rprofile.ServerPort = (uint)region.ExternalEndPoint.Port; + rprofile.Uuid = region.RegionID; + return rprofile; } public XmlRpcResponse RegionStartup(XmlRpcRequest request, IPEndPoint remoteClient) -- cgit v1.1