From 8f61da0759b203ab845810c201d69e2b9e4c72a8 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 13 Jul 2012 00:44:00 +0100 Subject: [PATCH] Don't cache regions data on the other unused LocalGridServiceConnector that the module code still sets up even if we're using one directly instantiated from the RemoteGridServiceConnector. Also improves log messages to indicate which regions are sending/receiving various neighbour protocol messages. --- .../Grid/LocalGridServiceConnector.cs | 55 +++++++++---------- .../ServiceConnectorsOut/Grid/RegionCache.cs | 1 + .../LocalNeighbourServiceConnector.cs | 6 +- .../Scenes/SceneCommunicationService.cs | 22 ++++++-- 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 3cc1b146cd..423fa5a4e2 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -41,19 +41,16 @@ using OpenMetaverse; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { - public class LocalGridServicesConnector : - ISharedRegionModule, IGridService + public class LocalGridServicesConnector : ISharedRegionModule, IGridService { private static readonly ILog m_log = 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; + private bool m_Enabled; public LocalGridServicesConnector() { @@ -61,8 +58,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public LocalGridServicesConnector(IConfigSource source) { - m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated"); - m_MainInstance = this; + m_log.Debug("[LOCAL GRID SERVICE CONNECTOR]: LocalGridServicesConnector instantiated directly."); InitialiseService(source); } @@ -87,9 +83,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"); + m_log.Info("[LOCAL GRID SERVICE CONNECTOR]: Local grid connector enabled"); } } } @@ -99,7 +93,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid IConfig assetConfig = source.Configs["GridService"]; if (assetConfig == null) { - m_log.Error("[LOCAL GRID CONNECTOR]: GridService missing from OpenSim.ini"); + m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: GridService missing from OpenSim.ini"); return; } @@ -108,7 +102,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (serviceDll == String.Empty) { - m_log.Error("[LOCAL GRID CONNECTOR]: No LocalServiceModule named in section GridService"); + m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: No LocalServiceModule named in section GridService"); return; } @@ -119,16 +113,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (m_GridService == null) { - m_log.Error("[LOCAL GRID CONNECTOR]: Can't load grid service"); + m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: Can't load grid service"); return; } + + m_Enabled = true; } public void PostInitialise() { + // FIXME: We will still add this command even if we aren't enabled since RemoteGridServiceConnector + // will have instantiated us directly. MainConsole.Instance.Commands.AddCommand("Regions", false, "show neighbours", "show neighbours", - "Shows the local regions' neighbours", NeighboursCommand); + "Shows the local regions' neighbours", HandleShowNeighboursCommand); } public void Close() @@ -137,25 +135,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void AddRegion(Scene scene) { - if (m_Enabled) - scene.RegisterModuleInterface(this); + if (!m_Enabled) + return; - 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); + + if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID)) + m_log.ErrorFormat("[LOCAL GRID SERVICE 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)); } public void RemoveRegion(Scene scene) { - if (m_MainInstance == this) - { - m_LocalCache[scene.RegionInfo.RegionID].Clear(); - m_LocalCache.Remove(scene.RegionInfo.RegionID); - } + if (!m_Enabled) + return; + + m_LocalCache[scene.RegionInfo.RegionID].Clear(); + m_LocalCache.Remove(scene.RegionInfo.RegionID); } public void RegionLoaded(Scene scene) @@ -242,7 +239,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #endregion - public void NeighboursCommand(string module, string[] cmdparams) + public void HandleShowNeighboursCommand(string module, string[] cmdparams) { System.Text.StringBuilder caps = new System.Text.StringBuilder(); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs index 9172536742..8d83fb64e7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs @@ -55,6 +55,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public RegionCache(Scene s) { + Util.PrintCallStack(); m_scene = s; m_scene.EventManager.OnRegionUp += OnRegionUp; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs index 40cc536916..7a90686839 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs @@ -125,13 +125,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour uint x, y; Utils.LongToUInts(regionHandle, out x, out y); - m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from region {0} to region at {1}-{2}", - thisRegion.RegionName, x / Constants.RegionSize, y / Constants.RegionSize); - foreach (Scene s in m_Scenes) { if (s.RegionInfo.RegionHandle == regionHandle) { + m_log.DebugFormat("[LOCAL NEIGHBOUR SERVICE CONNECTOR]: HelloNeighbour from region {0} to neighbour {1} at {2}-{3}", + thisRegion.RegionName, s.Name, x / Constants.RegionSize, y / Constants.RegionSize); + //m_log.Debug("[NEIGHBOUR CONNECTOR]: Found region to SendHelloNeighbour"); return s.IncomingHelloNeighbour(thisRegion); } diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index e2834af901..55a963ae2c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -84,16 +84,23 @@ namespace OpenSim.Region.Framework.Scenes if (neighbourService != null) neighbour = neighbourService.HelloNeighbour(regionhandle, region); else - m_log.DebugFormat("[SCENE COMMUNICATION SERVICE]: No neighbour service provided for informing neigbhours of this region"); + m_log.DebugFormat( + "[SCENE COMMUNICATION SERVICE]: No neighbour service provided for region {0} to inform neigbhours of status", + m_scene.Name); if (neighbour != null) { - m_log.DebugFormat("[SCENE COMMUNICATION SERVICE]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize); + m_log.DebugFormat( + "[SCENE COMMUNICATION SERVICE]: Region {0} successfully informed neighbour {1} at {2}-{3} that it is up", + m_scene.Name, neighbour.RegionName, x / Constants.RegionSize, y / Constants.RegionSize); + m_scene.EventManager.TriggerOnRegionUp(neighbour); } else { - m_log.InfoFormat("[SCENE COMMUNICATION SERVICE]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize); + m_log.WarnFormat( + "[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.", + x / Constants.RegionSize, y / Constants.RegionSize); } } @@ -101,8 +108,13 @@ namespace OpenSim.Region.Framework.Scenes { //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); - List neighbours = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID); - m_log.DebugFormat("[SCENE COMMUNICATION SERVICE]: Informing {0} neighbours that this region is up", neighbours.Count); + List neighbours + = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID); + + m_log.DebugFormat( + "[SCENE COMMUNICATION SERVICE]: Informing {0} neighbours that region {1} is up", + neighbours.Count, m_scene.Name); + foreach (GridRegion n in neighbours) { InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;