Merge branch 'dev_kitty' into dev

dsg
Huaiyu (Kitty) Liu 2011-01-25 11:15:13 -08:00
commit ea2dc04bac
8 changed files with 183 additions and 95 deletions

View File

@ -85,7 +85,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation; //m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
//Register for Scene/SceneGraph events //Register for Scene/SceneGraph events
m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ClientManager_OnObjectCreate); //m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ClientManager_OnObjectCreate);
m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(ClientManager_OnObjectCreateBySync);
m_scene.EventManager.OnSymmetricSyncStop += ClientManager_OnSymmetricSyncStop; m_scene.EventManager.OnSymmetricSyncStop += ClientManager_OnSymmetricSyncStop;
} }
@ -151,7 +152,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
/// <summary> /// <summary>
/// Script Engine's action upon an object is added to the local scene /// Script Engine's action upon an object is added to the local scene
/// </summary> /// </summary>
private void ClientManager_OnObjectCreate(EntityBase entity) private void ClientManager_OnObjectCreateBySync(EntityBase entity)
{ {
if (entity is SceneObjectGroup) if (entity is SceneObjectGroup)
{ {

View File

@ -85,7 +85,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation; //m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
//Register for Scene/SceneGraph events //Register for Scene/SceneGraph events
m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(PhysicsEngine_OnObjectCreate); //m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(PhysicsEngine_OnObjectCreate);
m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(PhysicsEngine_OnObjectCreateBySync);
m_scene.EventManager.OnSymmetricSyncStop += PhysicsEngine_OnSymmetricSyncStop; m_scene.EventManager.OnSymmetricSyncStop += PhysicsEngine_OnSymmetricSyncStop;
} }
@ -151,7 +152,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
/// <summary> /// <summary>
/// Script Engine's action upon an object is added to the local scene /// Script Engine's action upon an object is added to the local scene
/// </summary> /// </summary>
private void PhysicsEngine_OnObjectCreate(EntityBase entity) private void PhysicsEngine_OnObjectCreateBySync(EntityBase entity)
{ {
if (entity is SceneObjectGroup) if (entity is SceneObjectGroup)
{ {

View File

@ -215,9 +215,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
return; return;
} }
List<SceneObjectGroup> primUpdates; List<SceneObjectGroup> primUpdates=null;
List<ScenePresence> presenceUpdates; List<ScenePresence> presenceUpdates=null;
if (m_primUpdates.Count > 0)
{
lock (m_updateSceneObjectPartLock) lock (m_updateSceneObjectPartLock)
{ {
primUpdates = new List<SceneObjectGroup>(m_primUpdates.Values); primUpdates = new List<SceneObjectGroup>(m_primUpdates.Values);
@ -225,12 +227,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_primUpdates.Clear(); m_primUpdates.Clear();
//m_presenceUpdates.Clear(); //m_presenceUpdates.Clear();
} }
}
if (m_presenceUpdates.Count > 0)
{
lock (m_updateScenePresenceLock) lock (m_updateScenePresenceLock)
{ {
presenceUpdates = new List<ScenePresence>(m_presenceUpdates.Values); presenceUpdates = new List<ScenePresence>(m_presenceUpdates.Values);
m_presenceUpdates.Clear(); m_presenceUpdates.Clear();
} }
}
// This could be another thread for sending outgoing messages or just have the Queue functions // This could be another thread for sending outgoing messages or just have the Queue functions
// create and queue the messages directly into the outgoing server thread. // create and queue the messages directly into the outgoing server thread.
@ -238,6 +244,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{ {
// Dan's note: Sending the message when it's first queued would yield lower latency but much higher load on the simulator // Dan's note: Sending the message when it's first queued would yield lower latency but much higher load on the simulator
// as parts may be updated many many times very quickly. Need to implement a higher resolution send in heartbeat // as parts may be updated many many times very quickly. Need to implement a higher resolution send in heartbeat
if (primUpdates != null)
{
foreach (SceneObjectGroup sog in primUpdates) foreach (SceneObjectGroup sog in primUpdates)
{ {
//If this is a relay node, or at least one part of the object has the last update caused by this actor, then send the update //If this is a relay node, or at least one part of the object has the last update caused by this actor, then send the update
@ -249,7 +258,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
SendObjectUpdateToRelevantSyncConnectors(sog, syncMsg); SendObjectUpdateToRelevantSyncConnectors(sog, syncMsg);
} }
} }
}
/* /*
if(presenceUpdates!=null){
foreach (ScenePresence presence in presenceUpdates) foreach (ScenePresence presence in presenceUpdates)
{ {
try try
@ -291,7 +302,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{ {
m_log.ErrorFormat("[REGION SYNC MODULE] Caught exception sending presence updates for {0}: {1}", presence.Name, e.Message); m_log.ErrorFormat("[REGION SYNC MODULE] Caught exception sending presence updates for {0}: {1}", presence.Name, e.Message);
} }
} }}
* */ * */
// Indicate that the current batch of updates has been completed // Indicate that the current batch of updates has been completed
@ -415,6 +426,7 @@ 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.");
} }
//Object updates are sent by enqueuing into each connector's outQueue.
private void SendObjectUpdateToRelevantSyncConnectors(SceneObjectGroup sog, SymmetricSyncMessage syncMsg) private void SendObjectUpdateToRelevantSyncConnectors(SceneObjectGroup sog, SymmetricSyncMessage syncMsg)
{ {
List<SyncConnector> syncConnectors = GetSyncConnectorsForObjectUpdates(sog); List<SyncConnector> syncConnectors = GetSyncConnectorsForObjectUpdates(sog);
@ -427,6 +439,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
} }
} }
//Events are send out right away, without being put into the connector's outQueue first.
//May need a better method for managing the outgoing messages (i.e. prioritizing object updates and events)
private void SendSceneEventToRelevantSyncConnectors(string init_actorID, SymmetricSyncMessage rsm) private void SendSceneEventToRelevantSyncConnectors(string init_actorID, SymmetricSyncMessage rsm)
{ {
List<SyncConnector> syncConnectors = GetSyncConnectorsForSceneEvents(init_actorID, rsm); List<SyncConnector> syncConnectors = GetSyncConnectorsForSceneEvents(init_actorID, rsm);
@ -784,8 +798,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
} }
/// <summary> /// <summary>
/// This function will enqueue a message for each SyncConnector in the connector's outgoing queue. /// This function will send out the sync message right away, without putting it into the SyncConnector's queue.
/// Each SyncConnector has a SendLoop thread to send the messages in its outgoing queue. /// Should only be called for infrequent or high prority messages.
/// </summary> /// </summary>
/// <param name="msgType"></param> /// <param name="msgType"></param>
/// <param name="data"></param> /// <param name="data"></param>

