diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/Null/NullRegionData.cs | 5 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | 187 | ||||
-rw-r--r-- | OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | 151 | ||||
-rw-r--r-- | OpenSim/Services/Interfaces/IGridService.cs | 4 | ||||
-rw-r--r-- | OpenSim/Tests/Clients/Grid/GridClient.cs | 64 |
5 files changed, 327 insertions, 84 deletions
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index e976c40..218fcd0 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs | |||
@@ -101,10 +101,7 @@ namespace OpenSim.Data.Null | |||
101 | ret.Add(r); | 101 | ret.Add(r); |
102 | } | 102 | } |
103 | 103 | ||
104 | if (ret.Count > 0) | 104 | return ret; |
105 | return ret; | ||
106 | |||
107 | return null; | ||
108 | } | 105 | } |
109 | 106 | ||
110 | public bool Store(RegionData data) | 107 | public bool Store(RegionData data) |
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 | |||
164 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | 164 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); |
165 | 165 | ||
166 | Dictionary<string, object> result = new Dictionary<string, object>(); | 166 | Dictionary<string, object> result = new Dictionary<string, object>(); |
167 | int i = 0; | 167 | if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) |
168 | foreach (GridRegion rinfo in rinfos) | 168 | result["result"] = "null"; |
169 | else | ||
169 | { | 170 | { |
170 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | 171 | int i = 0; |
171 | result["region" + i] = rinfoDict; | 172 | foreach (GridRegion rinfo in rinfos) |
172 | i++; | 173 | { |
174 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | ||
175 | result["region" + i] = rinfoDict; | ||
176 | i++; | ||
177 | } | ||
173 | } | 178 | } |
174 | 179 | ||
175 | string xmlString = ServerUtils.BuildXmlResponse(result); | 180 | string xmlString = ServerUtils.BuildXmlResponse(result); |
@@ -181,32 +186,184 @@ namespace OpenSim.Server.Handlers.Grid | |||
181 | 186 | ||
182 | byte[] GetRegionByUUID(Dictionary<string, string> request) | 187 | byte[] GetRegionByUUID(Dictionary<string, string> request) |
183 | { | 188 | { |
184 | // TODO | 189 | UUID scopeID = UUID.Zero; |
185 | return new byte[0]; | 190 | if (request["SCOPEID"] != null) |
191 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
192 | else | ||
193 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); | ||
194 | |||
195 | UUID regionID = UUID.Zero; | ||
196 | if (request["REGIONID"] != null) | ||
197 | UUID.TryParse(request["REGIONID"], out regionID); | ||
198 | else | ||
199 | m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); | ||
200 | |||
201 | GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID); | ||
202 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
203 | |||
204 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
205 | if (rinfo == null) | ||
206 | result["result"] = "null"; | ||
207 | else | ||
208 | result["result"] = rinfo.ToKeyValuePairs(); | ||
209 | |||
210 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
211 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
212 | UTF8Encoding encoding = new UTF8Encoding(); | ||
213 | return encoding.GetBytes(xmlString); | ||
186 | } | 214 | } |
187 | 215 | ||
188 | byte[] GetRegionByPosition(Dictionary<string, string> request) | 216 | byte[] GetRegionByPosition(Dictionary<string, string> request) |
189 | { | 217 | { |
190 | // TODO | 218 | UUID scopeID = UUID.Zero; |
191 | return new byte[0]; | 219 | if (request["SCOPEID"] != null) |
220 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
221 | else | ||
222 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position"); | ||
223 | |||
224 | int x = 0, y = 0; | ||
225 | if (request["X"] != null) | ||
226 | Int32.TryParse(request["X"], out x); | ||
227 | else | ||
228 | m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position"); | ||
229 | if (request["Y"] != null) | ||
230 | Int32.TryParse(request["Y"], out y); | ||
231 | else | ||
232 | m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); | ||
233 | |||
234 | GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y); | ||
235 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
236 | |||
237 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
238 | if (rinfo == null) | ||
239 | result["result"] = "null"; | ||
240 | else | ||
241 | result["result"] = rinfo.ToKeyValuePairs(); | ||
242 | |||
243 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
244 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
245 | UTF8Encoding encoding = new UTF8Encoding(); | ||
246 | return encoding.GetBytes(xmlString); | ||
192 | } | 247 | } |
193 | 248 | ||
194 | byte[] GetRegionByName(Dictionary<string, string> request) | 249 | byte[] GetRegionByName(Dictionary<string, string> request) |
195 | { | 250 | { |
196 | // TODO | 251 | UUID scopeID = UUID.Zero; |
197 | return new byte[0]; | 252 | if (request["SCOPEID"] != null) |
253 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
254 | else | ||
255 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name"); | ||
256 | |||
257 | string regionName = string.Empty; | ||
258 | if (request["NAME"] != null) | ||
259 | regionName = request["NAME"]; | ||
260 | else | ||
261 | m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name"); | ||
262 | |||
263 | GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName); | ||
264 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
265 | |||
266 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
267 | if (rinfo == null) | ||
268 | result["result"] = "null"; | ||
269 | else | ||
270 | result["result"] = rinfo.ToKeyValuePairs(); | ||
271 | |||
272 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
273 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
274 | UTF8Encoding encoding = new UTF8Encoding(); | ||
275 | return encoding.GetBytes(xmlString); | ||
198 | } | 276 | } |
199 | 277 | ||
200 | byte[] GetRegionsByName(Dictionary<string, string> request) | 278 | byte[] GetRegionsByName(Dictionary<string, string> request) |
201 | { | 279 | { |
202 | // TODO | 280 | UUID scopeID = UUID.Zero; |
203 | return new byte[0]; | 281 | if (request["SCOPEID"] != null) |
282 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
283 | else | ||
284 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name"); | ||
285 | |||
286 | string regionName = string.Empty; | ||
287 | if (request["NAME"] != null) | ||
288 | regionName = request["NAME"]; | ||
289 | else | ||
290 | m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name"); | ||
291 | |||
292 | int max = 0; | ||
293 | if (request["MAX"] != null) | ||
294 | Int32.TryParse(request["MAX"], out max); | ||
295 | else | ||
296 | m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name"); | ||
297 | |||
298 | List<GridRegion> rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max); | ||
299 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
300 | |||
301 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
302 | if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) | ||
303 | result["result"] = "null"; | ||
304 | else | ||
305 | { | ||
306 | int i = 0; | ||
307 | foreach (GridRegion rinfo in rinfos) | ||
308 | { | ||
309 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | ||
310 | result["region" + i] = rinfoDict; | ||
311 | i++; | ||
312 | } | ||
313 | } | ||
314 | |||
315 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
316 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
317 | UTF8Encoding encoding = new UTF8Encoding(); | ||
318 | return encoding.GetBytes(xmlString); | ||
204 | } | 319 | } |
205 | 320 | ||
206 | byte[] GetRegionRange(Dictionary<string, string> request) | 321 | byte[] GetRegionRange(Dictionary<string, string> request) |
207 | { | 322 | { |
208 | // TODO | 323 | UUID scopeID = UUID.Zero; |
209 | return new byte[0]; | 324 | if (request["SCOPEID"] != null) |
325 | UUID.TryParse(request["SCOPEID"], out scopeID); | ||
326 | else | ||
327 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); | ||
328 | |||
329 | int xmin = 0, xmax = 0, ymin = 0, ymax = 0; | ||
330 | if (request["XMIN"] != null) | ||
331 | Int32.TryParse(request["XMIN"], out xmin); | ||
332 | else | ||
333 | m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range"); | ||
334 | if (request["XMAX"] != null) | ||
335 | Int32.TryParse(request["XMAX"], out xmax); | ||
336 | else | ||
337 | m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range"); | ||
338 | if (request["YMIN"] != null) | ||
339 | Int32.TryParse(request["YMIN"], out ymin); | ||
340 | else | ||
341 | m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range"); | ||
342 | if (request["YMAX"] != null) | ||
343 | Int32.TryParse(request["YMAX"], out ymax); | ||
344 | else | ||
345 | m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range"); | ||
346 | |||
347 | |||
348 | List<GridRegion> rinfos = m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); | ||
349 | |||
350 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
351 | if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) | ||
352 | result["result"] = "null"; | ||
353 | else | ||
354 | { | ||
355 | int i = 0; | ||
356 | foreach (GridRegion rinfo in rinfos) | ||
357 | { | ||
358 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | ||
359 | result["region" + i] = rinfoDict; | ||
360 | i++; | ||
361 | } | ||
362 | } | ||
363 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
364 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
365 | UTF8Encoding encoding = new UTF8Encoding(); | ||
366 | return encoding.GetBytes(xmlString); | ||
210 | } | 367 | } |
211 | 368 | ||
212 | #endregion | 369 | #endregion |
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index fa197c8..ebb66a7 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | |||
@@ -98,15 +98,19 @@ namespace OpenSim.Services.Connectors | |||
98 | sendData["METHOD"] = "register"; | 98 | sendData["METHOD"] = "register"; |
99 | 99 | ||
100 | string reqString = ServerUtils.BuildQueryString(sendData); | 100 | string reqString = ServerUtils.BuildQueryString(sendData); |
101 | m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); | 101 | //m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); |
102 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | 102 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", |
103 | m_ServerURI + "/grid", | 103 | m_ServerURI + "/grid", |
104 | reqString); | 104 | reqString); |
105 | if (reply != string.Empty) | ||
106 | { | ||
107 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
105 | 108 | ||
106 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | 109 | if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) |
107 | 110 | return true; | |
108 | if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) | 111 | } |
109 | return true; | 112 | else |
113 | m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply"); | ||
110 | 114 | ||
111 | return false; | 115 | return false; |
112 | } | 116 | } |
@@ -123,10 +127,15 @@ namespace OpenSim.Services.Connectors | |||
123 | m_ServerURI + "/grid", | 127 | m_ServerURI + "/grid", |
124 | ServerUtils.BuildQueryString(sendData)); | 128 | ServerUtils.BuildQueryString(sendData)); |
125 | 129 | ||
126 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | 130 | if (reply != string.Empty) |
131 | { | ||
132 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
127 | 133 | ||
128 | if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) | 134 | if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) |
129 | return true; | 135 | return true; |
136 | } | ||
137 | else | ||
138 | m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply"); | ||
130 | 139 | ||
131 | return false; | 140 | return false; |
132 | } | 141 | } |
@@ -151,7 +160,7 @@ namespace OpenSim.Services.Connectors | |||
151 | if (replyData != null) | 160 | if (replyData != null) |
152 | { | 161 | { |
153 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; | 162 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; |
154 | m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count); | 163 | //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count); |
155 | foreach (object r in rinfosList) | 164 | foreach (object r in rinfosList) |
156 | { | 165 | { |
157 | if (r is Dictionary<string, object>) | 166 | if (r is Dictionary<string, object>) |
@@ -184,20 +193,26 @@ namespace OpenSim.Services.Connectors | |||
184 | m_ServerURI + "/grid", | 193 | m_ServerURI + "/grid", |
185 | ServerUtils.BuildQueryString(sendData)); | 194 | ServerUtils.BuildQueryString(sendData)); |
186 | 195 | ||
187 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
188 | |||
189 | GridRegion rinfo = null; | 196 | GridRegion rinfo = null; |
190 | if ((replyData != null) && (replyData["result"] != null)) | 197 | |
198 | if (reply != string.Empty) | ||
191 | { | 199 | { |
192 | if (replyData["result"] is Dictionary<string, object>) | 200 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
193 | rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); | 201 | |
202 | if ((replyData != null) && (replyData["result"] != null)) | ||
203 | { | ||
204 | if (replyData["result"] is Dictionary<string, object>) | ||
205 | rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); | ||
206 | //else | ||
207 | // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", | ||
208 | // scopeID, regionID); | ||
209 | } | ||
194 | else | 210 | else |
195 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", | 211 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", |
196 | scopeID, regionID); | 212 | scopeID, regionID); |
197 | } | 213 | } |
198 | else | 214 | else |
199 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", | 215 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply"); |
200 | scopeID, regionID); | ||
201 | 216 | ||
202 | return rinfo; | 217 | return rinfo; |
203 | } | 218 | } |
@@ -216,20 +231,25 @@ namespace OpenSim.Services.Connectors | |||
216 | m_ServerURI + "/grid", | 231 | m_ServerURI + "/grid", |
217 | ServerUtils.BuildQueryString(sendData)); | 232 | ServerUtils.BuildQueryString(sendData)); |
218 | 233 | ||
219 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
220 | |||
221 | GridRegion rinfo = null; | 234 | GridRegion rinfo = null; |
222 | if ((replyData != null) && (replyData["result"] != null)) | 235 | if (reply != string.Empty) |
223 | { | 236 | { |
224 | if (replyData["result"] is Dictionary<string, object>) | 237 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
225 | rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); | 238 | |
239 | if ((replyData != null) && (replyData["result"] != null)) | ||
240 | { | ||
241 | if (replyData["result"] is Dictionary<string, object>) | ||
242 | rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); | ||
243 | else | ||
244 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", | ||
245 | scopeID, x, y); | ||
246 | } | ||
226 | else | 247 | else |
227 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", | 248 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", |
228 | scopeID, x, y); | 249 | scopeID, x, y); |
229 | } | 250 | } |
230 | else | 251 | else |
231 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", | 252 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply"); |
232 | scopeID, x, y); | ||
233 | 253 | ||
234 | return rinfo; | 254 | return rinfo; |
235 | } | 255 | } |
@@ -247,20 +267,22 @@ namespace OpenSim.Services.Connectors | |||
247 | m_ServerURI + "/grid", | 267 | m_ServerURI + "/grid", |
248 | ServerUtils.BuildQueryString(sendData)); | 268 | ServerUtils.BuildQueryString(sendData)); |
249 | 269 | ||
250 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
251 | |||
252 | GridRegion rinfo = null; | 270 | GridRegion rinfo = null; |
253 | if ((replyData != null) && (replyData["result"] != null)) | 271 | if (reply != string.Empty) |
254 | { | 272 | { |
255 | if (replyData["result"] is Dictionary<string, object>) | 273 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
256 | rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); | 274 | |
275 | if ((replyData != null) && (replyData["result"] != null)) | ||
276 | { | ||
277 | if (replyData["result"] is Dictionary<string, object>) | ||
278 | rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); | ||
279 | } | ||
257 | else | 280 | else |
258 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", | 281 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response", |
259 | scopeID, regionName); | 282 | scopeID, regionName); |
260 | } | 283 | } |
261 | else | 284 | else |
262 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response", | 285 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply"); |
263 | scopeID, regionName); | ||
264 | 286 | ||
265 | return rinfo; | 287 | return rinfo; |
266 | } | 288 | } |
@@ -279,27 +301,33 @@ namespace OpenSim.Services.Connectors | |||
279 | m_ServerURI + "/grid", | 301 | m_ServerURI + "/grid", |
280 | ServerUtils.BuildQueryString(sendData)); | 302 | ServerUtils.BuildQueryString(sendData)); |
281 | 303 | ||
282 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
283 | |||
284 | List<GridRegion> rinfos = new List<GridRegion>(); | 304 | List<GridRegion> rinfos = new List<GridRegion>(); |
285 | if (replyData != null) | 305 | |
306 | if (reply != string.Empty) | ||
286 | { | 307 | { |
287 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; | 308 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
288 | foreach (object r in rinfosList) | 309 | |
310 | if (replyData != null) | ||
289 | { | 311 | { |
290 | if (r is Dictionary<string, object>) | 312 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; |
313 | foreach (object r in rinfosList) | ||
291 | { | 314 | { |
292 | GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); | 315 | if (r is Dictionary<string, object>) |
293 | rinfos.Add(rinfo); | 316 | { |
317 | GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); | ||
318 | rinfos.Add(rinfo); | ||
319 | } | ||
320 | else | ||
321 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response", | ||
322 | scopeID, name, maxNumber); | ||
294 | } | 323 | } |
295 | else | ||
296 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response", | ||
297 | scopeID, name, maxNumber); | ||
298 | } | 324 | } |
325 | else | ||
326 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response", | ||
327 | scopeID, name, maxNumber); | ||
299 | } | 328 | } |
300 | else | 329 | else |
301 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response", | 330 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply"); |
302 | scopeID, name, maxNumber); | ||
303 | 331 | ||
304 | return rinfos; | 332 | return rinfos; |
305 | } | 333 | } |
@@ -316,31 +344,36 @@ namespace OpenSim.Services.Connectors | |||
316 | 344 | ||
317 | sendData["METHOD"] = "get_region_range"; | 345 | sendData["METHOD"] = "get_region_range"; |
318 | 346 | ||
347 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
348 | |||
319 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | 349 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", |
320 | m_ServerURI + "/grid", | 350 | m_ServerURI + "/grid", |
321 | ServerUtils.BuildQueryString(sendData)); | 351 | ServerUtils.BuildQueryString(sendData)); |
322 | 352 | ||
323 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | 353 | //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); |
324 | 354 | ||
325 | List<GridRegion> rinfos = new List<GridRegion>(); | 355 | if (reply != string.Empty) |
326 | if (replyData != null) | ||
327 | { | 356 | { |
328 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; | 357 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
329 | foreach (object r in rinfosList) | 358 | |
359 | if (replyData != null) | ||
330 | { | 360 | { |
331 | if (r is Dictionary<string, object>) | 361 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; |
362 | foreach (object r in rinfosList) | ||
332 | { | 363 | { |
333 | GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); | 364 | if (r is Dictionary<string, object>) |
334 | rinfos.Add(rinfo); | 365 | { |
366 | GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); | ||
367 | rinfos.Add(rinfo); | ||
368 | } | ||
335 | } | 369 | } |
336 | else | ||
337 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received invalid response", | ||
338 | scopeID, xmin, xmax, ymin, ymax); | ||
339 | } | 370 | } |
371 | else | ||
372 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response", | ||
373 | scopeID, xmin, xmax, ymin, ymax); | ||
340 | } | 374 | } |
341 | else | 375 | else |
342 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response", | 376 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply"); |
343 | scopeID, xmin, xmax, ymin, ymax); | ||
344 | 377 | ||
345 | return rinfos; | 378 | return rinfos; |
346 | } | 379 | } |
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index d12276f..4bdcde2 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs | |||
@@ -263,6 +263,7 @@ namespace OpenSim.Services.Interfaces | |||
263 | kvp["uuid"] = RegionID.ToString(); | 263 | kvp["uuid"] = RegionID.ToString(); |
264 | kvp["locX"] = RegionLocX.ToString(); | 264 | kvp["locX"] = RegionLocX.ToString(); |
265 | kvp["locY"] = RegionLocY.ToString(); | 265 | kvp["locY"] = RegionLocY.ToString(); |
266 | kvp["name"] = RegionName; | ||
266 | kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); | 267 | kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); |
267 | kvp["external_port"] = ExternalEndPoint.Port.ToString(); | 268 | kvp["external_port"] = ExternalEndPoint.Port.ToString(); |
268 | kvp["external_host_name"] = ExternalHostName; | 269 | kvp["external_host_name"] = ExternalHostName; |
@@ -286,6 +287,9 @@ namespace OpenSim.Services.Interfaces | |||
286 | if (kvp["locY"] != null) | 287 | if (kvp["locY"] != null) |
287 | RegionLocY = Convert.ToInt32((string)kvp["locY"]); | 288 | RegionLocY = Convert.ToInt32((string)kvp["locY"]); |
288 | 289 | ||
290 | if (kvp["name"] != null) | ||
291 | RegionName = (string)kvp["name"]; | ||
292 | |||
289 | if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) | 293 | if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) |
290 | { | 294 | { |
291 | int port = 0; | 295 | int port = 0; |
diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs index 0b84f9b..155f38e 100644 --- a/OpenSim/Tests/Clients/Grid/GridClient.cs +++ b/OpenSim/Tests/Clients/Grid/GridClient.cs | |||
@@ -35,21 +35,21 @@ namespace OpenSim.Tests.Clients.GridClient | |||
35 | GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000); | 35 | GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000); |
36 | GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000); | 36 | GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000); |
37 | 37 | ||
38 | Console.WriteLine("[GRID CLIENT]: Registering region 1"); | 38 | Console.WriteLine("[GRID CLIENT]: *** Registering region 1"); |
39 | bool success = m_Connector.RegisterRegion(UUID.Zero, r1); | 39 | bool success = m_Connector.RegisterRegion(UUID.Zero, r1); |
40 | if (success) | 40 | if (success) |
41 | Console.WriteLine("[GRID CLIENT]: Successfully registered region 1"); | 41 | Console.WriteLine("[GRID CLIENT]: Successfully registered region 1"); |
42 | else | 42 | else |
43 | Console.WriteLine("[GRID CLIENT]: region 1 failed to register"); | 43 | Console.WriteLine("[GRID CLIENT]: region 1 failed to register"); |
44 | 44 | ||
45 | Console.WriteLine("[GRID CLIENT]: Registering region 2"); | 45 | Console.WriteLine("[GRID CLIENT]: *** Registering region 2"); |
46 | success = m_Connector.RegisterRegion(UUID.Zero, r2); | 46 | success = m_Connector.RegisterRegion(UUID.Zero, r2); |
47 | if (success) | 47 | if (success) |
48 | Console.WriteLine("[GRID CLIENT]: Successfully registered region 2"); | 48 | Console.WriteLine("[GRID CLIENT]: Successfully registered region 2"); |
49 | else | 49 | else |
50 | Console.WriteLine("[GRID CLIENT]: region 2 failed to register"); | 50 | Console.WriteLine("[GRID CLIENT]: region 2 failed to register"); |
51 | 51 | ||
52 | Console.WriteLine("[GRID CLIENT]: Registering region 3"); | 52 | Console.WriteLine("[GRID CLIENT]: *** Registering region 3"); |
53 | success = m_Connector.RegisterRegion(UUID.Zero, r3); | 53 | success = m_Connector.RegisterRegion(UUID.Zero, r3); |
54 | if (success) | 54 | if (success) |
55 | Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); | 55 | Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); |
@@ -57,20 +57,20 @@ namespace OpenSim.Tests.Clients.GridClient | |||
57 | Console.WriteLine("[GRID CLIENT]: region 3 failed to register"); | 57 | Console.WriteLine("[GRID CLIENT]: region 3 failed to register"); |
58 | 58 | ||
59 | 59 | ||
60 | Console.WriteLine("[GRID CLIENT]: Deregistering region 3"); | 60 | Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3"); |
61 | success = m_Connector.DeregisterRegion(r3.RegionID); | 61 | success = m_Connector.DeregisterRegion(r3.RegionID); |
62 | if (success) | 62 | if (success) |
63 | Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3"); | 63 | Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3"); |
64 | else | 64 | else |
65 | Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister"); | 65 | Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister"); |
66 | Console.WriteLine("[GRID CLIENT]: Registering region 3 again"); | 66 | Console.WriteLine("[GRID CLIENT]: *** Registering region 3 again"); |
67 | success = m_Connector.RegisterRegion(UUID.Zero, r3); | 67 | success = m_Connector.RegisterRegion(UUID.Zero, r3); |
68 | if (success) | 68 | if (success) |
69 | Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); | 69 | Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); |
70 | else | 70 | else |
71 | Console.WriteLine("[GRID CLIENT]: region 3 failed to register"); | 71 | Console.WriteLine("[GRID CLIENT]: region 3 failed to register"); |
72 | 72 | ||
73 | Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1"); | 73 | Console.WriteLine("[GRID CLIENT]: *** GetNeighbours of region 1"); |
74 | List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID); | 74 | List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID); |
75 | if (regions == null) | 75 | if (regions == null) |
76 | Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 failed"); | 76 | Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 failed"); |
@@ -85,6 +85,58 @@ namespace OpenSim.Tests.Clients.GridClient | |||
85 | Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours"); | 85 | Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours"); |
86 | 86 | ||
87 | 87 | ||
88 | Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of region 2 (this should succeed)"); | ||
89 | GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID); | ||
90 | if (region == null) | ||
91 | Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null"); | ||
92 | else | ||
93 | Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName); | ||
94 | |||
95 | Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of non-existent region (this should fail)"); | ||
96 | region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random()); | ||
97 | if (region == null) | ||
98 | Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null"); | ||
99 | else | ||
100 | Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName); | ||
101 | |||
102 | Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of region 3 (this should succeed)"); | ||
103 | region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName); | ||
104 | if (region == null) | ||
105 | Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null"); | ||
106 | else | ||
107 | Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName); | ||
108 | |||
109 | Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of non-existent region (this should fail)"); | ||
110 | region = m_Connector.GetRegionByName(UUID.Zero, "Foo"); | ||
111 | if (region == null) | ||
112 | Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null"); | ||
113 | else | ||
114 | Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName); | ||
115 | |||
116 | Console.WriteLine("[GRID CLIENT]: *** GetRegionsByName (this should return 3 regions)"); | ||
117 | regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10); | ||
118 | if (regions == null) | ||
119 | Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned null"); | ||
120 | else | ||
121 | Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned " + regions.Count + " regions"); | ||
122 | |||
123 | Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 2 regions)"); | ||
124 | regions = m_Connector.GetRegionRange(UUID.Zero, | ||
125 | 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize, | ||
126 | 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize); | ||
127 | if (regions == null) | ||
128 | Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null"); | ||
129 | else | ||
130 | Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions"); | ||
131 | Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 0 regions)"); | ||
132 | regions = m_Connector.GetRegionRange(UUID.Zero, | ||
133 | 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize, | ||
134 | 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize); | ||
135 | if (regions == null) | ||
136 | Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null"); | ||
137 | else | ||
138 | Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions"); | ||
139 | |||
88 | } | 140 | } |
89 | 141 | ||
90 | private static GridRegion CreateRegion(string name, uint xcell, uint ycell) | 142 | private static GridRegion CreateRegion(string name, uint xcell, uint ycell) |