From ae07b220c61cc92453c67e602907f0b3c8fcc707 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 21 Sep 2009 17:16:30 -0700 Subject: [PATCH 01/18] Changed position methods so that they assume the input params are in meters. --- OpenSim/Services/GridService/GridService.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 2229421c23..dd529f5c66 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -95,7 +95,9 @@ namespace OpenSim.Services.GridService if (region != null) { // Not really? Maybe? - List rdatas = m_Database.Get(region.posX - 1, region.posY - 1, region.posX + 1, region.posY + 1, scopeID); + List rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize, region.posY - (int)Constants.RegionSize, + region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); + foreach (RegionData rdata in rdatas) rinfos.Add(RegionData2RegionInfo(rdata)); @@ -114,7 +116,9 @@ namespace OpenSim.Services.GridService public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) { - RegionData rdata = m_Database.Get(x, y, scopeID); + int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; + int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; + RegionData rdata = m_Database.Get(snapX, snapY, scopeID); if (rdata != null) return RegionData2RegionInfo(rdata); @@ -151,7 +155,12 @@ namespace OpenSim.Services.GridService public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { - List rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); + int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; + int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; + int yminSnap = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; + int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; + + List rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); List rinfos = new List(); foreach (RegionData rdata in rdatas) rinfos.Add(RegionData2RegionInfo(rdata)); From a9ced0fe7962654be7bf7282babd475761f8bb50 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 21 Sep 2009 19:33:56 -0700 Subject: [PATCH 02/18] Added Remote grid connector module. --- .../Grid/RemoteGridServiceConnector.cs | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs new file mode 100644 index 0000000000..b0cfc9cf0b --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -0,0 +1,108 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using log4net; +using System; +using System.Collections.Generic; +using System.Reflection; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Services.Connectors; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid +{ + public class RemoteGridServicesConnector : + GridServicesConnector, ISharedRegionModule, IGridService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private bool m_Enabled = false; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "RemoteGridServicesConnector"; } + } + + public override void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("GridServices", ""); + if (name == Name) + { + IConfig gridConfig = source.Configs["GridService"]; + if (gridConfig == null) + { + m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini"); + return; + } + + m_Enabled = true; + + base.Initialise(source); + + m_log.Info("[GRID CONNECTOR]: Remote grid enabled"); + } + } + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(this); + } + + public void RemoveRegion(Scene scene) + { + } + + public void RegionLoaded(Scene scene) + { + } + } +} From 34f4738159300ab6370e3db47df5187b6cea8771 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 11:58:40 -0700 Subject: [PATCH 03/18] Added HGGridConnector and related code. --- .../Grid/HGGridConnector.cs | 304 ++++++++++++++++++ .../Grid/LocalGridServiceConnector.cs | 64 ++-- .../Grid/RemoteGridServiceConnector.cs | 34 +- .../Handlers/Grid/GridServerConnector.cs | 2 +- .../Grid/HypergridServiceConnector.cs | 155 +++++++++ prebuild.xml | 1 + 6 files changed, 521 insertions(+), 39 deletions(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs create mode 100644 OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs new file mode 100644 index 0000000000..b7e3213dac --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -0,0 +1,304 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; + +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenSim.Server.Base; +using OpenSim.Services.Connectors.Grid; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid +{ + public class HGGridConnector : ISharedRegionModule, IGridService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private bool m_Enabled = false; + private bool m_Initialized = false; + + private IGridService m_GridServiceConnector; + private HypergridServiceConnector m_HypergridServiceConnector; + + // Hyperlink regions are hyperlinks on the map + protected Dictionary m_HyperlinkRegions = new Dictionary(); + + // Known regions are home regions of visiting foreign users. + // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when + // the visitor goes away. They are mapped to X=0 on the map. + // This is key-ed on agent ID + protected Dictionary m_knownRegions = new Dictionary(); + + #region ISharedRegionModule + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "HGGridServicesConnector"; } + } + + public void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("GridServices", ""); + if (name == Name) + { + IConfig gridConfig = source.Configs["GridService"]; + if (gridConfig == null) + { + m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini"); + return; + } + + + InitialiseConnectorModule(source); + + m_Enabled = true; + m_log.Info("[HGGRID CONNECTOR]: HG grid enabled"); + } + } + } + + private void InitialiseConnectorModule(IConfigSource source) + { + IConfig gridConfig = source.Configs["GridService"]; + if (gridConfig == null) + { + m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini"); + throw new Exception("Grid connector init error"); + } + + string module = gridConfig.GetString("GridServiceConnectorModule", String.Empty); + if (module == String.Empty) + { + m_log.Error("[HGGRID CONNECTOR]: No GridServiceConnectorModule named in section GridService"); + //return; + throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); + } + + Object[] args = new Object[] { source }; + m_GridServiceConnector = ServerUtils.LoadPlugin(module, args); + + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(this); + } + + public void RemoveRegion(Scene scene) + { + } + + public void RegionLoaded(Scene scene) + { + if (m_Enabled && !m_Initialized) + { + m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); + m_Initialized = true; + } + } + + #endregion + + #region IGridService + + public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + { + // Region doesn't exist here. Trying to link remote region + if (regionInfo.RegionID.Equals(UUID.Zero)) + { + m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort); + regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo); + if (!regionInfo.RegionID.Equals(UUID.Zero)) + { + m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); + m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID); + + // Try get the map image + m_HypergridServiceConnector.GetMapImage(regionInfo); + return true; + } + else + { + m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")"); + return false; + } + // Note that these remote regions aren't registered in localBackend, so return null, no local listeners + } + else // normal grid + return m_GridServiceConnector.RegisterRegion(scopeID, regionInfo); + } + + public bool DeregisterRegion(UUID regionID) + { + // Try the hyperlink collection + if (m_HyperlinkRegions.ContainsKey(regionID)) + { + m_HyperlinkRegions.Remove(regionID); + return true; + } + // Try the foreign users home collection + if (m_knownRegions.ContainsKey(regionID)) + { + m_knownRegions.Remove(regionID); + return true; + } + // Finally, try the normal route + return m_GridServiceConnector.DeregisterRegion(regionID); + } + + public List GetNeighbours(UUID scopeID, UUID regionID) + { + // No serving neighbours on hyperliked regions. + // Just the regular regions. + return m_GridServiceConnector.GetNeighbours(scopeID, regionID); + } + + public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + { + // Try the hyperlink collection + if (m_HyperlinkRegions.ContainsKey(regionID)) + return m_HyperlinkRegions[regionID]; + + // Try the foreign users home collection + if (m_knownRegions.ContainsKey(regionID)) + return m_knownRegions[regionID]; + + // Finally, try the normal route + return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); + } + + public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + { + int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize; + int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize; + // Try the hyperlink collection + foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + { + if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) + return r; + } + + // Try the foreign users home collection + foreach (SimpleRegionInfo r in m_knownRegions.Values) + { + if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) + return r; + } + + // Finally, try the normal route + return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); + } + + public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + { + // Try normal grid first + SimpleRegionInfo region = m_GridServiceConnector.GetRegionByName(scopeID, regionName); + if (region != null) + return region; + + // !!! Commenting until region name exists + //// Try the hyperlink collection + //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + //{ + // if (r.RegionName == regionName) + // return r; + //} + + //// Try the foreign users home collection + //foreach (SimpleRegionInfo r in m_knownRegions.Values) + //{ + // if (r.RegionName == regionName) + // return r; + //} + return null; + } + + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + { + List rinfos = new List(); + + // Commenting until regionname exists + //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + // if ((r.RegionName != null) && r.RegionName.StartsWith(name)) + // rinfos.Add(r); + + rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber)); + return rinfos; + } + + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + { + int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; + int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; + int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; + int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; + + List rinfos = new List(); + foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) && + (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax)) + rinfos.Add(r); + + rinfos.AddRange(m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax)); + + return rinfos; + } + + #endregion + + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 74ece2e6b0..3f294013d4 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -50,6 +50,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private bool m_Enabled = false; + public LocalGridServicesConnector(IConfigSource source) + { + InitialiseService(source); + } + #region ISharedRegionModule public Type ReplaceableInterface @@ -70,38 +75,43 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid string name = moduleConfig.GetString("GridServices", ""); if (name == Name) { - IConfig assetConfig = source.Configs["GridService"]; - if (assetConfig == null) - { - m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini"); - return; - } - - string serviceDll = assetConfig.GetString("LocalServiceModule", - String.Empty); - - if (serviceDll == String.Empty) - { - m_log.Error("[GRID CONNECTOR]: No LocalServiceModule named in section GridService"); - return; - } - - Object[] args = new Object[] { source }; - m_GridService = - ServerUtils.LoadPlugin(serviceDll, - args); - - if (m_GridService == null) - { - m_log.Error("[GRID CONNECTOR]: Can't load asset service"); - return; - } + InitialiseService(source); m_Enabled = true; - m_log.Info("[GRID CONNECTOR]: Local grid connector enabled"); + m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled"); } } } + private void InitialiseService(IConfigSource source) + { + IConfig assetConfig = source.Configs["GridService"]; + if (assetConfig == null) + { + m_log.Error("[LOCAL GRID CONNECTOR]: GridService missing from OpenSim.ini"); + return; + } + + string serviceDll = assetConfig.GetString("LocalServiceModule", + String.Empty); + + if (serviceDll == String.Empty) + { + m_log.Error("[LOCAL GRID CONNECTOR]: No LocalServiceModule named in section GridService"); + return; + } + + Object[] args = new Object[] { source }; + m_GridService = + ServerUtils.LoadPlugin(serviceDll, + args); + + if (m_GridService == null) + { + m_log.Error("[LOCAL GRID CONNECTOR]: Can't load asset service"); + return; + } + } + public void PostInitialise() { } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index b0cfc9cf0b..22b1015073 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -47,6 +47,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private bool m_Enabled = false; + public RemoteGridServicesConnector(IConfigSource source) + { + InitialiseService(source); + } + + #region ISharedRegionmodule + public Type ReplaceableInterface { get { return null; } @@ -65,22 +72,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid string name = moduleConfig.GetString("GridServices", ""); if (name == Name) { - IConfig gridConfig = source.Configs["GridService"]; - if (gridConfig == null) - { - m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini"); - return; - } - + InitialiseService(source); m_Enabled = true; - - base.Initialise(source); - - m_log.Info("[GRID CONNECTOR]: Remote grid enabled"); + m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled"); } } } + private void InitialiseService(IConfigSource source) + { + IConfig gridConfig = source.Configs["GridService"]; + if (gridConfig == null) + { + m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini"); + return; + } + + base.Initialise(source); + } + public void PostInitialise() { } @@ -104,5 +114,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void RegionLoaded(Scene scene) { } + + #endregion } } diff --git a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs index b80c479072..7bf2e664d7 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs @@ -49,7 +49,7 @@ namespace OpenSim.Server.Handlers.Grid String.Empty); if (gridService == String.Empty) - throw new Exception("No AuthenticationService in config file"); + throw new Exception("No GridService in config file"); Object[] args = new Object[] { config }; m_GridService = ServerUtils.LoadPlugin(gridService, args); diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs new file mode 100644 index 0000000000..f68c10a956 --- /dev/null +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -0,0 +1,155 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Drawing; +using System.Net; +using System.Reflection; +using OpenSim.Services.Interfaces; + +using OpenSim.Framework; + +using OpenMetaverse; +using OpenMetaverse.Imaging; +using log4net; +using Nwc.XmlRpc; + +namespace OpenSim.Services.Connectors.Grid +{ + public class HypergridServiceConnector + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private IAssetService m_AssetService; + + public HypergridServiceConnector(IAssetService assService) + { + m_AssetService = assService; + } + + public UUID LinkRegion(SimpleRegionInfo info) + { + UUID uuid = UUID.Zero; + + //Hashtable hash = new Hashtable(); + //hash["region_name"] = info.RegionName; + + //IList paramList = new ArrayList(); + //paramList.Add(hash); + + //XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); + //string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; + //m_log.Debug("[HGrid]: Linking to " + uri); + //XmlRpcResponse response = request.Send(uri, 10000); + //if (response.IsFault) + //{ + // m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); + //} + //else + //{ + // hash = (Hashtable)response.Value; + // //foreach (Object o in hash) + // // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); + // try + // { + // UUID.TryParse((string)hash["uuid"], out uuid); + // info.RegionID = uuid; + // if ((string)hash["handle"] != null) + // { + // info.regionSecret = (string)hash["handle"]; + // //m_log.Debug(">> HERE: " + info.regionSecret); + // } + // if (hash["region_image"] != null) + // { + // UUID img = UUID.Zero; + // UUID.TryParse((string)hash["region_image"], out img); + // info.RegionSettings.TerrainImageID = img; + // } + // if (hash["region_name"] != null) + // { + // info.RegionName = (string)hash["region_name"]; + // //m_log.Debug(">> " + info.RegionName); + // } + // if (hash["internal_port"] != null) + // { + // int port = Convert.ToInt32((string)hash["internal_port"]); + // info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); + // //m_log.Debug(">> " + info.InternalEndPoint.ToString()); + // } + // if (hash["remoting_port"] != null) + // { + // info.RemotingPort = Convert.ToUInt32(hash["remoting_port"]); + // //m_log.Debug(">> " + info.RemotingPort); + // } + + // } + // catch (Exception e) + // { + // m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); + // } + //} + return uuid; + } + + public void GetMapImage(SimpleRegionInfo info) + { + try + { + string regionimage = "regionImage" + info.RegionID.ToString(); + regionimage = regionimage.Replace("-", ""); + + WebClient c = new WebClient(); + string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage; + //m_log.Debug("JPEG: " + uri); + c.DownloadFile(uri, info.RegionID.ToString() + ".jpg"); + Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); + //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); + byte[] imageData = OpenJPEG.EncodeFromImage(m, true); + AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString()); + + // !!! for now + //info.RegionSettings.TerrainImageID = ass.FullID; + + ass.Type = (int)AssetType.Texture; + ass.Temporary = true; + ass.Local = true; + ass.Data = imageData; + + m_AssetService.Store(ass); + + } + catch // LEGIT: Catching problems caused by OpenJPEG p/invoke + { + m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache"); + } + } + + } +} diff --git a/prebuild.xml b/prebuild.xml index 2265b099e3..b131019aad 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1205,6 +1205,7 @@ ../../../bin/ + From ffd30b8ac31bc408316079ba86076bf9e984a8be Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 14:46:05 -0700 Subject: [PATCH 04/18] Moved RegionName from RegionInfo to SimpleRegionInfo. --- OpenSim/Framework/RegionInfo.cs | 8 +- .../Scripting/LSLHttp/UrlModule.cs | 484 +++++++++--------- .../Grid/HGGridConnector.cs | 81 ++- .../Shared/Api/Implementation/LSL_Api.cs | 10 +- .../Grid/HypergridServiceConnector.cs | 106 ++-- OpenSim/Services/GridService/GridService.cs | 4 +- 6 files changed, 365 insertions(+), 328 deletions(-) diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index afd50a9e27..0dc35a51e9 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -64,6 +64,13 @@ namespace OpenSim.Framework } protected string m_serverURI; + public string RegionName + { + get { return m_regionName; } + set { m_regionName = value; } + } + protected string m_regionName = String.Empty; + protected bool Allow_Alternate_Ports; public bool m_allow_alternate_ports; protected string m_externalHostName; @@ -284,7 +291,6 @@ namespace OpenSim.Framework public UUID originRegionID = UUID.Zero; public string proxyUrl = ""; public int ProxyOffset = 0; - public string RegionName = String.Empty; public string regionSecret = UUID.Random().ToString(); public string osSecret; diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 2d81e4c191..8b7a878da6 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -54,12 +54,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { public UUID requestID; public Dictionary headers; - public string body; - public int responseCode; + public string body; + public int responseCode; public string responseBody; - public ManualResetEvent ev; + public ManualResetEvent ev; public bool requestDone; - public int startTime; + public int startTime; public string uri; } @@ -73,23 +73,23 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp new Dictionary(); private Dictionary m_UrlMap = - new Dictionary(); - + new Dictionary(); + private int m_TotalUrls = 100; - private IHttpServer m_HttpServer = null; - - private string m_ExternalHostNameForLSL = ""; + private IHttpServer m_HttpServer = null; + + private string m_ExternalHostNameForLSL = ""; public Type ReplaceableInterface { get { return null; } - } - - private Hashtable HandleHttpPoll(Hashtable request) - { - return new Hashtable(); + } + + private Hashtable HandleHttpPoll(Hashtable request) + { + return new Hashtable(); } public string Name @@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } public void Initialise(IConfigSource config) - { + { m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName); } @@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public void Close() { - } + } public UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID) { UUID urlcode = UUID.Random(); @@ -141,8 +141,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; - } - string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; + } + string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; @@ -152,14 +152,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp urlData.urlcode = urlcode; urlData.requests = new Dictionary(); - - m_UrlMap[url] = urlData; - - string uri = "/lslhttp/" + urlcode.ToString() + "/"; - - m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, - new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, - urlcode)); + + m_UrlMap[url] = urlData; + + string uri = "/lslhttp/" + urlcode.ToString() + "/"; + + m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, + new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, + urlcode)); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } @@ -180,11 +180,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { lock (m_UrlMap) { - UrlData data; - - if (!m_UrlMap.TryGetValue(url, out data)) - { - return; + UrlData data; + + if (!m_UrlMap.TryGetValue(url, out data)) + { + return; } foreach (UUID req in data.requests.Keys) @@ -196,36 +196,36 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } public void HttpResponse(UUID request, int status, string body) - { - if (m_RequestMap.ContainsKey(request)) - { - UrlData urlData = m_RequestMap[request]; - RequestData requestData=urlData.requests[request]; - urlData.requests[request].responseCode = status; - urlData.requests[request].responseBody = body; - //urlData.requests[request].ev.Set(); - urlData.requests[request].requestDone=true; - } - else - { - m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); + { + if (m_RequestMap.ContainsKey(request)) + { + UrlData urlData = m_RequestMap[request]; + RequestData requestData=urlData.requests[request]; + urlData.requests[request].responseCode = status; + urlData.requests[request].responseBody = body; + //urlData.requests[request].ev.Set(); + urlData.requests[request].requestDone=true; + } + else + { + m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); } } public string GetHttpHeader(UUID requestId, string header) - { - if (m_RequestMap.ContainsKey(requestId)) - { - UrlData urlData=m_RequestMap[requestId]; - string value; - if (urlData.requests[requestId].headers.TryGetValue(header,out value)) - return value; - } - else - { + { + if (m_RequestMap.ContainsKey(requestId)) + { + UrlData urlData=m_RequestMap[requestId]; + string value; + if (urlData.requests[requestId].headers.TryGetValue(header,out value)) + return value; + } + else + { m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); - } - return String.Empty; + } + return String.Empty; } public int GetFreeUrls() @@ -275,63 +275,63 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp foreach (string urlname in removeURLs) m_UrlMap.Remove(urlname); } - } - + } + private void RemoveUrl(UrlData data) { - m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); - } - - private Hashtable NoEvents(UUID requestID, UUID sessionID) - { - Hashtable response = new Hashtable(); - UrlData url; - lock (m_RequestMap) - { - if (!m_RequestMap.ContainsKey(requestID)) - return response; - url = m_RequestMap[requestID]; - } - - if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) - { - response["int_response_code"] = 500; - response["str_response_string"] = "Script timeout"; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - - //remove from map - lock (url) - { - url.requests.Remove(requestID); - m_RequestMap.Remove(requestID); - } - - return response; + m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); + } + + private Hashtable NoEvents(UUID requestID, UUID sessionID) + { + Hashtable response = new Hashtable(); + UrlData url; + lock (m_RequestMap) + { + if (!m_RequestMap.ContainsKey(requestID)) + return response; + url = m_RequestMap[requestID]; } - - return response; - } - + if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) + { + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + //remove from map + lock (url) + { + url.requests.Remove(requestID); + m_RequestMap.Remove(requestID); + } + + return response; + } + + + return response; + } + private bool HasEvents(UUID requestID, UUID sessionID) { - UrlData url=null; + UrlData url=null; lock (m_RequestMap) - { - if (!m_RequestMap.ContainsKey(requestID)) - { - return false; - } - url = m_RequestMap[requestID]; - if (!url.requests.ContainsKey(requestID)) - { - return false; + { + if (!m_RequestMap.ContainsKey(requestID)) + { + return false; } - } + url = m_RequestMap[requestID]; + if (!url.requests.ContainsKey(requestID)) + { + return false; + } + } if (System.Environment.TickCount-url.requests[requestID].startTime>25000) { @@ -343,146 +343,146 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp else return false; - } - private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) - { - UrlData url = null; - RequestData requestData = null; - - lock (m_RequestMap) - { - if (!m_RequestMap.ContainsKey(requestID)) - return NoEvents(requestID,sessionID); - url = m_RequestMap[requestID]; - requestData = url.requests[requestID]; - } - - if (!requestData.requestDone) - return NoEvents(requestID,sessionID); - - Hashtable response = new Hashtable(); - - if (System.Environment.TickCount - requestData.startTime > 25000) - { - response["int_response_code"] = 500; - response["str_response_string"] = "Script timeout"; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - return response; - } - //put response - response["int_response_code"] = requestData.responseCode; - response["str_response_string"] = requestData.responseBody; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - - //remove from map - lock (url) - { - url.requests.Remove(requestID); - m_RequestMap.Remove(requestID); - } - - return response; - } + } + private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) + { + UrlData url = null; + RequestData requestData = null; + + lock (m_RequestMap) + { + if (!m_RequestMap.ContainsKey(requestID)) + return NoEvents(requestID,sessionID); + url = m_RequestMap[requestID]; + requestData = url.requests[requestID]; + } + + if (!requestData.requestDone) + return NoEvents(requestID,sessionID); + + Hashtable response = new Hashtable(); + + if (System.Environment.TickCount - requestData.startTime > 25000) + { + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + return response; + } + //put response + response["int_response_code"] = requestData.responseCode; + response["str_response_string"] = requestData.responseBody; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + //remove from map + lock (url) + { + url.requests.Remove(requestID); + m_RequestMap.Remove(requestID); + } + + return response; + } public void HttpRequestHandler(UUID requestID, Hashtable request) - { - lock (request) - { - string uri = request["uri"].ToString(); - - try - { - Hashtable headers = (Hashtable)request["headers"]; - - string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; - - int pos1 = uri.IndexOf("/");// /lslhttp - int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ - int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp// - string uri_tmp = uri.Substring(0, pos3 + 1); - //HTTP server code doesn't provide us with QueryStrings - string pathInfo; - string queryString; - queryString = ""; - - pathInfo = uri.Substring(pos3); - - UrlData url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; - - //for llGetHttpHeader support we need to store original URI here - //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers - //as per http://wiki.secondlife.com/wiki/LlGetHTTPHeader - - RequestData requestData = new RequestData(); - requestData.requestID = requestID; - requestData.requestDone = false; - requestData.startTime = System.Environment.TickCount; - requestData.uri = uri; - if (requestData.headers == null) - requestData.headers = new Dictionary(); - - foreach (DictionaryEntry header in headers) - { - string key = (string)header.Key; - string value = (string)header.Value; - requestData.headers.Add(key, value); - } - foreach (DictionaryEntry de in request) - { - if (de.Key.ToString() == "querystringkeys") - { - System.String[] keys = (System.String[])de.Value; - foreach (String key in keys) - { - if (request.ContainsKey(key)) - { - string val = (String)request[key]; - queryString = queryString + key + "=" + val + "&"; - } - } - if (queryString.Length > 1) - queryString = queryString.Substring(0, queryString.Length - 1); - - } - - } - - //if this machine is behind DNAT/port forwarding, currently this is being - //set to address of port forwarding router - requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; - requestData.headers["x-path-info"] = pathInfo; - requestData.headers["x-query-string"] = queryString; - requestData.headers["x-script-url"] = url.url; - - requestData.ev = new ManualResetEvent(false); - lock (url.requests) - { - url.requests.Add(requestID, requestData); - } - lock (m_RequestMap) - { - //add to request map - m_RequestMap.Add(requestID, url); - } - - url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); - - //send initial response? - Hashtable response = new Hashtable(); - - return; - - } - catch (Exception we) - { - //Hashtable response = new Hashtable(); - m_log.Warn("[HttpRequestHandler]: http-in request failed"); - m_log.Warn(we.Message); - m_log.Warn(we.StackTrace); - } + { + lock (request) + { + string uri = request["uri"].ToString(); + + try + { + Hashtable headers = (Hashtable)request["headers"]; + + string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; + + int pos1 = uri.IndexOf("/");// /lslhttp + int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ + int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp// + string uri_tmp = uri.Substring(0, pos3 + 1); + //HTTP server code doesn't provide us with QueryStrings + string pathInfo; + string queryString; + queryString = ""; + + pathInfo = uri.Substring(pos3); + + UrlData url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; + + //for llGetHttpHeader support we need to store original URI here + //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers + //as per http://wiki.secondlife.com/wiki/LlGetHTTPHeader + + RequestData requestData = new RequestData(); + requestData.requestID = requestID; + requestData.requestDone = false; + requestData.startTime = System.Environment.TickCount; + requestData.uri = uri; + if (requestData.headers == null) + requestData.headers = new Dictionary(); + + foreach (DictionaryEntry header in headers) + { + string key = (string)header.Key; + string value = (string)header.Value; + requestData.headers.Add(key, value); + } + foreach (DictionaryEntry de in request) + { + if (de.Key.ToString() == "querystringkeys") + { + System.String[] keys = (System.String[])de.Value; + foreach (String key in keys) + { + if (request.ContainsKey(key)) + { + string val = (String)request[key]; + queryString = queryString + key + "=" + val + "&"; + } + } + if (queryString.Length > 1) + queryString = queryString.Substring(0, queryString.Length - 1); + + } + + } + + //if this machine is behind DNAT/port forwarding, currently this is being + //set to address of port forwarding router + requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; + requestData.headers["x-path-info"] = pathInfo; + requestData.headers["x-query-string"] = queryString; + requestData.headers["x-script-url"] = url.url; + + requestData.ev = new ManualResetEvent(false); + lock (url.requests) + { + url.requests.Add(requestID, requestData); + } + lock (m_RequestMap) + { + //add to request map + m_RequestMap.Add(requestID, url); + } + + url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); + + //send initial response? + Hashtable response = new Hashtable(); + + return; + + } + catch (Exception we) + { + //Hashtable response = new Hashtable(); + m_log.Warn("[HttpRequestHandler]: http-in request failed"); + m_log.Warn(we.Message); + m_log.Warn(we.StackTrace); + } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index b7e3213dac..e3cb05cd29 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -63,6 +63,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // This is key-ed on agent ID protected Dictionary m_knownRegions = new Dictionary(); + protected Dictionary m_HyperlinkHandles = new Dictionary(); + #region ISharedRegionModule public Type ReplaceableInterface @@ -160,10 +162,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (regionInfo.RegionID.Equals(UUID.Zero)) { m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort); - regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo); + ulong regionHandle = 0; + regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo, out regionHandle); if (!regionInfo.RegionID.Equals(UUID.Zero)) { - m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); + AddHyperlinkRegion(regionInfo, regionHandle); m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID); // Try get the map image @@ -186,15 +189,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // Try the hyperlink collection if (m_HyperlinkRegions.ContainsKey(regionID)) { - m_HyperlinkRegions.Remove(regionID); + RemoveHyperlinkRegion(regionID); return true; } // Try the foreign users home collection - if (m_knownRegions.ContainsKey(regionID)) - { - m_knownRegions.Remove(regionID); - return true; - } + + foreach (SimpleRegionInfo r in m_knownRegions.Values) + if (r.RegionID == regionID) + { + RemoveHyperlinkHomeRegion(regionID); + return true; + } + // Finally, try the normal route return m_GridServiceConnector.DeregisterRegion(regionID); } @@ -213,8 +219,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return m_HyperlinkRegions[regionID]; // Try the foreign users home collection - if (m_knownRegions.ContainsKey(regionID)) - return m_knownRegions[regionID]; + foreach (SimpleRegionInfo r in m_knownRegions.Values) + if (r.RegionID == regionID) + return m_knownRegions[regionID]; // Finally, try the normal route return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); @@ -249,20 +256,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (region != null) return region; - // !!! Commenting until region name exists - //// Try the hyperlink collection - //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) - //{ - // if (r.RegionName == regionName) - // return r; - //} + // Try the hyperlink collection + foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + { + if (r.RegionName == regionName) + return r; + } - //// Try the foreign users home collection - //foreach (SimpleRegionInfo r in m_knownRegions.Values) - //{ - // if (r.RegionName == regionName) - // return r; - //} + // Try the foreign users home collection + foreach (SimpleRegionInfo r in m_knownRegions.Values) + { + if (r.RegionName == regionName) + return r; + } return null; } @@ -299,6 +305,35 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #endregion + private void AddHyperlinkRegion(SimpleRegionInfo regionInfo, ulong regionHandle) + { + m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); + m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); + } + + private void RemoveHyperlinkRegion(UUID regionID) + { + m_HyperlinkRegions.Remove(regionID); + m_HyperlinkHandles.Remove(regionID); + } + + private void AddHyperlinkHomeRegion(UUID userID, SimpleRegionInfo regionInfo, ulong regionHandle) + { + m_knownRegions.Add(userID, regionInfo); + m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); + } + + private void RemoveHyperlinkHomeRegion(UUID regionID) + { + foreach (KeyValuePair kvp in m_knownRegions) + { + if (kvp.Value.RegionID == regionID) + { + m_knownRegions.Remove(kvp.Key); + } + } + m_HyperlinkHandles.Remove(regionID); + } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b63147860f..d4d5ccc414 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7838,8 +7838,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetHTTPHeader(LSL_Key request_id, string header) { m_host.AddScriptLPS(1); - - if (m_UrlModule != null) + + if (m_UrlModule != null) return m_UrlModule.GetHttpHeader(new UUID(request_id), header); return String.Empty; } @@ -9124,9 +9124,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Partial implementation: support for parameter flags needed // see http://wiki.secondlife.com/wiki/llHTTPResponse - m_host.AddScriptLPS(1); - - if (m_UrlModule != null) + m_host.AddScriptLPS(1); + + if (m_UrlModule != null) m_UrlModule.HttpResponse(new UUID(id), status,body); } diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index f68c10a956..6b0518c860 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -54,67 +54,63 @@ namespace OpenSim.Services.Connectors.Grid m_AssetService = assService; } - public UUID LinkRegion(SimpleRegionInfo info) + public UUID LinkRegion(SimpleRegionInfo info, out ulong realHandle) { UUID uuid = UUID.Zero; + realHandle = 0; - //Hashtable hash = new Hashtable(); - //hash["region_name"] = info.RegionName; + Hashtable hash = new Hashtable(); + hash["region_name"] = info.RegionName; - //IList paramList = new ArrayList(); - //paramList.Add(hash); + IList paramList = new ArrayList(); + paramList.Add(hash); - //XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); - //string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; - //m_log.Debug("[HGrid]: Linking to " + uri); - //XmlRpcResponse response = request.Send(uri, 10000); - //if (response.IsFault) - //{ - // m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); - //} - //else - //{ - // hash = (Hashtable)response.Value; - // //foreach (Object o in hash) - // // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); - // try - // { - // UUID.TryParse((string)hash["uuid"], out uuid); - // info.RegionID = uuid; - // if ((string)hash["handle"] != null) - // { - // info.regionSecret = (string)hash["handle"]; - // //m_log.Debug(">> HERE: " + info.regionSecret); - // } - // if (hash["region_image"] != null) - // { - // UUID img = UUID.Zero; - // UUID.TryParse((string)hash["region_image"], out img); - // info.RegionSettings.TerrainImageID = img; - // } - // if (hash["region_name"] != null) - // { - // info.RegionName = (string)hash["region_name"]; - // //m_log.Debug(">> " + info.RegionName); - // } - // if (hash["internal_port"] != null) - // { - // int port = Convert.ToInt32((string)hash["internal_port"]); - // info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); - // //m_log.Debug(">> " + info.InternalEndPoint.ToString()); - // } - // if (hash["remoting_port"] != null) - // { - // info.RemotingPort = Convert.ToUInt32(hash["remoting_port"]); - // //m_log.Debug(">> " + info.RemotingPort); - // } + XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); + string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; + m_log.Debug("[HGrid]: Linking to " + uri); + XmlRpcResponse response = request.Send(uri, 10000); + if (response.IsFault) + { + m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); + } + else + { + hash = (Hashtable)response.Value; + //foreach (Object o in hash) + // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); + try + { + UUID.TryParse((string)hash["uuid"], out uuid); + info.RegionID = uuid; + if ((string)hash["handle"] != null) + { + realHandle = Convert.ToUInt64((string)hash["handle"]); + m_log.Debug(">> HERE, realHandle: " + realHandle); + } + //if (hash["region_image"] != null) + //{ + // UUID img = UUID.Zero; + // UUID.TryParse((string)hash["region_image"], out img); + // info.RegionSettings.TerrainImageID = img; + //} + if (hash["region_name"] != null) + { + info.RegionName = (string)hash["region_name"]; + //m_log.Debug(">> " + info.RegionName); + } + if (hash["internal_port"] != null) + { + int port = Convert.ToInt32((string)hash["internal_port"]); + info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); + //m_log.Debug(">> " + info.InternalEndPoint.ToString()); + } - // } - // catch (Exception e) - // { - // m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); - // } - //} + } + catch (Exception e) + { + m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); + } + } return uuid; } diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index dd529f5c66..b37a51b8ff 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -179,7 +179,7 @@ namespace OpenSim.Services.GridService rdata.posY = (int)rinfo.RegionLocY; rdata.RegionID = rinfo.RegionID; rdata.Data = rinfo.ToKeyValuePairs(); - //rdata.RegionName = rinfo.RegionName; + rdata.RegionName = rinfo.RegionName; return rdata; } @@ -190,7 +190,7 @@ namespace OpenSim.Services.GridService rinfo.RegionLocX = (uint)rdata.posX; rinfo.RegionLocY = (uint)rdata.posY; rinfo.RegionID = rdata.RegionID; - //rinfo.RegionName = rdata.RegionName; + rinfo.RegionName = rdata.RegionName; return rinfo; } From 882d2c9cc399c4c7d1809702104ce94c9c2c7b17 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 20:25:00 -0700 Subject: [PATCH 05/18] Added hg console commands to the module. Added the IN connector module for link-region and corresponding handler to be used in the regions only. No service as such is needed. This will replace the current link-region machinery. Compiles but not tested. --- OpenSim/Framework/RegionInfo.cs | 1 + .../Grid/HypergridServiceInConnectorModule.cs | 129 ++++++++ .../ServiceConnectorsOut/Grid/HGCommands.cs | 295 ++++++++++++++++++ .../Grid/HGGridConnector.cs | 213 ++++++++++++- .../Grid/RemoteGridServiceConnector.cs | 64 +++- .../Handlers/Grid/HypergridServerConnector.cs | 112 +++++++ .../Connectors/Grid/GridServiceConnector.cs | 16 +- 7 files changed, 817 insertions(+), 13 deletions(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs create mode 100644 OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 0dc35a51e9..cee1d4b850 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -108,6 +108,7 @@ namespace OpenSim.Framework public SimpleRegionInfo(RegionInfo ConvertFrom) { + m_regionName = ConvertFrom.RegionName; m_regionLocX = ConvertFrom.RegionLocX; m_regionLocY = ConvertFrom.RegionLocY; m_internalEndPoint = ConvertFrom.InternalEndPoint; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs new file mode 100644 index 0000000000..8d113d38d0 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs @@ -0,0 +1,129 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Reflection; +using System.Collections.Generic; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Server.Base; +using OpenSim.Server.Handlers.Base; +using OpenSim.Server.Handlers.Grid; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid +{ + public class HypergridServiceInConnectorModule : ISharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static bool m_Enabled = false; + + private IConfigSource m_Config; + bool m_Registered = false; + HypergridServiceInConnector m_HypergridHandler; + + #region IRegionModule interface + + public void Initialise(IConfigSource config) + { + //// This module is only on for standalones in hypergrid mode + //enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) && + // config.Configs["Startup"].GetBoolean("hypergrid", true); + //m_log.DebugFormat("[RegionInventoryService]: enabled? {0}", enabled); + m_Config = config; + IConfig moduleConfig = config.Configs["Modules"]; + if (moduleConfig != null) + { + m_Enabled = moduleConfig.GetBoolean("HypergridServiceInConnector", false); + if (m_Enabled) + { + m_log.Info("[INVENTORY IN CONNECTOR]: Hypergrid Service In Connector enabled"); + } + + } + + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "HypergridService"; } + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + if (!m_Registered) + { + m_Registered = true; + + m_log.Info("[HypergridService]: Starting..."); + + Object[] args = new Object[] { m_Config, MainServer.Instance }; + + m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance); + //ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); + } + + SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo); + m_HypergridHandler.AddRegion(rinfo); + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + + SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo); + m_HypergridHandler.RemoveRegion(rinfo); + } + + public void RegionLoaded(Scene scene) + { + } + + #endregion + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs new file mode 100644 index 0000000000..eee3a6ccdf --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs @@ -0,0 +1,295 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Xml; +using log4net; +using Nini.Config; +using OpenSim.Framework; +//using OpenSim.Framework.Communications; +using OpenSim.Framework.Console; +using OpenSim.Region.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Hypergrid; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid +{ + public class HGCommands + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private HGGridConnector m_HGGridConnector; + private Scene m_scene; + + private static uint m_autoMappingX = 0; + private static uint m_autoMappingY = 0; + private static bool m_enableAutoMapping = false; + + public HGCommands(HGGridConnector hgConnector, Scene scene) + { + m_HGGridConnector = hgConnector; + m_scene = scene; + } + + //public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, + // StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) + //{ + // HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices); + + // return + // new HGScene( + // regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager, + // m_moduleLoader, false, m_configSettings.PhysicalPrim, + // m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); + //} + + public void RunCommand(string module, string[] cmdparams) + { + List args = new List(cmdparams); + if (args.Count < 1) + return; + + string command = args[0]; + args.RemoveAt(0); + + cmdparams = args.ToArray(); + + RunHGCommand(command, cmdparams); + + } + + private void RunHGCommand(string command, string[] cmdparams) + { + if (command.Equals("link-mapping")) + { + if (cmdparams.Length == 2) + { + try + { + m_autoMappingX = Convert.ToUInt32(cmdparams[0]); + m_autoMappingY = Convert.ToUInt32(cmdparams[1]); + m_enableAutoMapping = true; + } + catch (Exception) + { + m_autoMappingX = 0; + m_autoMappingY = 0; + m_enableAutoMapping = false; + } + } + } + else if (command.Equals("link-region")) + { + if (cmdparams.Length < 3) + { + if ((cmdparams.Length == 1) || (cmdparams.Length == 2)) + { + LoadXmlLinkFile(cmdparams); + } + else + { + LinkRegionCmdUsage(); + } + return; + } + + if (cmdparams[2].Contains(":")) + { + // New format + uint xloc, yloc; + string mapName; + try + { + xloc = Convert.ToUInt32(cmdparams[0]); + yloc = Convert.ToUInt32(cmdparams[1]); + mapName = cmdparams[2]; + if (cmdparams.Length > 3) + for (int i = 3; i < cmdparams.Length; i++) + mapName += " " + cmdparams[i]; + + m_log.Info(">> MapName: " + mapName); + //internalPort = Convert.ToUInt32(cmdparams[4]); + //remotingPort = Convert.ToUInt32(cmdparams[5]); + } + catch (Exception e) + { + m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message); + LinkRegionCmdUsage(); + return; + } + + m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc); + } + else + { + // old format + SimpleRegionInfo regInfo; + uint xloc, yloc; + uint externalPort; + string externalHostName; + try + { + xloc = Convert.ToUInt32(cmdparams[0]); + yloc = Convert.ToUInt32(cmdparams[1]); + externalPort = Convert.ToUInt32(cmdparams[3]); + externalHostName = cmdparams[2]; + //internalPort = Convert.ToUInt32(cmdparams[4]); + //remotingPort = Convert.ToUInt32(cmdparams[5]); + } + catch (Exception e) + { + m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message); + LinkRegionCmdUsage(); + return; + } + + //if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo)) + if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo)) + { + if (cmdparams.Length >= 5) + { + regInfo.RegionName = ""; + for (int i = 4; i < cmdparams.Length; i++) + regInfo.RegionName += cmdparams[i] + " "; + } + } + } + return; + } + else if (command.Equals("unlink-region")) + { + if (cmdparams.Length < 1) + { + UnlinkRegionCmdUsage(); + return; + } + if (m_HGGridConnector.TryUnlinkRegion(m_scene, 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(string[] cmdparams) + { + //use http://www.hgurl.com/hypergrid.xml for test + try + { + XmlReader r = XmlReader.Create(cmdparams[0]); + XmlConfigSource cs = new XmlConfigSource(r); + string[] excludeSections = null; + + if (cmdparams.Length == 2) + { + if (cmdparams[1].ToLower().StartsWith("excludelist:")) + { + string excludeString = cmdparams[1].ToLower(); + excludeString = excludeString.Remove(0, 12); + char[] splitter = { ';' }; + + excludeSections = excludeString.Split(splitter); + } + } + + for (int i = 0; i < cs.Configs.Count; i++) + { + bool skip = false; + if ((excludeSections != null) && (excludeSections.Length > 0)) + { + for (int n = 0; n < excludeSections.Length; n++) + { + if (excludeSections[n] == cs.Configs[i].Name.ToLower()) + { + skip = true; + break; + } + } + } + if (!skip) + { + ReadLinkFromConfig(cs.Configs[i]); + } + } + } + catch (Exception e) + { + m_log.Error(e.ToString()); + } + } + + + private void ReadLinkFromConfig(IConfig config) + { + SimpleRegionInfo regInfo; + uint xloc, yloc; + uint externalPort; + string externalHostName; + uint realXLoc, realYLoc; + + xloc = Convert.ToUInt32(config.GetString("xloc", "0")); + yloc = Convert.ToUInt32(config.GetString("yloc", "0")); + externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); + externalHostName = config.GetString("externalHostName", ""); + realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); + realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0")); + + if (m_enableAutoMapping) + { + xloc = (uint)((xloc % 100) + m_autoMappingX); + yloc = (uint)((yloc % 100) + m_autoMappingY); + } + + if (((realXLoc == 0) && (realYLoc == 0)) || + (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && + ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) + { + if ( + m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, + externalHostName, out regInfo)) + { + regInfo.RegionName = config.GetString("localName", ""); + } + } + } + + + private void LinkRegionCmdUsage() + { + m_log.Info("Usage: link-region :[:]"); + 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 "); + } + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index e3cb05cd29..7aeb761db3 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -27,14 +27,18 @@ using System; using System.Collections.Generic; +using System.Net; using System.Reflection; +using System.Xml; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Services.Interfaces; using OpenSim.Server.Base; using OpenSim.Services.Connectors.Grid; +using OpenSim.Framework.Console; using OpenMetaverse; using log4net; @@ -94,7 +98,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid InitialiseConnectorModule(source); - + m_Enabled = true; m_log.Info("[HGGRID CONNECTOR]: HG grid enabled"); } @@ -137,6 +141,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return; scene.RegisterModuleInterface(this); + } public void RemoveRegion(Scene scene) @@ -145,11 +150,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void RegionLoaded(Scene scene) { - if (m_Enabled && !m_Initialized) + if (!m_Enabled) + return; + + if (!m_Initialized) { m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); m_Initialized = true; } + + HGCommands hgCommands = new HGCommands(this, scene); + scene.AddCommand("HG", "link-region", + "link-region :[:] ", + "Link a hypergrid region", hgCommands.RunCommand); + scene.AddCommand("HG", "unlink-region", + "unlink-region or : ", + "Unlink a hypergrid region", hgCommands.RunCommand); + scene.AddCommand("HG", "link-mapping", "link-mapping [ ] ", + "Set local coordinate to map HG regions to", hgCommands.RunCommand); + } #endregion @@ -305,6 +324,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #endregion + #region Auxiliary + private void AddHyperlinkRegion(SimpleRegionInfo regionInfo, ulong regionHandle) { m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); @@ -334,6 +355,194 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } m_HyperlinkHandles.Remove(regionID); } + #endregion + + #region Hyperlinks + + private static Random random = new Random(); + + public SimpleRegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc) + { + 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]; + } + + // Sanity check. Don't ever link to this sim. + IPAddress ipaddr = null; + try + { + ipaddr = Util.GetHostFromDNS(host); + } + catch { } + + if ((ipaddr != null) && + !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port))) + { + SimpleRegionInfo regInfo; + bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); + if (success) + { + regInfo.RegionName = mapName; + return regInfo; + } + } + + return null; + } + + public SimpleRegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) + { + uint xloc = (uint)(random.Next(0, Int16.MaxValue)); + return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); + } + + public bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc, + string externalRegionName, uint externalPort, string externalHostName, out SimpleRegionInfo regInfo) + { + m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); + + regInfo = new SimpleRegionInfo(); + regInfo.RegionName = externalRegionName; + regInfo.HttpPort = externalPort; + regInfo.ExternalHostName = externalHostName; + regInfo.RegionLocX = xloc; + regInfo.RegionLocY = yloc; + + try + { + regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); + } + catch (Exception e) + { + m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message); + return false; + } + + // Finally, link it + try + { + RegisterRegion(UUID.Zero, regInfo); + } + catch (Exception e) + { + m_log.Warn("[HGrid]: Unable to link region: " + e.Message); + return false; + } + + uint x, y; + if (!Check4096(m_scene, regInfo, out x, out y)) + { + DeregisterRegion(regInfo.RegionID); + if (client != null) + client.SendAlertMessage("Region is too far (" + x + ", " + y + ")"); + m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")"); + return false; + } + + if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y)) + { + DeregisterRegion(regInfo.RegionID); + if (client != null) + client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")"); + m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")"); + return false; + } + + m_log.Debug("[HGrid]: link region succeeded"); + return true; + } + + public bool TryUnlinkRegion(Scene m_scene, string mapName) + { + SimpleRegionInfo 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]; + // } + foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) + regInfo = r; + } + else + { + foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + if (r.RegionName.Equals(mapName)) + regInfo = r; + } + if (regInfo != null) + { + return DeregisterRegion(regInfo.RegionID); + } + else + { + m_log.InfoFormat("[HGrid]: Region {0} not found", mapName); + return false; + } + } + + /// + /// Cope with this viewer limitation. + /// + /// + /// + public bool Check4096(Scene m_scene, SimpleRegionInfo regInfo, out uint x, out uint y) + { + ulong realHandle = m_HyperlinkHandles[regInfo.RegionID]; + Utils.LongToUInts(realHandle, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + + if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) || + (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096)) + { + return false; + } + return true; + } + + public bool CheckCoords(uint thisx, uint thisy, uint x, uint y) + { + if ((thisx == x) && (thisy == y)) + return false; + return true; + } + + #endregion } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 22b1015073..8526653031 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -30,6 +30,8 @@ using System; using System.Collections.Generic; using System.Reflection; using Nini.Config; +using OpenMetaverse; + using OpenSim.Framework; using OpenSim.Services.Connectors; using OpenSim.Region.Framework.Interfaces; @@ -47,9 +49,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private bool m_Enabled = false; + private IGridService m_LocalGridService; + public RemoteGridServicesConnector(IConfigSource source) { - InitialiseService(source); + InitialiseServices(source); } #region ISharedRegionmodule @@ -72,14 +76,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid string name = moduleConfig.GetString("GridServices", ""); if (name == Name) { - InitialiseService(source); + InitialiseServices(source); m_Enabled = true; m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled"); } } } - private void InitialiseService(IConfigSource source) + private void InitialiseServices(IConfigSource source) { IConfig gridConfig = source.Configs["GridService"]; if (gridConfig == null) @@ -89,6 +93,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } base.Initialise(source); + + m_LocalGridService = new LocalGridServicesConnector(source); } public void PostInitialise() @@ -116,5 +122,57 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } #endregion + + #region IGridService + + public override bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + { + if (m_LocalGridService.RegisterRegion(scopeID, regionInfo)) + return base.RegisterRegion(scopeID, regionInfo); + + return false; + } + + public override bool DeregisterRegion(UUID regionID) + { + if (m_LocalGridService.DeregisterRegion(regionID)) + return base.DeregisterRegion(regionID); + + return false; + } + + // Let's not override GetNeighbours -- let's get them all from the grid server + + public override SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + { + SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID); + if (rinfo == null) + rinfo = base.GetRegionByUUID(scopeID, regionID); + + return rinfo; + } + + public override SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + { + SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); + if (rinfo == null) + rinfo = base.GetRegionByPosition(scopeID, x, y); + + return rinfo; + } + + public override SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + { + SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName); + if (rinfo == null) + rinfo = base.GetRegionByName(scopeID, regionName); + + return rinfo; + } + + // Let's not override GetRegionsByName -- let's get them all from the grid server + // Let's not override GetRegionRange -- let's get them all from the grid server + + #endregion } } diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs new file mode 100644 index 0000000000..b8d9c7db87 --- /dev/null +++ b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs @@ -0,0 +1,112 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; + +using log4net; +using Nwc.XmlRpc; + +namespace OpenSim.Server.Handlers.Grid +{ + public class HypergridServiceInConnector : ServiceConnector + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private List m_RegionsOnSim = new List(); + + public HypergridServiceInConnector(IConfigSource config, IHttpServer server) : + base(config, server) + { + server.AddXmlRPCHandler("link_region", LinkRegionRequest, false); + } + + /// + /// Someone wants to link to us + /// + /// + /// + public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient) + { + Hashtable requestData = (Hashtable)request.Params[0]; + //string host = (string)requestData["host"]; + //string portstr = (string)requestData["port"]; + string name = (string)requestData["region_name"]; + + m_log.DebugFormat("[HGrid]: Hyperlink request"); + + SimpleRegionInfo regInfo = null; + foreach (SimpleRegionInfo r in m_RegionsOnSim) + { + if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower())) + { + regInfo = r; + break; + } + } + + if (regInfo == null) + regInfo = m_RegionsOnSim[0]; // Send out the first region + + Hashtable hash = new Hashtable(); + hash["uuid"] = regInfo.RegionID.ToString(); + hash["handle"] = regInfo.RegionHandle.ToString(); + //m_log.Debug(">> Here " + regInfo.RegionHandle); + //hash["region_image"] = regInfo.RegionSettings.TerrainImageID.ToString(); + hash["region_name"] = regInfo.RegionName; + hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); + //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port); + + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = hash; + return response; + } + + public void AddRegion(SimpleRegionInfo rinfo) + { + m_RegionsOnSim.Add(rinfo); + } + + public void RemoveRegion(SimpleRegionInfo rinfo) + { + if (m_RegionsOnSim.Contains(rinfo)) + m_RegionsOnSim.Remove(rinfo); + } + } +} diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index ae7db7e05c..1962bcf17d 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -85,7 +85,7 @@ namespace OpenSim.Services.Connectors #region IGridService - public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + public virtual bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) { Dictionary rinfo = regionInfo.ToKeyValuePairs(); Dictionary sendData = new Dictionary(); @@ -108,7 +108,7 @@ namespace OpenSim.Services.Connectors return false; } - public bool DeregisterRegion(UUID regionID) + public virtual bool DeregisterRegion(UUID regionID) { Dictionary sendData = new Dictionary(); @@ -128,7 +128,7 @@ namespace OpenSim.Services.Connectors return false; } - public List GetNeighbours(UUID scopeID, UUID regionID) + public virtual List GetNeighbours(UUID scopeID, UUID regionID) { Dictionary sendData = new Dictionary(); @@ -166,7 +166,7 @@ namespace OpenSim.Services.Connectors return rinfos; } - public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public virtual SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) { Dictionary sendData = new Dictionary(); @@ -197,7 +197,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public virtual SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) { Dictionary sendData = new Dictionary(); @@ -229,7 +229,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public virtual SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) { Dictionary sendData = new Dictionary(); @@ -260,7 +260,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public virtual List GetRegionsByName(UUID scopeID, string name, int maxNumber) { Dictionary sendData = new Dictionary(); @@ -299,7 +299,7 @@ namespace OpenSim.Services.Connectors return rinfos; } - public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public virtual List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { Dictionary sendData = new Dictionary(); From 35deff7ec4df6156abccdbeed83b14a6083e28f9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 09:27:01 -0700 Subject: [PATCH 06/18] Modules active. Tested HGGridConnector in standalone only for now. Modules commands work. --- .../Resources/CoreModulePlugin.addin.xml | 4 +++ .../Grid/HypergridServiceInConnectorModule.cs | 2 +- .../ServiceConnectorsOut/Grid/HGCommands.cs | 6 ++-- .../Grid/HGGridConnector.cs | 28 +++++++++++++------ .../Grid/LocalGridServiceConnector.cs | 4 +++ .../Grid/RemoteGridServiceConnector.cs | 4 +++ bin/config-include/Standalone.ini | 5 ++++ bin/config-include/StandaloneHypergrid.ini | 7 ++++- 8 files changed, 46 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index f9e61aa972..8f8271845d 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -38,11 +38,15 @@ + + + \ + \ diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs index 8d113d38d0..4fbee7f4c8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs @@ -64,7 +64,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid m_Enabled = moduleConfig.GetBoolean("HypergridServiceInConnector", false); if (m_Enabled) { - m_log.Info("[INVENTORY IN CONNECTOR]: Hypergrid Service In Connector enabled"); + m_log.Info("[HGGRID IN CONNECTOR]: Hypergrid Service In Connector enabled"); } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs index eee3a6ccdf..2a862d4fbe 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs @@ -85,7 +85,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private void RunHGCommand(string command, string[] cmdparams) { - if (command.Equals("link-mapping")) + if (command.Equals("linkk-mapping")) { if (cmdparams.Length == 2) { @@ -103,7 +103,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } } } - else if (command.Equals("link-region")) + else if (command.Equals("linkk-region")) { if (cmdparams.Length < 3) { @@ -181,7 +181,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } return; } - else if (command.Equals("unlink-region")) + else if (command.Equals("unlinkk-region")) { if (cmdparams.Length < 1) { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 7aeb761db3..c6ade15779 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -156,18 +156,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (!m_Initialized) { m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); + HGCommands hgCommands = new HGCommands(this, scene); + MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-region", + "link-region :[:] ", + "Link a hypergrid region", hgCommands.RunCommand); + MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlinkk-region", + "unlink-region or : ", + "Unlink a hypergrid region", hgCommands.RunCommand); + MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-mapping", "link-mapping [ ] ", + "Set local coordinate to map HG regions to", hgCommands.RunCommand); m_Initialized = true; } - HGCommands hgCommands = new HGCommands(this, scene); - scene.AddCommand("HG", "link-region", - "link-region :[:] ", - "Link a hypergrid region", hgCommands.RunCommand); - scene.AddCommand("HG", "unlink-region", - "unlink-region or : ", - "Unlink a hypergrid region", hgCommands.RunCommand); - scene.AddCommand("HG", "link-mapping", "link-mapping [ ] ", - "Set local coordinate to map HG regions to", hgCommands.RunCommand); + + //scene.AddCommand("HGGridServicesConnector", "linkk-region", + // "link-region :[:] ", + // "Link a hypergrid region", hgCommands.RunCommand); + //scene.AddCommand("HGGridServicesConnector", "unlinkk-region", + // "unlink-region or : ", + // "Unlink a hypergrid region", hgCommands.RunCommand); + //scene.AddCommand("HGGridServicesConnector", "linkk-mapping", "link-mapping [ ] ", + // "Set local coordinate to map HG regions to", hgCommands.RunCommand); } @@ -407,6 +416,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return null; } + // From the map search and secondlife://blah public SimpleRegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) { uint xloc = (uint)(random.Next(0, Int16.MaxValue)); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 3f294013d4..c1b7235eae 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -50,6 +50,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private bool m_Enabled = false; + public LocalGridServicesConnector() + { + } + public LocalGridServicesConnector(IConfigSource source) { InitialiseService(source); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 8526653031..4303fa85ff 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -51,6 +51,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private IGridService m_LocalGridService; + public RemoteGridServicesConnector() + { + } + public RemoteGridServicesConnector(IConfigSource source) { InitialiseServices(source); diff --git a/bin/config-include/Standalone.ini b/bin/config-include/Standalone.ini index 24020b63ff..69c60ee342 100644 --- a/bin/config-include/Standalone.ini +++ b/bin/config-include/Standalone.ini @@ -12,6 +12,7 @@ InventoryServices = "LocalInventoryServicesConnector" NeighbourServices = "LocalNeighbourServicesConnector" AuthorizationServices = "LocalAuthorizationServicesConnector" + GridServices = "LocalGridServicesConnector" [AssetService] LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService" @@ -21,3 +22,7 @@ [AuthorizationService] LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService" + +[GridService] + LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" + \ No newline at end of file diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index aa122be34e..24b0f2664c 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini @@ -12,9 +12,11 @@ InventoryServices = "HGInventoryBroker" NeighbourServices = "LocalNeighbourServicesConnector" AuthorizationServices = "LocalAuthorizationServicesConnector" + GridServices = "HGGridServicesConnector" InventoryServiceInConnector = true AssetServiceInConnector = true HGAuthServiceInConnector = true + HypergridServiceInConnector = true [AssetService] ; For the AssetServiceInConnector @@ -39,4 +41,7 @@ ; For the HGAuthServiceInConnector LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:HGAuthenticationService" - \ No newline at end of file +[GridService] + LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" + GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:LocalGridServiceConnector" + StorageProvider = "OpenSim.Data.Null.dll" \ No newline at end of file From 9c2ffa8f2e49aa70e0b2c6afff875bbdb84ba0dc Mon Sep 17 00:00:00 2001 From: "Teravus Ovares (Dan Olivares)" Date: Wed, 23 Sep 2009 14:55:22 -0400 Subject: [PATCH 07/18] * fix endlines in LSL_api.cs --- .../Shared/Api/Implementation/LSL_Api.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b63147860f..4c52b114ea 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + using System; using System.Collections; using System.Collections.Generic; @@ -7838,8 +7838,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetHTTPHeader(LSL_Key request_id, string header) { m_host.AddScriptLPS(1); - - if (m_UrlModule != null) + + if (m_UrlModule != null) return m_UrlModule.GetHttpHeader(new UUID(request_id), header); return String.Empty; } @@ -9124,9 +9124,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Partial implementation: support for parameter flags needed // see http://wiki.secondlife.com/wiki/llHTTPResponse - m_host.AddScriptLPS(1); - - if (m_UrlModule != null) + m_host.AddScriptLPS(1); + + if (m_UrlModule != null) m_UrlModule.HttpResponse(new UUID(id), status,body); } From c592a60f4613587fd6c297de57f9958bcc60deaa Mon Sep 17 00:00:00 2001 From: "Teravus Ovares (Dan Olivares)" Date: Wed, 23 Sep 2009 15:00:18 -0400 Subject: [PATCH 08/18] Fix endlines on UrlModule.cs --- .../Scripting/LSLHttp/UrlModule.cs | 484 +++++++++--------- 1 file changed, 242 insertions(+), 242 deletions(-) diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 2d81e4c191..8b7a878da6 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -54,12 +54,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { public UUID requestID; public Dictionary headers; - public string body; - public int responseCode; + public string body; + public int responseCode; public string responseBody; - public ManualResetEvent ev; + public ManualResetEvent ev; public bool requestDone; - public int startTime; + public int startTime; public string uri; } @@ -73,23 +73,23 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp new Dictionary(); private Dictionary m_UrlMap = - new Dictionary(); - + new Dictionary(); + private int m_TotalUrls = 100; - private IHttpServer m_HttpServer = null; - - private string m_ExternalHostNameForLSL = ""; + private IHttpServer m_HttpServer = null; + + private string m_ExternalHostNameForLSL = ""; public Type ReplaceableInterface { get { return null; } - } - - private Hashtable HandleHttpPoll(Hashtable request) - { - return new Hashtable(); + } + + private Hashtable HandleHttpPoll(Hashtable request) + { + return new Hashtable(); } public string Name @@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } public void Initialise(IConfigSource config) - { + { m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName); } @@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public void Close() { - } + } public UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID) { UUID urlcode = UUID.Random(); @@ -141,8 +141,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; - } - string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; + } + string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; @@ -152,14 +152,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp urlData.urlcode = urlcode; urlData.requests = new Dictionary(); - - m_UrlMap[url] = urlData; - - string uri = "/lslhttp/" + urlcode.ToString() + "/"; - - m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, - new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, - urlcode)); + + m_UrlMap[url] = urlData; + + string uri = "/lslhttp/" + urlcode.ToString() + "/"; + + m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, + new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, + urlcode)); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } @@ -180,11 +180,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { lock (m_UrlMap) { - UrlData data; - - if (!m_UrlMap.TryGetValue(url, out data)) - { - return; + UrlData data; + + if (!m_UrlMap.TryGetValue(url, out data)) + { + return; } foreach (UUID req in data.requests.Keys) @@ -196,36 +196,36 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } public void HttpResponse(UUID request, int status, string body) - { - if (m_RequestMap.ContainsKey(request)) - { - UrlData urlData = m_RequestMap[request]; - RequestData requestData=urlData.requests[request]; - urlData.requests[request].responseCode = status; - urlData.requests[request].responseBody = body; - //urlData.requests[request].ev.Set(); - urlData.requests[request].requestDone=true; - } - else - { - m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); + { + if (m_RequestMap.ContainsKey(request)) + { + UrlData urlData = m_RequestMap[request]; + RequestData requestData=urlData.requests[request]; + urlData.requests[request].responseCode = status; + urlData.requests[request].responseBody = body; + //urlData.requests[request].ev.Set(); + urlData.requests[request].requestDone=true; + } + else + { + m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); } } public string GetHttpHeader(UUID requestId, string header) - { - if (m_RequestMap.ContainsKey(requestId)) - { - UrlData urlData=m_RequestMap[requestId]; - string value; - if (urlData.requests[requestId].headers.TryGetValue(header,out value)) - return value; - } - else - { + { + if (m_RequestMap.ContainsKey(requestId)) + { + UrlData urlData=m_RequestMap[requestId]; + string value; + if (urlData.requests[requestId].headers.TryGetValue(header,out value)) + return value; + } + else + { m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); - } - return String.Empty; + } + return String.Empty; } public int GetFreeUrls() @@ -275,63 +275,63 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp foreach (string urlname in removeURLs) m_UrlMap.Remove(urlname); } - } - + } + private void RemoveUrl(UrlData data) { - m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); - } - - private Hashtable NoEvents(UUID requestID, UUID sessionID) - { - Hashtable response = new Hashtable(); - UrlData url; - lock (m_RequestMap) - { - if (!m_RequestMap.ContainsKey(requestID)) - return response; - url = m_RequestMap[requestID]; - } - - if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) - { - response["int_response_code"] = 500; - response["str_response_string"] = "Script timeout"; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - - //remove from map - lock (url) - { - url.requests.Remove(requestID); - m_RequestMap.Remove(requestID); - } - - return response; + m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); + } + + private Hashtable NoEvents(UUID requestID, UUID sessionID) + { + Hashtable response = new Hashtable(); + UrlData url; + lock (m_RequestMap) + { + if (!m_RequestMap.ContainsKey(requestID)) + return response; + url = m_RequestMap[requestID]; } - - return response; - } - + if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) + { + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + //remove from map + lock (url) + { + url.requests.Remove(requestID); + m_RequestMap.Remove(requestID); + } + + return response; + } + + + return response; + } + private bool HasEvents(UUID requestID, UUID sessionID) { - UrlData url=null; + UrlData url=null; lock (m_RequestMap) - { - if (!m_RequestMap.ContainsKey(requestID)) - { - return false; - } - url = m_RequestMap[requestID]; - if (!url.requests.ContainsKey(requestID)) - { - return false; + { + if (!m_RequestMap.ContainsKey(requestID)) + { + return false; } - } + url = m_RequestMap[requestID]; + if (!url.requests.ContainsKey(requestID)) + { + return false; + } + } if (System.Environment.TickCount-url.requests[requestID].startTime>25000) { @@ -343,146 +343,146 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp else return false; - } - private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) - { - UrlData url = null; - RequestData requestData = null; - - lock (m_RequestMap) - { - if (!m_RequestMap.ContainsKey(requestID)) - return NoEvents(requestID,sessionID); - url = m_RequestMap[requestID]; - requestData = url.requests[requestID]; - } - - if (!requestData.requestDone) - return NoEvents(requestID,sessionID); - - Hashtable response = new Hashtable(); - - if (System.Environment.TickCount - requestData.startTime > 25000) - { - response["int_response_code"] = 500; - response["str_response_string"] = "Script timeout"; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - return response; - } - //put response - response["int_response_code"] = requestData.responseCode; - response["str_response_string"] = requestData.responseBody; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - - //remove from map - lock (url) - { - url.requests.Remove(requestID); - m_RequestMap.Remove(requestID); - } - - return response; - } + } + private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) + { + UrlData url = null; + RequestData requestData = null; + + lock (m_RequestMap) + { + if (!m_RequestMap.ContainsKey(requestID)) + return NoEvents(requestID,sessionID); + url = m_RequestMap[requestID]; + requestData = url.requests[requestID]; + } + + if (!requestData.requestDone) + return NoEvents(requestID,sessionID); + + Hashtable response = new Hashtable(); + + if (System.Environment.TickCount - requestData.startTime > 25000) + { + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + return response; + } + //put response + response["int_response_code"] = requestData.responseCode; + response["str_response_string"] = requestData.responseBody; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + //remove from map + lock (url) + { + url.requests.Remove(requestID); + m_RequestMap.Remove(requestID); + } + + return response; + } public void HttpRequestHandler(UUID requestID, Hashtable request) - { - lock (request) - { - string uri = request["uri"].ToString(); - - try - { - Hashtable headers = (Hashtable)request["headers"]; - - string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; - - int pos1 = uri.IndexOf("/");// /lslhttp - int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ - int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp// - string uri_tmp = uri.Substring(0, pos3 + 1); - //HTTP server code doesn't provide us with QueryStrings - string pathInfo; - string queryString; - queryString = ""; - - pathInfo = uri.Substring(pos3); - - UrlData url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; - - //for llGetHttpHeader support we need to store original URI here - //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers - //as per http://wiki.secondlife.com/wiki/LlGetHTTPHeader - - RequestData requestData = new RequestData(); - requestData.requestID = requestID; - requestData.requestDone = false; - requestData.startTime = System.Environment.TickCount; - requestData.uri = uri; - if (requestData.headers == null) - requestData.headers = new Dictionary(); - - foreach (DictionaryEntry header in headers) - { - string key = (string)header.Key; - string value = (string)header.Value; - requestData.headers.Add(key, value); - } - foreach (DictionaryEntry de in request) - { - if (de.Key.ToString() == "querystringkeys") - { - System.String[] keys = (System.String[])de.Value; - foreach (String key in keys) - { - if (request.ContainsKey(key)) - { - string val = (String)request[key]; - queryString = queryString + key + "=" + val + "&"; - } - } - if (queryString.Length > 1) - queryString = queryString.Substring(0, queryString.Length - 1); - - } - - } - - //if this machine is behind DNAT/port forwarding, currently this is being - //set to address of port forwarding router - requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; - requestData.headers["x-path-info"] = pathInfo; - requestData.headers["x-query-string"] = queryString; - requestData.headers["x-script-url"] = url.url; - - requestData.ev = new ManualResetEvent(false); - lock (url.requests) - { - url.requests.Add(requestID, requestData); - } - lock (m_RequestMap) - { - //add to request map - m_RequestMap.Add(requestID, url); - } - - url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); - - //send initial response? - Hashtable response = new Hashtable(); - - return; - - } - catch (Exception we) - { - //Hashtable response = new Hashtable(); - m_log.Warn("[HttpRequestHandler]: http-in request failed"); - m_log.Warn(we.Message); - m_log.Warn(we.StackTrace); - } + { + lock (request) + { + string uri = request["uri"].ToString(); + + try + { + Hashtable headers = (Hashtable)request["headers"]; + + string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; + + int pos1 = uri.IndexOf("/");// /lslhttp + int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ + int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp// + string uri_tmp = uri.Substring(0, pos3 + 1); + //HTTP server code doesn't provide us with QueryStrings + string pathInfo; + string queryString; + queryString = ""; + + pathInfo = uri.Substring(pos3); + + UrlData url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; + + //for llGetHttpHeader support we need to store original URI here + //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers + //as per http://wiki.secondlife.com/wiki/LlGetHTTPHeader + + RequestData requestData = new RequestData(); + requestData.requestID = requestID; + requestData.requestDone = false; + requestData.startTime = System.Environment.TickCount; + requestData.uri = uri; + if (requestData.headers == null) + requestData.headers = new Dictionary(); + + foreach (DictionaryEntry header in headers) + { + string key = (string)header.Key; + string value = (string)header.Value; + requestData.headers.Add(key, value); + } + foreach (DictionaryEntry de in request) + { + if (de.Key.ToString() == "querystringkeys") + { + System.String[] keys = (System.String[])de.Value; + foreach (String key in keys) + { + if (request.ContainsKey(key)) + { + string val = (String)request[key]; + queryString = queryString + key + "=" + val + "&"; + } + } + if (queryString.Length > 1) + queryString = queryString.Substring(0, queryString.Length - 1); + + } + + } + + //if this machine is behind DNAT/port forwarding, currently this is being + //set to address of port forwarding router + requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; + requestData.headers["x-path-info"] = pathInfo; + requestData.headers["x-query-string"] = queryString; + requestData.headers["x-script-url"] = url.url; + + requestData.ev = new ManualResetEvent(false); + lock (url.requests) + { + url.requests.Add(requestID, requestData); + } + lock (m_RequestMap) + { + //add to request map + m_RequestMap.Add(requestID, url); + } + + url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); + + //send initial response? + Hashtable response = new Hashtable(); + + return; + + } + catch (Exception we) + { + //Hashtable response = new Hashtable(); + m_log.Warn("[HttpRequestHandler]: http-in request failed"); + m_log.Warn(we.Message); + m_log.Warn(we.StackTrace); + } } } From 67276589c883fe1a74d8d52057db1431d637dade Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 17:20:07 -0700 Subject: [PATCH 09/18] Changed IGridService to use the new GridRegion data structure instead of old SimpleRegionInfo. Added grid configs to standalones. --- OpenSim/Data/Null/NullRegionData.cs | 1 + .../ServiceConnectorsOut/Grid/HGCommands.cs | 36 ++- .../Grid/HGGridConnector.cs | 82 +++--- .../Grid/LocalGridServiceConnector.cs | 18 +- .../Grid/RemoteGridServiceConnector.cs | 15 +- .../Handlers/Grid/GridServerPostHandler.cs | 7 +- .../Connectors/Grid/GridServiceConnector.cs | 39 +-- .../Grid/HypergridServiceConnector.cs | 5 +- OpenSim/Services/GridService/GridService.cs | 32 +-- .../Services/GridService/GridServiceBase.cs | 2 +- OpenSim/Services/Interfaces/IGridService.cs | 249 +++++++++++++++++- bin/config-include/Standalone.ini | 1 + bin/config-include/StandaloneHypergrid.ini | 4 +- 13 files changed, 371 insertions(+), 120 deletions(-) diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index 588b8ace5c..03489f90b6 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs @@ -40,6 +40,7 @@ namespace OpenSim.Data.Null public NullRegionData(string connectionString, string realm) { + Console.WriteLine("[XXX] NullRegionData constructor"); } public List Get(string regionName, UUID scopeID) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs index 2a862d4fbe..36915effb5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs @@ -37,6 +37,7 @@ using OpenSim.Framework.Console; using OpenSim.Region.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Hypergrid; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { @@ -121,12 +122,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (cmdparams[2].Contains(":")) { // New format - uint xloc, yloc; + int xloc, yloc; string mapName; try { - xloc = Convert.ToUInt32(cmdparams[0]); - yloc = Convert.ToUInt32(cmdparams[1]); + xloc = Convert.ToInt32(cmdparams[0]); + yloc = Convert.ToInt32(cmdparams[1]); mapName = cmdparams[2]; if (cmdparams.Length > 3) for (int i = 3; i < cmdparams.Length; i++) @@ -143,19 +144,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return; } + // Convert cell coordinates given by the user to meters + xloc = xloc * (int)Constants.RegionSize; + yloc = yloc * (int)Constants.RegionSize; m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc); } else { // old format - SimpleRegionInfo regInfo; - uint xloc, yloc; + GridRegion regInfo; + int xloc, yloc; uint externalPort; string externalHostName; try { - xloc = Convert.ToUInt32(cmdparams[0]); - yloc = Convert.ToUInt32(cmdparams[1]); + xloc = Convert.ToInt32(cmdparams[0]); + yloc = Convert.ToInt32(cmdparams[1]); externalPort = Convert.ToUInt32(cmdparams[3]); externalHostName = cmdparams[2]; //internalPort = Convert.ToUInt32(cmdparams[4]); @@ -168,7 +172,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return; } - //if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo)) + // Convert cell coordinates given by the user to meters + xloc = xloc * (int)Constants.RegionSize; + yloc = yloc * (int)Constants.RegionSize; if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo)) { if (cmdparams.Length >= 5) @@ -245,14 +251,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private void ReadLinkFromConfig(IConfig config) { - SimpleRegionInfo regInfo; - uint xloc, yloc; + GridRegion regInfo; + int xloc, yloc; uint externalPort; string externalHostName; uint realXLoc, realYLoc; - xloc = Convert.ToUInt32(config.GetString("xloc", "0")); - yloc = Convert.ToUInt32(config.GetString("yloc", "0")); + xloc = Convert.ToInt32(config.GetString("xloc", "0")); + yloc = Convert.ToInt32(config.GetString("yloc", "0")); externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); externalHostName = config.GetString("externalHostName", ""); realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); @@ -260,14 +266,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (m_enableAutoMapping) { - xloc = (uint)((xloc % 100) + m_autoMappingX); - yloc = (uint)((yloc % 100) + m_autoMappingY); + xloc = (int)((xloc % 100) + m_autoMappingX); + yloc = (int)((yloc % 100) + m_autoMappingY); } if (((realXLoc == 0) && (realYLoc == 0)) || (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) { + xloc = xloc * (int)Constants.RegionSize; + yloc = yloc * (int)Constants.RegionSize; if ( m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo)) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index c6ade15779..0c2a835c13 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -36,6 +36,7 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; using OpenSim.Services.Connectors.Grid; using OpenSim.Framework.Console; @@ -59,13 +60,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private HypergridServiceConnector m_HypergridServiceConnector; // Hyperlink regions are hyperlinks on the map - protected Dictionary m_HyperlinkRegions = new Dictionary(); + protected Dictionary m_HyperlinkRegions = new Dictionary(); // Known regions are home regions of visiting foreign users. // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when // the visitor goes away. They are mapped to X=0 on the map. // This is key-ed on agent ID - protected Dictionary m_knownRegions = new Dictionary(); + protected Dictionary m_knownRegions = new Dictionary(); protected Dictionary m_HyperlinkHandles = new Dictionary(); @@ -184,7 +185,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #region IGridService - public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + public bool RegisterRegion(UUID scopeID, GridRegion regionInfo) { // Region doesn't exist here. Trying to link remote region if (regionInfo.RegionID.Equals(UUID.Zero)) @@ -222,7 +223,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } // Try the foreign users home collection - foreach (SimpleRegionInfo r in m_knownRegions.Values) + foreach (GridRegion r in m_knownRegions.Values) if (r.RegionID == regionID) { RemoveHyperlinkHomeRegion(regionID); @@ -233,21 +234,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return m_GridServiceConnector.DeregisterRegion(regionID); } - public List GetNeighbours(UUID scopeID, UUID regionID) + public List GetNeighbours(UUID scopeID, UUID regionID) { // No serving neighbours on hyperliked regions. // Just the regular regions. return m_GridServiceConnector.GetNeighbours(scopeID, regionID); } - public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { // Try the hyperlink collection if (m_HyperlinkRegions.ContainsKey(regionID)) return m_HyperlinkRegions[regionID]; // Try the foreign users home collection - foreach (SimpleRegionInfo r in m_knownRegions.Values) + foreach (GridRegion r in m_knownRegions.Values) if (r.RegionID == regionID) return m_knownRegions[regionID]; @@ -255,19 +256,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); } - public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize; int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize; // Try the hyperlink collection - foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + foreach (GridRegion r in m_HyperlinkRegions.Values) { if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) return r; } // Try the foreign users home collection - foreach (SimpleRegionInfo r in m_knownRegions.Values) + foreach (GridRegion r in m_knownRegions.Values) { if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) return r; @@ -277,22 +278,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); } - public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public GridRegion GetRegionByName(UUID scopeID, string regionName) { // Try normal grid first - SimpleRegionInfo region = m_GridServiceConnector.GetRegionByName(scopeID, regionName); + GridRegion region = m_GridServiceConnector.GetRegionByName(scopeID, regionName); if (region != null) return region; // Try the hyperlink collection - foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + foreach (GridRegion r in m_HyperlinkRegions.Values) { if (r.RegionName == regionName) return r; } // Try the foreign users home collection - foreach (SimpleRegionInfo r in m_knownRegions.Values) + foreach (GridRegion r in m_knownRegions.Values) { if (r.RegionName == regionName) return r; @@ -300,9 +301,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return null; } - public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { - List rinfos = new List(); + List rinfos = new List(); // Commenting until regionname exists //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) @@ -313,15 +314,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return rinfos; } - public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; - List rinfos = new List(); - foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + List rinfos = new List(); + foreach (GridRegion r in m_HyperlinkRegions.Values) if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) && (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax)) rinfos.Add(r); @@ -335,7 +336,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #region Auxiliary - private void AddHyperlinkRegion(SimpleRegionInfo regionInfo, ulong regionHandle) + private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) { m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); @@ -347,7 +348,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid m_HyperlinkHandles.Remove(regionID); } - private void AddHyperlinkHomeRegion(UUID userID, SimpleRegionInfo regionInfo, ulong regionHandle) + private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle) { m_knownRegions.Add(userID, regionInfo); m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); @@ -355,7 +356,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private void RemoveHyperlinkHomeRegion(UUID regionID) { - foreach (KeyValuePair kvp in m_knownRegions) + foreach (KeyValuePair kvp in m_knownRegions) { if (kvp.Value.RegionID == regionID) { @@ -370,7 +371,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private static Random random = new Random(); - public SimpleRegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc) + public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc) { string host = "127.0.0.1"; string portstr; @@ -404,7 +405,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if ((ipaddr != null) && !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port))) { - SimpleRegionInfo regInfo; + GridRegion regInfo; bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); if (success) { @@ -417,18 +418,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } // From the map search and secondlife://blah - public SimpleRegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) + public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) { - uint xloc = (uint)(random.Next(0, Int16.MaxValue)); + int xloc = random.Next(0, Int16.MaxValue); return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); } - public bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc, - string externalRegionName, uint externalPort, string externalHostName, out SimpleRegionInfo regInfo) + public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc, + string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo) { m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); - regInfo = new SimpleRegionInfo(); + regInfo = new GridRegion(); regInfo.RegionName = externalRegionName; regInfo.HttpPort = externalPort; regInfo.ExternalHostName = externalHostName; @@ -456,7 +457,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return false; } - uint x, y; + int x, y; if (!Check4096(m_scene, regInfo, out x, out y)) { DeregisterRegion(regInfo.RegionID); @@ -481,7 +482,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public bool TryUnlinkRegion(Scene m_scene, string mapName) { - SimpleRegionInfo regInfo = null; + GridRegion regInfo = null; if (mapName.Contains(":")) { string host = "127.0.0.1"; @@ -504,13 +505,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // { // regionName = parts[2]; // } - foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + foreach (GridRegion r in m_HyperlinkRegions.Values) if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) regInfo = r; } else { - foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + foreach (GridRegion r in m_HyperlinkRegions.Values) if (r.RegionName.Equals(mapName)) regInfo = r; } @@ -530,22 +531,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid /// /// /// - public bool Check4096(Scene m_scene, SimpleRegionInfo regInfo, out uint x, out uint y) + public bool Check4096(Scene m_scene, GridRegion regInfo, out int x, out int y) { ulong realHandle = m_HyperlinkHandles[regInfo.RegionID]; - Utils.LongToUInts(realHandle, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; + uint ux = 0, uy = 0; + Utils.LongToUInts(realHandle, out ux, out uy); + x = (int)(ux / Constants.RegionSize); + y = (int)(uy / Constants.RegionSize); - if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) || - (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096)) + if ((Math.Abs((int)(m_scene.RegionInfo.RegionLocX / Constants.RegionSize) - x) >= 4096) || + (Math.Abs((int)(m_scene.RegionInfo.RegionLocY / Constants.RegionSize) - y) >= 4096)) { return false; } return true; } - public bool CheckCoords(uint thisx, uint thisy, uint x, uint y) + public bool CheckCoords(uint thisx, uint thisy, int x, int y) { if ((thisx == x) && (thisy == y)) return false; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index c1b7235eae..743d3b9a66 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -35,6 +35,7 @@ using OpenSim.Server.Base; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenMetaverse; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid @@ -56,6 +57,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public LocalGridServicesConnector(IConfigSource source) { + m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated"); InitialiseService(source); } @@ -111,7 +113,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (m_GridService == null) { - m_log.Error("[LOCAL GRID CONNECTOR]: Can't load asset service"); + m_log.Error("[LOCAL GRID CONNECTOR]: Can't load grid service"); return; } } @@ -144,7 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #region IGridService - public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + public bool RegisterRegion(UUID scopeID, GridRegion regionInfo) { return m_GridService.RegisterRegion(scopeID, regionInfo); } @@ -154,32 +156,32 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return m_GridService.DeregisterRegion(regionID); } - public List GetNeighbours(UUID scopeID, UUID regionID) + public List GetNeighbours(UUID scopeID, UUID regionID) { return m_GridService.GetNeighbours(scopeID, regionID); } - public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { return m_GridService.GetRegionByUUID(scopeID, regionID); } - public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { return m_GridService.GetRegionByPosition(scopeID, x, y); } - public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public GridRegion GetRegionByName(UUID scopeID, string regionName) { return m_GridService.GetRegionByName(scopeID, regionName); } - public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { return m_GridService.GetRegionsByName(scopeID, name, maxNumber); } - public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 4303fa85ff..91a808b21f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -37,6 +37,7 @@ using OpenSim.Services.Connectors; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { @@ -129,7 +130,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #region IGridService - public override bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + public override bool RegisterRegion(UUID scopeID, GridRegion regionInfo) { if (m_LocalGridService.RegisterRegion(scopeID, regionInfo)) return base.RegisterRegion(scopeID, regionInfo); @@ -147,27 +148,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // Let's not override GetNeighbours -- let's get them all from the grid server - public override SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { - SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID); + GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID); if (rinfo == null) rinfo = base.GetRegionByUUID(scopeID, regionID); return rinfo; } - public override SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public override GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { - SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); + GridRegion rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); if (rinfo == null) rinfo = base.GetRegionByPosition(scopeID, x, y); return rinfo; } - public override SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public override GridRegion GetRegionByName(UUID scopeID, string regionName) { - SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName); + GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName); if (rinfo == null) rinfo = base.GetRegionByName(scopeID, regionName); diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index 39c0584aa5..e72c2eb491 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -38,6 +38,7 @@ using System.Xml.Serialization; using System.Collections.Generic; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Framework; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -117,7 +118,7 @@ namespace OpenSim.Server.Handlers.Grid Dictionary rinfoData = new Dictionary(); foreach (KeyValuePair kvp in request) rinfoData[kvp.Key] = kvp.Value; - SimpleRegionInfo rinfo = new SimpleRegionInfo(rinfoData); + GridRegion rinfo = new GridRegion(rinfoData); bool result = m_GridService.RegisterRegion(scopeID, rinfo); @@ -158,11 +159,11 @@ namespace OpenSim.Server.Handlers.Grid else m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); - List rinfos = m_GridService.GetNeighbours(scopeID, regionID); + List rinfos = m_GridService.GetNeighbours(scopeID, regionID); Dictionary result = new Dictionary(); int i = 0; - foreach (SimpleRegionInfo rinfo in rinfos) + foreach (GridRegion rinfo in rinfos) { Dictionary rinfoDict = rinfo.ToKeyValuePairs(); result["region" + i] = rinfoDict; diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 1962bcf17d..0a867db630 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -35,6 +35,7 @@ using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; using OpenMetaverse; @@ -85,7 +86,7 @@ namespace OpenSim.Services.Connectors #region IGridService - public virtual bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo) { Dictionary rinfo = regionInfo.ToKeyValuePairs(); Dictionary sendData = new Dictionary(); @@ -128,7 +129,7 @@ namespace OpenSim.Services.Connectors return false; } - public virtual List GetNeighbours(UUID scopeID, UUID regionID) + public virtual List GetNeighbours(UUID scopeID, UUID regionID) { Dictionary sendData = new Dictionary(); @@ -143,7 +144,7 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - List rinfos = new List(); + List rinfos = new List(); if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; @@ -151,7 +152,7 @@ namespace OpenSim.Services.Connectors { if (r is Dictionary) { - SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + GridRegion rinfo = new GridRegion((Dictionary)r); rinfos.Add(rinfo); } else @@ -166,7 +167,7 @@ namespace OpenSim.Services.Connectors return rinfos; } - public virtual SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { Dictionary sendData = new Dictionary(); @@ -181,11 +182,11 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - SimpleRegionInfo rinfo = null; + GridRegion rinfo = null; if ((replyData != null) && (replyData["result"] != null)) { if (replyData["result"] is Dictionary) - rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + rinfo = new GridRegion((Dictionary)replyData["result"]); else m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", scopeID, regionID); @@ -197,7 +198,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public virtual SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { Dictionary sendData = new Dictionary(); @@ -213,11 +214,11 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - SimpleRegionInfo rinfo = null; + GridRegion rinfo = null; if ((replyData != null) && (replyData["result"] != null)) { if (replyData["result"] is Dictionary) - rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + rinfo = new GridRegion((Dictionary)replyData["result"]); else m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", scopeID, x, y); @@ -229,7 +230,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public virtual SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public virtual GridRegion GetRegionByName(UUID scopeID, string regionName) { Dictionary sendData = new Dictionary(); @@ -244,11 +245,11 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - SimpleRegionInfo rinfo = null; + GridRegion rinfo = null; if ((replyData != null) && (replyData["result"] != null)) { if (replyData["result"] is Dictionary) - rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + rinfo = new GridRegion((Dictionary)replyData["result"]); else m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", scopeID, regionName); @@ -260,7 +261,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public virtual List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public virtual List GetRegionsByName(UUID scopeID, string name, int maxNumber) { Dictionary sendData = new Dictionary(); @@ -276,7 +277,7 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - List rinfos = new List(); + List rinfos = new List(); if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; @@ -284,7 +285,7 @@ namespace OpenSim.Services.Connectors { if (r is Dictionary) { - SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + GridRegion rinfo = new GridRegion((Dictionary)r); rinfos.Add(rinfo); } else @@ -299,7 +300,7 @@ namespace OpenSim.Services.Connectors return rinfos; } - public virtual List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public virtual List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { Dictionary sendData = new Dictionary(); @@ -317,7 +318,7 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - List rinfos = new List(); + List rinfos = new List(); if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; @@ -325,7 +326,7 @@ namespace OpenSim.Services.Connectors { if (r is Dictionary) { - SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + GridRegion rinfo = new GridRegion((Dictionary)r); rinfos.Add(rinfo); } else diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index 6b0518c860..616c2c1f73 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -33,6 +33,7 @@ using System.Drawing; using System.Net; using System.Reflection; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Framework; @@ -54,7 +55,7 @@ namespace OpenSim.Services.Connectors.Grid m_AssetService = assService; } - public UUID LinkRegion(SimpleRegionInfo info, out ulong realHandle) + public UUID LinkRegion(GridRegion info, out ulong realHandle) { UUID uuid = UUID.Zero; realHandle = 0; @@ -114,7 +115,7 @@ namespace OpenSim.Services.Connectors.Grid return uuid; } - public void GetMapImage(SimpleRegionInfo info) + public void GetMapImage(GridRegion info) { try { diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index b37a51b8ff..cd462ab531 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -35,6 +35,7 @@ using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Data; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenMetaverse; namespace OpenSim.Services.GridService @@ -48,6 +49,7 @@ namespace OpenSim.Services.GridService public GridService(IConfigSource config) : base(config) { + m_log.DebugFormat("[GRID SERVICE]: Starting..."); MainConsole.Instance.Commands.AddCommand("kfs", false, "show digest", "show digest ", @@ -62,7 +64,7 @@ namespace OpenSim.Services.GridService #region IGridService - public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) + public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) { if (m_Database.Get(regionInfos.RegionID, scopeID) != null) { @@ -88,9 +90,9 @@ namespace OpenSim.Services.GridService return m_Database.Delete(regionID); } - public List GetNeighbours(UUID scopeID, UUID regionID) + public List GetNeighbours(UUID scopeID, UUID regionID) { - List rinfos = new List(); + List rinfos = new List(); RegionData region = m_Database.Get(regionID, scopeID); if (region != null) { @@ -105,7 +107,7 @@ namespace OpenSim.Services.GridService return rinfos; } - public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { RegionData rdata = m_Database.Get(regionID, scopeID); if (rdata != null) @@ -114,7 +116,7 @@ namespace OpenSim.Services.GridService return null; } - public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; @@ -125,7 +127,7 @@ namespace OpenSim.Services.GridService return null; } - public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public GridRegion GetRegionByName(UUID scopeID, string regionName) { List rdatas = m_Database.Get(regionName + "%", scopeID); if ((rdatas != null) && (rdatas.Count > 0)) @@ -134,12 +136,12 @@ namespace OpenSim.Services.GridService return null; } - public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { List rdatas = m_Database.Get("%" + name + "%", scopeID); int count = 0; - List rinfos = new List(); + List rinfos = new List(); if (rdatas != null) { @@ -153,7 +155,7 @@ namespace OpenSim.Services.GridService return rinfos; } - public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; @@ -161,7 +163,7 @@ namespace OpenSim.Services.GridService int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; List rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); - List rinfos = new List(); + List rinfos = new List(); foreach (RegionData rdata in rdatas) rinfos.Add(RegionData2RegionInfo(rdata)); @@ -172,7 +174,7 @@ namespace OpenSim.Services.GridService #region Data structure conversions - protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) + protected RegionData RegionInfo2RegionData(GridRegion rinfo) { RegionData rdata = new RegionData(); rdata.posX = (int)rinfo.RegionLocX; @@ -184,11 +186,11 @@ namespace OpenSim.Services.GridService return rdata; } - protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) + protected GridRegion RegionData2RegionInfo(RegionData rdata) { - SimpleRegionInfo rinfo = new SimpleRegionInfo(rdata.Data); - rinfo.RegionLocX = (uint)rdata.posX; - rinfo.RegionLocY = (uint)rdata.posY; + GridRegion rinfo = new GridRegion(rdata.Data); + rinfo.RegionLocX = rdata.posX; + rinfo.RegionLocY = rdata.posY; rinfo.RegionID = rdata.RegionID; rinfo.RegionName = rdata.RegionName; diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs index 7522e64ef2..444f79b40f 100644 --- a/OpenSim/Services/GridService/GridServiceBase.cs +++ b/OpenSim/Services/GridService/GridServiceBase.cs @@ -68,7 +68,7 @@ namespace OpenSim.Services.GridService connString = gridConfig.GetString("ConnectionString", connString); realm = gridConfig.GetString("Realm", realm); } - + // // We tried, but this doesn't exist. We can't proceed. // diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 8f6c5247c9..a188f7e0d0 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -25,8 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using OpenSim.Framework; +using System; using System.Collections.Generic; +using System.Net; +using System.Net.Sockets; +using OpenSim.Framework; using OpenMetaverse; namespace OpenSim.Services.Interfaces @@ -39,7 +42,7 @@ namespace OpenSim.Services.Interfaces /// /// /// Thrown if region registration failed - bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos); + bool RegisterRegion(UUID scopeID, GridRegion regionInfos); /// /// Deregister a region with the grid service. @@ -55,9 +58,9 @@ namespace OpenSim.Services.Interfaces /// /// /// - List GetNeighbours(UUID scopeID, UUID regionID); + List GetNeighbours(UUID scopeID, UUID regionID); - SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); + GridRegion GetRegionByUUID(UUID scopeID, UUID regionID); /// /// Get the region at the given position (in meters) @@ -66,9 +69,9 @@ namespace OpenSim.Services.Interfaces /// /// /// - SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); - - SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName); + GridRegion GetRegionByPosition(UUID scopeID, int x, int y); + + GridRegion GetRegionByName(UUID scopeID, string regionName); /// /// Get information about regions starting with the provided name. @@ -83,9 +86,237 @@ namespace OpenSim.Services.Interfaces /// A list of s of regions with matching name. If the /// grid-server couldn't be contacted or returned an error, return null. /// - List GetRegionsByName(UUID scopeID, string name, int maxNumber); + List GetRegionsByName(UUID scopeID, string name, int maxNumber); - List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); + List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); } + + public class GridRegion + { + + /// + /// The port by which http communication occurs with the region + /// + public uint HttpPort + { + get { return m_httpPort; } + set { m_httpPort = value; } + } + protected uint m_httpPort; + + /// + /// A well-formed URI for the host region server (namely "http://" + ExternalHostName) + /// + public string ServerURI + { + get { return m_serverURI; } + set { m_serverURI = value; } + } + protected string m_serverURI; + + public string RegionName + { + get { return m_regionName; } + set { m_regionName = value; } + } + protected string m_regionName = String.Empty; + + protected bool Allow_Alternate_Ports; + public bool m_allow_alternate_ports; + + protected string m_externalHostName; + + protected IPEndPoint m_internalEndPoint; + + public int RegionLocX + { + get { return m_regionLocX; } + set { m_regionLocX = value; } + } + protected int m_regionLocX; + + public int RegionLocY + { + get { return m_regionLocY; } + set { m_regionLocY = value; } + } + protected int m_regionLocY; + + public UUID RegionID = UUID.Zero; + public UUID ScopeID = UUID.Zero; + + public GridRegion() + { + } + + public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri) + { + m_regionLocX = regionLocX; + m_regionLocY = regionLocY; + + m_internalEndPoint = internalEndPoint; + m_externalHostName = externalUri; + } + + public GridRegion(int regionLocX, int regionLocY, string externalUri, uint port) + { + m_regionLocX = regionLocX; + m_regionLocY = regionLocY; + + m_externalHostName = externalUri; + + m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port); + } + + public GridRegion(uint xcell, uint ycell) + { + m_regionLocX = (int)(xcell * Constants.RegionSize); + m_regionLocY = (int)(ycell * Constants.RegionSize); + } + + public GridRegion(RegionInfo ConvertFrom) + { + m_regionName = ConvertFrom.RegionName; + m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize); + m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize); + m_internalEndPoint = ConvertFrom.InternalEndPoint; + m_externalHostName = ConvertFrom.ExternalHostName; + m_httpPort = ConvertFrom.HttpPort; + m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; + RegionID = UUID.Zero; + ServerURI = ConvertFrom.ServerURI; + } + + + /// + /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. + /// + /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method? + /// + public IPEndPoint ExternalEndPoint + { + get + { + // Old one defaults to IPv6 + //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port); + + IPAddress ia = null; + // If it is already an IP, don't resolve it - just return directly + if (IPAddress.TryParse(m_externalHostName, out ia)) + return new IPEndPoint(ia, m_internalEndPoint.Port); + + // Reset for next check + ia = null; + try + { + foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName)) + { + if (ia == null) + ia = Adr; + + if (Adr.AddressFamily == AddressFamily.InterNetwork) + { + ia = Adr; + break; + } + } + } + catch (SocketException e) + { + throw new Exception( + "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + + e + "' attached to this exception", e); + } + + return new IPEndPoint(ia, m_internalEndPoint.Port); + } + + set { m_externalHostName = value.ToString(); } + } + + public string ExternalHostName + { + get { return m_externalHostName; } + set { m_externalHostName = value; } + } + + public IPEndPoint InternalEndPoint + { + get { return m_internalEndPoint; } + set { m_internalEndPoint = value; } + } + + public ulong RegionHandle + { + get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); } + } + + public int getInternalEndPointPort() + { + return m_internalEndPoint.Port; + } + + public Dictionary ToKeyValuePairs() + { + Dictionary kvp = new Dictionary(); + kvp["uuid"] = RegionID.ToString(); + kvp["locX"] = RegionLocX.ToString(); + kvp["locY"] = RegionLocY.ToString(); + kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); + kvp["external_port"] = ExternalEndPoint.Port.ToString(); + kvp["external_host_name"] = ExternalHostName; + kvp["http_port"] = HttpPort.ToString(); + kvp["internal_ip_address"] = InternalEndPoint.Address.ToString(); + kvp["internal_port"] = InternalEndPoint.Port.ToString(); + kvp["alternate_ports"] = m_allow_alternate_ports.ToString(); + kvp["server_uri"] = ServerURI; + + return kvp; + } + + public GridRegion(Dictionary kvp) + { + if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) + { + int port = 0; + Int32.TryParse((string)kvp["external_port"], out port); + IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port); + ExternalEndPoint = ep; + } + else + ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); + + if (kvp["external_host_name"] != null) + ExternalHostName = (string)kvp["external_host_name"]; + + if (kvp["http_port"] != null) + { + UInt32 port = 0; + UInt32.TryParse((string)kvp["http_port"], out port); + HttpPort = port; + } + + if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null)) + { + int port = 0; + Int32.TryParse((string)kvp["internal_port"], out port); + IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port); + InternalEndPoint = ep; + } + else + InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); + + if (kvp["alternate_ports"] != null) + { + bool alts = false; + Boolean.TryParse((string)kvp["alternate_ports"], out alts); + m_allow_alternate_ports = alts; + } + + if (kvp["server_uri"] != null) + ServerURI = (string)kvp["server_uri"]; + } + } + } diff --git a/bin/config-include/Standalone.ini b/bin/config-include/Standalone.ini index 69c60ee342..5a5cbffde7 100644 --- a/bin/config-include/Standalone.ini +++ b/bin/config-include/Standalone.ini @@ -25,4 +25,5 @@ [GridService] LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" + StorageProvider = "OpenSim.Data.Null.dll:NullRegionData" \ No newline at end of file diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index 24b0f2664c..b14517df9f 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini @@ -43,5 +43,5 @@ [GridService] LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" - GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:LocalGridServiceConnector" - StorageProvider = "OpenSim.Data.Null.dll" \ No newline at end of file + GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:LocalGridServicesConnector" + StorageProvider = "OpenSim.Data.Null.dll:NullRegionData" \ No newline at end of file From 3c19bd5142479e468aa9841a2177ddd33b46f8f6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 20:35:16 -0700 Subject: [PATCH 10/18] Unit tests for the grid service. Yey! --- .../Grid/Tests/GridConnectorsTests.cs | 122 ++++++++++++++++++ prebuild.xml | 1 + 2 files changed, 123 insertions(+) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs new file mode 100644 index 0000000000..8d4424947d --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs @@ -0,0 +1,122 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Threading; +using log4net.Config; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenMetaverse; +using OpenSim.Framework; +using Nini.Config; + +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; +using OpenSim.Region.Framework.Scenes; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Setup; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests +{ + [TestFixture] + public class GridConnectorsTests + { + LocalGridServicesConnector m_LocalConnector; + private void SetUp() + { + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.AddConfig("GridService"); + config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); + config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); + config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); + + m_LocalConnector = new LocalGridServicesConnector(config); + } + + /// + /// Test saving a V0.2 OpenSim Region Archive. + /// + [Test] + public void TestRegisterRegionV0_2() + { + SetUp(); + + // Create 3 regions + GridRegion r1 = new GridRegion(); + r1.RegionName = "Test Region 1"; + r1.RegionID = new UUID(1); + r1.RegionLocX = 1000 * (int)Constants.RegionSize; + r1.RegionLocY = 1000 * (int)Constants.RegionSize; + r1.ExternalHostName = "127.0.0.1"; + r1.HttpPort = 9001; + r1.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); + + GridRegion r2 = new GridRegion(); + r2.RegionName = "Test Region 2"; + r2.RegionID = new UUID(2); + r2.RegionLocX = 1000 * (int)Constants.RegionSize + 1; + r2.RegionLocY = 1000 * (int)Constants.RegionSize; + r2.ExternalHostName = "127.0.0.1"; + r2.HttpPort = 9002; + r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); + + GridRegion r3 = new GridRegion(); + r3.RegionName = "Test Region 3"; + r3.RegionID = new UUID(3); + r3.RegionLocX = 1000 * (int)Constants.RegionSize + 5; + r3.RegionLocY = 1000 * (int)Constants.RegionSize; + r3.ExternalHostName = "127.0.0.1"; + r3.HttpPort = 9003; + r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); + + m_LocalConnector.RegisterRegion(UUID.Zero, r1); + GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test"); + Assert.IsNotNull(result, "Retrieved GetRegionByName is null"); + Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match"); + + result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1)); + Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null"); + Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match"); + + result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize); + Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null"); + Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match"); + + m_LocalConnector.RegisterRegion(UUID.Zero, r2); + m_LocalConnector.RegisterRegion(UUID.Zero, r3); + + List results = m_LocalConnector.GetNeighbours(UUID.Zero, new UUID(1)); + Assert.IsNotNull(results, "Retrieved neighbours list is null"); + Assert.That(results.Count, Is.EqualTo(1), "Retrieved neighbour collection is greater than expected"); + Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2))); + } + } +} diff --git a/prebuild.xml b/prebuild.xml index b131019aad..cb2031906a 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -3592,6 +3592,7 @@ + From fd8fb7735b0eb6150679ccad84b2a32fd5315a38 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 20:39:25 -0700 Subject: [PATCH 11/18] First test passes -- regions being registered and retrieved correctly in Data.Null. --- .../ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | 4 ++-- OpenSim/Services/GridService/GridService.cs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index 8d4424947d..bd3293dbc1 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs @@ -82,7 +82,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests GridRegion r2 = new GridRegion(); r2.RegionName = "Test Region 2"; r2.RegionID = new UUID(2); - r2.RegionLocX = 1000 * (int)Constants.RegionSize + 1; + r2.RegionLocX = 1001 * (int)Constants.RegionSize; r2.RegionLocY = 1000 * (int)Constants.RegionSize; r2.ExternalHostName = "127.0.0.1"; r2.HttpPort = 9002; @@ -91,7 +91,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests GridRegion r3 = new GridRegion(); r3.RegionName = "Test Region 3"; r3.RegionID = new UUID(3); - r3.RegionLocX = 1000 * (int)Constants.RegionSize + 5; + r3.RegionLocX = 1005 * (int)Constants.RegionSize; r3.RegionLocY = 1000 * (int)Constants.RegionSize; r3.ExternalHostName = "127.0.0.1"; r3.HttpPort = 9003; diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index cd462ab531..1b297dc6a6 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -101,7 +101,8 @@ namespace OpenSim.Services.GridService region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); foreach (RegionData rdata in rdatas) - rinfos.Add(RegionData2RegionInfo(rdata)); + if (rdata.RegionID != regionID) + rinfos.Add(RegionData2RegionInfo(rdata)); } return rinfos; From 1260c81a9cfc19306e2053a8b066e50c78dbc7c1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 20:51:04 -0700 Subject: [PATCH 12/18] More tests. Seems to be working. Grid connector modules are enabled for standalones only, but nothing in the simulator uses them yet, so it's safe to go in. --- OpenSim/Data/Null/NullRegionData.cs | 2 +- .../Grid/Tests/GridConnectorsTests.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index 03489f90b6..e976c40685 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs @@ -40,7 +40,7 @@ namespace OpenSim.Data.Null public NullRegionData(string connectionString, string realm) { - Console.WriteLine("[XXX] NullRegionData constructor"); + //Console.WriteLine("[XXX] NullRegionData constructor"); } public List Get(string regionName, UUID scopeID) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index bd3293dbc1..be32d6ba5f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs @@ -116,7 +116,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests List results = m_LocalConnector.GetNeighbours(UUID.Zero, new UUID(1)); Assert.IsNotNull(results, "Retrieved neighbours list is null"); Assert.That(results.Count, Is.EqualTo(1), "Retrieved neighbour collection is greater than expected"); - Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2))); + Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved region's UUID does not match"); + + results = m_LocalConnector.GetRegionsByName(UUID.Zero, "Test", 10); + Assert.IsNotNull(results, "Retrieved GetRegionsByName list is null"); + Assert.That(results.Count, Is.EqualTo(3), "Retrieved neighbour collection is less than expected"); + + results = m_LocalConnector.GetRegionRange(UUID.Zero, 900 * (int)Constants.RegionSize, 1002 * (int)Constants.RegionSize, + 900 * (int)Constants.RegionSize, 1100 * (int)Constants.RegionSize); + Assert.IsNotNull(results, "Retrieved GetRegionRange list is null"); + Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected"); } } } From aca9fd182ee6dec5ac778f7aafd9a8fa6a5fd4e2 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 24 Sep 2009 20:27:11 +1000 Subject: [PATCH 13/18] * Added two new commands to EstateManagementModule * Also, I hate git. --- .../World/Estate/EstateManagementModule.cs | 61 +++++++++++++++++-- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 75b3fe6b53..f52a287e31 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -33,7 +33,6 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Region.CoreModules.World.Terrain; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -47,7 +46,7 @@ namespace OpenSim.Region.CoreModules.World.Estate private Scene m_scene; - private EstateTerrainXferHandler TerrainUploader = null; + private EstateTerrainXferHandler TerrainUploader; #region Packet Data Responders @@ -668,7 +667,7 @@ namespace OpenSim.Region.CoreModules.World.Estate LookupUUID(uuidNameLookupList); } - private void LookupUUIDSCompleted(IAsyncResult iar) + private static void LookupUUIDSCompleted(IAsyncResult iar) { LookupUUIDS icon = (LookupUUIDS)iar.AsyncState; icon.EndInvoke(iar); @@ -683,7 +682,7 @@ namespace OpenSim.Region.CoreModules.World.Estate } private void LookupUUIDsAsync(List uuidLst) { - UUID[] uuidarr = new UUID[0]; + UUID[] uuidarr; lock (uuidLst) { @@ -707,7 +706,7 @@ namespace OpenSim.Region.CoreModules.World.Estate for (int i = 0; i < avatars.Count; i++) { - HandleRegionInfoRequest(avatars[i].ControllingClient); ; + HandleRegionInfoRequest(avatars[i].ControllingClient); } } @@ -768,7 +767,7 @@ namespace OpenSim.Region.CoreModules.World.Estate else { m_scene.RegionInfo.EstateSettings.UseGlobalTime = false; - m_scene.RegionInfo.EstateSettings.SunPosition = (double)(parms2 - 0x1800)/1024.0; + m_scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0; } if ((parms1 & 0x00000010) != 0) @@ -828,8 +827,58 @@ namespace OpenSim.Region.CoreModules.World.Estate m_scene.RegisterModuleInterface(this); m_scene.EventManager.OnNewClient += EventManager_OnNewClient; m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight; + + m_scene.AddCommand(this, "set terrain texture", + "set terrain texture [] []", + "Sets the terrain to , if or are specified, it will only " + + "set it on regions with a matching coordinate. Specify -1 in or to wildcard" + + " that coordinate.", + consoleSetTerrainTexture); + + m_scene.AddCommand(this, "set terrain heights", + "set terrain heights [] []", + "Sets the terrain texture heights on corner # to /, if or are specified, it will only " + + "set it on regions with a matching coordinate. Specify -1 in or to wildcard" + + " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3.", + consoleSetTerrainTexture); } + #region Console Commands + + public void consoleSetTerrainTexture(string module, string[] args) + { + string num = args[3]; + string uuid = args[4]; + int x = (args.Length > 5 ? int.Parse(args[5]) : -1); + int y = (args.Length > 6 ? int.Parse(args[6]) : -1); + + if (x != -1 && m_scene.RegionInfo.RegionLocX != x) + { + if (y != -1 && m_scene.RegionInfo.RegionLocY != y) + { + setEstateTerrainBaseTexture(null, int.Parse(num), UUID.Parse(uuid)); + } + } + } + + public void consoleSetTerrainHeights(string module, string[] args) + { + string num = args[3]; + string min = args[4]; + string max = args[5]; + int x = (args.Length > 6 ? int.Parse(args[6]) : -1); + int y = (args.Length > 7 ? int.Parse(args[7]) : -1); + + if (x != -1 && m_scene.RegionInfo.RegionLocX != x) + { + if (y != -1 && m_scene.RegionInfo.RegionLocY != y) + { + setEstateTerrainTextureHeights(null, int.Parse(num), float.Parse(min), float.Parse(max)); + } + } + } + + #endregion public void PostInitialise() { From 71a4b02c7e9a2587759fd40092d1bdcfef648eff Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 24 Sep 2009 20:56:01 +1000 Subject: [PATCH 14/18] * Minor commit, added two new math utility functions. --- OpenSim/Framework/Util.cs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 58344f30c8..45b5a105fd 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -70,6 +70,39 @@ namespace OpenSim.Framework public static readonly Regex UUIDPattern = new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"); + /// + /// Linear interpolates B<->C using percent A + /// + /// + /// + /// + /// + public static double lerp(double a, double b, double c) + { + return (b*a) + (c*(1 - a)); + } + + /// + /// Bilinear Interpolate, see Lerp but for 2D using 'percents' X & Y. + /// Layout: + /// A B + /// C D + /// A<->C = Y + /// C<->D = X + /// + /// + /// + /// + /// + /// + /// + /// + public static double lerp2D(double x, double y, double a, double b, double c, double d) + { + return lerp(y, lerp(x, a, b), lerp(x, c, d)); + } + + /// /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards) /// From 57429423bbb080d5381dd91ffe4d927537fbf62f Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 24 Sep 2009 21:29:57 +1000 Subject: [PATCH 15/18] * Fixing typo. --- .../Region/CoreModules/World/Estate/EstateManagementModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index f52a287e31..fa52334a9d 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -840,7 +840,7 @@ namespace OpenSim.Region.CoreModules.World.Estate "Sets the terrain texture heights on corner # to /, if or are specified, it will only " + "set it on regions with a matching coordinate. Specify -1 in or to wildcard" + " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3.", - consoleSetTerrainTexture); + consoleSetTerrainHeights); } #region Console Commands From 8605c5d2eb0d514c1475b94120fd6db9644874cf Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 24 Sep 2009 21:46:41 +1000 Subject: [PATCH 16/18] * Establishing why new console commands fail to work. >_> --- .../CoreModules/World/Estate/EstateManagementModule.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index fa52334a9d..bb77bd5b26 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -852,10 +852,11 @@ namespace OpenSim.Region.CoreModules.World.Estate int x = (args.Length > 5 ? int.Parse(args[5]) : -1); int y = (args.Length > 6 ? int.Parse(args[6]) : -1); - if (x != -1 && m_scene.RegionInfo.RegionLocX != x) + if (x == -1 || m_scene.RegionInfo.RegionLocX == x) { - if (y != -1 && m_scene.RegionInfo.RegionLocY != y) + if (y == -1 || m_scene.RegionInfo.RegionLocY == y) { + m_log.Debug("[ESTATEMODULE] Setting terrain textures for " + m_scene.RegionInfo.RegionName); setEstateTerrainBaseTexture(null, int.Parse(num), UUID.Parse(uuid)); } } @@ -869,10 +870,11 @@ namespace OpenSim.Region.CoreModules.World.Estate int x = (args.Length > 6 ? int.Parse(args[6]) : -1); int y = (args.Length > 7 ? int.Parse(args[7]) : -1); - if (x != -1 && m_scene.RegionInfo.RegionLocX != x) + if (x == -1 || m_scene.RegionInfo.RegionLocX == x) { - if (y != -1 && m_scene.RegionInfo.RegionLocY != y) + if (y == -1 || m_scene.RegionInfo.RegionLocY == y) { + m_log.Debug("[ESTATEMODULE] Setting terrain heights " + m_scene.RegionInfo.RegionName); setEstateTerrainTextureHeights(null, int.Parse(num), float.Parse(min), float.Parse(max)); } } From ca69fac13e2a0b648b02bf32a368f77d2fbec1fb Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 24 Sep 2009 22:02:29 +1000 Subject: [PATCH 17/18] * Send Updated Information Packet to Clients after updating estate settings. --- .../Region/CoreModules/World/Estate/EstateManagementModule.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index bb77bd5b26..0d51cf475e 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -154,6 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Estate break; } m_scene.RegionInfo.RegionSettings.Save(); + sendRegionInfoPacketToAll(); } public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue) @@ -178,6 +179,7 @@ namespace OpenSim.Region.CoreModules.World.Estate break; } m_scene.RegionInfo.RegionSettings.Save(); + sendRegionInfoPacketToAll(); } private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient) From 2824bbc47b30ab6fb9a12bce3201bb5b79b20bd5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 05:48:35 -0700 Subject: [PATCH 18/18] Changed name of the hyperlink XMLRPC method to linkk-region, so that it doesn't conflict with the existing one. --- OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs | 2 +- OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs | 2 +- OpenSim/Services/GridService/GridService.cs | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs index b8d9c7db87..ad634853dc 100644 --- a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs +++ b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs @@ -53,7 +53,7 @@ namespace OpenSim.Server.Handlers.Grid public HypergridServiceInConnector(IConfigSource config, IHttpServer server) : base(config, server) { - server.AddXmlRPCHandler("link_region", LinkRegionRequest, false); + server.AddXmlRPCHandler("linkk_region", LinkRegionRequest, false); } /// diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index 616c2c1f73..b5e87439bf 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -66,7 +66,7 @@ namespace OpenSim.Services.Connectors.Grid IList paramList = new ArrayList(); paramList.Add(hash); - XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); + XmlRpcRequest request = new XmlRpcRequest("linkk_region", paramList); string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; m_log.Debug("[HGrid]: Linking to " + uri); XmlRpcResponse response = request.Send(uri, 10000); diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 1b297dc6a6..01ffa1dbf5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -71,7 +71,9 @@ namespace OpenSim.Services.GridService m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); return false; } - if (m_Database.Get((int)regionInfos.RegionLocX, (int)regionInfos.RegionLocY, scopeID) != null) + // This needs better sanity testing. What if regionInfo is registering in + // overlapping coords? + if (m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID) != null) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);