aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/GridService/HypergridLinker.cs
diff options
context:
space:
mode:
authorMarck2010-10-27 19:03:56 +0200
committerDiva Canto2010-10-28 17:21:17 -0700
commit7b0d6439995cd6c192c2bc0de80a5b4dcc9bb5b0 (patch)
tree0da4c93e1005205668dffd9f0063175e933584c5 /OpenSim/Services/GridService/HypergridLinker.cs
parentFormatting cleanup. (diff)
downloadopensim-SC_OLD-7b0d6439995cd6c192c2bc0de80a5b4dcc9bb5b0.zip
opensim-SC_OLD-7b0d6439995cd6c192c2bc0de80a5b4dcc9bb5b0.tar.gz
opensim-SC_OLD-7b0d6439995cd6c192c2bc0de80a5b4dcc9bb5b0.tar.bz2
opensim-SC_OLD-7b0d6439995cd6c192c2bc0de80a5b4dcc9bb5b0.tar.xz
HypergridLinker optimizations and enable use of owner_uuid/EstateOwner with linked regions.
* Added check for already occupied region coordinates. * Optimized Check4096.
Diffstat (limited to 'OpenSim/Services/GridService/HypergridLinker.cs')
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs47
1 files changed, 27 insertions, 20 deletions
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index b86fb6f..a67404f 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Linq;
30using System.Net; 31using System.Net;
31using System.Reflection; 32using System.Reflection;
32using System.Xml; 33using System.Xml;
@@ -154,6 +155,11 @@ namespace OpenSim.Services.GridService
154 // From the command line link-region 155 // From the command line link-region
155 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason) 156 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason)
156 { 157 {
158 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
159 }
160
161 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason)
162 {
157 reason = string.Empty; 163 reason = string.Empty;
158 string host = "127.0.0.1"; 164 string host = "127.0.0.1";
159 string portstr; 165 string portstr;
@@ -189,7 +195,7 @@ namespace OpenSim.Services.GridService
189 //} 195 //}
190 196
191 GridRegion regInfo; 197 GridRegion regInfo;
192 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, out regInfo, out reason); 198 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason);
193 if (success) 199 if (success)
194 { 200 {
195 regInfo.RegionName = mapName; 201 regInfo.RegionName = mapName;
@@ -202,7 +208,8 @@ namespace OpenSim.Services.GridService
202 208
203 // From the command line and the 2 above 209 // From the command line and the 2 above
204 public bool TryCreateLink(UUID scopeID, int xloc, int yloc, 210 public bool TryCreateLink(UUID scopeID, int xloc, int yloc,
205 string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo, out string reason) 211 string externalRegionName, uint externalPort, string externalHostName, UUID ownerID,
212 out GridRegion regInfo, out string reason)
206 { 213 {
207 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}:{2}, in {3}-{4}", externalHostName, externalPort, externalRegionName, xloc, yloc); 214 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}:{2}, in {3}-{4}", externalHostName, externalPort, externalRegionName, xloc, yloc);
208 215
@@ -214,12 +221,22 @@ namespace OpenSim.Services.GridService
214 regInfo.RegionLocX = xloc; 221 regInfo.RegionLocX = xloc;
215 regInfo.RegionLocY = yloc; 222 regInfo.RegionLocY = yloc;
216 regInfo.ScopeID = scopeID; 223 regInfo.ScopeID = scopeID;
224 regInfo.EstateOwner = ownerID;
217 225
218 // Big HACK for Simian Grid !!! 226 // Big HACK for Simian Grid !!!
219 // We need to clean up all URLs used in OpenSim !!! 227 // We need to clean up all URLs used in OpenSim !!!
220 if (externalHostName.Contains("/")) 228 if (externalHostName.Contains("/"))
221 regInfo.ServerURI = externalHostName; 229 regInfo.ServerURI = externalHostName;
222 230
231 // Check for free coordinates
232 GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY);
233 if (region != null)
234 {
235 m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}", regInfo.RegionLocX, regInfo.RegionLocY, region.RegionName, region.RegionID);
236 reason = "Coordinates are already in use";
237 return false;
238 }
239
223 try 240 try
224 { 241 {
225 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); 242 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
@@ -241,11 +258,11 @@ namespace OpenSim.Services.GridService
241 258
242 if (regionID != UUID.Zero) 259 if (regionID != UUID.Zero)
243 { 260 {
244 GridRegion r = m_GridService.GetRegionByUUID(scopeID, regionID); 261 region = m_GridService.GetRegionByUUID(scopeID, regionID);
245 if (r != null) 262 if (region != null)
246 { 263 {
247 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); 264 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize);
248 regInfo = r; 265 regInfo = region;
249 return true; 266 return true;
250 } 267 }
251 268
@@ -355,17 +372,8 @@ namespace OpenSim.Services.GridService
355 { 372 {
356 // Check for regions which are not linked regions 373 // Check for regions which are not linked regions
357 List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); 374 List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID);
358 // would like to use .Except, but doesn't seem to exist 375 IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks);
359 //IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks); 376 if (availableRegions.Count() == 0)
360 List<GridRegion> availableRegions = regions.FindAll(delegate(GridRegion region)
361 {
362 // Ewww! n^2
363 if (hyperlinks.Find(delegate(GridRegion r) { return r.RegionID == region.RegionID; }) == null) // not hyperlink. good.
364 return true;
365
366 return false;
367 });
368 if (availableRegions.Count == 0)
369 return false; 377 return false;
370 } 378 }
371 379
@@ -529,7 +537,7 @@ namespace OpenSim.Services.GridService
529 xloc = xloc * (int)Constants.RegionSize; 537 xloc = xloc * (int)Constants.RegionSize;
530 yloc = yloc * (int)Constants.RegionSize; 538 yloc = yloc * (int)Constants.RegionSize;
531 string reason = string.Empty; 539 string reason = string.Empty;
532 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason)) 540 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
533 { 541 {
534 if (cmdparams.Length >= 5) 542 if (cmdparams.Length >= 5)
535 { 543 {
@@ -631,8 +639,7 @@ namespace OpenSim.Services.GridService
631 xloc = xloc * (int)Constants.RegionSize; 639 xloc = xloc * (int)Constants.RegionSize;
632 yloc = yloc * (int)Constants.RegionSize; 640 yloc = yloc * (int)Constants.RegionSize;
633 string reason = string.Empty; 641 string reason = string.Empty;
634 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, 642 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
635 externalHostName, out regInfo, out reason))
636 { 643 {
637 regInfo.RegionName = config.GetString("localName", ""); 644 regInfo.RegionName = config.GetString("localName", "");
638 } 645 }