diff options
author | Marck | 2010-08-06 07:46:19 +0200 |
---|---|---|
committer | Diva Canto | 2010-08-06 17:02:03 -0700 |
commit | 7e47ab746ef588648b8edbbc7cfb48c4d90c5e34 (patch) | |
tree | 0ba450dffb35724504634f88cc21b9c59a983130 /OpenSim | |
parent | Remove old test classes that don't actually test anything not done elsewhere (diff) | |
download | opensim-SC-7e47ab746ef588648b8edbbc7cfb48c4d90c5e34.zip opensim-SC-7e47ab746ef588648b8edbbc7cfb48c4d90c5e34.tar.gz opensim-SC-7e47ab746ef588648b8edbbc7cfb48c4d90c5e34.tar.bz2 opensim-SC-7e47ab746ef588648b8edbbc7cfb48c4d90c5e34.tar.xz |
Allow creation of link regions if there is an existing region within a 4096 range.
Also add GetHyperlinks() to the grid service.
Diffstat (limited to '')
8 files changed, 146 insertions, 4 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index b2e3f4f..9ea04d4 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs | |||
@@ -233,6 +233,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
233 | return m_GridService.GetFallbackRegions(scopeID, x, y); | 233 | return m_GridService.GetFallbackRegions(scopeID, x, y); |
234 | } | 234 | } |
235 | 235 | ||
236 | public List<GridRegion> GetHyperlinks(UUID scopeID) | ||
237 | { | ||
238 | return m_GridService.GetHyperlinks(scopeID); | ||
239 | } | ||
240 | |||
236 | public int GetRegionFlags(UUID scopeID, UUID regionID) | 241 | public int GetRegionFlags(UUID scopeID, UUID regionID) |
237 | { | 242 | { |
238 | return m_GridService.GetRegionFlags(scopeID, regionID); | 243 | return m_GridService.GetRegionFlags(scopeID, regionID); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index 95d8737..1366980 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | |||
@@ -136,6 +136,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | |||
136 | 900 * (int)Constants.RegionSize, 1100 * (int)Constants.RegionSize); | 136 | 900 * (int)Constants.RegionSize, 1100 * (int)Constants.RegionSize); |
137 | Assert.IsNotNull(results, "Retrieved GetRegionRange list is null"); | 137 | Assert.IsNotNull(results, "Retrieved GetRegionRange list is null"); |
138 | Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected"); | 138 | Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected"); |
139 | |||
140 | results = m_LocalConnector.GetHyperlinks(UUID.Zero); | ||
141 | Assert.IsNotNull(results, "Retrieved GetHyperlinks list is null"); | ||
142 | Assert.That(results.Count, Is.EqualTo(0), "Retrieved linked regions collection is not the number expected"); | ||
143 | |||
139 | } | 144 | } |
140 | } | 145 | } |
141 | } | 146 | } |
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index c90dd6f..913c6c9 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | |||
@@ -109,6 +109,9 @@ namespace OpenSim.Server.Handlers.Grid | |||
109 | case "get_fallback_regions": | 109 | case "get_fallback_regions": |
110 | return GetFallbackRegions(request); | 110 | return GetFallbackRegions(request); |
111 | 111 | ||
112 | case "get_hyperlinks": | ||
113 | return GetHyperlinks(request); | ||
114 | |||
112 | case "get_region_flags": | 115 | case "get_region_flags": |
113 | return GetRegionFlags(request); | 116 | return GetRegionFlags(request); |
114 | } | 117 | } |
@@ -483,6 +486,36 @@ namespace OpenSim.Server.Handlers.Grid | |||
483 | return encoding.GetBytes(xmlString); | 486 | return encoding.GetBytes(xmlString); |
484 | } | 487 | } |
485 | 488 | ||
489 | byte[] GetHyperlinks(Dictionary<string, object> request) | ||
490 | { | ||
491 | //m_log.DebugFormat("[GRID HANDLER]: GetHyperlinks"); | ||
492 | UUID scopeID = UUID.Zero; | ||
493 | if (request.ContainsKey("SCOPEID")) | ||
494 | UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); | ||
495 | else | ||
496 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get linked regions"); | ||
497 | |||
498 | List<GridRegion> rinfos = m_GridService.GetHyperlinks(scopeID); | ||
499 | |||
500 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
501 | if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) | ||
502 | result["result"] = "null"; | ||
503 | else | ||
504 | { | ||
505 | int i = 0; | ||
506 | foreach (GridRegion rinfo in rinfos) | ||
507 | { | ||
508 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | ||
509 | result["region" + i] = rinfoDict; | ||
510 | i++; | ||
511 | } | ||
512 | } | ||
513 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
514 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
515 | UTF8Encoding encoding = new UTF8Encoding(); | ||
516 | return encoding.GetBytes(xmlString); | ||
517 | } | ||
518 | |||
486 | byte[] GetRegionFlags(Dictionary<string, object> request) | 519 | byte[] GetRegionFlags(Dictionary<string, object> request) |
487 | { | 520 | { |
488 | UUID scopeID = UUID.Zero; | 521 | UUID scopeID = UUID.Zero; |
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 1831533..202bad7 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | |||
@@ -556,6 +556,56 @@ namespace OpenSim.Services.Connectors | |||
556 | return rinfos; | 556 | return rinfos; |
557 | } | 557 | } |
558 | 558 | ||
559 | public List<GridRegion> GetHyperlinks(UUID scopeID) | ||
560 | { | ||
561 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
562 | |||
563 | sendData["SCOPEID"] = scopeID.ToString(); | ||
564 | |||
565 | sendData["METHOD"] = "get_hyperlinks"; | ||
566 | |||
567 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
568 | string reply = string.Empty; | ||
569 | try | ||
570 | { | ||
571 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
572 | m_ServerURI + "/grid", | ||
573 | ServerUtils.BuildQueryString(sendData)); | ||
574 | |||
575 | //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); | ||
576 | } | ||
577 | catch (Exception e) | ||
578 | { | ||
579 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
580 | return rinfos; | ||
581 | } | ||
582 | |||
583 | if (reply != string.Empty) | ||
584 | { | ||
585 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
586 | |||
587 | if (replyData != null) | ||
588 | { | ||
589 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; | ||
590 | foreach (object r in rinfosList) | ||
591 | { | ||
592 | if (r is Dictionary<string, object>) | ||
593 | { | ||
594 | GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); | ||
595 | rinfos.Add(rinfo); | ||
596 | } | ||
597 | } | ||
598 | } | ||
599 | else | ||
600 | m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks {0} received null response", | ||
601 | scopeID); | ||
602 | } | ||
603 | else | ||
604 | m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks received null reply"); | ||
605 | |||
606 | return rinfos; | ||
607 | } | ||
608 | |||
559 | public virtual int GetRegionFlags(UUID scopeID, UUID regionID) | 609 | public virtual int GetRegionFlags(UUID scopeID, UUID regionID) |
560 | { | 610 | { |
561 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | 611 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs index bea8172..7bc85c6 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs | |||
@@ -357,6 +357,12 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
357 | return new List<GridRegion>(0); | 357 | return new List<GridRegion>(0); |
358 | } | 358 | } |
359 | 359 | ||
360 | public List<GridRegion> GetHyperlinks(UUID scopeID) | ||
361 | { | ||
362 | // Hypergrid/linked regions are not supported | ||
363 | return new List<GridRegion>(); | ||
364 | } | ||
365 | |||
360 | public int GetRegionFlags(UUID scopeID, UUID regionID) | 366 | public int GetRegionFlags(UUID scopeID, UUID regionID) |
361 | { | 367 | { |
362 | const int REGION_ONLINE = 4; | 368 | const int REGION_ONLINE = 4; |
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index ebaed42..79a45fe 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -426,6 +426,22 @@ namespace OpenSim.Services.GridService | |||
426 | return ret; | 426 | return ret; |
427 | } | 427 | } |
428 | 428 | ||
429 | public List<GridRegion> GetHyperlinks(UUID scopeID) | ||
430 | { | ||
431 | List<GridRegion> ret = new List<GridRegion>(); | ||
432 | |||
433 | List<RegionData> regions = m_Database.GetHyperlinks(scopeID); | ||
434 | |||
435 | foreach (RegionData r in regions) | ||
436 | { | ||
437 | if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) | ||
438 | ret.Add(RegionData2RegionInfo(r)); | ||
439 | } | ||
440 | |||
441 | m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count); | ||
442 | return ret; | ||
443 | } | ||
444 | |||
429 | public int GetRegionFlags(UUID scopeID, UUID regionID) | 445 | public int GetRegionFlags(UUID scopeID, UUID regionID) |
430 | { | 446 | { |
431 | RegionData region = m_Database.Get(regionID, scopeID); | 447 | RegionData region = m_Database.Get(regionID, scopeID); |
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 1f53007..017df41 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Linq; | ||
30 | using System.Net; | 31 | using System.Net; |
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using System.Xml; | 33 | using System.Xml; |
@@ -332,18 +333,43 @@ namespace OpenSim.Services.GridService | |||
332 | /// <returns></returns> | 333 | /// <returns></returns> |
333 | public bool Check4096(ulong realHandle, out uint x, out uint y) | 334 | public bool Check4096(ulong realHandle, out uint x, out uint y) |
334 | { | 335 | { |
335 | GridRegion defRegion = DefaultRegion; | ||
336 | |||
337 | uint ux = 0, uy = 0; | 336 | uint ux = 0, uy = 0; |
338 | Utils.LongToUInts(realHandle, out ux, out uy); | 337 | Utils.LongToUInts(realHandle, out ux, out uy); |
339 | x = ux / Constants.RegionSize; | 338 | x = ux / Constants.RegionSize; |
340 | y = uy / Constants.RegionSize; | 339 | y = uy / Constants.RegionSize; |
341 | 340 | ||
342 | if ((Math.Abs((int)defRegion.RegionLocX - ux) >= 4096 * Constants.RegionSize) || | 341 | const uint limit = (4096 - 1) * Constants.RegionSize; |
343 | (Math.Abs((int)defRegion.RegionLocY - uy) >= 4096 * Constants.RegionSize)) | 342 | uint xmin = ux - limit; |
343 | uint xmax = ux + limit; | ||
344 | uint ymin = uy - limit; | ||
345 | uint ymax = uy + limit; | ||
346 | // World map boundary checks | ||
347 | if (xmin < 0 || xmin > ux) | ||
348 | xmin = 0; | ||
349 | if (xmax > int.MaxValue || xmax < ux) | ||
350 | xmax = int.MaxValue; | ||
351 | if (ymin < 0 || ymin > uy) | ||
352 | ymin = 0; | ||
353 | if (ymax > int.MaxValue || ymax < uy) | ||
354 | ymax = int.MaxValue; | ||
355 | |||
356 | // Check for any regions that are within the possible teleport range to the linked region | ||
357 | List<GridRegion> regions = m_GridService.GetRegionRange(m_ScopeID, (int)xmin, (int)xmax, (int)ymin, (int)ymax); | ||
358 | if (regions.Count == 0) | ||
359 | { | ||
360 | return false; | ||
361 | } | ||
362 | else | ||
363 | { | ||
364 | // Check for regions which are not linked regions | ||
365 | List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); | ||
366 | IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks); | ||
367 | if (availableRegions.Count() == 0) | ||
344 | { | 368 | { |
345 | return false; | 369 | return false; |
346 | } | 370 | } |
371 | } | ||
372 | |||
347 | return true; | 373 | return true; |
348 | } | 374 | } |
349 | 375 | ||
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index e55b633..77230a3 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs | |||
@@ -92,6 +92,7 @@ namespace OpenSim.Services.Interfaces | |||
92 | 92 | ||
93 | List<GridRegion> GetDefaultRegions(UUID scopeID); | 93 | List<GridRegion> GetDefaultRegions(UUID scopeID); |
94 | List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y); | 94 | List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y); |
95 | List<GridRegion> GetHyperlinks(UUID scopeID); | ||
95 | 96 | ||
96 | int GetRegionFlags(UUID scopeID, UUID regionID); | 97 | int GetRegionFlags(UUID scopeID, UUID regionID); |
97 | } | 98 | } |