Actually call Close() for shared region modules when the simulator is being shutdown.
Adds regression test for this case.bullet-2.82
parent
fe6dab7f13
commit
889194db63
|
@ -32,6 +32,7 @@ using log4net;
|
||||||
using Mono.Addins;
|
using Mono.Addins;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenSim;
|
using OpenSim;
|
||||||
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
|
@ -45,6 +46,12 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||||
LogManager.GetLogger(
|
LogManager.GetLogger(
|
||||||
MethodBase.GetCurrentMethod().DeclaringType);
|
MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Controls whether we load modules from Mono.Addins.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>For debug purposes. Defaults to true.</remarks>
|
||||||
|
public bool LoadModulesFromAddins { get; set; }
|
||||||
|
|
||||||
// Config access
|
// Config access
|
||||||
private OpenSimBase m_openSim;
|
private OpenSimBase m_openSim;
|
||||||
|
|
||||||
|
@ -61,6 +68,11 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||||
private List<ISharedRegionModule> m_sharedInstances =
|
private List<ISharedRegionModule> m_sharedInstances =
|
||||||
new List<ISharedRegionModule>();
|
new List<ISharedRegionModule>();
|
||||||
|
|
||||||
|
public RegionModulesControllerPlugin()
|
||||||
|
{
|
||||||
|
LoadModulesFromAddins = true;
|
||||||
|
}
|
||||||
|
|
||||||
#region IApplicationPlugin implementation
|
#region IApplicationPlugin implementation
|
||||||
|
|
||||||
public void Initialise (OpenSimBase openSim)
|
public void Initialise (OpenSimBase openSim)
|
||||||
|
@ -69,6 +81,9 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||||
m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this);
|
m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this);
|
||||||
m_log.DebugFormat("[REGIONMODULES]: Initializing...");
|
m_log.DebugFormat("[REGIONMODULES]: Initializing...");
|
||||||
|
|
||||||
|
if (!LoadModulesFromAddins)
|
||||||
|
return;
|
||||||
|
|
||||||
// Who we are
|
// Who we are
|
||||||
string id = AddinManager.CurrentAddin.Id;
|
string id = AddinManager.CurrentAddin.Id;
|
||||||
|
|
||||||
|
@ -88,40 +103,8 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||||
Dictionary<RuntimeAddin, IList<int>> loadedModules = new Dictionary<RuntimeAddin, IList<int>>();
|
Dictionary<RuntimeAddin, IList<int>> loadedModules = new Dictionary<RuntimeAddin, IList<int>>();
|
||||||
|
|
||||||
// Scan modules and load all that aren't disabled
|
// Scan modules and load all that aren't disabled
|
||||||
foreach (TypeExtensionNode node in
|
foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/RegionModules"))
|
||||||
AddinManager.GetExtensionNodes("/OpenSim/RegionModules"))
|
AddNode(node, modulesConfig, loadedModules);
|
||||||
{
|
|
||||||
IList<int> loadedModuleData;
|
|
||||||
|
|
||||||
if (!loadedModules.ContainsKey(node.Addin))
|
|
||||||
loadedModules.Add(node.Addin, new List<int> { 0, 0, 0 });
|
|
||||||
|
|
||||||
loadedModuleData = loadedModules[node.Addin];
|
|
||||||
|
|
||||||
if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null)
|
|
||||||
{
|
|
||||||
if (CheckModuleEnabled(node, modulesConfig))
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
|
|
||||||
m_sharedModules.Add(node);
|
|
||||||
loadedModuleData[0]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null)
|
|
||||||
{
|
|
||||||
if (CheckModuleEnabled(node, modulesConfig))
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
|
|
||||||
m_nonSharedModules.Add(node);
|
|
||||||
loadedModuleData[1]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type);
|
|
||||||
loadedModuleData[2]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (KeyValuePair<RuntimeAddin, IList<int>> loadedModuleData in loadedModules)
|
foreach (KeyValuePair<RuntimeAddin, IList<int>> loadedModuleData in loadedModules)
|
||||||
{
|
{
|
||||||
|
@ -194,6 +177,41 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||||
|
|
||||||
#region IPlugin implementation
|
#region IPlugin implementation
|
||||||
|
|
||||||
|
private void AddNode(
|
||||||
|
TypeExtensionNode node, IConfig modulesConfig, Dictionary<RuntimeAddin, IList<int>> loadedModules)
|
||||||
|
{
|
||||||
|
IList<int> loadedModuleData;
|
||||||
|
|
||||||
|
if (!loadedModules.ContainsKey(node.Addin))
|
||||||
|
loadedModules.Add(node.Addin, new List<int> { 0, 0, 0 });
|
||||||
|
|
||||||
|
loadedModuleData = loadedModules[node.Addin];
|
||||||
|
|
||||||
|
if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null)
|
||||||
|
{
|
||||||
|
if (CheckModuleEnabled(node, modulesConfig))
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
|
||||||
|
m_sharedModules.Add(node);
|
||||||
|
loadedModuleData[0]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null)
|
||||||
|
{
|
||||||
|
if (CheckModuleEnabled(node, modulesConfig))
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
|
||||||
|
m_nonSharedModules.Add(node);
|
||||||
|
loadedModuleData[1]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type);
|
||||||
|
loadedModuleData[2]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We don't do that here
|
// We don't do that here
|
||||||
//
|
//
|
||||||
public void Initialise ()
|
public void Initialise ()
|
||||||
|
@ -215,6 +233,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||||
m_sharedInstances[0].Close();
|
m_sharedInstances[0].Close();
|
||||||
m_sharedInstances.RemoveAt(0);
|
m_sharedInstances.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sharedModules.Clear();
|
m_sharedModules.Clear();
|
||||||
m_nonSharedModules.Clear();
|
m_nonSharedModules.Clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,11 @@ namespace OpenSim.Framework.Servers
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used by tests to suppress Environment.Exit(0) so that post-run operations are possible.
|
||||||
|
/// </summary>
|
||||||
|
public bool SuppressExit { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This will control a periodic log printout of the current 'show stats' (if they are active) for this
|
/// This will control a periodic log printout of the current 'show stats' (if they are active) for this
|
||||||
/// server.
|
/// server.
|
||||||
|
@ -109,7 +114,8 @@ namespace OpenSim.Framework.Servers
|
||||||
|
|
||||||
base.ShutdownSpecific();
|
base.ShutdownSpecific();
|
||||||
|
|
||||||
Environment.Exit(0);
|
if (!SuppressExit)
|
||||||
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1964,10 +1964,15 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
if (maxThreads < 2)
|
if (maxThreads < 2)
|
||||||
throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2");
|
throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2");
|
||||||
|
|
||||||
if (minThreads > maxThreads || minThreads < 2)
|
if (minThreads > maxThreads || minThreads < 2)
|
||||||
throw new ArgumentOutOfRangeException("minThreads", "minThreads must be greater than 2 and less than or equal to maxThreads");
|
throw new ArgumentOutOfRangeException("minThreads", "minThreads must be greater than 2 and less than or equal to maxThreads");
|
||||||
|
|
||||||
if (m_ThreadPool != null)
|
if (m_ThreadPool != null)
|
||||||
throw new InvalidOperationException("SmartThreadPool is already initialized");
|
{
|
||||||
|
m_log.Warn("SmartThreadPool is already initialized. Ignoring request.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
STPStartInfo startInfo = new STPStartInfo();
|
STPStartInfo startInfo = new STPStartInfo();
|
||||||
startInfo.ThreadPoolName = "Util";
|
startInfo.ThreadPoolName = "Util";
|
||||||
|
|
|
@ -71,6 +71,20 @@ namespace OpenSim
|
||||||
// OpenSim.ini Section name for ESTATES Settings
|
// OpenSim.ini Section name for ESTATES Settings
|
||||||
public const string ESTATE_SECTION_NAME = "Estates";
|
public const string ESTATE_SECTION_NAME = "Estates";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allow all plugin loading to be disabled for tests/debug.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// true by default
|
||||||
|
/// </remarks>
|
||||||
|
public bool EnableInitialPluginLoad { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Control whether we attempt to load an estate data service.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>For tests/debugging</remarks>
|
||||||
|
public bool LoadEstateDataService { get; set; }
|
||||||
|
|
||||||
protected string proxyUrl;
|
protected string proxyUrl;
|
||||||
protected int proxyOffset = 0;
|
protected int proxyOffset = 0;
|
||||||
|
|
||||||
|
@ -96,7 +110,7 @@ namespace OpenSim
|
||||||
|
|
||||||
public ConsoleCommand CreateAccount = null;
|
public ConsoleCommand CreateAccount = null;
|
||||||
|
|
||||||
protected List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>();
|
public List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>();
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The config information passed into the OpenSimulator region server.
|
/// The config information passed into the OpenSimulator region server.
|
||||||
|
@ -135,6 +149,8 @@ namespace OpenSim
|
||||||
/// <param name="configSource"></param>
|
/// <param name="configSource"></param>
|
||||||
public OpenSimBase(IConfigSource configSource) : base()
|
public OpenSimBase(IConfigSource configSource) : base()
|
||||||
{
|
{
|
||||||
|
EnableInitialPluginLoad = true;
|
||||||
|
LoadEstateDataService = true;
|
||||||
LoadConfigSettings(configSource);
|
LoadConfigSettings(configSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,20 +252,25 @@ namespace OpenSim
|
||||||
if (String.IsNullOrEmpty(module))
|
if (String.IsNullOrEmpty(module))
|
||||||
throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] or [EstateService] section");
|
throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] or [EstateService] section");
|
||||||
|
|
||||||
m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { Config });
|
if (LoadEstateDataService)
|
||||||
if (m_estateDataService == null)
|
{
|
||||||
throw new Exception(
|
m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { Config });
|
||||||
string.Format(
|
if (m_estateDataService == null)
|
||||||
"Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.",
|
throw new Exception(
|
||||||
module));
|
string.Format(
|
||||||
|
"Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.",
|
||||||
|
module));
|
||||||
|
}
|
||||||
|
|
||||||
base.StartupSpecific();
|
base.StartupSpecific();
|
||||||
|
|
||||||
LoadPlugins();
|
if (EnableInitialPluginLoad)
|
||||||
|
LoadPlugins();
|
||||||
|
|
||||||
|
// We still want to post initalize any plugins even if loading has been disabled since a test may have
|
||||||
|
// inserted them manually.
|
||||||
foreach (IApplicationPlugin plugin in m_plugins)
|
foreach (IApplicationPlugin plugin in m_plugins)
|
||||||
{
|
|
||||||
plugin.PostInitialise();
|
plugin.PostInitialise();
|
||||||
}
|
|
||||||
|
|
||||||
if (m_console != null)
|
if (m_console != null)
|
||||||
AddPluginCommands(m_console);
|
AddPluginCommands(m_console);
|
||||||
|
@ -874,6 +895,9 @@ namespace OpenSim
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SceneManager.Close();
|
SceneManager.Close();
|
||||||
|
|
||||||
|
foreach (IApplicationPlugin plugin in m_plugins)
|
||||||
|
plugin.Dispose();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -316,9 +316,12 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
m_enabled = false;
|
if (m_enabled)
|
||||||
m_cache.Clear();
|
{
|
||||||
m_cache = null;
|
m_enabled = false;
|
||||||
|
m_cache.Clear();
|
||||||
|
m_cache = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1894,6 +1894,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
RegionInfo.RegionID,
|
RegionInfo.RegionID,
|
||||||
RegionInfo.RegionLocX, RegionInfo.RegionLocY,
|
RegionInfo.RegionLocX, RegionInfo.RegionLocY,
|
||||||
RegionInfo.RegionSizeX, RegionInfo.RegionSizeY);
|
RegionInfo.RegionSizeX, RegionInfo.RegionSizeY);
|
||||||
|
|
||||||
if (error != String.Empty)
|
if (error != String.Empty)
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,249 @@
|
||||||
|
/*
|
||||||
|
* 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.Net;
|
||||||
|
using Mono.Addins;
|
||||||
|
using Nini.Config;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenSim;
|
||||||
|
using OpenSim.ApplicationPlugins.RegionModulesController;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
|
||||||
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
using OpenSim.Tests.Common;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
|
{
|
||||||
|
public class SharedRegionModuleTests : OpenSimTestCase
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestLifecycle()
|
||||||
|
{
|
||||||
|
TestHelpers.InMethod();
|
||||||
|
// TestHelpers.EnableLogging();
|
||||||
|
|
||||||
|
UUID estateOwnerId = TestHelpers.ParseTail(0x1);
|
||||||
|
UUID regionId = TestHelpers.ParseTail(0x10);
|
||||||
|
|
||||||
|
IConfigSource configSource = new IniConfigSource();
|
||||||
|
configSource.AddConfig("Startup");
|
||||||
|
configSource.AddConfig("Modules");
|
||||||
|
|
||||||
|
// // We use this to skip estate questions
|
||||||
|
// Turns out not to be needed is estate owner id is pre-set in region information.
|
||||||
|
// IConfig estateConfig = configSource.AddConfig(OpenSimBase.ESTATE_SECTION_NAME);
|
||||||
|
// estateConfig.Set("DefaultEstateOwnerName", "Zaphod Beeblebrox");
|
||||||
|
// estateConfig.Set("DefaultEstateOwnerUUID", estateOwnerId);
|
||||||
|
// estateConfig.Set("DefaultEstateOwnerEMail", "zaphod@galaxy.com");
|
||||||
|
// estateConfig.Set("DefaultEstateOwnerPassword", "two heads");
|
||||||
|
|
||||||
|
// For grid servic
|
||||||
|
configSource.AddConfig("GridService");
|
||||||
|
configSource.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
|
||||||
|
configSource.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
|
||||||
|
configSource.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
|
||||||
|
configSource.Configs["GridService"].Set("ConnectionString", "!static");
|
||||||
|
|
||||||
|
LocalGridServicesConnector gridService = new LocalGridServicesConnector();
|
||||||
|
//
|
||||||
|
OpenSim sim = new OpenSim(configSource);
|
||||||
|
|
||||||
|
sim.SuppressExit = true;
|
||||||
|
sim.EnableInitialPluginLoad = false;
|
||||||
|
sim.LoadEstateDataService = false;
|
||||||
|
sim.NetServersInfo.HttpListenerPort = 0;
|
||||||
|
|
||||||
|
IRegistryCore reg = sim.ApplicationRegistry;
|
||||||
|
|
||||||
|
RegionInfo ri = new RegionInfo();
|
||||||
|
ri.RegionID = regionId;
|
||||||
|
ri.EstateSettings.EstateOwner = estateOwnerId;
|
||||||
|
ri.InternalEndPoint = new IPEndPoint(0, 0);
|
||||||
|
|
||||||
|
MockRegionModulesControllerPlugin rmcp = new MockRegionModulesControllerPlugin();
|
||||||
|
sim.m_plugins = new List<IApplicationPlugin>() { rmcp };
|
||||||
|
reg.RegisterInterface<IRegionModulesController>(rmcp);
|
||||||
|
|
||||||
|
// XXX: Have to initialize directly for now
|
||||||
|
rmcp.Initialise(sim);
|
||||||
|
|
||||||
|
rmcp.AddNode(gridService);
|
||||||
|
|
||||||
|
TestSharedRegion tsr = new TestSharedRegion();
|
||||||
|
rmcp.AddNode(tsr);
|
||||||
|
|
||||||
|
// FIXME: Want to use the real one eventually but this is currently directly tied into Mono.Addins
|
||||||
|
// which has been written in such a way that makes it impossible to use for regression tests.
|
||||||
|
// RegionModulesControllerPlugin rmcp = new RegionModulesControllerPlugin();
|
||||||
|
// rmcp.LoadModulesFromAddins = false;
|
||||||
|
//// reg.RegisterInterface<IRegionModulesController>(rmcp);
|
||||||
|
// rmcp.Initialise(sim);
|
||||||
|
// rmcp.PostInitialise();
|
||||||
|
// TypeExtensionNode node = new TypeExtensionNode();
|
||||||
|
// node.
|
||||||
|
// rmcp.AddNode(node, configSource.Configs["Modules"], new Dictionary<RuntimeAddin, IList<int>>());
|
||||||
|
|
||||||
|
sim.Startup();
|
||||||
|
IScene scene;
|
||||||
|
sim.CreateRegion(ri, out scene);
|
||||||
|
|
||||||
|
sim.Shutdown();
|
||||||
|
|
||||||
|
List<string> co = tsr.CallOrder;
|
||||||
|
int expectedEventCount = 6;
|
||||||
|
|
||||||
|
Assert.AreEqual(
|
||||||
|
expectedEventCount,
|
||||||
|
co.Count,
|
||||||
|
"Expected {0} events but only got {1} ({2})",
|
||||||
|
expectedEventCount, co.Count, string.Join(",", co));
|
||||||
|
Assert.AreEqual("Initialise", co[0]);
|
||||||
|
Assert.AreEqual("PostInitialise", co[1]);
|
||||||
|
Assert.AreEqual("AddRegion", co[2]);
|
||||||
|
Assert.AreEqual("RegionLoaded", co[3]);
|
||||||
|
Assert.AreEqual("RemoveRegion", co[4]);
|
||||||
|
Assert.AreEqual("Close", co[5]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestSharedRegion : ISharedRegionModule
|
||||||
|
{
|
||||||
|
// FIXME: Should really use MethodInfo
|
||||||
|
public List<string> CallOrder = new List<string>();
|
||||||
|
|
||||||
|
public string Name { get { return "TestSharedRegion"; } }
|
||||||
|
|
||||||
|
public Type ReplaceableInterface { get { return null; } }
|
||||||
|
|
||||||
|
public void PostInitialise()
|
||||||
|
{
|
||||||
|
CallOrder.Add("PostInitialise");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialise(IConfigSource source)
|
||||||
|
{
|
||||||
|
CallOrder.Add("Initialise");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
CallOrder.Add("Close");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddRegion(Scene scene)
|
||||||
|
{
|
||||||
|
CallOrder.Add("AddRegion");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveRegion(Scene scene)
|
||||||
|
{
|
||||||
|
CallOrder.Add("RemoveRegion");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegionLoaded(Scene scene)
|
||||||
|
{
|
||||||
|
CallOrder.Add("RegionLoaded");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MockRegionModulesControllerPlugin : IRegionModulesController, IApplicationPlugin
|
||||||
|
{
|
||||||
|
// List of shared module instances, for adding to Scenes
|
||||||
|
private List<ISharedRegionModule> m_sharedInstances = new List<ISharedRegionModule>();
|
||||||
|
|
||||||
|
// Config access
|
||||||
|
private OpenSimBase m_openSim;
|
||||||
|
|
||||||
|
public string Version { get { return "0"; } }
|
||||||
|
public string Name { get { return "MockRegionModulesControllerPlugin"; } }
|
||||||
|
|
||||||
|
public void Initialise() {}
|
||||||
|
|
||||||
|
public void Initialise(OpenSimBase sim)
|
||||||
|
{
|
||||||
|
m_openSim = sim;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the application loading is completed
|
||||||
|
/// </summary>
|
||||||
|
public void PostInitialise()
|
||||||
|
{
|
||||||
|
foreach (ISharedRegionModule module in m_sharedInstances)
|
||||||
|
module.PostInitialise();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddRegionToModules(Scene scene)
|
||||||
|
{
|
||||||
|
List<ISharedRegionModule> sharedlist = new List<ISharedRegionModule>();
|
||||||
|
|
||||||
|
foreach (ISharedRegionModule module in m_sharedInstances)
|
||||||
|
{
|
||||||
|
module.AddRegion(scene);
|
||||||
|
scene.AddRegionModule(module.Name, module);
|
||||||
|
|
||||||
|
sharedlist.Add(module);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (ISharedRegionModule module in sharedlist)
|
||||||
|
{
|
||||||
|
module.RegionLoaded(scene);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveRegionFromModules(Scene scene)
|
||||||
|
{
|
||||||
|
foreach (IRegionModuleBase module in scene.RegionModules.Values)
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat("[REGIONMODULE]: Removing scene {0} from module {1}",
|
||||||
|
// scene.RegionInfo.RegionName, module.Name);
|
||||||
|
module.RemoveRegion(scene);
|
||||||
|
}
|
||||||
|
|
||||||
|
scene.RegionModules.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddNode(ISharedRegionModule module)
|
||||||
|
{
|
||||||
|
m_sharedInstances.Add(module);
|
||||||
|
module.Initialise(m_openSim.ConfigSource.Source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
// We expect that all regions have been removed already
|
||||||
|
while (m_sharedInstances.Count > 0)
|
||||||
|
{
|
||||||
|
m_sharedInstances[0].Close();
|
||||||
|
m_sharedInstances.RemoveAt(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
|
|
||||||
namespace OpenSim.Tests.Common
|
namespace OpenSim.Tests.Common
|
||||||
|
|
|
@ -3185,8 +3185,11 @@
|
||||||
<Reference name="System.Xml"/>
|
<Reference name="System.Xml"/>
|
||||||
<Reference name="System.Drawing"/>
|
<Reference name="System.Drawing"/>
|
||||||
<Reference name="System.Runtime.Remoting"/>
|
<Reference name="System.Runtime.Remoting"/>
|
||||||
|
<Reference name="Mono.Addins" path="../../../bin/"/>
|
||||||
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
|
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
|
||||||
<Reference name="OpenMetaverse" path="../../../bin/"/>
|
<Reference name="OpenMetaverse" path="../../../bin/"/>
|
||||||
|
<Reference name="OpenSim"/>
|
||||||
|
<Reference name="OpenSim.ApplicationPlugins.RegionModulesController"/>
|
||||||
<Reference name="OpenSim.Capabilities"/>
|
<Reference name="OpenSim.Capabilities"/>
|
||||||
<Reference name="OpenSim.Data"/>
|
<Reference name="OpenSim.Data"/>
|
||||||
<Reference name="OpenSim.Framework"/>
|
<Reference name="OpenSim.Framework"/>
|
||||||
|
@ -3195,6 +3198,7 @@
|
||||||
<Reference name="OpenSim.Framework.Monitoring"/>
|
<Reference name="OpenSim.Framework.Monitoring"/>
|
||||||
<Reference name="OpenSim.Framework.Servers"/>
|
<Reference name="OpenSim.Framework.Servers"/>
|
||||||
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
|
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
|
||||||
|
<Reference name="OpenSim.Region.ClientStack"/>
|
||||||
<Reference name="OpenSim.Region.ClientStack.LindenCaps"/>
|
<Reference name="OpenSim.Region.ClientStack.LindenCaps"/>
|
||||||
<Reference name="OpenSim.Region.Framework"/>
|
<Reference name="OpenSim.Region.Framework"/>
|
||||||
<Reference name="OpenSim.Region.CoreModules"/>
|
<Reference name="OpenSim.Region.CoreModules"/>
|
||||||
|
|
Loading…
Reference in New Issue