View File

@ -82,7 +82,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation; //m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
//Register for Scene/SceneGraph events //Register for Scene/SceneGraph events
m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ScenePersistence_OnObjectCreate); //m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ScenePersistence_OnObjectCreate);
m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(ScenePersistence_OnObjectCreateBySync);
} }
//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.
@ -156,12 +157,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
/// <summary> /// <summary>
/// ScenePersistence's actions upon an object is added to the local scene. /// ScenePersistence's actions upon an object is added to the local scene.
/// </summary> /// </summary>
private void ScenePersistence_OnObjectCreate(EntityBase entity) private void ScenePersistence_OnObjectCreateBySync(EntityBase entity)
{ {
if (entity is SceneObjectGroup) if (entity is SceneObjectGroup)
{ {
m_log.Warn(LogHeader + ": link to backup for " + entity.UUID); m_log.Warn(LogHeader + ": link to backup for " + entity.UUID);
SceneObjectGroup sog = (SceneObjectGroup)entity; SceneObjectGroup sog = (SceneObjectGroup)entity;
//probably what we should do here is to set some variable sog.SyncToBackup to true, and sog.ProcessBackup will only run if that value is true,
//then we do not need to worry about where an object is attach-to-backup and modify all those lines.
sog.AttachToBackup(); sog.AttachToBackup();
} }
} }

View File

