Fixed interface between the Messaging server and the grid server.

prioritization
Diva Canto 2009-10-03 11:55:52 -07:00
parent df7049008a
commit b75b887798
2 changed files with 32 additions and 42 deletions

View File

@ -39,6 +39,10 @@ using OpenSim.Data;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Grid.Framework; using OpenSim.Grid.Framework;
using Timer = System.Timers.Timer; using Timer = System.Timers.Timer;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Connectors;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Grid.MessagingServer.Modules namespace OpenSim.Grid.MessagingServer.Modules
{ {
@ -52,6 +56,8 @@ namespace OpenSim.Grid.MessagingServer.Modules
private IGridServiceCore m_messageCore; private IGridServiceCore m_messageCore;
private IGridService m_GridService;
// a dictionary of all current regions this server knows about // a dictionary of all current regions this server knows about
private Dictionary<ulong, RegionProfileData> m_regionInfoCache = new Dictionary<ulong, RegionProfileData>(); private Dictionary<ulong, RegionProfileData> m_regionInfoCache = new Dictionary<ulong, RegionProfileData>();
@ -59,6 +65,8 @@ namespace OpenSim.Grid.MessagingServer.Modules
{ {
m_cfg = config; m_cfg = config;
m_messageCore = messageCore; m_messageCore = messageCore;
m_GridService = new GridServicesConnector(m_cfg.GridServerURL);
} }
public void Initialise() public void Initialise()
@ -134,51 +142,30 @@ namespace OpenSim.Grid.MessagingServer.Modules
/// <returns></returns> /// <returns></returns>
public RegionProfileData RequestRegionInfo(ulong regionHandle) public RegionProfileData RequestRegionInfo(ulong regionHandle)
{ {
RegionProfileData regionProfile = null; uint x = 0, y = 0;
try Utils.LongToUInts(regionHandle, out x, out y);
{ GridRegion region = m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
Hashtable requestData = new Hashtable();
requestData["region_handle"] = regionHandle.ToString();
requestData["authkey"] = m_cfg.GridSendKey;
ArrayList SendParams = new ArrayList(); if (region != null)
SendParams.Add(requestData); return GridRegionToRegionProfile(region);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); else
return null;
}
XmlRpcResponse GridResp = GridReq.Send(m_cfg.GridServerURL, 3000); private RegionProfileData GridRegionToRegionProfile(GridRegion region)
{
Hashtable responseData = (Hashtable)GridResp.Value; RegionProfileData rprofile = new RegionProfileData();
rprofile.httpPort = region.HttpPort;
if (responseData.ContainsKey("error")) rprofile.httpServerURI = region.ServerURI;
{ rprofile.regionLocX = (uint)(region.RegionLocX / Constants.RegionSize);
m_log.Error("[GRID]: error received from grid server" + responseData["error"]); rprofile.regionLocY = (uint)(region.RegionLocY / Constants.RegionSize);
return null; rprofile.RegionName = region.RegionName;
} rprofile.ServerHttpPort = region.HttpPort;
rprofile.ServerIP = region.ExternalHostName;
uint regX = Convert.ToUInt32((string)responseData["region_locx"]); rprofile.ServerPort = (uint)region.ExternalEndPoint.Port;
uint regY = Convert.ToUInt32((string)responseData["region_locy"]); rprofile.Uuid = region.RegionID;
string internalIpStr = (string)responseData["sim_ip"]; return rprofile;
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?");
}
return regionProfile;
} }
public XmlRpcResponse RegionStartup(XmlRpcRequest request, IPEndPoint remoteClient) public XmlRpcResponse RegionStartup(XmlRpcRequest request, IPEndPoint remoteClient)

View File

@ -980,10 +980,13 @@
<Reference name="OpenSim.Framework.Servers"/> <Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/> <Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Grid.Framework"/> <Reference name="OpenSim.Grid.Framework"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Services.Connectors"/>
<Reference name="OpenMetaverseTypes.dll"/> <Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.dll"/> <Reference name="OpenMetaverse.dll"/>
<Reference name="XMLRPC.dll"/> <Reference name="XMLRPC.dll"/>
<Reference name="log4net.dll"/> <Reference name="log4net.dll"/>
<Reference name="Nini.dll"/>
<Files> <Files>
<Match pattern="*.cs" recurse="true"/> <Match pattern="*.cs" recurse="true"/>