aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/GridService/HypergridLinker.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/GridService/HypergridLinker.cs')
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs60
1 files changed, 32 insertions, 28 deletions
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index 74e864b..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;
@@ -127,7 +128,7 @@ namespace OpenSim.Services.GridService
127 if (MainConsole.Instance != null) 128 if (MainConsole.Instance != null)
128 { 129 {
129 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", 130 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region",
130 "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RegionServerURI] [<RemoteRegionName>] <cr>", 131 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
131 "Link a hypergrid region", RunCommand); 132 "Link a hypergrid region", RunCommand);
132 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region", 133 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region",
133 "unlink-region <local name> or <HostName>:<HttpPort> <cr>", 134 "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
@@ -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;
@@ -198,7 +204,12 @@ namespace OpenSim.Services.GridService
198 204
199 return null; 205 return null;
200 } 206 }
201 public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo, out string reason) 207
208
209 // From the command line and the 2 above
210 public bool TryCreateLink(UUID scopeID, int xloc, int yloc,
211 string externalRegionName, uint externalPort, string externalHostName, UUID ownerID,
212 out GridRegion regInfo, out string reason)
202 { 213 {
203 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);
204 215
@@ -210,13 +221,20 @@ namespace OpenSim.Services.GridService
210 regInfo.RegionLocX = xloc; 221 regInfo.RegionLocX = xloc;
211 regInfo.RegionLocY = yloc; 222 regInfo.RegionLocY = yloc;
212 regInfo.ScopeID = scopeID; 223 regInfo.ScopeID = scopeID;
224 regInfo.EstateOwner = ownerID;
213 225
214 // Big HACK for Simian Grid !!! 226 // Big HACK for Simian Grid !!!
215 // We need to clean up all URLs used in OpenSim !!! 227 // We need to clean up all URLs used in OpenSim !!!
216 if (externalHostName.Contains("/")) { 228 if (externalHostName.Contains("/"))
217 regInfo.ServerURI = externalHostName; 229 regInfo.ServerURI = externalHostName;
218 } else { 230
219 regInfo.ServerURI = "http://" + externalHostName + ":" + externalPort.ToString(); 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;
220 } 238 }
221 239
222 try 240 try
@@ -240,11 +258,11 @@ namespace OpenSim.Services.GridService
240 258
241 if (regionID != UUID.Zero) 259 if (regionID != UUID.Zero)
242 { 260 {
243 GridRegion r = m_GridService.GetRegionByUUID(scopeID, regionID); 261 region = m_GridService.GetRegionByUUID(scopeID, regionID);
244 if (r != null) 262 if (region != null)
245 { 263 {
246 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);
247 regInfo = r; 265 regInfo = region;
248 return true; 266 return true;
249 } 267 }
250 268
@@ -354,17 +372,8 @@ namespace OpenSim.Services.GridService
354 { 372 {
355 // Check for regions which are not linked regions 373 // Check for regions which are not linked regions
356 List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); 374 List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID);
357 // would like to use .Except, but doesn't seem to exist 375 IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks);
358 //IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks); 376 if (availableRegions.Count() == 0)
359 List<GridRegion> availableRegions = regions.FindAll(delegate(GridRegion region)
360 {
361 // Ewww! n^2
362 if (hyperlinks.Find(delegate(GridRegion r) { return r.RegionID == region.RegionID; }) == null) // not hyperlink. good.
363 return true;
364
365 return false;
366 });
367 if (availableRegions.Count == 0)
368 return false; 377 return false;
369 } 378 }
370 379
@@ -508,16 +517,12 @@ namespace OpenSim.Services.GridService
508 int xloc, yloc; 517 int xloc, yloc;
509 uint externalPort; 518 uint externalPort;
510 string externalHostName; 519 string externalHostName;
511 string serverURI;
512 try 520 try
513 { 521 {
514 xloc = Convert.ToInt32(cmdparams[0]); 522 xloc = Convert.ToInt32(cmdparams[0]);
515 yloc = Convert.ToInt32(cmdparams[1]); 523 yloc = Convert.ToInt32(cmdparams[1]);
516 externalPort = Convert.ToUInt32(cmdparams[3]); 524 externalPort = Convert.ToUInt32(cmdparams[3]);
517 externalHostName = cmdparams[2]; 525 externalHostName = cmdparams[2];
518 if ( cmdparams.Length == 4 ) {
519
520 }
521 //internalPort = Convert.ToUInt32(cmdparams[4]); 526 //internalPort = Convert.ToUInt32(cmdparams[4]);
522 //remotingPort = Convert.ToUInt32(cmdparams[5]); 527 //remotingPort = Convert.ToUInt32(cmdparams[5]);
523 } 528 }
@@ -532,7 +537,7 @@ namespace OpenSim.Services.GridService
532 xloc = xloc * (int)Constants.RegionSize; 537 xloc = xloc * (int)Constants.RegionSize;
533 yloc = yloc * (int)Constants.RegionSize; 538 yloc = yloc * (int)Constants.RegionSize;
534 string reason = string.Empty; 539 string reason = string.Empty;
535 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))
536 { 541 {
537 if (cmdparams.Length >= 5) 542 if (cmdparams.Length >= 5)
538 { 543 {
@@ -634,8 +639,7 @@ namespace OpenSim.Services.GridService
634 xloc = xloc * (int)Constants.RegionSize; 639 xloc = xloc * (int)Constants.RegionSize;
635 yloc = yloc * (int)Constants.RegionSize; 640 yloc = yloc * (int)Constants.RegionSize;
636 string reason = string.Empty; 641 string reason = string.Empty;
637 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, 642 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
638 externalHostName, out regInfo, out reason))
639 { 643 {
640 regInfo.RegionName = config.GetString("localName", ""); 644 regInfo.RegionName = config.GetString("localName", "");
641 } 645 }