From a7d610ffcca8d707c7f9e9fdd7ad1477981ec2a9 Mon Sep 17 00:00:00 2001 From: diva Date: Wed, 18 Mar 2009 16:37:26 +0000 Subject: Adds support for unlink-region command in hypergrid. --- OpenSim/Framework/Communications/IGridServices.cs | 3 ++ OpenSim/Region/Application/HGOpenSimNode.cs | 22 ++++++++++++ .../Communications/Hypergrid/HGGridServices.cs | 41 +++++++++++++++++++++ .../Communications/Local/LocalBackEndServices.cs | 32 +++++++++++++++++ .../Region/Communications/OGS1/OGS1GridServices.cs | 22 ++++++++++++ .../Framework/Scenes/Hypergrid/HGHyperlink.cs | 42 ++++++++++++++++++++++ 6 files changed, 162 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 69e8756..fa4d8d0 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -65,6 +65,9 @@ namespace OpenSim.Framework.Communications RegionInfo RequestNeighbourInfo(ulong regionHandle); RegionInfo RequestNeighbourInfo(UUID regionID); + RegionInfo RequestNeighbourInfo(string name); + RegionInfo RequestNeighbourInfo(string host, uint port); + RegionInfo RequestClosestRegion(string regionName); Dictionary GetGridSettings(); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); diff --git a/OpenSim/Region/Application/HGOpenSimNode.cs b/OpenSim/Region/Application/HGOpenSimNode.cs index 6e7f1c5..f4f3062 100644 --- a/OpenSim/Region/Application/HGOpenSimNode.cs +++ b/OpenSim/Region/Application/HGOpenSimNode.cs @@ -69,6 +69,9 @@ namespace OpenSim MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", "link-region :[:] ", "Link a hypergrid region", RunCommand); + MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region", + "unlink-region or : ", + "Unlink a hypergrid region", RunCommand); } protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, @@ -188,6 +191,18 @@ namespace OpenSim } return; } + else if (command.Equals("unlink-region")) + { + if (cmdparams.Count < 1) + { + UnlinkRegionCmdUsage(); + return; + } + if (HGHyperlink.TryUnlinkRegion(m_sceneManager.CurrentOrFirstScene, cmdparams[0])) + m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]); + else + m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]); + } } private void LoadXmlLinkFile(List cmdparams) @@ -279,5 +294,12 @@ namespace OpenSim m_log.Info("Usage: link-region []"); m_log.Info("Usage: link-region []"); } + + private void UnlinkRegionCmdUsage() + { + m_log.Info("Usage: unlink-region :"); + m_log.Info("Usage: unlink-region "); + } + } } \ No newline at end of file diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs index 4493591..5b3343a 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs @@ -258,6 +258,47 @@ namespace OpenSim.Region.Communications.Hypergrid return null; } + public virtual RegionInfo RequestNeighbourInfo(string name) + { + foreach (RegionInfo info in m_hyperlinkRegions) + { + //m_log.Debug(" .. " + info.RegionHandle); + if (info.RegionName == name) return info; + } + + foreach (RegionInfo info in m_knownRegions.Values) + { + if (info.RegionName == name) + { + //m_log.Debug("XXX------ known region " + info.RegionHandle); + return info; + } + } + + return null; + } + + public virtual RegionInfo RequestNeighbourInfo(string hostName, uint port) + { + foreach (RegionInfo info in m_hyperlinkRegions) + { + //m_log.Debug(" .. " + info.RegionHandle); + if ((info.ExternalHostName == hostName) && (info.HttpPort == port)) + return info; + } + + foreach (RegionInfo info in m_knownRegions.Values) + { + if ((info.ExternalHostName == hostName) && (info.HttpPort == port)) + { + //m_log.Debug("XXX------ known region " + info.RegionHandle); + return info; + } + } + + return null; + } + public virtual RegionInfo RequestClosestRegion(string regionName) { foreach (RegionInfo info in m_hyperlinkRegions) diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs index 33bc2fa..c52f825 100644 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs @@ -199,6 +199,38 @@ namespace OpenSim.Region.Communications.Local } /// + /// Get information about a neighbouring region + /// + /// + /// + public RegionInfo RequestNeighbourInfo(string name) + { + foreach (RegionInfo info in m_regions.Values) + { + if (info.RegionName == name) + return info; + } + + return null; + } + + /// + /// Get information about a neighbouring region + /// + /// + /// + public RegionInfo RequestNeighbourInfo(string host, uint port) + { + foreach (RegionInfo info in m_regions.Values) + { + if ((info.ExternalHostName == host) && (info.HttpPort == port)) + return info; + } + + return null; + } + + /// /// Get information about the closet region given a region name. /// /// diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index a397093..f47abe8 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -445,6 +445,28 @@ namespace OpenSim.Region.Communications.OGS1 return regionInfo; } + /// + /// Get information about a neighbouring region + /// + /// + /// + public RegionInfo RequestNeighbourInfo(string name) + { + // Not implemented yet + return null; + } + + /// + /// Get information about a neighbouring region + /// + /// + /// + public RegionInfo RequestNeighbourInfo(string host, uint port) + { + // Not implemented yet + return null; + } + public RegionInfo RequestClosestRegion(string regionName) { foreach (RegionInfo ri in m_remoteRegionInfoCache.Values) diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs index ad98273..e05b001 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs @@ -149,6 +149,48 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid return true; } + public static bool TryUnlinkRegion(Scene m_scene, string mapName) + { + RegionInfo regInfo = null; + if (mapName.Contains(":")) + { + string host = "127.0.0.1"; + string portstr; + string regionName = ""; + uint port = 9000; + string[] parts = mapName.Split(new char[] { ':' }); + if (parts.Length >= 1) + { + host = parts[0]; + } + if (parts.Length >= 2) + { + portstr = parts[1]; + if (!UInt32.TryParse(portstr, out port)) + regionName = parts[1]; + } + // always take the last one + if (parts.Length >= 3) + { + regionName = parts[2]; + } + regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(host, port); + } + else + { + regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(mapName); + } + if (regInfo != null) + { + return m_scene.CommsManager.GridService.DeregisterRegion(regInfo); + } + else + { + m_log.InfoFormat("[HGrid]: Region {0} not found", mapName); + return false; + } + } + /// /// Cope with this viewer limitation. /// -- cgit v1.1