aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorMelanie2009-09-27 21:25:10 +0100
committerMelanie2009-09-27 21:25:10 +0100
commitb5bf3f87d552f8aef7fc8f4ab8fa34d6dbefcd30 (patch)
treeb7e6844d7f037541640e489d3c8bec53159b5df0 /OpenSim/Services
parentAdd the Migration for the regions table (diff)
parentMerge branch 'master' of ssh://MyConnection/var/git/opensim (diff)
downloadopensim-SC_OLD-b5bf3f87d552f8aef7fc8f4ab8fa34d6dbefcd30.zip
opensim-SC_OLD-b5bf3f87d552f8aef7fc8f4ab8fa34d6dbefcd30.tar.gz
opensim-SC_OLD-b5bf3f87d552f8aef7fc8f4ab8fa34d6dbefcd30.tar.bz2
opensim-SC_OLD-b5bf3f87d552f8aef7fc8f4ab8fa34d6dbefcd30.tar.xz
Merge branch 'master' of ssh://melanie@opensimulator.org/var/git/opensim
Conflicts: OpenSim/Data/MySQL/MySQLRegionData.cs
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs6
-rw-r--r--OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs6
-rw-r--r--OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs6
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServiceConnector.cs300
-rw-r--r--OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs152
-rw-r--r--OpenSim/Services/GridService/GridService.cs145
-rw-r--r--OpenSim/Services/GridService/GridServiceBase.cs2
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs245
8 files changed, 644 insertions, 218 deletions
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
index 8904461..dcf090e 100644
--- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
+++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
@@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService
43 // 43 //
44 public class AuthenticationServiceBase : ServiceBase 44 public class AuthenticationServiceBase : ServiceBase
45 { 45 {
46 private static readonly ILog m_log = 46// private static readonly ILog m_log =
47 LogManager.GetLogger( 47// LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType); 48// MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 protected IAuthenticationData m_Database; 50 protected IAuthenticationData m_Database;
51 51
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
index 6c99b66..d65665a 100644
--- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
@@ -47,9 +47,9 @@ namespace OpenSim.Services.AuthenticationService
47 public class PasswordAuthenticationService : 47 public class PasswordAuthenticationService :
48 AuthenticationServiceBase, IAuthenticationService 48 AuthenticationServiceBase, IAuthenticationService
49 { 49 {
50 private static readonly ILog m_log = 50// private static readonly ILog m_log =
51 LogManager.GetLogger( 51// LogManager.GetLogger(
52 MethodBase.GetCurrentMethod().DeclaringType); 52// MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 public PasswordAuthenticationService(IConfigSource config) : 54 public PasswordAuthenticationService(IConfigSource config) :
55 base(config) 55 base(config)
diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
index 8831c8a..d1a5b0f 100644
--- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
@@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService
43 public class WebkeyAuthenticationService : 43 public class WebkeyAuthenticationService :
44 AuthenticationServiceBase, IAuthenticationService 44 AuthenticationServiceBase, IAuthenticationService
45 { 45 {
46 private static readonly ILog m_log = 46// private static readonly ILog m_log =
47 LogManager.GetLogger( 47// LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType); 48// MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 public WebkeyAuthenticationService(IConfigSource config) : 50 public WebkeyAuthenticationService(IConfigSource config) :
51 base(config) 51 base(config)
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 }
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
new file mode 100644
index 0000000..b5e8743
--- /dev/null
+++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
@@ -0,0 +1,152 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32using System.Drawing;
33using System.Net;
34using System.Reflection;
35using OpenSim.Services.Interfaces;
36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37
38using OpenSim.Framework;
39
40using OpenMetaverse;
41using OpenMetaverse.Imaging;
42using log4net;
43using Nwc.XmlRpc;
44
45namespace OpenSim.Services.Connectors.Grid
46{
47 public class HypergridServiceConnector
48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 private IAssetService m_AssetService;
52
53 public HypergridServiceConnector(IAssetService assService)
54 {
55 m_AssetService = assService;
56 }
57
58 public UUID LinkRegion(GridRegion info, out ulong realHandle)
59 {
60 UUID uuid = UUID.Zero;
61 realHandle = 0;
62
63 Hashtable hash = new Hashtable();
64 hash["region_name"] = info.RegionName;
65
66 IList paramList = new ArrayList();
67 paramList.Add(hash);
68
69 XmlRpcRequest request = new XmlRpcRequest("linkk_region", paramList);
70 string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
71 m_log.Debug("[HGrid]: Linking to " + uri);
72 XmlRpcResponse response = request.Send(uri, 10000);
73 if (response.IsFault)
74 {
75 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
76 }
77 else
78 {
79 hash = (Hashtable)response.Value;
80 //foreach (Object o in hash)
81 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
82 try
83 {
84 UUID.TryParse((string)hash["uuid"], out uuid);
85 info.RegionID = uuid;
86 if ((string)hash["handle"] != null)
87 {
88 realHandle = Convert.ToUInt64((string)hash["handle"]);
89 m_log.Debug(">> HERE, realHandle: " + realHandle);
90 }
91 //if (hash["region_image"] != null)
92 //{
93 // UUID img = UUID.Zero;
94 // UUID.TryParse((string)hash["region_image"], out img);
95 // info.RegionSettings.TerrainImageID = img;
96 //}
97 if (hash["region_name"] != null)
98 {
99 info.RegionName = (string)hash["region_name"];
100 //m_log.Debug(">> " + info.RegionName);
101 }
102 if (hash["internal_port"] != null)
103 {
104 int port = Convert.ToInt32((string)hash["internal_port"]);
105 info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
106 //m_log.Debug(">> " + info.InternalEndPoint.ToString());
107 }
108
109 }
110 catch (Exception e)
111 {
112 m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
113 }
114 }
115 return uuid;
116 }
117
118 public void GetMapImage(GridRegion info)
119 {
120 try
121 {
122 string regionimage = "regionImage" + info.RegionID.ToString();
123 regionimage = regionimage.Replace("-", "");
124
125 WebClient c = new WebClient();
126 string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage;
127 //m_log.Debug("JPEG: " + uri);
128 c.DownloadFile(uri, info.RegionID.ToString() + ".jpg");
129 Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg");
130 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
131 byte[] imageData = OpenJPEG.EncodeFromImage(m, true);
132 AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString());
133
134 // !!! for now
135 //info.RegionSettings.TerrainImageID = ass.FullID;
136
137 ass.Type = (int)AssetType.Texture;
138 ass.Temporary = true;
139 ass.Local = true;
140 ass.Data = imageData;
141
142 m_AssetService.Store(ass);
143
144 }
145 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
146 {
147 m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache");
148 }
149 }
150
151 }
152}
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 2229421..991acf2 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Data; 36using OpenSim.Data;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenMetaverse; 39using OpenMetaverse;
39 40
40namespace OpenSim.Services.GridService 41namespace OpenSim.Services.GridService
@@ -48,33 +49,28 @@ namespace OpenSim.Services.GridService
48 public GridService(IConfigSource config) 49 public GridService(IConfigSource config)
49 : base(config) 50 : base(config)
50 { 51 {
51 MainConsole.Instance.Commands.AddCommand("kfs", false, 52 m_log.DebugFormat("[GRID SERVICE]: Starting...");
52 "show digest",
53 "show digest <ID>",
54 "Show asset digest", HandleShowDigest);
55
56 MainConsole.Instance.Commands.AddCommand("kfs", false,
57 "delete asset",
58 "delete asset <ID>",
59 "Delete asset from database", HandleDeleteAsset);
60
61 } 53 }
62 54
63 #region IGridService 55 #region IGridService
64 56
65 public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) 57 public bool RegisterRegion(UUID scopeID, GridRegion regionInfos)
66 { 58 {
67 if (m_Database.Get(regionInfos.RegionID, scopeID) != null) 59 // This needs better sanity testing. What if regionInfo is registering in
68 { 60 // overlapping coords?
69 m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); 61 RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
70 return false; 62 if ((region != null) && (region.RegionID != regionInfos.RegionID))
71 }
72 if (m_Database.Get((int)regionInfos.RegionLocX, (int)regionInfos.RegionLocY, scopeID) != null)
73 { 63 {
74 m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", 64 m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.",
75 regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); 65 regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
76 return false; 66 return false;
77 } 67 }
68 if ((region != null) && (region.RegionID == regionInfos.RegionID) &&
69 ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
70 {
71 // Region reregistering in other coordinates. Delete the old entry
72 m_Database.Delete(regionInfos.RegionID);
73 }
78 74
79 // Everything is ok, let's register 75 // Everything is ok, let's register
80 RegionData rdata = RegionInfo2RegionData(regionInfos); 76 RegionData rdata = RegionInfo2RegionData(regionInfos);
@@ -88,22 +84,25 @@ namespace OpenSim.Services.GridService
88 return m_Database.Delete(regionID); 84 return m_Database.Delete(regionID);
89 } 85 }
90 86
91 public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) 87 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
92 { 88 {
93 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 89 List<GridRegion> rinfos = new List<GridRegion>();
94 RegionData region = m_Database.Get(regionID, scopeID); 90 RegionData region = m_Database.Get(regionID, scopeID);
95 if (region != null) 91 if (region != null)
96 { 92 {
97 // Not really? Maybe? 93 // Not really? Maybe?
98 List<RegionData> rdatas = m_Database.Get(region.posX - 1, region.posY - 1, region.posX + 1, region.posY + 1, scopeID); 94 List<RegionData> rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize, region.posY - (int)Constants.RegionSize,
95 region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID);
96
99 foreach (RegionData rdata in rdatas) 97 foreach (RegionData rdata in rdatas)
100 rinfos.Add(RegionData2RegionInfo(rdata)); 98 if (rdata.RegionID != regionID)
99 rinfos.Add(RegionData2RegionInfo(rdata));
101 100
102 } 101 }
103 return rinfos; 102 return rinfos;
104 } 103 }
105 104
106 public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) 105 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
107 { 106 {
108 RegionData rdata = m_Database.Get(regionID, scopeID); 107 RegionData rdata = m_Database.Get(regionID, scopeID);
109 if (rdata != null) 108 if (rdata != null)
@@ -112,16 +111,18 @@ namespace OpenSim.Services.GridService
112 return null; 111 return null;
113 } 112 }
114 113
115 public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) 114 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
116 { 115 {
117 RegionData rdata = m_Database.Get(x, y, scopeID); 116 int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize;
117 int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize;
118 RegionData rdata = m_Database.Get(snapX, snapY, scopeID);
118 if (rdata != null) 119 if (rdata != null)
119 return RegionData2RegionInfo(rdata); 120 return RegionData2RegionInfo(rdata);
120 121
121 return null; 122 return null;
122 } 123 }
123 124
124 public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) 125 public GridRegion GetRegionByName(UUID scopeID, string regionName)
125 { 126 {
126 List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID); 127 List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID);
127 if ((rdatas != null) && (rdatas.Count > 0)) 128 if ((rdatas != null) && (rdatas.Count > 0))
@@ -130,12 +131,12 @@ namespace OpenSim.Services.GridService
130 return null; 131 return null;
131 } 132 }
132 133
133 public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) 134 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
134 { 135 {
135 List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID); 136 List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID);
136 137
137 int count = 0; 138 int count = 0;
138 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 139 List<GridRegion> rinfos = new List<GridRegion>();
139 140
140 if (rdatas != null) 141 if (rdatas != null)
141 { 142 {
@@ -149,10 +150,15 @@ namespace OpenSim.Services.GridService
149 return rinfos; 150 return rinfos;
150 } 151 }
151 152
152 public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 153 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
153 { 154 {
154 List<RegionData> rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); 155 int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
155 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 156 int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize;
157 int yminSnap = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize;
158 int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
159
160 List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID);
161 List<GridRegion> rinfos = new List<GridRegion>();
156 foreach (RegionData rdata in rdatas) 162 foreach (RegionData rdata in rdatas)
157 rinfos.Add(RegionData2RegionInfo(rdata)); 163 rinfos.Add(RegionData2RegionInfo(rdata));
158 164
@@ -163,92 +169,31 @@ namespace OpenSim.Services.GridService
163 169
164 #region Data structure conversions 170 #region Data structure conversions
165 171
166 protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) 172 protected RegionData RegionInfo2RegionData(GridRegion rinfo)
167 { 173 {
168 RegionData rdata = new RegionData(); 174 RegionData rdata = new RegionData();
169 rdata.posX = (int)rinfo.RegionLocX; 175 rdata.posX = (int)rinfo.RegionLocX;
170 rdata.posY = (int)rinfo.RegionLocY; 176 rdata.posY = (int)rinfo.RegionLocY;
171 rdata.RegionID = rinfo.RegionID; 177 rdata.RegionID = rinfo.RegionID;
178 rdata.RegionName = rinfo.RegionName;
172 rdata.Data = rinfo.ToKeyValuePairs(); 179 rdata.Data = rinfo.ToKeyValuePairs();
173 //rdata.RegionName = rinfo.RegionName; 180 rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY);
174
175 return rdata; 181 return rdata;
176 } 182 }
177 183
178 protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) 184 protected GridRegion RegionData2RegionInfo(RegionData rdata)
179 { 185 {
180 SimpleRegionInfo rinfo = new SimpleRegionInfo(rdata.Data); 186 GridRegion rinfo = new GridRegion(rdata.Data);
181 rinfo.RegionLocX = (uint)rdata.posX; 187 rinfo.RegionLocX = rdata.posX;
182 rinfo.RegionLocY = (uint)rdata.posY; 188 rinfo.RegionLocY = rdata.posY;
183 rinfo.RegionID = rdata.RegionID; 189 rinfo.RegionID = rdata.RegionID;
184 //rinfo.RegionName = rdata.RegionName; 190 rinfo.RegionName = rdata.RegionName;
191 rinfo.ScopeID = rdata.ScopeID;
185 192
186 return rinfo; 193 return rinfo;
187 } 194 }
188 195
189 #endregion 196 #endregion
190 197
191 void HandleShowDigest(string module, string[] args)
192 {
193 //if (args.Length < 3)
194 //{
195 // MainConsole.Instance.Output("Syntax: show digest <ID>");
196 // return;
197 //}
198
199 //AssetBase asset = Get(args[2]);
200
201 //if (asset == null || asset.Data.Length == 0)
202 //{
203 // MainConsole.Instance.Output("Asset not found");
204 // return;
205 //}
206
207 //int i;
208
209 //MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name));
210 //MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description));
211 //MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type));
212 //MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType));
213
214 //for (i = 0 ; i < 5 ; i++)
215 //{
216 // int off = i * 16;
217 // if (asset.Data.Length <= off)
218 // break;
219 // int len = 16;
220 // if (asset.Data.Length < off + len)
221 // len = asset.Data.Length - off;
222
223 // byte[] line = new byte[len];
224 // Array.Copy(asset.Data, off, line, 0, len);
225
226 // string text = BitConverter.ToString(line);
227 // MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text));
228 //}
229 }
230
231 void HandleDeleteAsset(string module, string[] args)
232 {
233 //if (args.Length < 3)
234 //{
235 // MainConsole.Instance.Output("Syntax: delete asset <ID>");
236 // return;
237 //}
238
239 //AssetBase asset = Get(args[2]);
240
241 //if (asset == null || asset.Data.Length == 0)
242 // MainConsole.Instance.Output("Asset not found");
243 // return;
244 //}
245
246 //Delete(args[2]);
247
248 ////MainConsole.Instance.Output("Asset deleted");
249 //// TODO: Implement this
250
251 //MainConsole.Instance.Output("Asset deletion not supported by database");
252 }
253 } 198 }
254} 199}
diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs
index 7522e64..444f79b 100644
--- a/OpenSim/Services/GridService/GridServiceBase.cs
+++ b/OpenSim/Services/GridService/GridServiceBase.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Services.GridService
68 connString = gridConfig.GetString("ConnectionString", connString); 68 connString = gridConfig.GetString("ConnectionString", connString);
69 realm = gridConfig.GetString("Realm", realm); 69 realm = gridConfig.GetString("Realm", realm);
70 } 70 }
71 71
72 // 72 //
73 // We tried, but this doesn't exist. We can't proceed. 73 // We tried, but this doesn't exist. We can't proceed.
74 // 74 //
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index 8f6c524..ce432ab 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -25,8 +25,11 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using OpenSim.Framework; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net;
31using System.Net.Sockets;
32using OpenSim.Framework;
30using OpenMetaverse; 33using OpenMetaverse;
31 34
32namespace OpenSim.Services.Interfaces 35namespace OpenSim.Services.Interfaces
@@ -39,7 +42,7 @@ namespace OpenSim.Services.Interfaces
39 /// <param name="regionInfos"> </param> 42 /// <param name="regionInfos"> </param>
40 /// <returns></returns> 43 /// <returns></returns>
41 /// <exception cref="System.Exception">Thrown if region registration failed</exception> 44 /// <exception cref="System.Exception">Thrown if region registration failed</exception>
42 bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos); 45 bool RegisterRegion(UUID scopeID, GridRegion regionInfos);
43 46
44 /// <summary> 47 /// <summary>
45 /// Deregister a region with the grid service. 48 /// Deregister a region with the grid service.
@@ -55,9 +58,9 @@ namespace OpenSim.Services.Interfaces
55 /// <param name="x"></param> 58 /// <param name="x"></param>
56 /// <param name="y"></param> 59 /// <param name="y"></param>
57 /// <returns></returns> 60 /// <returns></returns>
58 List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID); 61 List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID);
59 62
60 SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); 63 GridRegion GetRegionByUUID(UUID scopeID, UUID regionID);
61 64
62 /// <summary> 65 /// <summary>
63 /// Get the region at the given position (in meters) 66 /// Get the region at the given position (in meters)
@@ -66,9 +69,9 @@ namespace OpenSim.Services.Interfaces
66 /// <param name="x"></param> 69 /// <param name="x"></param>
67 /// <param name="y"></param> 70 /// <param name="y"></param>
68 /// <returns></returns> 71 /// <returns></returns>
69 SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); 72 GridRegion GetRegionByPosition(UUID scopeID, int x, int y);
70 73
71 SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName); 74 GridRegion GetRegionByName(UUID scopeID, string regionName);
72 75
73 /// <summary> 76 /// <summary>
74 /// Get information about regions starting with the provided name. 77 /// Get information about regions starting with the provided name.
@@ -83,9 +86,233 @@ namespace OpenSim.Services.Interfaces
83 /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the 86 /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the
84 /// grid-server couldn't be contacted or returned an error, return null. 87 /// grid-server couldn't be contacted or returned an error, return null.
85 /// </returns> 88 /// </returns>
86 List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber); 89 List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber);
87 90
88 List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); 91 List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax);
89 92
90 } 93 }
94
95 public class GridRegion
96 {
97
98 /// <summary>
99 /// The port by which http communication occurs with the region
100 /// </summary>
101 public uint HttpPort
102 {
103 get { return m_httpPort; }
104 set { m_httpPort = value; }
105 }
106 protected uint m_httpPort;
107
108 /// <summary>
109 /// A well-formed URI for the host region server (namely "http://" + ExternalHostName)
110 /// </summary>
111 public string ServerURI
112 {
113 get { return m_serverURI; }
114 set { m_serverURI = value; }
115 }
116 protected string m_serverURI;
117
118 public string RegionName
119 {
120 get { return m_regionName; }
121 set { m_regionName = value; }
122 }
123 protected string m_regionName = String.Empty;
124
125 protected bool Allow_Alternate_Ports;
126 public bool m_allow_alternate_ports;
127
128 protected string m_externalHostName;
129
130 protected IPEndPoint m_internalEndPoint;
131
132 public int RegionLocX
133 {
134 get { return m_regionLocX; }
135 set { m_regionLocX = value; }
136 }
137 protected int m_regionLocX;
138
139 public int RegionLocY
140 {
141 get { return m_regionLocY; }
142 set { m_regionLocY = value; }
143 }
144 protected int m_regionLocY;
145
146 public UUID RegionID = UUID.Zero;
147 public UUID ScopeID = UUID.Zero;
148
149 public GridRegion()
150 {
151 }
152
153 public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri)
154 {
155 m_regionLocX = regionLocX;
156 m_regionLocY = regionLocY;
157
158 m_internalEndPoint = internalEndPoint;
159 m_externalHostName = externalUri;
160 }
161
162 public GridRegion(int regionLocX, int regionLocY, string externalUri, uint port)
163 {
164 m_regionLocX = regionLocX;
165 m_regionLocY = regionLocY;
166
167 m_externalHostName = externalUri;
168
169 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port);
170 }
171
172 public GridRegion(uint xcell, uint ycell)
173 {
174 m_regionLocX = (int)(xcell * Constants.RegionSize);
175 m_regionLocY = (int)(ycell * Constants.RegionSize);
176 }
177
178 public GridRegion(RegionInfo ConvertFrom)
179 {
180 m_regionName = ConvertFrom.RegionName;
181 m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize);
182 m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize);
183 m_internalEndPoint = ConvertFrom.InternalEndPoint;
184 m_externalHostName = ConvertFrom.ExternalHostName;
185 m_httpPort = ConvertFrom.HttpPort;
186 m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
187 RegionID = UUID.Zero;
188 ServerURI = ConvertFrom.ServerURI;
189 }
190
191
192 /// <value>
193 /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.
194 ///
195 /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method?
196 /// </value>
197 public IPEndPoint ExternalEndPoint
198 {
199 get
200 {
201 // Old one defaults to IPv6
202 //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port);
203
204 IPAddress ia = null;
205 // If it is already an IP, don't resolve it - just return directly
206 if (IPAddress.TryParse(m_externalHostName, out ia))
207 return new IPEndPoint(ia, m_internalEndPoint.Port);
208
209 // Reset for next check
210 ia = null;
211 try
212 {
213 foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
214 {
215 if (ia == null)
216 ia = Adr;
217
218 if (Adr.AddressFamily == AddressFamily.InterNetwork)
219 {
220 ia = Adr;
221 break;
222 }
223 }
224 }
225 catch (SocketException e)
226 {
227 throw new Exception(
228 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
229 e + "' attached to this exception", e);
230 }
231
232 return new IPEndPoint(ia, m_internalEndPoint.Port);
233 }
234
235 set { m_externalHostName = value.ToString(); }
236 }
237
238 public string ExternalHostName
239 {
240 get { return m_externalHostName; }
241 set { m_externalHostName = value; }
242 }
243
244 public IPEndPoint InternalEndPoint
245 {
246 get { return m_internalEndPoint; }
247 set { m_internalEndPoint = value; }
248 }
249
250 public ulong RegionHandle
251 {
252 get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); }
253 }
254
255 public int getInternalEndPointPort()
256 {
257 return m_internalEndPoint.Port;
258 }
259
260 public Dictionary<string, object> ToKeyValuePairs()
261 {
262 Dictionary<string, object> kvp = new Dictionary<string, object>();
263 kvp["uuid"] = RegionID.ToString();
264 kvp["locX"] = RegionLocX.ToString();
265 kvp["locY"] = RegionLocY.ToString();
266 kvp["regionName"] = RegionName;
267 kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString();
268 kvp["serverHttpPort"] = HttpPort.ToString();
269 kvp["serverURI"] = ServerURI;
270 kvp["serverPort"] = InternalEndPoint.Port.ToString();
271
272 return kvp;
273 }
274
275 public GridRegion(Dictionary<string, object> kvp)
276 {
277 if (kvp.ContainsKey("uuid"))
278 RegionID = new UUID((string)kvp["uuid"]);
279
280 if (kvp.ContainsKey("locX"))
281 RegionLocX = Convert.ToInt32((string)kvp["locX"]);
282
283 if (kvp.ContainsKey("locY"))
284 RegionLocY = Convert.ToInt32((string)kvp["locY"]);
285
286 if (kvp.ContainsKey("regionName"))
287 RegionName = (string)kvp["regionName"];
288
289 if (kvp.ContainsKey("serverIP"))
290 {
291 //int port = 0;
292 //Int32.TryParse((string)kvp["serverPort"], out port);
293 //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port);
294 ExternalHostName = (string)kvp["serverIP"];
295 }
296 else
297 ExternalHostName = "127.0.0.1";
298
299 if (kvp.ContainsKey("serverPort"))
300 {
301 Int32 port = 0;
302 Int32.TryParse((string)kvp["serverPort"], out port);
303 InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
304 }
305
306 if (kvp.ContainsKey("serverHttpPort"))
307 {
308 UInt32 port = 0;
309 UInt32.TryParse((string)kvp["serverHttpPort"], out port);
310 HttpPort = port;
311 }
312
313 if (kvp.ContainsKey("serverURI"))
314 ServerURI = (string)kvp["serverURI"];
315 }
316 }
317
91} 318}