/// <summary> /// Request information about a region. /// </summary> /// <param name="regionHandle"></param> /// <returns></returns> public RegionInfo RequestNeighbourInfo(ulong regionHandle) { RegionInfo regionInfo = m_localBackend.RequestNeighbourInfo(regionHandle); if (regionInfo != null) { return regionInfo; } if (m_useRemoteRegionCache) { lock (m_remoteRegionInfoCache) { RegionInfoCacheEntry entry; if (m_remoteRegionInfoCache.TryGetValue(regionHandle, out entry)) { if (DateTime.Now - entry.CachedTime < TimeSpan.FromMinutes(15.0)) { if (entry.Exists) { return entry.Info; } else { return null; } } else { m_remoteRegionInfoCache.Remove(regionHandle); } } } } try { Hashtable requestData = new Hashtable(); requestData["region_handle"] = regionHandle.ToString(); requestData["authkey"] = serversInfo.GridSendKey; ArrayList SendParams = new ArrayList(); SendParams.Add(requestData); string methodName = "simulator_data_request"; XmlRpcRequest GridReq = new XmlRpcRequest(methodName, SendParams); XmlRpcResponse GridResp = GridReq.Send(Util.XmlRpcRequestURI(serversInfo.GridURL, methodName), 3000); Hashtable responseData = (Hashtable) GridResp.Value; if (responseData.ContainsKey("error")) { m_log.Error("[OGS1 GRID SERVICES]: Error received from grid server: " + responseData["error"]); if (m_useRemoteRegionCache) { lock (m_remoteRegionInfoCache) { if (!m_remoteRegionInfoCache.ContainsKey(regionHandle)) { RegionInfoCacheEntry entry = new RegionInfoCacheEntry { CachedTime = DateTime.Now, Info = null, Exists = false }; m_remoteRegionInfoCache[regionHandle] = entry; } } } return null; } uint regX = Convert.ToUInt32((string) responseData["region_locx"]); uint regY = Convert.ToUInt32((string) responseData["region_locy"]); string externalHostName = (string) responseData["sim_ip"]; uint simPort = Convert.ToUInt32(responseData["sim_port"]); string regionName = (string)responseData["region_name"]; UUID regionID = new UUID((string)responseData["region_UUID"]); uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); uint httpPort = 9000; if (responseData.ContainsKey("http_port")) { httpPort = Convert.ToUInt32((string)responseData["http_port"]); } string outsideIp = null; if (responseData.ContainsKey("outside_ip")) outsideIp = (string)responseData["outside_ip"]; //IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, outsideIp); if (requestData.ContainsKey("product")) regionInfo.Product = (ProductRulesUse)Convert.ToInt32(requestData["product"]); if (m_useRemoteRegionCache) { lock (m_remoteRegionInfoCache) { if (!m_remoteRegionInfoCache.ContainsKey(regionHandle)) { RegionInfoCacheEntry entry = new RegionInfoCacheEntry { CachedTime = DateTime.Now, Info = regionInfo, Exists = true }; m_remoteRegionInfoCache[regionHandle] = entry; } } } } catch (Exception e) { m_log.Error("[OGS1 GRID SERVICES]: " + "Region lookup failed for: " + regionHandle.ToString() + " - Is the GridServer down?" + e.ToString()); return null; } return regionInfo; }
/// <summary> /// Request information about a region. /// </summary> /// <param name="regionHandle"></param> /// <returns></returns> public RegionInfo RequestNeighbourInfo(ulong regionHandle) { RegionInfo regionInfo = m_localBackend.RequestNeighbourInfo(regionHandle); if (regionInfo != null) { return(regionInfo); } if (m_useRemoteRegionCache) { lock (m_remoteRegionInfoCache) { RegionInfoCacheEntry entry; if (m_remoteRegionInfoCache.TryGetValue(regionHandle, out entry)) { if (DateTime.Now - entry.CachedTime < TimeSpan.FromMinutes(15.0)) { if (entry.Exists) { return(entry.Info); } else { return(null); } } else { m_remoteRegionInfoCache.Remove(regionHandle); } } } } try { Hashtable requestData = new Hashtable(); requestData["region_handle"] = regionHandle.ToString(); requestData["authkey"] = serversInfo.GridSendKey; ArrayList SendParams = new ArrayList(); SendParams.Add(requestData); string methodName = "simulator_data_request"; XmlRpcRequest GridReq = new XmlRpcRequest(methodName, SendParams); XmlRpcResponse GridResp = GridReq.Send(Util.XmlRpcRequestURI(serversInfo.GridURL, methodName), 3000); Hashtable responseData = (Hashtable)GridResp.Value; if (responseData.ContainsKey("error")) { m_log.Error("[OGS1 GRID SERVICES]: Error received from grid server: " + responseData["error"]); if (m_useRemoteRegionCache) { lock (m_remoteRegionInfoCache) { if (!m_remoteRegionInfoCache.ContainsKey(regionHandle)) { RegionInfoCacheEntry entry = new RegionInfoCacheEntry { CachedTime = DateTime.Now, Info = null, Exists = false }; m_remoteRegionInfoCache[regionHandle] = entry; } } } return(null); } uint regX = Convert.ToUInt32((string)responseData["region_locx"]); uint regY = Convert.ToUInt32((string)responseData["region_locy"]); string externalHostName = (string)responseData["sim_ip"]; uint simPort = Convert.ToUInt32(responseData["sim_port"]); string regionName = (string)responseData["region_name"]; UUID regionID = new UUID((string)responseData["region_UUID"]); uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); uint httpPort = 9000; if (responseData.ContainsKey("http_port")) { httpPort = Convert.ToUInt32((string)responseData["http_port"]); } string outsideIp = null; if (responseData.ContainsKey("outside_ip")) { outsideIp = (string)responseData["outside_ip"]; } //IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, outsideIp); if (requestData.ContainsKey("product")) { regionInfo.Product = (ProductRulesUse)Convert.ToInt32(requestData["product"]); } if (m_useRemoteRegionCache) { lock (m_remoteRegionInfoCache) { if (!m_remoteRegionInfoCache.ContainsKey(regionHandle)) { RegionInfoCacheEntry entry = new RegionInfoCacheEntry { CachedTime = DateTime.Now, Info = regionInfo, Exists = true }; m_remoteRegionInfoCache[regionHandle] = entry; } } } } catch (Exception e) { m_log.Error("[OGS1 GRID SERVICES]: " + "Region lookup failed for: " + regionHandle.ToString() + " - Is the GridServer down?" + e.ToString()); return(null); } return(regionInfo); }
/// <summary> /// Request information about a region. /// </summary> /// <param name="regionHandle"></param> /// <returns> /// null on a failure to contact or get a response from the grid server /// FIXME: Might be nicer to return a proper exception here since we could inform the client more about the /// nature of the faiulre. /// </returns> public RegionInfo RequestNeighbourInfo(UUID Region_UUID) { // don't ask the gridserver about regions on this instance... foreach (RegionInfo info in m_regionsOnInstance) { if (info.RegionID == Region_UUID) return info; } // didn't find it so far, we have to go the long way RegionInfo regionInfo; Hashtable requestData = new Hashtable(); requestData["region_UUID"] = Region_UUID.ToString(); requestData["authkey"] = serversInfo.GridSendKey; ArrayList SendParams = new ArrayList(); SendParams.Add(requestData); string methodName = "simulator_data_request"; XmlRpcRequest gridReq = new XmlRpcRequest(methodName, SendParams); XmlRpcResponse gridResp = null; try { gridResp = gridReq.Send(Util.XmlRpcRequestURI(serversInfo.GridURL, methodName), 3000); } catch (Exception e) { m_log.ErrorFormat( "[OGS1 GRID SERVICES]: Communication with the grid server at {0} failed, {1}", serversInfo.GridURL, e); return null; } Hashtable responseData = (Hashtable)gridResp.Value; if (responseData.ContainsKey("error")) { // this happens all the time normally and pollutes the log // m_log.WarnFormat("[OGS1 GRID SERVICES]: Error received from grid server: {0}", responseData["error"]); if (m_useRemoteRegionCache) { RegionInfoCacheEntry cacheEntry = new RegionInfoCacheEntry { CachedTime = DateTime.Now, Info = null, Exists = false }; lock (m_remoteRegionInfoCache) { m_remoteRegionInfoCache[Convert.ToUInt64((string)requestData["regionHandle"])] = cacheEntry; } } return null; } regionInfo = buildRegionInfo(responseData, String.Empty); if ((m_useRemoteRegionCache) && (requestData.ContainsKey("regionHandle"))) { RegionInfoCacheEntry cacheEntry = new RegionInfoCacheEntry { CachedTime = DateTime.Now, Info = regionInfo, Exists = true }; lock (m_remoteRegionInfoCache) { m_remoteRegionInfoCache[Convert.ToUInt64((string)requestData["regionHandle"])] = cacheEntry; } } return regionInfo; }
/// <summary> /// Request information about a region. /// </summary> /// <param name="regionHandle"></param> /// <returns> /// null on a failure to contact or get a response from the grid server /// FIXME: Might be nicer to return a proper exception here since we could inform the client more about the /// nature of the faiulre. /// </returns> public RegionInfo RequestNeighbourInfo(UUID Region_UUID) { // don't ask the gridserver about regions on this instance... foreach (RegionInfo info in m_regionsOnInstance) { if (info.RegionID == Region_UUID) { return(info); } } // didn't find it so far, we have to go the long way RegionInfo regionInfo; Hashtable requestData = new Hashtable(); requestData["region_UUID"] = Region_UUID.ToString(); requestData["authkey"] = serversInfo.GridSendKey; ArrayList SendParams = new ArrayList(); SendParams.Add(requestData); string methodName = "simulator_data_request"; XmlRpcRequest gridReq = new XmlRpcRequest(methodName, SendParams); XmlRpcResponse gridResp = null; try { gridResp = gridReq.Send(Util.XmlRpcRequestURI(serversInfo.GridURL, methodName), 3000); } catch (Exception e) { m_log.ErrorFormat( "[OGS1 GRID SERVICES]: Communication with the grid server at {0} failed, {1}", serversInfo.GridURL, e); return(null); } Hashtable responseData = (Hashtable)gridResp.Value; if (responseData.ContainsKey("error")) { // this happens all the time normally and pollutes the log // m_log.WarnFormat("[OGS1 GRID SERVICES]: Error received from grid server: {0}", responseData["error"]); if (m_useRemoteRegionCache) { RegionInfoCacheEntry cacheEntry = new RegionInfoCacheEntry { CachedTime = DateTime.Now, Info = null, Exists = false }; lock (m_remoteRegionInfoCache) { m_remoteRegionInfoCache[Convert.ToUInt64((string)requestData["regionHandle"])] = cacheEntry; } } return(null); } regionInfo = buildRegionInfo(responseData, String.Empty); if ((m_useRemoteRegionCache) && (requestData.ContainsKey("regionHandle"))) { RegionInfoCacheEntry cacheEntry = new RegionInfoCacheEntry { CachedTime = DateTime.Now, Info = regionInfo, Exists = true }; lock (m_remoteRegionInfoCache) { m_remoteRegionInfoCache[Convert.ToUInt64((string)requestData["regionHandle"])] = cacheEntry; } } return(regionInfo); }