@ -84,14 +84,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation; //m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
//Register for Scene/SceneGraph events //Register for Scene/SceneGraph events
m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ScriptEngine_OnObjectCreate); //m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ScriptEngine_OnObjectCreate);
m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(ScriptEngine_OnObjectCreateBySync);
m_scene.EventManager.OnSymmetricSyncStop += ScriptEngine_OnSymmetricSyncStop; m_scene.EventManager.OnSymmetricSyncStop += ScriptEngine_OnSymmetricSyncStop;
//for local OnUpdateScript, we'll handle it the same way as a remove OnUpdateScript. //for local OnUpdateScript, we'll handle it the same way as a remove OnUpdateScript.
//RegionSyncModule will capture a locally initiated OnUpdateScript event and publish it to other actors. //RegionSyncModule will capture a locally initiated OnUpdateScript event and publish it to other actors.
m_scene.EventManager.OnNewScript += ScriptEngine_OnNewScript; m_scene.EventManager.OnNewScript += ScriptEngine_OnNewScript;
m_scene.EventManager.OnUpdateScript += ScriptEngine_OnUpdateScript; m_scene.EventManager.OnUpdateScript += ScriptEngine_OnUpdateScript;
//m_scene.EventManager.OnUpdateScriptBySync += ScriptEngine_OnUpdateScript;
m_scene.EventManager.OnAggregateScriptEvents += ScriptEngine_OnAggregateScriptEvents;
LogHeader += "-" + m_actorID + "-" + m_scene.RegionInfo.RegionName; LogHeader += "-" + m_actorID + "-" + m_scene.RegionInfo.RegionName;
} }
@ -166,7 +168,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
/// <summary> /// <summary>
/// Script Engine's action upon an object is added to the local scene /// Script Engine's action upon an object is added to the local scene
/// </summary> /// </summary>
private void ScriptEngine_OnObjectCreate(EntityBase entity) private void ScriptEngine_OnObjectCreateBySync(EntityBase entity)
{ {
if (entity is SceneObjectGroup) if (entity is SceneObjectGroup)
{ {
@ -199,6 +201,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_scene.SymSync_OnUpdateScript(agentID, itemID, primID, isScriptRunning, newAssetID); m_scene.SymSync_OnUpdateScript(agentID, itemID, primID, isScriptRunning, newAssetID);
} }
public void ScriptEngine_OnAggregateScriptEvents(SceneObjectPart part)
{
part.aggregateScriptEvents();
}
#endregion //ScriptEngineSyncModule #endregion //ScriptEngineSyncModule
} }

View File

@ -2528,6 +2528,28 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public delegate void AggregateScriptEvents(SceneObjectPart part);
public event AggregateScriptEvents OnAggregateScriptEvents;
public void TriggerAggregateScriptEvents(SceneObjectPart part)
{
AggregateScriptEvents handlerAggregateScriptEvents = OnAggregateScriptEvents;
if (handlerAggregateScriptEvents != null)
{
foreach (AggregateScriptEvents d in handlerAggregateScriptEvents.GetInvocationList())
{
try
{
d(part);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerAggregateScriptEvents failed - continuing. {0} {1}",
e.Message, e.StackTrace);
}
}
}
}
//end of SYMMETRIC SYNC //end of SYMMETRIC SYNC
} }
} }

View File

