From dd770c384c2e63cf8a1e2f522741afb8adfab4c2 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 22 Oct 2007 17:55:49 +0000 Subject: * Made EstateSetting static since there's only one instance, and we only need to create it once * Now cacheing RegionInfos indefinitively; we should add a tiomeout to this cache --- .../Region/Communications/OGS1/OGS1GridServices.cs | 62 +++++++++++++--------- 1 file changed, 36 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/Communications/OGS1/OGS1GridServices.cs') diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index cc56078..9e74148 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -50,6 +50,7 @@ namespace OpenSim.Region.Communications.OGS1 public class OGS1GridServices : IGridServices, IInterRegionCommunications { private LocalBackEndServices m_localBackend = new LocalBackEndServices(); + private Dictionary m_remoteRegionInfoCache = new Dictionary(); public BaseHttpServer httpListener; public NetworkServersInfo serversInfo; @@ -89,7 +90,7 @@ namespace OpenSim.Region.Communications.OGS1 GridParams["sim_name"] = regionInfo.RegionName; GridParams["http_port"] = serversInfo.HttpListenerPort.ToString(); GridParams["remoting_port"] = serversInfo.RemotingListenerPort.ToString(); - GridParams["map-image-id"] = regionInfo.estateSettings.terrainImageID.ToStringHyphenated(); + GridParams["map-image-id"] = regionInfo.EstateSettings.terrainImageID.ToStringHyphenated(); // Package into an XMLRPC Request ArrayList SendParams = new ArrayList(); @@ -152,6 +153,7 @@ namespace OpenSim.Region.Communications.OGS1 return neighbours; } + /// /// /// @@ -166,37 +168,45 @@ namespace OpenSim.Region.Communications.OGS1 return regionInfo; } - Hashtable requestData = new Hashtable(); - requestData["region_handle"] = regionHandle.ToString(); - requestData["authkey"] = this.serversInfo.GridSendKey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse GridResp = GridReq.Send(this.serversInfo.GridURL, 3000); - - Hashtable responseData = (Hashtable)GridResp.Value; - - if (responseData.ContainsKey("error")) + if (m_remoteRegionInfoCache.TryGetValue(regionHandle, out regionInfo)) { - Console.WriteLine("error received from grid server" + responseData["error"]); - return null; } + else + { + Hashtable requestData = new Hashtable(); + requestData["region_handle"] = regionHandle.ToString(); + requestData["authkey"] = this.serversInfo.GridSendKey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); + XmlRpcResponse GridResp = GridReq.Send(this.serversInfo.GridURL, 3000); - uint regX = Convert.ToUInt32((string)responseData["region_locx"]); - uint regY = Convert.ToUInt32((string)responseData["region_locy"]); - string internalIpStr = (string)responseData["sim_ip"]; - uint port = Convert.ToUInt32(responseData["sim_port"]); - string externalUri = (string)responseData["sim_uri"]; + Hashtable responseData = (Hashtable) GridResp.Value; - IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); - string neighbourExternalUri = externalUri; - regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); + if (responseData.ContainsKey("error")) + { + Console.WriteLine("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"]; + uint port = Convert.ToUInt32(responseData["sim_port"]); + string externalUri = (string) responseData["sim_uri"]; - regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); - regionInfo.RemotingAddress = internalIpStr; + IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); + string neighbourExternalUri = externalUri; + regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); - regionInfo.RegionID = new LLUUID((string)responseData["region_UUID"]); - regionInfo.RegionName = (string)responseData["region_name"]; + regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); + regionInfo.RemotingAddress = internalIpStr; + + regionInfo.RegionID = new LLUUID((string) responseData["region_UUID"]); + regionInfo.RegionName = (string) responseData["region_name"]; + + m_remoteRegionInfoCache.Add( regionHandle, regionInfo ); + } return regionInfo; } -- cgit v1.1