Exemplo n.º 1
0
        public List <GridRegion> GetRegionsByName(List <UUID> scopeIDs, string name, uint?start, uint?count)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["SCOPEID"] = GetScopeID(scopeIDs);
            sendData["NAME"]    = name;
            sendData["MAX"]     = count == null ? "0" : count.ToString();

            sendData["METHOD"] = "get_regions_by_name";
            List <GridRegion> rinfos     = new List <GridRegion>();
            string            reply      = string.Empty;
            List <string>     serverURIs =
                m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("GridServerURI");

            foreach (string uri in serverURIs)
            {
                try
                {
                    reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                      uri,
                                                                      WebUtils.BuildQueryString(sendData));
                }
                catch (Exception e)
                {
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
                    return(rinfos);
                }

                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply);

                    if (replyData != null)
                    {
                        Dictionary <string, object> .ValueCollection rinfosList = replyData.Values;
                        foreach (object r in rinfosList)
                        {
                            if (r is Dictionary <string, object> )
                            {
                                GridRegion rinfo = new GridRegion();
                                rinfo.FromKVP((Dictionary <string, object>)r);
                                rinfos.Add(rinfo);
                            }
                        }
                    }
                    else
                    {
                        MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0} received null response",
                                                         name);
                    }
                }
                else
                {
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply");
                }
            }

            return(FixGridRegions(rinfos));
        }
Exemplo n.º 2
0
        public GridRegion GetRegionByPosition(List <UUID> scopeIDs, int x, int y)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["SCOPEID"] = GetScopeID(scopeIDs);
            sendData["X"]       = x.ToString();
            sendData["Y"]       = y.ToString();

            sendData["METHOD"] = "get_region_by_position";
            string        reply      = string.Empty;
            List <string> serverURIs =
                m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("GridServerURI");

            foreach (string uri in serverURIs)
            {
                try
                {
                    reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                      uri,
                                                                      WebUtils.BuildQueryString(sendData));
                }
                catch (Exception e)
                {
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
                    return(null);
                }

                GridRegion rinfo = null;
                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply);

                    if ((replyData != null) && (replyData["result"] != null))
                    {
                        if (replyData["result"] is Dictionary <string, object> )
                        {
                            rinfo = new GridRegion();
                            rinfo.FromKVP((Dictionary <string, object>)replyData["result"]);
                            return(FixGridRegion(rinfo));
                        }
                        //else
                        //    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received no region",
                        //        scopeID, x, y);
                    }
                    else
                    {
                        MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}-{1} received null response",
                                                         x, y);
                    }
                }
                else
                {
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
                }
            }

            return(null);
        }
