aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs4
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs4
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs11
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServiceConnector.cs12
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs9
-rw-r--r--OpenSim/Tests/Clients/Grid/GridClient.cs102
7 files changed, 132 insertions, 12 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
index 0f0c790..ebb2691 100644
--- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
+++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
@@ -56,14 +56,14 @@ namespace OpenSim.Framework.Servers.HttpServer
56 request.ContentType = "text/www-form-urlencoded"; 56 request.ContentType = "text/www-form-urlencoded";
57 57
58 MemoryStream buffer = new MemoryStream(); 58 MemoryStream buffer = new MemoryStream();
59 59 int length = 0;
60 using (StreamWriter writer = new StreamWriter(buffer)) 60 using (StreamWriter writer = new StreamWriter(buffer))
61 { 61 {
62 writer.WriteLine(obj); 62 writer.WriteLine(obj);
63 writer.Flush(); 63 writer.Flush();
64 length = (int)buffer.Length;
64 } 65 }
65 66
66 int length = (int) buffer.Length;
67 request.ContentLength = length; 67 request.ContentLength = length;
68 68
69 Stream requestStream = request.GetRequestStream(); 69 Stream requestStream = request.GetRequestStream();
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
258 258
259 public static Dictionary<string, object> ParseXmlResponse(string data) 259 public static Dictionary<string, object> ParseXmlResponse(string data)
260 { 260 {
261 //m_log.DebugFormat("[XXX]: received xml string: {0}", data);
262
261 Dictionary<string, object> ret = new Dictionary<string, object>(); 263 Dictionary<string, object> ret = new Dictionary<string, object>();
262 264
263 XmlDocument doc = new XmlDocument(); 265 XmlDocument doc = new XmlDocument();
@@ -284,7 +286,7 @@ namespace OpenSim.Server.Base
284 286
285 foreach (XmlNode part in partL) 287 foreach (XmlNode part in partL)
286 { 288 {
287 XmlNode type = part.Attributes.GetNamedItem("Type"); 289 XmlNode type = part.Attributes.GetNamedItem("type");
288 if (type == null || type.Value != "List") 290 if (type == null || type.Value != "List")
289 { 291 {
290 ret[part.Name] = part.InnerText; 292 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
45 if (serverConfig == null) 45 if (serverConfig == null)
46 throw new Exception("No section 'Server' in config file"); 46 throw new Exception("No section 'Server' in config file");
47 47
48 string gridService = serverConfig.GetString("GridServiceModule", 48 string gridService = serverConfig.GetString("LocalServiceModule",
49 String.Empty); 49 String.Empty);
50 50
51 if (gridService == String.Empty) 51 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
63 StreamReader sr = new StreamReader(requestData); 63 StreamReader sr = new StreamReader(requestData);
64 string body = sr.ReadToEnd(); 64 string body = sr.ReadToEnd();
65 sr.Close(); 65 sr.Close();
66 body = body.Trim();
66 67
67 Dictionary<string, string> request = 68 Dictionary<string, string> request =
68 ServerUtils.ParseQueryString(body); 69 ServerUtils.ParseQueryString(body);
@@ -98,11 +99,11 @@ namespace OpenSim.Server.Handlers.Grid
98 case "get_region_range": 99 case "get_region_range":
99 return GetRegionRange(request); 100 return GetRegionRange(request);
100 101
101 default:
102 m_log.DebugFormat("[GRID HANDLER]: unknown method request {0}", method);
103 return FailureResult();
104 } 102 }
105 103
104 m_log.DebugFormat("[GRID HANDLER XXX]: unknown method {0} request {1}", method.Length, method);
105 return FailureResult();
106
106 } 107 }
107 108
108 #region Method-specific handlers 109 #region Method-specific handlers
@@ -155,11 +156,12 @@ namespace OpenSim.Server.Handlers.Grid
155 156
156 UUID regionID = UUID.Zero; 157 UUID regionID = UUID.Zero;
157 if (request["REGIONID"] != null) 158 if (request["REGIONID"] != null)
158 UUID.TryParse(request["REGIONID"], out scopeID); 159 UUID.TryParse(request["REGIONID"], out regionID);
159 else 160 else
160 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); 161 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
161 162
162 List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID); 163 List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID);
164 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
163 165
164 Dictionary<string, object> result = new Dictionary<string, object>(); 166 Dictionary<string, object> result = new Dictionary<string, object>();
165 int i = 0; 167 int i = 0;
@@ -171,6 +173,7 @@ namespace OpenSim.Server.Handlers.Grid
171 } 173 }
172 174
173 string xmlString = ServerUtils.BuildXmlResponse(result); 175 string xmlString = ServerUtils.BuildXmlResponse(result);
176 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
174 UTF8Encoding encoding = new UTF8Encoding(); 177 UTF8Encoding encoding = new UTF8Encoding();
175 return encoding.GetBytes(xmlString); 178 return encoding.GetBytes(xmlString);
176 179
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
index 0a867db..fa197c8 100644
--- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
@@ -97,9 +97,11 @@ namespace OpenSim.Services.Connectors
97 97
98 sendData["METHOD"] = "register"; 98 sendData["METHOD"] = "register";
99 99
100 string reqString = ServerUtils.BuildQueryString(sendData);
101 m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
100 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 102 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
101 m_ServerURI + "/grid", 103 m_ServerURI + "/grid",
102 ServerUtils.BuildQueryString(sendData)); 104 reqString);
103 105
104 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 106 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
105 107
@@ -138,9 +140,10 @@ namespace OpenSim.Services.Connectors
138 140
139 sendData["METHOD"] = "get_neighbours"; 141 sendData["METHOD"] = "get_neighbours";
140 142
143 string reqString = ServerUtils.BuildQueryString(sendData);
141 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 144 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
142 m_ServerURI + "/grid", 145 m_ServerURI + "/grid",
143 ServerUtils.BuildQueryString(sendData)); 146 reqString);
144 147
145 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 148 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
146 149
@@ -148,6 +151,7 @@ namespace OpenSim.Services.Connectors
148 if (replyData != null) 151 if (replyData != null)
149 { 152 {
150 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; 153 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
154 m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
151 foreach (object r in rinfosList) 155 foreach (object r in rinfosList)
152 { 156 {
153 if (r is Dictionary<string, object>) 157 if (r is Dictionary<string, object>)
@@ -156,8 +160,8 @@ namespace OpenSim.Services.Connectors
156 rinfos.Add(rinfo); 160 rinfos.Add(rinfo);
157 } 161 }
158 else 162 else
159 m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response", 163 m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response type {2}",
160 scopeID, regionID); 164 scopeID, regionID, r.GetType());
161 } 165 }
162 } 166 }
163 else 167 else
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index a188f7e..d12276f 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -277,6 +277,15 @@ namespace OpenSim.Services.Interfaces
277 277
278 public GridRegion(Dictionary<string, object> kvp) 278 public GridRegion(Dictionary<string, object> kvp)
279 { 279 {
280 if (kvp["uuid"] != null)
281 RegionID = new UUID((string)kvp["uuid"]);
282
283 if (kvp["locX"] != null)
284 RegionLocX = Convert.ToInt32((string)kvp["locX"]);
285
286 if (kvp["locY"] != null)
287 RegionLocY = Convert.ToInt32((string)kvp["locY"]);
288
280 if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) 289 if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null))
281 { 290 {
282 int port = 0; 291 int port = 0;
diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs
new file mode 100644
index 0000000..0b84f9b
--- /dev/null
+++ b/OpenSim/Tests/Clients/Grid/GridClient.cs
@@ -0,0 +1,102 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Reflection;
5
6using OpenMetaverse;
7using log4net;
8using log4net.Appender;
9using log4net.Layout;
10
11using OpenSim.Framework;
12using OpenSim.Services.Interfaces;
13using GridRegion = OpenSim.Services.Interfaces.GridRegion;
14using OpenSim.Services.Connectors;
15
16namespace OpenSim.Tests.Clients.GridClient
17{
18 public class GridClient
19 {
20 private static readonly ILog m_log =
21 LogManager.GetLogger(
22 MethodBase.GetCurrentMethod().DeclaringType);
23
24 public static void Main(string[] args)
25 {
26 ConsoleAppender consoleAppender = new ConsoleAppender();
27 consoleAppender.Layout =
28 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
29 log4net.Config.BasicConfigurator.Configure(consoleAppender);
30
31 string serverURI = "http://127.0.0.1:8002";
32 GridServicesConnector m_Connector = new GridServicesConnector(serverURI);
33
34 GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000);
35 GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000);
36 GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000);
37
38 Console.WriteLine("[GRID CLIENT]: Registering region 1");
39 bool success = m_Connector.RegisterRegion(UUID.Zero, r1);
40 if (success)
41 Console.WriteLine("[GRID CLIENT]: Successfully registered region 1");
42 else
43 Console.WriteLine("[GRID CLIENT]: region 1 failed to register");
44
45 Console.WriteLine("[GRID CLIENT]: Registering region 2");
46 success = m_Connector.RegisterRegion(UUID.Zero, r2);
47 if (success)
48 Console.WriteLine("[GRID CLIENT]: Successfully registered region 2");
49 else
50 Console.WriteLine("[GRID CLIENT]: region 2 failed to register");
51
52 Console.WriteLine("[GRID CLIENT]: Registering region 3");
53 success = m_Connector.RegisterRegion(UUID.Zero, r3);
54 if (success)
55 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
56 else
57 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
58
59
60 Console.WriteLine("[GRID CLIENT]: Deregistering region 3");
61 success = m_Connector.DeregisterRegion(r3.RegionID);
62 if (success)
63 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
64 else
65 Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
66 Console.WriteLine("[GRID CLIENT]: Registering region 3 again");
67 success = m_Connector.RegisterRegion(UUID.Zero, r3);
68 if (success)
69 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
70 else
71 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
72
73 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1");
74 List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID);
75 if (regions == null)
76 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 failed");
77 else if (regions.Count > 0)
78 {
79 if (regions.Count != 1)
80 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned more neighbours than expected: " + regions.Count);
81 else
82 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned the right neighbour " + regions[0].RegionName);
83 }
84 else
85 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours");
86
87
88 }
89
90 private static GridRegion CreateRegion(string name, uint xcell, uint ycell)
91 {
92 GridRegion region = new GridRegion(xcell, ycell);
93 region.RegionName = name;
94 region.RegionID = UUID.Random();
95 region.ExternalHostName = "127.0.0.1";
96 region.HttpPort = 9000;
97 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
98
99 return region;
100 }
101 }
102}