aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Connectors/Grid/GridServiceConnector.cs')
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServiceConnector.cs300
1 files changed, 201 insertions, 99 deletions
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
index ae7db7e..748892a 100644
--- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer; 36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenSim.Server.Base; 39using OpenSim.Server.Base;
39using OpenMetaverse; 40using OpenMetaverse;
40 41
@@ -85,7 +86,7 @@ namespace OpenSim.Services.Connectors
85 86
86 #region IGridService 87 #region IGridService
87 88
88 public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) 89 public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
89 { 90 {
90 Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); 91 Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
91 Dictionary<string, string> sendData = new Dictionary<string,string>(); 92 Dictionary<string, string> sendData = new Dictionary<string,string>();
@@ -96,19 +97,32 @@ namespace OpenSim.Services.Connectors
96 97
97 sendData["METHOD"] = "register"; 98 sendData["METHOD"] = "register";
98 99
99 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 100 string reqString = ServerUtils.BuildQueryString(sendData);
100 m_ServerURI + "/grid", 101 //m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
101 ServerUtils.BuildQueryString(sendData)); 102 try
102 103 {
103 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 104 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
105 m_ServerURI + "/grid",
106 reqString);
107 if (reply != string.Empty)
108 {
109 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
104 110
105 if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) 111 if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
106 return true; 112 return true;
113 }
114 else
115 m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
116 }
117 catch (Exception e)
118 {
119 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
120 }
107 121
108 return false; 122 return false;
109 } 123 }
110 124
111 public bool DeregisterRegion(UUID regionID) 125 public virtual bool DeregisterRegion(UUID regionID)
112 { 126 {
113 Dictionary<string, string> sendData = new Dictionary<string, string>(); 127 Dictionary<string, string> sendData = new Dictionary<string, string>();
114 128
@@ -116,19 +130,31 @@ namespace OpenSim.Services.Connectors
116 130
117 sendData["METHOD"] = "deregister"; 131 sendData["METHOD"] = "deregister";
118 132
119 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 133 try
120 m_ServerURI + "/grid", 134 {
121 ServerUtils.BuildQueryString(sendData)); 135 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
136 m_ServerURI + "/grid",
137 ServerUtils.BuildQueryString(sendData));
122 138
123 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 139 if (reply != string.Empty)
140 {
141 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
124 142
125 if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) 143 if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
126 return true; 144 return true;
145 }
146 else
147 m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply");
148 }
149 catch (Exception e)
150 {
151 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
152 }
127 153
128 return false; 154 return false;
129 } 155 }
130 156
131 public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) 157 public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
132 { 158 {
133 Dictionary<string, string> sendData = new Dictionary<string, string>(); 159 Dictionary<string, string> sendData = new Dictionary<string, string>();
134 160
@@ -137,26 +163,38 @@ namespace OpenSim.Services.Connectors
137 163
138 sendData["METHOD"] = "get_neighbours"; 164 sendData["METHOD"] = "get_neighbours";
139 165
140 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 166 List<GridRegion> rinfos = new List<GridRegion>();
141 m_ServerURI + "/grid", 167
142 ServerUtils.BuildQueryString(sendData)); 168 string reqString = ServerUtils.BuildQueryString(sendData);
169 string reply = string.Empty;
170 try
171 {
172 reply = SynchronousRestFormsRequester.MakeRequest("POST",
173 m_ServerURI + "/grid",
174 reqString);
175 }
176 catch (Exception e)
177 {
178 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
179 return rinfos;
180 }
143 181
144 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 182 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
145 183
146 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>();
147 if (replyData != null) 184 if (replyData != null)
148 { 185 {
149 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; 186 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
187 //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
150 foreach (object r in rinfosList) 188 foreach (object r in rinfosList)
151 { 189 {
152 if (r is Dictionary<string, object>) 190 if (r is Dictionary<string, object>)
153 { 191 {
154 SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary<string, object>)r); 192 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
155 rinfos.Add(rinfo); 193 rinfos.Add(rinfo);
156 } 194 }
157 else 195 else
158 m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response", 196 m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response type {2}",
159 scopeID, regionID); 197 scopeID, regionID, r.GetType());
160 } 198 }
161 } 199 }
162 else 200 else
@@ -166,7 +204,7 @@ namespace OpenSim.Services.Connectors
166 return rinfos; 204 return rinfos;
167 } 205 }
168 206
169 public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) 207 public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
170 { 208 {
171 Dictionary<string, string> sendData = new Dictionary<string, string>(); 209 Dictionary<string, string> sendData = new Dictionary<string, string>();
172 210
@@ -175,29 +213,44 @@ namespace OpenSim.Services.Connectors
175 213
176 sendData["METHOD"] = "get_region_by_uuid"; 214 sendData["METHOD"] = "get_region_by_uuid";
177 215
178 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 216 string reply = string.Empty;
179 m_ServerURI + "/grid", 217 try
180 ServerUtils.BuildQueryString(sendData)); 218 {
219 reply = SynchronousRestFormsRequester.MakeRequest("POST",
220 m_ServerURI + "/grid",
221 ServerUtils.BuildQueryString(sendData));
222 }
223 catch (Exception e)
224 {
225 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
226 return null;
227 }
181 228
182 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 229 GridRegion rinfo = null;
183 230
184 SimpleRegionInfo rinfo = null; 231 if (reply != string.Empty)
185 if ((replyData != null) && (replyData["result"] != null))
186 { 232 {
187 if (replyData["result"] is Dictionary<string, object>) 233 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
188 rinfo = new SimpleRegionInfo((Dictionary<string, object>)replyData["result"]); 234
235 if ((replyData != null) && (replyData["result"] != null))
236 {
237 if (replyData["result"] is Dictionary<string, object>)
238 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
239 //else
240 // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
241 // scopeID, regionID);
242 }
189 else 243 else
190 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", 244 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
191 scopeID, regionID); 245 scopeID, regionID);
192 } 246 }
193 else 247 else
194 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", 248 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply");
195 scopeID, regionID);
196 249
197 return rinfo; 250 return rinfo;
198 } 251 }
199 252
200 public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) 253 public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
201 { 254 {
202 Dictionary<string, string> sendData = new Dictionary<string, string>(); 255 Dictionary<string, string> sendData = new Dictionary<string, string>();
203 256
@@ -206,30 +259,43 @@ namespace OpenSim.Services.Connectors
206 sendData["Y"] = y.ToString(); 259 sendData["Y"] = y.ToString();
207 260
208 sendData["METHOD"] = "get_region_by_position"; 261 sendData["METHOD"] = "get_region_by_position";
262 string reply = string.Empty;
263 try
264 {
265 reply = SynchronousRestFormsRequester.MakeRequest("POST",
266 m_ServerURI + "/grid",
267 ServerUtils.BuildQueryString(sendData));
268 }
269 catch (Exception e)
270 {
271 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
272 return null;
273 }
209 274
210 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 275 GridRegion rinfo = null;
211 m_ServerURI + "/grid", 276 if (reply != string.Empty)
212 ServerUtils.BuildQueryString(sendData));
213
214 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
215
216 SimpleRegionInfo rinfo = null;
217 if ((replyData != null) && (replyData["result"] != null))
218 { 277 {
219 if (replyData["result"] is Dictionary<string, object>) 278 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
220 rinfo = new SimpleRegionInfo((Dictionary<string, object>)replyData["result"]); 279
280 if ((replyData != null) && (replyData["result"] != null))
281 {
282 if (replyData["result"] is Dictionary<string, object>)
283 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
284 else
285 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response",
286 scopeID, x, y);
287 }
221 else 288 else
222 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", 289 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response",
223 scopeID, x, y); 290 scopeID, x, y);
224 } 291 }
225 else 292 else
226 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", 293 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
227 scopeID, x, y);
228 294
229 return rinfo; 295 return rinfo;
230 } 296 }
231 297
232 public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) 298 public virtual GridRegion GetRegionByName(UUID scopeID, string regionName)
233 { 299 {
234 Dictionary<string, string> sendData = new Dictionary<string, string>(); 300 Dictionary<string, string> sendData = new Dictionary<string, string>();
235 301
@@ -237,30 +303,40 @@ namespace OpenSim.Services.Connectors
237 sendData["NAME"] = regionName; 303 sendData["NAME"] = regionName;
238 304
239 sendData["METHOD"] = "get_region_by_name"; 305 sendData["METHOD"] = "get_region_by_name";
306 string reply = string.Empty;
307 try
308 {
309 reply = SynchronousRestFormsRequester.MakeRequest("POST",
310 m_ServerURI + "/grid",
311 ServerUtils.BuildQueryString(sendData));
312 }
313 catch (Exception e)
314 {
315 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
316 return null;
317 }
240 318
241 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 319 GridRegion rinfo = null;
242 m_ServerURI + "/grid", 320 if (reply != string.Empty)
243 ServerUtils.BuildQueryString(sendData));
244
245 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
246
247 SimpleRegionInfo rinfo = null;
248 if ((replyData != null) && (replyData["result"] != null))
249 { 321 {
250 if (replyData["result"] is Dictionary<string, object>) 322 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
251 rinfo = new SimpleRegionInfo((Dictionary<string, object>)replyData["result"]); 323
324 if ((replyData != null) && (replyData["result"] != null))
325 {
326 if (replyData["result"] is Dictionary<string, object>)
327 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
328 }
252 else 329 else
253 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", 330 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response",
254 scopeID, regionName); 331 scopeID, regionName);
255 } 332 }
256 else 333 else
257 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response", 334 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply");
258 scopeID, regionName);
259 335
260 return rinfo; 336 return rinfo;
261 } 337 }
262 338
263 public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) 339 public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
264 { 340 {
265 Dictionary<string, string> sendData = new Dictionary<string, string>(); 341 Dictionary<string, string> sendData = new Dictionary<string, string>();
266 342
@@ -269,37 +345,50 @@ namespace OpenSim.Services.Connectors
269 sendData["MAX"] = maxNumber.ToString(); 345 sendData["MAX"] = maxNumber.ToString();
270 346
271 sendData["METHOD"] = "get_regions_by_name"; 347 sendData["METHOD"] = "get_regions_by_name";
348 List<GridRegion> rinfos = new List<GridRegion>();
349 string reply = string.Empty;
350 try
351 {
352 reply = SynchronousRestFormsRequester.MakeRequest("POST",
353 m_ServerURI + "/grid",
354 ServerUtils.BuildQueryString(sendData));
355 }
356 catch (Exception e)
357 {
358 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
359 return rinfos;
360 }
272 361
273 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 362 if (reply != string.Empty)
274 m_ServerURI + "/grid",
275 ServerUtils.BuildQueryString(sendData));
276
277 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
278
279 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>();
280 if (replyData != null)
281 { 363 {
282 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; 364 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
283 foreach (object r in rinfosList) 365
366 if (replyData != null)
284 { 367 {
285 if (r is Dictionary<string, object>) 368 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
369 foreach (object r in rinfosList)
286 { 370 {
287 SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary<string, object>)r); 371 if (r is Dictionary<string, object>)
288 rinfos.Add(rinfo); 372 {
373 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
374 rinfos.Add(rinfo);
375 }
376 else
377 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response",
378 scopeID, name, maxNumber);
289 } 379 }
290 else
291 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response",
292 scopeID, name, maxNumber);
293 } 380 }
381 else
382 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response",
383 scopeID, name, maxNumber);
294 } 384 }
295 else 385 else
296 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response", 386 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply");
297 scopeID, name, maxNumber);
298 387
299 return rinfos; 388 return rinfos;
300 } 389 }
301 390
302 public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 391 public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
303 { 392 {
304 Dictionary<string, string> sendData = new Dictionary<string, string>(); 393 Dictionary<string, string> sendData = new Dictionary<string, string>();
305 394
@@ -311,31 +400,44 @@ namespace OpenSim.Services.Connectors
311 400
312 sendData["METHOD"] = "get_region_range"; 401 sendData["METHOD"] = "get_region_range";
313 402
314 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 403 List<GridRegion> rinfos = new List<GridRegion>();
315 m_ServerURI + "/grid", 404 string reply = string.Empty;
316 ServerUtils.BuildQueryString(sendData)); 405 try
406 {
407 reply = SynchronousRestFormsRequester.MakeRequest("POST",
408 m_ServerURI + "/grid",
409 ServerUtils.BuildQueryString(sendData));
317 410
318 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 411 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
412 }
413 catch (Exception e)
414 {
415 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
416 return rinfos;
417 }
319 418
320 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 419 if (reply != string.Empty)
321 if (replyData != null)
322 { 420 {
323 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; 421 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
324 foreach (object r in rinfosList) 422
423 if (replyData != null)
325 { 424 {
326 if (r is Dictionary<string, object>) 425 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
426 foreach (object r in rinfosList)
327 { 427 {
328 SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary<string, object>)r); 428 if (r is Dictionary<string, object>)
329 rinfos.Add(rinfo); 429 {
430 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
431 rinfos.Add(rinfo);
432 }
330 } 433 }
331 else
332 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received invalid response",
333 scopeID, xmin, xmax, ymin, ymax);
334 } 434 }
435 else
436 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response",
437 scopeID, xmin, xmax, ymin, ymax);
335 } 438 }
336 else 439 else
337 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response", 440 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply");
338 scopeID, xmin, xmax, ymin, ymax);
339 441
340 return rinfos; 442 return rinfos;
341 } 443 }