From dd3d52ae1faefbca85e2fe8d8cea67f7db4005ac Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 13:33:58 -0700 Subject: Added test GridClient, which allowed me to remove a few bugs out of the new code. --- OpenSim/Server/Base/ServerUtils.cs | 4 +++- OpenSim/Server/Handlers/Grid/GridServerConnector.cs | 2 +- OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | 11 +++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 6c2b3ed..656fcf5 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -258,6 +258,8 @@ namespace OpenSim.Server.Base public static Dictionary ParseXmlResponse(string data) { + //m_log.DebugFormat("[XXX]: received xml string: {0}", data); + Dictionary ret = new Dictionary(); XmlDocument doc = new XmlDocument(); @@ -284,7 +286,7 @@ namespace OpenSim.Server.Base foreach (XmlNode part in partL) { - XmlNode type = part.Attributes.GetNamedItem("Type"); + XmlNode type = part.Attributes.GetNamedItem("type"); if (type == null || type.Value != "List") { ret[part.Name] = part.InnerText; diff --git a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs index 7bf2e66..ebdf489 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs @@ -45,7 +45,7 @@ namespace OpenSim.Server.Handlers.Grid if (serverConfig == null) throw new Exception("No section 'Server' in config file"); - string gridService = serverConfig.GetString("GridServiceModule", + string gridService = serverConfig.GetString("LocalServiceModule", String.Empty); if (gridService == String.Empty) diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index e72c2eb..eaeed6f 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -63,6 +63,7 @@ namespace OpenSim.Server.Handlers.Grid StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); + body = body.Trim(); Dictionary request = ServerUtils.ParseQueryString(body); @@ -98,11 +99,11 @@ namespace OpenSim.Server.Handlers.Grid case "get_region_range": return GetRegionRange(request); - default: - m_log.DebugFormat("[GRID HANDLER]: unknown method request {0}", method); - return FailureResult(); } + m_log.DebugFormat("[GRID HANDLER XXX]: unknown method {0} request {1}", method.Length, method); + return FailureResult(); + } #region Method-specific handlers @@ -155,11 +156,12 @@ namespace OpenSim.Server.Handlers.Grid UUID regionID = UUID.Zero; if (request["REGIONID"] != null) - UUID.TryParse(request["REGIONID"], out scopeID); + UUID.TryParse(request["REGIONID"], out regionID); else m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); List rinfos = m_GridService.GetNeighbours(scopeID, regionID); + //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); Dictionary result = new Dictionary(); int i = 0; @@ -171,6 +173,7 @@ namespace OpenSim.Server.Handlers.Grid } string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); return encoding.GetBytes(xmlString); -- cgit v1.1 From 1faaa0a43a851c44af40336336ddbe3a7dbe83af Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 15:30:00 -0700 Subject: GridServerPostHandler finished. GridClient tests all work. More guards on getting parameters and replies over the wire. --- .../Server/Handlers/Grid/GridServerPostHandler.cs | 187 +++++++++++++++++++-- 1 file changed, 172 insertions(+), 15 deletions(-) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index eaeed6f..f50e6a2 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -164,12 +164,17 @@ namespace OpenSim.Server.Handlers.Grid //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); Dictionary result = new Dictionary(); - int i = 0; - foreach (GridRegion rinfo in rinfos) + if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) + result["result"] = "null"; + else { - Dictionary rinfoDict = rinfo.ToKeyValuePairs(); - result["region" + i] = rinfoDict; - i++; + int i = 0; + foreach (GridRegion rinfo in rinfos) + { + Dictionary rinfoDict = rinfo.ToKeyValuePairs(); + result["region" + i] = rinfoDict; + i++; + } } string xmlString = ServerUtils.BuildXmlResponse(result); @@ -181,32 +186,184 @@ namespace OpenSim.Server.Handlers.Grid byte[] GetRegionByUUID(Dictionary request) { - // TODO - return new byte[0]; + UUID scopeID = UUID.Zero; + if (request["SCOPEID"] != null) + UUID.TryParse(request["SCOPEID"], out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); + + UUID regionID = UUID.Zero; + if (request["REGIONID"] != null) + UUID.TryParse(request["REGIONID"], out regionID); + else + m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); + + GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID); + //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); + + Dictionary result = new Dictionary(); + if (rinfo == null) + result["result"] = "null"; + else + result["result"] = rinfo.ToKeyValuePairs(); + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); } byte[] GetRegionByPosition(Dictionary request) { - // TODO - return new byte[0]; + UUID scopeID = UUID.Zero; + if (request["SCOPEID"] != null) + UUID.TryParse(request["SCOPEID"], out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position"); + + int x = 0, y = 0; + if (request["X"] != null) + Int32.TryParse(request["X"], out x); + else + m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position"); + if (request["Y"] != null) + Int32.TryParse(request["Y"], out y); + else + m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); + + GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y); + //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); + + Dictionary result = new Dictionary(); + if (rinfo == null) + result["result"] = "null"; + else + result["result"] = rinfo.ToKeyValuePairs(); + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); } byte[] GetRegionByName(Dictionary request) { - // TODO - return new byte[0]; + UUID scopeID = UUID.Zero; + if (request["SCOPEID"] != null) + UUID.TryParse(request["SCOPEID"], out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name"); + + string regionName = string.Empty; + if (request["NAME"] != null) + regionName = request["NAME"]; + else + m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name"); + + GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName); + //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); + + Dictionary result = new Dictionary(); + if (rinfo == null) + result["result"] = "null"; + else + result["result"] = rinfo.ToKeyValuePairs(); + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); } byte[] GetRegionsByName(Dictionary request) { - // TODO - return new byte[0]; + UUID scopeID = UUID.Zero; + if (request["SCOPEID"] != null) + UUID.TryParse(request["SCOPEID"], out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name"); + + string regionName = string.Empty; + if (request["NAME"] != null) + regionName = request["NAME"]; + else + m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name"); + + int max = 0; + if (request["MAX"] != null) + Int32.TryParse(request["MAX"], out max); + else + m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name"); + + List rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max); + //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); + + Dictionary result = new Dictionary(); + if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) + result["result"] = "null"; + else + { + int i = 0; + foreach (GridRegion rinfo in rinfos) + { + Dictionary rinfoDict = rinfo.ToKeyValuePairs(); + result["region" + i] = rinfoDict; + i++; + } + } + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); } byte[] GetRegionRange(Dictionary request) { - // TODO - return new byte[0]; + UUID scopeID = UUID.Zero; + if (request["SCOPEID"] != null) + UUID.TryParse(request["SCOPEID"], out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); + + int xmin = 0, xmax = 0, ymin = 0, ymax = 0; + if (request["XMIN"] != null) + Int32.TryParse(request["XMIN"], out xmin); + else + m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range"); + if (request["XMAX"] != null) + Int32.TryParse(request["XMAX"], out xmax); + else + m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range"); + if (request["YMIN"] != null) + Int32.TryParse(request["YMIN"], out ymin); + else + m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range"); + if (request["YMAX"] != null) + Int32.TryParse(request["YMAX"], out ymax); + else + m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range"); + + + List rinfos = m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); + + Dictionary result = new Dictionary(); + if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) + result["result"] = "null"; + else + { + int i = 0; + foreach (GridRegion rinfo in rinfos) + { + Dictionary rinfoDict = rinfo.ToKeyValuePairs(); + result["region" + i] = rinfoDict; + i++; + } + } + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); } #endregion -- cgit v1.1 From b2772b3a2ded5149db6cd31dab745c2369d74075 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 25 Sep 2009 07:38:05 -0700 Subject: Added GridForm.html in Tests/Clients/Grid that shows how to interact with a grid server via regular Web forms. May be good for developing administrative tools. --- OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index f50e6a2..711639f 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -64,7 +64,9 @@ namespace OpenSim.Server.Handlers.Grid string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); - + + //m_log.DebugFormat("[XXX]: query String: {0}", body); + Dictionary request = ServerUtils.ParseQueryString(body); @@ -101,7 +103,7 @@ namespace OpenSim.Server.Handlers.Grid } - m_log.DebugFormat("[GRID HANDLER XXX]: unknown method {0} request {1}", method.Length, method); + m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); return FailureResult(); } @@ -320,26 +322,27 @@ namespace OpenSim.Server.Handlers.Grid byte[] GetRegionRange(Dictionary request) { + //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange"); UUID scopeID = UUID.Zero; - if (request["SCOPEID"] != null) + if (request.ContainsKey("SCOPEID")) UUID.TryParse(request["SCOPEID"], out scopeID); else m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); int xmin = 0, xmax = 0, ymin = 0, ymax = 0; - if (request["XMIN"] != null) + if (request.ContainsKey("XMIN")) Int32.TryParse(request["XMIN"], out xmin); else m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range"); - if (request["XMAX"] != null) + if (request.ContainsKey("XMAX")) Int32.TryParse(request["XMAX"], out xmax); else m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range"); - if (request["YMIN"] != null) + if (request.ContainsKey("YMIN")) Int32.TryParse(request["YMIN"], out ymin); else m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range"); - if (request["YMAX"] != null) + if (request.ContainsKey("YMAX")) Int32.TryParse(request["YMAX"], out ymax); else m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range"); -- cgit v1.1