From 66f8166bd0501a159e2eecad77cc92b0b3beb38e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 18 Sep 2009 20:01:33 -0700 Subject: First pass at LocalGridServiceConnector. Nothing of this is used by the simulator yet. --- .../Grid/LocalGridServiceConnector.cs | 175 +++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs new file mode 100644 index 0000000..6475817 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -0,0 +1,175 @@ +/* + * 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 Nini.Config; +using System; +using System.Collections.Generic; +using System.Reflection; +using OpenSim.Framework; +using OpenSim.Server.Base; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenMetaverse; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid +{ + public class LocalGridServicesConnector : + ISharedRegionModule, IGridService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private IGridService m_GridService; + + private bool m_Enabled = false; + + #region ISharedRegionModule + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "LocalGridServicesConnector"; } + } + + public void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + 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; + } + m_Enabled = true; + m_log.Info("[GRID CONNECTOR]: Local grid connector 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) + { + } + + #endregion + + #region IGridService + + public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + { + return m_GridService.RegisterRegion(scopeID, regionInfo); + } + + public bool DeregisterRegion(UUID regionID) + { + return m_GridService.DeregisterRegion(regionID); + } + + public List GetNeighbours(UUID scopeID, int x, int y) + { + return m_GridService.GetNeighbours(scopeID, x, y); + } + + public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + { + return m_GridService.GetRegionByUUID(scopeID, regionID); + } + + public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + { + return m_GridService.GetRegionByPosition(scopeID, x, y); + } + + public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + { + return m_GridService.GetRegionByName(scopeID, regionName); + } + + 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) + { + return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); + } + + #endregion + } +} -- cgit v1.1 From 390137d540b9ae39eba3ba9136bd49d5e992bc5f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 21 Sep 2009 11:05:01 -0700 Subject: Added grid handler and grid remote connector. --- .../ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 6475817..74ece2e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -140,9 +140,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return m_GridService.DeregisterRegion(regionID); } - public List GetNeighbours(UUID scopeID, int x, int y) + public List GetNeighbours(UUID scopeID, UUID regionID) { - return m_GridService.GetNeighbours(scopeID, x, y); + return m_GridService.GetNeighbours(scopeID, regionID); } public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) -- cgit v1.1 From 34f4738159300ab6370e3db47df5187b6cea8771 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 11:58:40 -0700 Subject: Added HGGridConnector and related code. --- .../Grid/LocalGridServiceConnector.cs | 64 +++++++++++++--------- 1 file changed, 37 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 74ece2e..3f29401 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() { } -- cgit v1.1 From 35deff7ec4df6156abccdbeed83b14a6083e28f9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 09:27:01 -0700 Subject: Modules active. Tested HGGridConnector in standalone only for now. Modules commands work. --- .../ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 3f29401..c1b7235 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); -- cgit v1.1 From 67276589c883fe1a74d8d52057db1431d637dade Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 17:20:07 -0700 Subject: Changed IGridService to use the new GridRegion data structure instead of old SimpleRegionInfo. Added grid configs to standalones. --- .../Grid/LocalGridServiceConnector.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index c1b7235..743d3b9 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); } -- cgit v1.1 From 2432cc607ec206b79149c1e9b1aa995794fec3bc Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Sep 2009 13:43:57 -0700 Subject: Neighbours cache working. --- .../Grid/LocalGridServiceConnector.cs | 54 ++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 743d3b9..6c2928a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -31,6 +31,7 @@ using System; using System.Collections.Generic; using System.Reflection; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Server.Base; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -47,7 +48,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); + private static LocalGridServicesConnector m_MainInstance; + private IGridService m_GridService; + private Dictionary m_LocalCache = new Dictionary(); private bool m_Enabled = false; @@ -58,6 +62,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public LocalGridServicesConnector(IConfigSource source) { m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated"); + m_MainInstance = this; InitialiseService(source); } @@ -82,6 +87,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (name == Name) { InitialiseService(source); + m_MainInstance = this; m_Enabled = true; m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled"); } @@ -120,6 +126,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void PostInitialise() { + if (m_MainInstance == this) + { + MainConsole.Instance.Commands.AddCommand("LocalGridConnector", false, "show neighbours", + "show neighbours", + "Shows the local regions' neighbours", NeighboursCommand); + } } public void Close() @@ -128,14 +140,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void AddRegion(Scene scene) { - if (!m_Enabled) - return; + if (m_Enabled) + scene.RegisterModuleInterface(this); + + if (m_MainInstance == this) + { + if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID)) + m_log.ErrorFormat("[LOCAL GRID CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!"); + else + m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene)); - scene.RegisterModuleInterface(this); + } } public void RemoveRegion(Scene scene) { + if (m_MainInstance == this) + { + m_LocalCache[scene.RegionInfo.RegionID].Clear(); + m_LocalCache.Remove(scene.RegionInfo.RegionID); + } } public void RegionLoaded(Scene scene) @@ -158,7 +182,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public List GetNeighbours(UUID scopeID, UUID regionID) { - return m_GridService.GetNeighbours(scopeID, regionID); + if (m_LocalCache.ContainsKey(regionID)) + { + return m_LocalCache[regionID].GetNeighbours(); + } + else + { + m_log.WarnFormat("[LOCAL GRID CONNECTOR]: GetNeighbours: Requested region {0} is not on this sim", regionID); + return new List(); + } + + // Don't go to the DB + //return m_GridService.GetNeighbours(scopeID, regionID); } public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) @@ -187,5 +222,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } #endregion + + public void NeighboursCommand(string module, string[] cmdparams) + { + foreach (KeyValuePair kvp in m_LocalCache) + { + m_log.InfoFormat("*** Neighbours of {0} {1} ***", kvp.Key, kvp.Value.RegionName); + List regions = kvp.Value.GetNeighbours(); + foreach (GridRegion r in regions) + m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); + } + } } } -- cgit v1.1 From 4eca59ec13bb48309120fea24890341c65157c65 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Sep 2009 17:33:34 -0700 Subject: Improved the Local grid connector to fetch data from the DB when it doesn't find it in the cache. Commented out the Standalone teleport test because it's failing, and the scene setup is very confusing. I suspect it may be wrong -- the connectors-as-ISharedRegionModules are being instantiated several times when there are several scenes. --- .../ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 6c2928a..3ca4882 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -149,7 +149,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid m_log.ErrorFormat("[LOCAL GRID CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!"); else m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene)); - } } @@ -184,7 +183,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { if (m_LocalCache.ContainsKey(regionID)) { - return m_LocalCache[regionID].GetNeighbours(); + List neighbours = m_LocalCache[regionID].GetNeighbours(); + if (neighbours.Count == 0) + // try the DB + neighbours = m_GridService.GetNeighbours(scopeID, regionID); + return neighbours; } else { -- cgit v1.1