Exemplo n.º 3
0
        public List <GridRegion> GetNeighbors(List <UUID> scopeIDs, GridRegion region)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["SCOPEID"]  = region.ScopeID.ToString();
            sendData["REGIONID"] = region.RegionID.ToString();

            sendData["METHOD"] = "get_neighbours";

            List <GridRegion> rinfos = new List <GridRegion>();

            string        reqString  = WebUtils.BuildQueryString(sendData);
            string        reply      = string.Empty;
            List <string> serverURIs =
                m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("GridServerURI");

            foreach (string uri in serverURIs)
            {
                try
                {
                    reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
                }
                catch (Exception e)
                {
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
                    return(rinfos);
                }

                Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply);

                if (replyData != null)
                {
                    Dictionary <string, object> .ValueCollection rinfosList = replyData.Values;
                    //MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
                    foreach (object r in rinfosList)
                    {
                        if (r is Dictionary <string, object> )
                        {
                            GridRegion rinfo = new GridRegion();
                            rinfo.FromKVP((Dictionary <string, object>)r);
                            rinfos.Add(rinfo);
                        }
                    }
                }
                else
                {
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received null response",
                                                     region.ScopeID, region.RegionID);
                }
            }

            return(FixGridRegions(rinfos));
        }
        public List<GridRegion> GetFallbackRegions(List<UUID> scopeIDs, int x, int y)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();

            sendData["SCOPEID"] = GetScopeID(scopeIDs);
            sendData["X"] = x.ToString();
            sendData["Y"] = y.ToString();

            sendData["METHOD"] = "get_fallback_regions";

            List<GridRegion> rinfos = new List<GridRegion>();
            string reply = string.Empty;
            List<string> serverURIs =
                m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf("GridServerURI");
            foreach (string uri in serverURIs)
            {
                try
                {
                    reply = SynchronousRestFormsRequester.MakeRequest("POST",
                            uri,
                            WebUtils.BuildQueryString(sendData));

                    //MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
                }
                catch (Exception e)
                {
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
                    return rinfos;
                }

                if (reply != string.Empty)
                {
                    Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                    if (replyData != null)
                    {
                        Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
                        foreach (object r in rinfosList)
                        {
                            if (r is Dictionary<string, object>)
                            {
                                GridRegion rinfo = new GridRegion();
                                rinfo.FromKVP((Dictionary<string, object>)r);
                                rinfos.Add(rinfo);
                            }
                        }
                    }
                    else
                        MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetFallbackRegions {0}-{1} received null response",
                            x, y);
                }
                else
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetFallbackRegions received null reply");
            }

            return FixGridRegions(rinfos);
        }
        public GridRegion GetRegionByName(List<UUID> scopeIDs, string regionName)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();

            sendData["SCOPEID"] = GetScopeID(scopeIDs);
            sendData["NAME"] = regionName;

            sendData["METHOD"] = "get_region_by_name";
            string reply = string.Empty;
            List<string> serverURIs =
                m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf("GridServerURI");
            foreach (string uri in serverURIs)
            {
                try
                {
                    reply = SynchronousRestFormsRequester.MakeRequest("POST",
                            uri,
                            WebUtils.BuildQueryString(sendData));
                }
                catch (Exception e)
                {
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
                    return null;
                }

                GridRegion rinfo = null;
                if (reply != string.Empty)
                {
                    Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                    if ((replyData != null) && (replyData["result"] != null))
                    {
                        if (replyData["result"] is Dictionary<string, object>)
                        {
                            rinfo = new GridRegion();
                            rinfo.FromKVP((Dictionary<string, object>)replyData["result"]);
                            return FixGridRegion(rinfo);
                        }
                    }
                    else
                        MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0} received null response",
                            regionName);
                }
                else
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply");
            }

            return null;
        }
        public List<GridRegion> GetNeighbors(List<UUID> scopeIDs, GridRegion region)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();

            sendData["SCOPEID"] = region.ScopeID.ToString();
            sendData["REGIONID"] = region.RegionID.ToString();

            sendData["METHOD"] = "get_neighbours";

            List<GridRegion> rinfos = new List<GridRegion>();

            string reqString = WebUtils.BuildQueryString(sendData);
            string reply = string.Empty;
            List<string> serverURIs =
                m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf("GridServerURI");
            foreach (string uri in serverURIs)
            {
                try
                {
                    reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
                }
                catch (Exception e)
                {
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
                    return rinfos;
                }

                Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                if (replyData != null)
                {
                    Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
                    //MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
                    foreach (object r in rinfosList)
                    {
                        if (r is Dictionary<string, object>)
                        {
                            GridRegion rinfo = new GridRegion();
                            rinfo.FromKVP((Dictionary<string, object>)r);
                            rinfos.Add(rinfo);
                        }
                    }
                }
                else
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received null response",
                        region.ScopeID, region.RegionID);
            }

            return FixGridRegions(rinfos);
        }
        public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();

            sendData["SCOPEID"] = scopeID.ToString();
            sendData["NAME"] = name;
            sendData["MAX"] = maxNumber.ToString();

            sendData["METHOD"] = "get_regions_by_name";
            List<GridRegion> rinfos = new List<GridRegion>();
            string reply = string.Empty;
            List<string> serverURIs =
                m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf("GridServerURI");
            foreach (string uri in serverURIs)
            {
                try
                {
                    reply = SynchronousRestFormsRequester.MakeRequest("POST",
                            uri,
                            WebUtils.BuildQueryString(sendData));
                }
                catch (Exception e)
                {
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
                    return rinfos;
                }

                if (reply != string.Empty)
                {
                    Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                    if (replyData != null)
                    {
                        Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
                        foreach (object r in rinfosList)
                        {
                            if (r is Dictionary<string, object>)
                            {
                                GridRegion rinfo = new GridRegion();
                                rinfo.FromKVP((Dictionary<string, object>)r);
                                rinfos.Add(rinfo);
                            }
                        }
                    }
                    else
                        MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response",
                            scopeID, name, maxNumber);
                }
                else
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply");
            }

            return FixGridRegions(rinfos);
        }
Exemplo n.º 8
0
        public List <GridRegion> GetRegionRange(List <UUID> scopeIDs, int xmin, int xmax, int ymin, int ymax)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["SCOPEID"] = GetScopeID(scopeIDs);
            sendData["XMIN"]    = xmin.ToString();
            sendData["XMAX"]    = xmax.ToString();
            sendData["YMIN"]    = ymin.ToString();
            sendData["YMAX"]    = ymax.ToString();

            sendData["METHOD"] = "get_region_range";

            List <GridRegion> rinfos     = new List <GridRegion>();
            string            reply      = string.Empty;
            List <string>     serverURIs =
                m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("GridServerURI");

            foreach (string uri in serverURIs)
            {
                try
                {
                    reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                      uri,
                                                                      WebUtils.BuildQueryString(sendData));

                    //MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
                }
                catch (Exception e)
                {
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
                    return(rinfos);
                }

                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply);

                    if (replyData != null)
                    {
                        Dictionary <string, object> .ValueCollection rinfosList = replyData.Values;
                        foreach (object r in rinfosList)
                        {
                            if (r is Dictionary <string, object> )
                            {
                                GridRegion rinfo = new GridRegion();
                                rinfo.FromKVP((Dictionary <string, object>)r);
                                rinfos.Add(rinfo);
                            }
                        }
                    }
                    else
                    {
                        MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}-{1} {2}-{3} received null response",
                                                         xmin, xmax, ymin, ymax);
                    }
                }
                else
                {
                    MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply");
                }
            }

            return(FixGridRegions(rinfos));
        }