Added event OnPostSceneCreation to OpenSim/Region/Framework/Scenes/EventManager.cs, and TriggerOnPostSceneCreation. Reason: to emulate what PostInitialise() used to do for IRegionsModules, which is no longer included in INonSharedRegionModule.

Added OnPostSceneCreation() in RegionSynModule.cs, to gain ActorType information from the
loaded Scene.ActorSyncModule. OpenSim, when configured as ScenePersistence, can start normally now.
dsg
Huaiyu (Kitty) Liu 2010-12-23 14:07:05 -08:00
parent 650b0bfe54
commit d63e3db533
5 changed files with 110 additions and 34 deletions

View File

@ -411,6 +411,12 @@ namespace OpenSim
scene.StartTimer(); scene.StartTimer();
//SYMMETRIC SYNC
//For INonSharedRegionModule, there is no more PostInitialise(). So we trigger OnPostSceneCreation event here
//to let the Sync modules to do their work once all modules are loaded and scene has interfaces to all of them.
scene.EventManager.TriggerOnPostSceneCreation(scene);
//end of SYMMETRIC SYNC
return clientServer; return clientServer;
} }

View File

@ -70,6 +70,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//Called after Initialise() //Called after Initialise()
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
{ {
m_log.Warn(LogHeader + " AddRegion() called");
if (!m_active) if (!m_active)
return; return;
@ -82,11 +84,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
// Setup the command line interface // Setup the command line interface
m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
InstallInterfaces(); InstallInterfaces();
//Register for the OnPostSceneCreation event
m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
} }
//Called after AddRegion() has been called for all region modules of the scene //Called after AddRegion() has been called for all region modules of the scene
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
{ {
m_log.Warn(LogHeader + " RegionLoaded() called");
//If this one is configured to start a listener so that other actors can connect to form a overlay, start the listener. //If this one is configured to start a listener so that other actors can connect to form a overlay, start the listener.
//For now, we use start topology, and ScenePersistence actor is always the one to start the listener. //For now, we use start topology, and ScenePersistence actor is always the one to start the listener.
if (m_isSyncListenerLocal) if (m_isSyncListenerLocal)
@ -265,6 +272,20 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_log.Warn("[REGION SYNC MODULE]: StatsTimerElapsed -- NOT yet implemented."); m_log.Warn("[REGION SYNC MODULE]: StatsTimerElapsed -- NOT yet implemented.");
} }
public void OnPostSceneCreation(Scene createdScene)
{
//If this is the local scene the actor is working on, find out the actor type.
if (createdScene.RegionInfo.RegionName == m_scene.RegionInfo.RegionName)
{
if(m_scene.ActorSyncModule == null){
m_log.Error(LogHeader + "interface Scene.ActorSyncModule has not been set yet");
return;
}
m_actorType = m_scene.ActorSyncModule.ActorType;
m_log.Warn(LogHeader + " informed about ActorType: "+m_actorType);
}
}
private void StartLocalSyncListener() private void StartLocalSyncListener()
{ {
RegionSyncListenerInfo localSyncListenerInfo = GetLocalSyncListenerInfo(); RegionSyncListenerInfo localSyncListenerInfo = GetLocalSyncListenerInfo();
@ -583,6 +604,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private RegionSyncListenerInfo m_listenerInfo; private RegionSyncListenerInfo m_listenerInfo;
private RegionSyncModule m_regionSyncModule; private RegionSyncModule m_regionSyncModule;
private ILog m_log; private ILog m_log;
private string LogHeader = "[RegionSyncListener]";
// The listener and the thread which listens for sync connection requests // The listener and the thread which listens for sync connection requests
private TcpListener m_listener; private TcpListener m_listener;
@ -607,7 +629,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{ {
m_listenerThread = new Thread(new ThreadStart(Listen)); m_listenerThread = new Thread(new ThreadStart(Listen));
m_listenerThread.Name = "RegionSyncListener"; m_listenerThread.Name = "RegionSyncListener";
m_log.WarnFormat("[REGION SYNC LISTENER] Starting {0} thread", m_listenerThread.Name); m_log.WarnFormat(LogHeader+" Starting {0} thread", m_listenerThread.Name);
m_listenerThread.Start(); m_listenerThread.Start();
m_isListening = true; m_isListening = true;
//m_log.Warn("[REGION SYNC SERVER] Started"); //m_log.Warn("[REGION SYNC SERVER] Started");

View File

@ -16,28 +16,11 @@ using log4net;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading; using System.Threading;
using Mono.Addins;
namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{ {
/* [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AttachmentsModule")]
public class DSGActorBase
{
protected RegionSyncModule m_regionSyncModule;
public DSGActorBase(RegionSyncModule regionSyncModule)
{
m_regionSyncModule = regionSyncModule;
}
public virtual void init()
{
}
}
* */
public class ScenePersistenceSyncModule : INonSharedRegionModule, IDSGActorSyncModule public class ScenePersistenceSyncModule : INonSharedRegionModule, IDSGActorSyncModule
{ {
#region INonSharedRegionModule #region INonSharedRegionModule
@ -66,6 +49,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
return; return;
} }
m_active = true;
m_log.Warn(LogHeader+" Initialised");
} }
//Called after Initialise() //Called after Initialise()
@ -73,7 +60,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{ {
if (!m_active) if (!m_active)
return; return;
m_log.Warn(LogHeader + " AddRegion() called");
//connect with scene //connect with scene
m_scene = scene; m_scene = scene;
@ -83,19 +70,19 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
// Setup the command line interface // Setup the command line interface
//m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; //m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
//InstallInterfaces(); //InstallInterfaces();
//Register for the OnPostSceneCreation event
//m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
} }
//Called after AddRegion() has been called for all region modules of the scene //Called after AddRegion() has been called for all region modules of the scene.
//NOTE::However, at this point, Scene may not have requested all the needed region module interfaces yet.
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
{ {
if (m_scene.RegionSyncModule != null) if (!m_active)
{ return;
m_scene.RegionSyncModule.DSGActorType = m_actorType; m_log.Warn(LogHeader + " RegionLoaded() called");
}
else
{
m_log.Warn("RegionSyncModule is not initiated!!");
}
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
@ -141,7 +128,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private Scene m_scene; private Scene m_scene;
private string LogHeader = "[ScenePersistenceSyncModule]";
public void OnPostSceneCreation(Scene createdScene)
{
//If this is the local scene the actor is working on, do something
if (createdScene == m_scene)
{
}
}
#endregion //ScenePersistenceSyncModule #endregion //ScenePersistenceSyncModule
} }

View File

@ -376,7 +376,6 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void RegionUp(GridRegion region); public delegate void RegionUp(GridRegion region);
public event RegionUp OnRegionUp; public event RegionUp OnRegionUp;
public class MoneyTransferArgs : EventArgs public class MoneyTransferArgs : EventArgs
{ {
public UUID sender; public UUID sender;
@ -2243,5 +2242,32 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
#endregion #endregion
//SYMMETRIC SYNC
public event PostSceneCreation OnPostSceneCreation;
public delegate void PostSceneCreation(Scene createdScene);
public void TriggerOnPostSceneCreation(Scene createdScene)
{
PostSceneCreation handler = OnPostSceneCreation;
if (handler != null)
{
foreach (PostSceneCreation d in handler.GetInvocationList())
{
try
{
m_log.Warn("TriggerOnPostSceneCreation");
d(createdScene);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerOnPostSceneCreation failed - continuing. {0} {1}",
e.Message, e.StackTrace);
}
}
}
}
//end of SYMMETRIC SYNC
} }
} }

View File

@ -588,8 +588,16 @@ namespace OpenSim.Region.Framework.Scenes
public IRegionSyncModule RegionSyncModule public IRegionSyncModule RegionSyncModule
{ {
get { return m_regionSyncModule; } get { return m_regionSyncModule; }
set { m_regionSyncModule = value; } //set { m_regionSyncModule = value; }
} }
private IDSGActorSyncModule m_DSGActorSyncModule = null;
public IDSGActorSyncModule ActorSyncModule
{
get { return m_DSGActorSyncModule; }
}
#endregion //SYMMETRIC SYNC #endregion //SYMMETRIC SYNC
public ICapabilitiesModule CapsModule public ICapabilitiesModule CapsModule
@ -1281,6 +1289,25 @@ namespace OpenSim.Region.Framework.Scenes
RegionSyncClientModule = RequestModuleInterface<IRegionSyncClientModule>(); RegionSyncClientModule = RequestModuleInterface<IRegionSyncClientModule>();
ScriptEngineToSceneConnectorModule = RequestModuleInterface<IScriptEngineToSceneConnectorModule>(); ScriptEngineToSceneConnectorModule = RequestModuleInterface<IScriptEngineToSceneConnectorModule>();
//////////////////////////////////////////////////////////////////////
//SYMMETRIC SYNC (KittyL: started 12/23/2010)
//////////////////////////////////////////////////////////////////////
m_regionSyncModule = RequestModuleInterface<IRegionSyncModule>();
if (m_regionSyncModule == null)
{
m_log.Warn("Does not find a RegionSyncModule interface");
}
else
{
m_log.Warn("SetModuleInterfaces: RegionSyncModule interface set.");
}
m_DSGActorSyncModule = RequestModuleInterface<IDSGActorSyncModule>();
//////////////////////////////////////////////////////////////////////
//end of SYMMETRIC SYNC
//////////////////////////////////////////////////////////////////////
// Shoving this in here for now, because we have the needed // Shoving this in here for now, because we have the needed
// interfaces at this point // interfaces at this point
// //