Пример #1
0
        public override RegionInfo RequestNeighbourInfo(UUID Region_UUID)
        {
            RegionInfo info = m_localBackend.RequestNeighbourInfo(Region_UUID);

            if (info == null)
            {
                info = base.RequestNeighbourInfo(Region_UUID);
            }
            return(info);
        }
Пример #2
0
        /// <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) || (!m_remoteRegionInfoCache.TryGetValue(regionHandle, out regionInfo)))
            {
                try
                {
                    Hashtable requestData = new Hashtable();
                    requestData["region_handle"] = regionHandle.ToString();
                    requestData["authkey"]       = serversInfo.GridSendKey;
                    ArrayList SendParams = new ArrayList();
                    SendParams.Add(requestData);
                    XmlRpcRequest  GridReq  = new XmlRpcRequest("simulator_data_request", SendParams);
                    XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000);

                    Hashtable responseData = (Hashtable)GridResp.Value;

                    if (responseData.ContainsKey("error"))
                    {
                        m_log.Error("[OGS1 GRID SERVICES]: 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 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"]);
                    }

                    // Ok, so this is definitively the wrong place to do this, way too hard coded, but it doesn't seem we GET this info?

                    string simURI = "http://" + externalHostName + ":" + simPort;

                    // string externalUri = (string) responseData["sim_uri"];

                    //IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port);
                    regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI);

                    if (m_useRemoteRegionCache)
                    {
                        lock (m_remoteRegionInfoCache)
                        {
                            if (!m_remoteRegionInfoCache.ContainsKey(regionHandle))
                            {
                                m_remoteRegionInfoCache.Add(regionHandle, regionInfo);
                            }
                        }
                    }
                }
                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);
        }
Пример #3
0
        /// <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);
        }