aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Interfaces/IGridService.cs
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Services/Interfaces/IGridService.cs
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Services/Interfaces/IGridService.cs')
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs286
1 files changed, 184 insertions, 102 deletions
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index d7da056..f5f1f75 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -26,12 +26,17 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Net; 31using System.Net;
31using System.Net.Sockets; 32using System.Net.Sockets;
33using System.Reflection;
34
32using OpenSim.Framework; 35using OpenSim.Framework;
33using OpenMetaverse; 36using OpenMetaverse;
34 37
38using log4net;
39
35namespace OpenSim.Services.Interfaces 40namespace OpenSim.Services.Interfaces
36{ 41{
37 public interface IGridService 42 public interface IGridService
@@ -97,6 +102,7 @@ namespace OpenSim.Services.Interfaces
97 List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); 102 List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax);
98 103
99 List<GridRegion> GetDefaultRegions(UUID scopeID); 104 List<GridRegion> GetDefaultRegions(UUID scopeID);
105 List<GridRegion> GetDefaultHypergridRegions(UUID scopeID);
100 List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y); 106 List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y);
101 List<GridRegion> GetHyperlinks(UUID scopeID); 107 List<GridRegion> GetHyperlinks(UUID scopeID);
102 108
@@ -114,19 +120,28 @@ namespace OpenSim.Services.Interfaces
114 /// <param name='scopeID'></param> 120 /// <param name='scopeID'></param>
115 /// <param name='regionID'></param> 121 /// <param name='regionID'></param>
116 int GetRegionFlags(UUID scopeID, UUID regionID); 122 int GetRegionFlags(UUID scopeID, UUID regionID);
123
124 Dictionary<string,object> GetExtraFeatures();
125 }
126
127 public interface IHypergridLinker
128 {
129 GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason);
130 bool TryUnlinkRegion(string mapName);
117 } 131 }
118 132
119 public class GridRegion 133 public class GridRegion
120 { 134 {
135// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
136
137#pragma warning disable 414
138 private static readonly string LogHeader = "[GRID REGION]";
139#pragma warning restore 414
140
121 /// <summary> 141 /// <summary>
122 /// The port by which http communication occurs with the region 142 /// The port by which http communication occurs with the region
123 /// </summary> 143 /// </summary>
124 public uint HttpPort 144 public uint HttpPort { get; set; }
125 {
126 get { return m_httpPort; }
127 set { m_httpPort = value; }
128 }
129 protected uint m_httpPort;
130 145
131 /// <summary> 146 /// <summary>
132 /// A well-formed URI for the host region server (namely "http://" + ExternalHostName) 147 /// A well-formed URI for the host region server (namely "http://" + ExternalHostName)
@@ -134,14 +149,17 @@ namespace OpenSim.Services.Interfaces
134 public string ServerURI 149 public string ServerURI
135 { 150 {
136 get { 151 get {
137 if ( m_serverURI != string.Empty ) { 152 if (!String.IsNullOrEmpty(m_serverURI)) {
138 return m_serverURI; 153 return m_serverURI;
139 } else { 154 } else {
140 return "http://" + m_externalHostName + ":" + m_httpPort + "/"; 155 if (HttpPort == 0)
156 return "http://" + m_externalHostName + "/";
157 else
158 return "http://" + m_externalHostName + ":" + HttpPort + "/";
141 } 159 }
142 } 160 }
143 set { 161 set {
144 if ( value.EndsWith("/") ) { 162 if (value.EndsWith("/")) {
145 m_serverURI = value; 163 m_serverURI = value;
146 } else { 164 } else {
147 m_serverURI = value + '/'; 165 m_serverURI = value + '/';
@@ -150,6 +168,16 @@ namespace OpenSim.Services.Interfaces
150 } 168 }
151 protected string m_serverURI; 169 protected string m_serverURI;
152 170
171 /// <summary>
172 /// Provides direct access to the 'm_serverURI' field, without returning a generated URL if m_serverURI is missing.
173 /// </summary>
174 public string RawServerURI
175 {
176 get { return m_serverURI; }
177 set { m_serverURI = value; }
178 }
179
180
153 public string RegionName 181 public string RegionName
154 { 182 {
155 get { return m_regionName; } 183 get { return m_regionName; }
@@ -157,22 +185,34 @@ namespace OpenSim.Services.Interfaces
157 } 185 }
158 protected string m_regionName = String.Empty; 186 protected string m_regionName = String.Empty;
159 187
188 /// <summary>
189 /// Region flags.
190 /// </summary>
191 /// <remarks>
192 /// If not set (chiefly if a robust service is running code pre OpenSim 0.8.1) then this will be null and
193 /// should be ignored. If you require flags information please use the separate IGridService.GetRegionFlags() call
194 /// XXX: This field is currently ignored when used in RegisterRegion, but could potentially be
195 /// used to set flags at this point.
196 /// </remarks>
197 public OpenSim.Framework.RegionFlags? RegionFlags { get; set; }
198
160 protected string m_externalHostName; 199 protected string m_externalHostName;
161 200
162 protected IPEndPoint m_internalEndPoint; 201 protected IPEndPoint m_internalEndPoint;
163 202
164 /// <summary> 203 /// <summary>
165 /// The co-ordinate of this region. 204 /// The co-ordinate of this region in region units.
166 /// </summary> 205 /// </summary>
167 public int RegionCoordX { get { return RegionLocX / (int)Constants.RegionSize; } } 206 public int RegionCoordX { get { return (int)Util.WorldToRegionLoc((uint)RegionLocX); } }
168 207
169 /// <summary> 208 /// <summary>
170 /// The co-ordinate of this region 209 /// The co-ordinate of this region in region units
171 /// </summary> 210 /// </summary>
172 public int RegionCoordY { get { return RegionLocY / (int)Constants.RegionSize; } } 211 public int RegionCoordY { get { return (int)Util.WorldToRegionLoc((uint)RegionLocY); } }
173 212
174 /// <summary> 213 /// <summary>
175 /// The location of this region in meters. 214 /// The location of this region in meters.
215 /// DANGER DANGER! Note that this name means something different in RegionInfo.
176 /// </summary> 216 /// </summary>
177 public int RegionLocX 217 public int RegionLocX
178 { 218 {
@@ -181,8 +221,12 @@ namespace OpenSim.Services.Interfaces
181 } 221 }
182 protected int m_regionLocX; 222 protected int m_regionLocX;
183 223
224 public int RegionSizeX { get; set; }
225 public int RegionSizeY { get; set; }
226
184 /// <summary> 227 /// <summary>
185 /// The location of this region in meters. 228 /// The location of this region in meters.
229 /// DANGER DANGER! Note that this name means something different in RegionInfo.
186 /// </summary> 230 /// </summary>
187 public int RegionLocY 231 public int RegionLocY
188 { 232 {
@@ -211,13 +255,18 @@ namespace OpenSim.Services.Interfaces
211 255
212 public GridRegion() 256 public GridRegion()
213 { 257 {
258 RegionSizeX = (int)Constants.RegionSize;
259 RegionSizeY = (int)Constants.RegionSize;
214 m_serverURI = string.Empty; 260 m_serverURI = string.Empty;
215 } 261 }
216 262
263 /*
217 public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri) 264 public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri)
218 { 265 {
219 m_regionLocX = regionLocX; 266 m_regionLocX = regionLocX;
220 m_regionLocY = regionLocY; 267 m_regionLocY = regionLocY;
268 RegionSizeX = (int)Constants.RegionSize;
269 RegionSizeY = (int)Constants.RegionSize;
221 270
222 m_internalEndPoint = internalEndPoint; 271 m_internalEndPoint = internalEndPoint;
223 m_externalHostName = externalUri; 272 m_externalHostName = externalUri;
@@ -227,26 +276,33 @@ namespace OpenSim.Services.Interfaces
227 { 276 {
228 m_regionLocX = regionLocX; 277 m_regionLocX = regionLocX;
229 m_regionLocY = regionLocY; 278 m_regionLocY = regionLocY;
279 RegionSizeX = (int)Constants.RegionSize;
280 RegionSizeY = (int)Constants.RegionSize;
230 281
231 m_externalHostName = externalUri; 282 m_externalHostName = externalUri;
232 283
233 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port); 284 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port);
234 } 285 }
286 */
235 287
236 public GridRegion(uint xcell, uint ycell) 288 public GridRegion(uint xcell, uint ycell)
237 { 289 {
238 m_regionLocX = (int)(xcell * Constants.RegionSize); 290 m_regionLocX = (int)Util.RegionToWorldLoc(xcell);
239 m_regionLocY = (int)(ycell * Constants.RegionSize); 291 m_regionLocY = (int)Util.RegionToWorldLoc(ycell);
292 RegionSizeX = (int)Constants.RegionSize;
293 RegionSizeY = (int)Constants.RegionSize;
240 } 294 }
241 295
242 public GridRegion(RegionInfo ConvertFrom) 296 public GridRegion(RegionInfo ConvertFrom)
243 { 297 {
244 m_regionName = ConvertFrom.RegionName; 298 m_regionName = ConvertFrom.RegionName;
245 m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize); 299 m_regionLocX = (int)(ConvertFrom.WorldLocX);
246 m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize); 300 m_regionLocY = (int)(ConvertFrom.WorldLocY);
301 RegionSizeX = (int)ConvertFrom.RegionSizeX;
302 RegionSizeY = (int)ConvertFrom.RegionSizeY;
247 m_internalEndPoint = ConvertFrom.InternalEndPoint; 303 m_internalEndPoint = ConvertFrom.InternalEndPoint;
248 m_externalHostName = ConvertFrom.ExternalHostName; 304 m_externalHostName = ConvertFrom.ExternalHostName;
249 m_httpPort = ConvertFrom.HttpPort; 305 HttpPort = ConvertFrom.HttpPort;
250 RegionID = ConvertFrom.RegionID; 306 RegionID = ConvertFrom.RegionID;
251 ServerURI = ConvertFrom.ServerURI; 307 ServerURI = ConvertFrom.ServerURI;
252 TerrainImage = ConvertFrom.RegionSettings.TerrainImageID; 308 TerrainImage = ConvertFrom.RegionSettings.TerrainImageID;
@@ -260,11 +316,14 @@ namespace OpenSim.Services.Interfaces
260 public GridRegion(GridRegion ConvertFrom) 316 public GridRegion(GridRegion ConvertFrom)
261 { 317 {
262 m_regionName = ConvertFrom.RegionName; 318 m_regionName = ConvertFrom.RegionName;
319 RegionFlags = ConvertFrom.RegionFlags;
263 m_regionLocX = ConvertFrom.RegionLocX; 320 m_regionLocX = ConvertFrom.RegionLocX;
264 m_regionLocY = ConvertFrom.RegionLocY; 321 m_regionLocY = ConvertFrom.RegionLocY;
322 RegionSizeX = ConvertFrom.RegionSizeX;
323 RegionSizeY = ConvertFrom.RegionSizeY;
265 m_internalEndPoint = ConvertFrom.InternalEndPoint; 324 m_internalEndPoint = ConvertFrom.InternalEndPoint;
266 m_externalHostName = ConvertFrom.ExternalHostName; 325 m_externalHostName = ConvertFrom.ExternalHostName;
267 m_httpPort = ConvertFrom.HttpPort; 326 HttpPort = ConvertFrom.HttpPort;
268 RegionID = ConvertFrom.RegionID; 327 RegionID = ConvertFrom.RegionID;
269 ServerURI = ConvertFrom.ServerURI; 328 ServerURI = ConvertFrom.ServerURI;
270 TerrainImage = ConvertFrom.TerrainImage; 329 TerrainImage = ConvertFrom.TerrainImage;
@@ -274,8 +333,112 @@ namespace OpenSim.Services.Interfaces
274 RegionSecret = ConvertFrom.RegionSecret; 333 RegionSecret = ConvertFrom.RegionSecret;
275 EstateOwner = ConvertFrom.EstateOwner; 334 EstateOwner = ConvertFrom.EstateOwner;
276 } 335 }
336
337 public GridRegion(Dictionary<string, object> kvp)
338 {
339 if (kvp.ContainsKey("uuid"))
340 RegionID = new UUID((string)kvp["uuid"]);
341
342 if (kvp.ContainsKey("locX"))
343 RegionLocX = Convert.ToInt32((string)kvp["locX"]);
344
345 if (kvp.ContainsKey("locY"))
346 RegionLocY = Convert.ToInt32((string)kvp["locY"]);
347
348 if (kvp.ContainsKey("sizeX"))
349 RegionSizeX = Convert.ToInt32((string)kvp["sizeX"]);
350 else
351 RegionSizeX = (int)Constants.RegionSize;
352
353 if (kvp.ContainsKey("sizeY"))
354 RegionSizeY = Convert.ToInt32((string)kvp["sizeY"]);
355 else
356 RegionSizeX = (int)Constants.RegionSize;
357
358 if (kvp.ContainsKey("regionName"))
359 RegionName = (string)kvp["regionName"];
360
361 if (kvp.ContainsKey("flags") && kvp["flags"] != null)
362 RegionFlags = (OpenSim.Framework.RegionFlags?)Convert.ToInt32((string)kvp["flags"]);
363
364 if (kvp.ContainsKey("serverIP"))
365 {
366 //int port = 0;
367 //Int32.TryParse((string)kvp["serverPort"], out port);
368 //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port);
369 ExternalHostName = (string)kvp["serverIP"];
370 }
371 else
372 ExternalHostName = "127.0.0.1";
373
374 if (kvp.ContainsKey("serverPort"))
375 {
376 Int32 port = 0;
377 Int32.TryParse((string)kvp["serverPort"], out port);
378 InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
379 }
380
381 if (kvp.ContainsKey("serverHttpPort"))
382 {
383 UInt32 port = 0;
384 UInt32.TryParse((string)kvp["serverHttpPort"], out port);
385 HttpPort = port;
386 }
387
388 if (kvp.ContainsKey("serverURI"))
389 ServerURI = (string)kvp["serverURI"];
390
391 if (kvp.ContainsKey("regionMapTexture"))
392 UUID.TryParse((string)kvp["regionMapTexture"], out TerrainImage);
393
394 if (kvp.ContainsKey("parcelMapTexture"))
395 UUID.TryParse((string)kvp["parcelMapTexture"], out ParcelImage);
396
397 if (kvp.ContainsKey("access"))
398 Access = Byte.Parse((string)kvp["access"]);
399
400 if (kvp.ContainsKey("regionSecret"))
401 RegionSecret =(string)kvp["regionSecret"];
402
403 if (kvp.ContainsKey("owner_uuid"))
404 EstateOwner = new UUID(kvp["owner_uuid"].ToString());
405
406 if (kvp.ContainsKey("Token"))
407 Token = kvp["Token"].ToString();
408
409 // m_log.DebugFormat("{0} New GridRegion. id={1}, loc=<{2},{3}>, size=<{4},{5}>",
410 // LogHeader, RegionID, RegionLocX, RegionLocY, RegionSizeX, RegionSizeY);
411 }
412
413 public Dictionary<string, object> ToKeyValuePairs()
414 {
415 Dictionary<string, object> kvp = new Dictionary<string, object>();
416 kvp["uuid"] = RegionID.ToString();
417 kvp["locX"] = RegionLocX.ToString();
418 kvp["locY"] = RegionLocY.ToString();
419 kvp["sizeX"] = RegionSizeX.ToString();
420 kvp["sizeY"] = RegionSizeY.ToString();
421 kvp["regionName"] = RegionName;
277 422
278 # region Definition of equality 423 if (RegionFlags != null)
424 kvp["flags"] = ((int)RegionFlags).ToString();
425
426 kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString();
427 kvp["serverHttpPort"] = HttpPort.ToString();
428 kvp["serverURI"] = ServerURI;
429 kvp["serverPort"] = InternalEndPoint.Port.ToString();
430 kvp["regionMapTexture"] = TerrainImage.ToString();
431 kvp["parcelMapTexture"] = ParcelImage.ToString();
432 kvp["access"] = Access.ToString();
433 kvp["regionSecret"] = RegionSecret;
434 kvp["owner_uuid"] = EstateOwner.ToString();
435 kvp["Token"] = Token.ToString();
436 // Maturity doesn't seem to exist in the DB
437
438 return kvp;
439 }
440
441 #region Definition of equality
279 442
280 /// <summary> 443 /// <summary>
281 /// Define equality as two regions having the same, non-zero UUID. 444 /// Define equality as two regions having the same, non-zero UUID.
@@ -362,86 +525,5 @@ namespace OpenSim.Services.Interfaces
362 { 525 {
363 get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); } 526 get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); }
364 } 527 }
365
366 public Dictionary<string, object> ToKeyValuePairs()
367 {
368 Dictionary<string, object> kvp = new Dictionary<string, object>();
369 kvp["uuid"] = RegionID.ToString();
370 kvp["locX"] = RegionLocX.ToString();
371 kvp["locY"] = RegionLocY.ToString();
372 kvp["regionName"] = RegionName;
373 kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString();
374 kvp["serverHttpPort"] = HttpPort.ToString();
375 kvp["serverURI"] = ServerURI;
376 kvp["serverPort"] = InternalEndPoint.Port.ToString();
377 kvp["regionMapTexture"] = TerrainImage.ToString();
378 kvp["parcelMapTexture"] = ParcelImage.ToString();
379 kvp["access"] = Access.ToString();
380 kvp["regionSecret"] = RegionSecret;
381 kvp["owner_uuid"] = EstateOwner.ToString();
382 kvp["Token"] = Token.ToString();
383 // Maturity doesn't seem to exist in the DB
384 return kvp;
385 }
386
387 public GridRegion(Dictionary<string, object> kvp)
388 {
389 if (kvp.ContainsKey("uuid"))
390 RegionID = new UUID((string)kvp["uuid"]);
391
392 if (kvp.ContainsKey("locX"))
393 RegionLocX = Convert.ToInt32((string)kvp["locX"]);
394
395 if (kvp.ContainsKey("locY"))
396 RegionLocY = Convert.ToInt32((string)kvp["locY"]);
397
398 if (kvp.ContainsKey("regionName"))
399 RegionName = (string)kvp["regionName"];
400
401 if (kvp.ContainsKey("serverIP"))
402 {
403 //int port = 0;
404 //Int32.TryParse((string)kvp["serverPort"], out port);
405 //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port);
406 ExternalHostName = (string)kvp["serverIP"];
407 }
408 else
409 ExternalHostName = "127.0.0.1";
410
411 if (kvp.ContainsKey("serverPort"))
412 {
413 Int32 port = 0;
414 Int32.TryParse((string)kvp["serverPort"], out port);
415 InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
416 }
417
418 if (kvp.ContainsKey("serverHttpPort"))
419 {
420 UInt32 port = 0;
421 UInt32.TryParse((string)kvp["serverHttpPort"], out port);
422 HttpPort = port;
423 }
424
425 if (kvp.ContainsKey("serverURI"))
426 ServerURI = (string)kvp["serverURI"];
427
428 if (kvp.ContainsKey("regionMapTexture"))
429 UUID.TryParse((string)kvp["regionMapTexture"], out TerrainImage);
430
431 if (kvp.ContainsKey("parcelMapTexture"))
432 UUID.TryParse((string)kvp["parcelMapTexture"], out ParcelImage);
433
434 if (kvp.ContainsKey("access"))
435 Access = Byte.Parse((string)kvp["access"]);
436
437 if (kvp.ContainsKey("regionSecret"))
438 RegionSecret =(string)kvp["regionSecret"];
439
440 if (kvp.ContainsKey("owner_uuid"))
441 EstateOwner = new UUID(kvp["owner_uuid"].ToString());
442
443 if (kvp.ContainsKey("Token"))
444 Token = kvp["Token"].ToString();
445 }
446 } 528 }
447} 529} \ No newline at end of file