@ -47,6 +47,11 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void ObjectDeleteDelegate(EntityBase obj); public delegate void ObjectDeleteDelegate(EntityBase obj);
//SYMMETRIC SYNC
public delegate void ObjectCreateBySyncDelegate(EntityBase obj);
//end of SYMMETRIC SYNC
/// <summary> /// <summary>
/// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components
/// should be migrated out over time. /// should be migrated out over time.
@ -64,6 +69,10 @@ namespace OpenSim.Region.Framework.Scenes
public event ObjectCreateDelegate OnObjectCreate; public event ObjectCreateDelegate OnObjectCreate;
public event ObjectDeleteDelegate OnObjectRemove; public event ObjectDeleteDelegate OnObjectRemove;
//SYMMETRIC SYNC
public event ObjectCreateBySyncDelegate OnObjectCreateBySync;
//end of SYMMETRIC SYNC
#endregion #endregion
#region Fields #region Fields
@ -1963,9 +1972,8 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
//This is an object added due to receiving a state synchronization message from Scene or an actor. Do similar things as the original AddSceneObject(), //This is called when an object is added due to receiving a state synchronization message from Scene or an actor. Do similar things as the original AddSceneObject(),
//but call ScheduleGroupForFullUpdate_TimeStampUnchanged() instead, so as not to modify the timestamp or actorID, since the object was not created //but call ScheduleGroupForFullUpdate_TimeStampUnchanged() instead, so as not to modify the timestamp or actorID, since the object was not created locally.
//locally.
public bool AddSceneObjectByStateSynch(SceneObjectGroup sceneObject) public bool AddSceneObjectByStateSynch(SceneObjectGroup sceneObject)
{ {
if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero) if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero)
@ -2007,8 +2015,12 @@ namespace OpenSim.Region.Framework.Scenes
//if (attachToBackup) //if (attachToBackup)
// sceneObject.AttachToBackup(); // sceneObject.AttachToBackup();
if (OnObjectCreate != null) //if (OnObjectCreate != null)
OnObjectCreate(sceneObject); // OnObjectCreate(sceneObject);
if (OnObjectCreateBySync != null)
OnObjectCreateBySync(sceneObject);
lock (SceneObjectGroupsByFullID) lock (SceneObjectGroupsByFullID)
{ {

View File

@ -4962,6 +4962,8 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
private Object propertyUpdateLock = new Object();
//!!!!!! -- TODO: //!!!!!! -- TODO:
//!!!!!! -- We should call UpdateXXX functions to update each property, cause some of such updates involves sanity checking. //!!!!!! -- We should call UpdateXXX functions to update each property, cause some of such updates involves sanity checking.
public Scene.ObjectUpdateResult UpdateAllProperties(SceneObjectPart updatedPart) public Scene.ObjectUpdateResult UpdateAllProperties(SceneObjectPart updatedPart)
@ -5005,6 +5007,9 @@ namespace OpenSim.Region.Framework.Scenes
//Otherwise, our timestamp is less up to date, update the prim with the received copy //Otherwise, our timestamp is less up to date, update the prim with the received copy
Scene.ObjectUpdateResult partUpdateResult = Scene.ObjectUpdateResult.Updated; Scene.ObjectUpdateResult partUpdateResult = Scene.ObjectUpdateResult.Updated;
bool collisionSoundUpdated = false;
lock (propertyUpdateLock)
{
//See SceneObjectSerializer for the properties that are included in a serialized SceneObjectPart. //See SceneObjectSerializer for the properties that are included in a serialized SceneObjectPart.
this.AllowedDrop = updatedPart.AllowedDrop; this.AllowedDrop = updatedPart.AllowedDrop;
@ -5058,7 +5063,12 @@ namespace OpenSim.Region.Framework.Scenes
this.EveryoneMask = updatedPart.EveryoneMask; this.EveryoneMask = updatedPart.EveryoneMask;
this.NextOwnerMask = updatedPart.NextOwnerMask; this.NextOwnerMask = updatedPart.NextOwnerMask;
this.Flags = updatedPart.Flags; this.Flags = updatedPart.Flags;
this.CollisionSound = updatedPart.CollisionSound;
//We will update CollisionSound with special care so that it does not lead to ScheduleFullUpdate of this part, to make the actor think it just made an update and
//need to propogate that update to other actors.
//this.CollisionSound = updatedPart.CollisionSound;
collisionSoundUpdated = UpdateCollisionSound(updatedPart.CollisionSound);
this.CollisionSoundVolume = updatedPart.CollisionSoundVolume; this.CollisionSoundVolume = updatedPart.CollisionSoundVolume;
this.MediaUrl = updatedPart.MediaUrl; this.MediaUrl = updatedPart.MediaUrl;
this.TextureAnimation = updatedPart.TextureAnimation; this.TextureAnimation = updatedPart.TextureAnimation;
@ -5067,10 +5077,26 @@ namespace OpenSim.Region.Framework.Scenes
//Update the timestamp and LastUpdatedByActorID first. //Update the timestamp and LastUpdatedByActorID first.
this.m_lastUpdateActorID = updatedPart.LastUpdateActorID; this.m_lastUpdateActorID = updatedPart.LastUpdateActorID;
this.m_lastUpdateTimeStamp = updatedPart.LastUpdateTimeStamp; this.m_lastUpdateTimeStamp = updatedPart.LastUpdateTimeStamp;
}
if (collisionSoundUpdated)
{
m_parentGroup.Scene.EventManager.TriggerAggregateScriptEvents(this);
}
return partUpdateResult; return partUpdateResult;
} }
private bool UpdateCollisionSound(UUID updatedCollisionSound)
{
if (this.CollisionSound != updatedCollisionSound)
{
m_collisionSound = updatedCollisionSound;
return true;
}
return false;
}
/// <summary> /// <summary>
/// Schedules this prim for a full update, without changing the timestamp or actorID (info on when and who modified any property). /// Schedules this prim for a full update, without changing the timestamp or actorID (info on when and who modified any property).
/// NOTE: this is the same as the original SceneObjectPart.ScheduleFullUpdate(). /// NOTE: this is the same as the original SceneObjectPart.ScheduleFullUpdate().