From b3574d23e465e6219e732ab6c28772f1359452ca Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 11:26:03 -0800 Subject: One more module converted: DataSnapshot. --- OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | 158 ++++++++++++--------- .../DataSnapshot/Interfaces/IDataSnapshot.cs | 1 - 2 files changed, 87 insertions(+), 72 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 5540656..defbadc 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs @@ -35,15 +35,20 @@ using System.Xml; using log4net; using Nini.Config; using OpenMetaverse; +using Mono.Addins; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.DataSnapshot.Interfaces; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +[assembly: Addin("LindenCaps", "0.1")] +[assembly: AddinDependency("OpenSim", "0.5")] + namespace OpenSim.Region.DataSnapshot { - public class DataSnapshotManager : IRegionModule, IDataSnapshot + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class DataSnapshotManager : ISharedRegionModule, IDataSnapshot { #region Class members //Information from config @@ -95,7 +100,7 @@ namespace OpenSim.Region.DataSnapshot #region IRegionModule - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { if (!m_configLoaded) { @@ -133,82 +138,121 @@ namespace OpenSim.Region.DataSnapshot m_enabled = false; return; } - } - if (m_enabled) - { - //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer - new DataRequestHandler(scene, this); + if (m_enabled) + m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); + } - m_hostname = scene.RegionInfo.ExternalHostName; - m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); + } - MakeEverythingStale(); + } - if (m_dataServices != "" && m_dataServices != "noservices") - NotifyDataServices(m_dataServices, "online"); - } - } + public void AddRegion(Scene scene) + { + if (!m_enabled) + return; - if (m_enabled) - { - m_log.Info("[DATASNAPSHOT]: Scene added to module."); + m_log.DebugFormat("[DATASNAPSHOT]: Module added to Scene {0}.", scene.RegionInfo.RegionName); - m_snapStore.AddScene(scene); - m_scenes.Add(scene); + m_snapStore.AddScene(scene); + m_scenes.Add(scene); - Assembly currentasm = Assembly.GetExecutingAssembly(); + Assembly currentasm = Assembly.GetExecutingAssembly(); - foreach (Type pluginType in currentasm.GetTypes()) + foreach (Type pluginType in currentasm.GetTypes()) + { + if (pluginType.IsPublic) { - if (pluginType.IsPublic) + if (!pluginType.IsAbstract) { - if (!pluginType.IsAbstract) + if (pluginType.GetInterface("IDataSnapshotProvider") != null) { - if (pluginType.GetInterface("IDataSnapshotProvider") != null) - { - IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType); - module.Initialize(scene, this); - module.OnStale += MarkDataStale; + IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType); + module.Initialize(scene, this); + module.OnStale += MarkDataStale; - m_dataproviders.Add(module); - m_snapStore.AddProvider(module); + m_dataproviders.Add(module); + m_snapStore.AddProvider(module); - m_log.Info("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name); - } + m_log.Debug("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name); } } } + } + } + + public void RemoveRegion(Scene scene) + { + if (!m_enabled) + return; + + m_log.Info("[DATASNAPSHOT]: Region " + scene.RegionInfo.RegionName + " is being removed, removing from indexing"); + Scene restartedScene = SceneForUUID(scene.RegionInfo.RegionID); + + m_scenes.Remove(restartedScene); + m_snapStore.RemoveScene(restartedScene); - //scene.OnRestart += OnSimRestart; - scene.EventManager.OnShutdown += delegate() { OnSimRestart(scene.RegionInfo); }; + //Getting around the fact that we can't remove objects from a collection we are enumerating over + List providersToRemove = new List(); + + foreach (IDataSnapshotProvider provider in m_dataproviders) + { + if (provider.GetParentScene == restartedScene) + { + providersToRemove.Add(provider); + } } - else + + foreach (IDataSnapshotProvider provider in providersToRemove) { - //m_log.Debug("[DATASNAPSHOT]: Data snapshot disabled, not adding scene to module (or anything else)."); + m_dataproviders.Remove(provider); + m_snapStore.RemoveProvider(provider); } + + m_snapStore.RemoveScene(restartedScene); } - public void Close() + public void PostInitialise() { - if (m_enabled && m_dataServices != "" && m_dataServices != "noservices") - NotifyDataServices(m_dataServices, "offline"); + if (!m_enabled) + return; + + //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer + new DataRequestHandler(m_scenes[0], this); + + m_hostname = m_scenes[0].RegionInfo.ExternalHostName; + + if (m_dataServices != "" && m_dataServices != "noservices") + NotifyDataServices(m_dataServices, "online"); } + public void RegionLoaded(Scene scene) + { + if (!m_enabled) + return; + + m_log.DebugFormat("[DATASNAPSHOT]: Marking scene {0} as stale.", scene.RegionInfo.RegionName); + m_snapStore.ForceSceneStale(scene); + } - public bool IsSharedModule + public void Close() { - get { return true; } + if (!m_enabled) + return; + + if (m_enabled && m_dataServices != "" && m_dataServices != "noservices") + NotifyDataServices(m_dataServices, "offline"); } + public string Name { get { return "External Data Generator"; } } - public void PostInitialise() + public Type ReplaceableInterface { - + get { return null; } } #endregion @@ -399,35 +443,7 @@ namespace OpenSim.Region.DataSnapshot m_snapStore.ForceSceneStale(scene); } } - #endregion - public void OnSimRestart(RegionInfo thisRegion) - { - m_log.Info("[DATASNAPSHOT]: Region " + thisRegion.RegionName + " is restarting, removing from indexing"); - Scene restartedScene = SceneForUUID(thisRegion.RegionID); - - m_scenes.Remove(restartedScene); - m_snapStore.RemoveScene(restartedScene); - - //Getting around the fact that we can't remove objects from a collection we are enumerating over - List providersToRemove = new List(); - - foreach (IDataSnapshotProvider provider in m_dataproviders) - { - if (provider.GetParentScene == restartedScene) - { - providersToRemove.Add(provider); - } - } - - foreach (IDataSnapshotProvider provider in providersToRemove) - { - m_dataproviders.Remove(provider); - m_snapStore.RemoveProvider(provider); - } - - m_snapStore.RemoveScene(restartedScene); - } } } diff --git a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs index 59cdab9..3b3db65 100644 --- a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs +++ b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs @@ -32,6 +32,5 @@ namespace OpenSim.Region.DataSnapshot.Interfaces public interface IDataSnapshot { XmlDocument GetSnapshot(string regionName); - void MakeEverythingStale(); } } -- cgit v1.1