Handler of SymmetricSyncMessage.MsgType.UpdatedObject changed to HandleUpdateObjectBySynchronization,

that is, since we add objects in scene by sending around NewObject, we no longer "add" objects after
receiving UpdateObject.
Also, ProcessBackup is now only executed by Persistece Actor (ScenePersistenceSyncModule, if configured
to run, will set each SOG's ToPersistObjectState to true).
dsg
Huaiyu (Kitty) Liu 2011-03-16 11:32:26 -07:00
parent a8c722bead
commit 271f460bae
5 changed files with 129 additions and 18 deletions

View File

@ -1631,8 +1631,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//SendSyncMessage(SymmetricSyncMessage.MsgType.NewObject, sogxml); //SendSyncMessage(SymmetricSyncMessage.MsgType.NewObject, sogxml);
SceneObjectGroup sog = (SceneObjectGroup)e; SceneObjectGroup sog = (SceneObjectGroup)e;
SendNewObject(sog); SendNewObject(sog);
//m_log.Debug(LogHeader + ": " + sogxml);
} }
} }
return; return;
@ -1642,8 +1640,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
break; break;
case SymmetricSyncMessage.MsgType.UpdatedObject: case SymmetricSyncMessage.MsgType.UpdatedObject:
{ {
HandleAddOrUpdateObjectBySynchronization(msg, senderActorID); //HandleAddOrUpdateObjectBySynchronization(msg, senderActorID);
//HandleAddNewObject(sog); HandleUpdateObjectBySynchronization(msg, senderActorID);
return; return;
} }
case SymmetricSyncMessage.MsgType.UpdatedBucketProperties: case SymmetricSyncMessage.MsgType.UpdatedBucketProperties:
@ -1722,7 +1720,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//First, create the object group and add it to Scene //First, create the object group and add it to Scene
string sogxml = data["sogxml"]; string sogxml = data["sogxml"];
SceneObjectGroup sog = SceneObjectSerializer.FromXml2Format(sogxml); SceneObjectGroup sog = SceneObjectSerializer.FromXml2Format(sogxml);
Scene.ObjectUpdateResult updateResult = m_scene.AddOrUpdateObjectBySynchronization(sog); //Scene.ObjectUpdateResult updateResult = m_scene.AddOrUpdateObjectBySynchronization(sog);
Scene.ObjectUpdateResult updateResult = m_scene.AddNewSceneObjectBySync(sog);
//if this is a relay node, forward the event //if this is a relay node, forward the event
if (m_isSyncRelay) if (m_isSyncRelay)
@ -1749,9 +1749,47 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_scene.UpdateObjectPartBucketProperties(bucketName, partUUID, data, rBucketSyncInfo); m_scene.UpdateObjectPartBucketProperties(bucketName, partUUID, data, rBucketSyncInfo);
} }
//m_log.DebugFormat("{0}: received NewObject sync message from {1}, for object {1}, {2}", LogHeader, senderActorID, sog.Name, sog.UUID); //m_log.DebugFormat("{0}: received NewObject sync message from {1}, for object {1}, {2}", LogHeader, senderActorID, sog.Name, sog.UUID);
}
private void HandleUpdateObjectBySynchronization(SymmetricSyncMessage msg, string senderActorID)
{
string sogxml = Encoding.ASCII.GetString(msg.Data, 0, msg.Length);
SceneObjectGroup sog = SceneObjectSerializer.FromXml2Format(sogxml);
lock (m_stats) m_statSOGBucketIn++;
if (sog.IsDeleted)
{
SymmetricSyncMessage.HandleTrivial(LogHeader, msg, String.Format("Ignoring update on deleted object, UUID: {0}.", sog.UUID));
return;
}
else
{
foreach (SceneObjectPart part in sog.Parts)
{
if (part.IsAttachment)
{
m_log.Debug(LogHeader + "HandleUpdateObjectBySynchronization: part " + part.Name + "," + part.UUID + ", IsAttachment = true");
}
}
Scene.ObjectUpdateResult updateResult = m_scene.UpdateObjectBySynchronization(sog);
switch (updateResult)
{
case Scene.ObjectUpdateResult.New:
m_log.DebugFormat("[{0} Object \"{1}\" ({1}) ({2}) added.", LogHeader, sog.Name, sog.UUID.ToString(), sog.LocalId.ToString());
break;
case Scene.ObjectUpdateResult.Updated:
m_log.DebugFormat("[{0} Object \"{1}\" ({1}) ({2}) updated.", LogHeader, sog.Name, sog.UUID.ToString(), sog.LocalId.ToString());
break;
case Scene.ObjectUpdateResult.Error:
m_log.WarnFormat("[{0} Object \"{1}\" ({1}) ({2}) -- add or update ERROR.", LogHeader, sog.Name, sog.UUID.ToString(), sog.LocalId.ToString());
break;
case Scene.ObjectUpdateResult.Unchanged:
//m_log.DebugFormat("[{0} Object \"{1}\" ({1}) ({2}) unchanged after receiving an update.", LogHeader, sog.Name, sog.UUID.ToString(), sog.LocalId.ToString());
break;
}
}
} }

View File

@ -89,7 +89,7 @@ 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); m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(ScenePersistence_OnObjectCreateBySync);
} }
@ -164,16 +164,33 @@ 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_OnObjectCreateBySync(EntityBase entity) private void ScenePersistence_OnObjectCreate(EntityBase entity)
{ {
if (entity is SceneObjectGroup) if (entity is SceneObjectGroup)
{ {
m_log.Warn(LogHeader + ": link to backup for " + entity.UUID); //m_log.Warn(LogHeader + ":OnObjectCreate -- 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, //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. //then we do not need to worry about where an object is attach-to-backup and modify all those lines.
sog.ToPersistObjectState = true;
sog.AttachToBackup();
}
}
/// <summary>
/// ScenePersistence's actions upon an object is added to the local scene.
/// </summary>
private void ScenePersistence_OnObjectCreateBySync(EntityBase entity)
{
if (entity is SceneObjectGroup)
{
//m_log.Warn(LogHeader + ":OnObjectCreateBySync -- link to backup for " + entity.UUID);
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.ToPersistObjectState = true;
sog.AttachToBackup(); sog.AttachToBackup();
} }
} }

View File

@ -684,6 +684,11 @@ namespace OpenSim.Region.Framework.Scenes
return m_sceneGraph.AddOrUpdateObjectBySynchronization(sog); return m_sceneGraph.AddOrUpdateObjectBySynchronization(sog);
} }
public ObjectUpdateResult UpdateObjectBySynchronization(SceneObjectGroup sog)
{
return m_sceneGraph.UpdateObjectBySynchronization(sog);
}
//Similar to DeleteSceneObject, except that this does not change LastUpdateActorID and LastUpdateTimeStamp //Similar to DeleteSceneObject, except that this does not change LastUpdateActorID and LastUpdateTimeStamp
public void DeleteSceneObjectBySynchronization(SceneObjectGroup group) public void DeleteSceneObjectBySynchronization(SceneObjectGroup group)
{ {
@ -732,12 +737,12 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.AddNewSceneObjectPart(newPart, parentGroup); m_sceneGraph.AddNewSceneObjectPart(newPart, parentGroup);
} }
public void AddNewSceneObjectBySync(SceneObjectGroup group, bool attachToBackup) public ObjectUpdateResult AddNewSceneObjectBySync(SceneObjectGroup group)
{ {
if(attachToBackup) //if(attachToBackup)
group.HasGroupChanged = true; // group.HasGroupChanged = true;
m_sceneGraph.AddSceneObjectByStateSynch(group); return m_sceneGraph.AddNewSceneObjectBySync(group);
} }
public void DebugSceneObjectGroups() public void DebugSceneObjectGroups()

View File

@ -2002,6 +2002,37 @@ namespace OpenSim.Region.Framework.Scenes
#region SYMMETRIC SYNC #region SYMMETRIC SYNC
public Scene.ObjectUpdateResult UpdateObjectBySynchronization(SceneObjectGroup updatedSog)
{
UUID sogID = updatedSog.UUID;
Scene.ObjectUpdateResult updateResult = Scene.ObjectUpdateResult.Unchanged;
if (Entities.ContainsKey(sogID))
{
//update the object
EntityBase entity = Entities[sogID];
if (entity is SceneObjectGroup)
{
SceneObjectGroup localSog = (SceneObjectGroup)entity;
updateResult = localSog.UpdateObjectGroupBySync(updatedSog);
}
else
{
m_log.WarnFormat("{0}: Entity with {1} is not of type SceneObjectGroup: {2}",
"[SCENE GRAPH]", sogID, entity.GetType().ToString());
//return false;
updateResult = Scene.ObjectUpdateResult.Error;
}
}
else
{
//An object no longer in Entity list, probably linked to other objects, or handed over to another quark.
m_log.WarnFormat("[SCENE GRAPH] UpdateObjectBySynchronization: received update for an object {0}, {1} no longer in local Entity list. Ignore update.", updatedSog.Name, updatedSog.UUID);
}
return updateResult;
}
public Scene.ObjectUpdateResult AddOrUpdateObjectBySynchronization(SceneObjectGroup updatedSog) public Scene.ObjectUpdateResult AddOrUpdateObjectBySynchronization(SceneObjectGroup updatedSog)
{ {
UUID sogID = updatedSog.UUID; UUID sogID = updatedSog.UUID;
@ -2027,7 +2058,7 @@ namespace OpenSim.Region.Framework.Scenes
else else
{ {
//m_log.Debug(updatedSog.Name+" "+updatedSog.UUID+" not found in Entities list. Need to add"); //m_log.Debug(updatedSog.Name+" "+updatedSog.UUID+" not found in Entities list. Need to add");
AddSceneObjectByStateSynch(updatedSog); AddNewSceneObjectBySync(updatedSog);
updateResult = Scene.ObjectUpdateResult.New; updateResult = Scene.ObjectUpdateResult.New;
} }
@ -2040,13 +2071,18 @@ namespace OpenSim.Region.Framework.Scenes
//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(), //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 locally. //but call ScheduleGroupForFullUpdate_TimeStampUnchanged() instead, so as not to modify the timestamp or actorID, since the object was not created locally.
public bool AddSceneObjectByStateSynch(SceneObjectGroup sceneObject) public Scene.ObjectUpdateResult AddNewSceneObjectBySync(SceneObjectGroup sceneObject)
{ {
Scene.ObjectUpdateResult updateResult = Scene.ObjectUpdateResult.New;
if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero) if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero)
return false; return Scene.ObjectUpdateResult.Error;
if (Entities.ContainsKey(sceneObject.UUID)) if (Entities.ContainsKey(sceneObject.UUID))
return false; {
m_log.WarnFormat("[SCENE GRAPH] AddNewSceneObjectBySync: Already has object {0}, {1} in local Entity list.", sceneObject.Name, sceneObject.UUID);
return Scene.ObjectUpdateResult.Error;
}
SceneObjectPart[] children = sceneObject.Parts; SceneObjectPart[] children = sceneObject.Parts;
@ -2111,7 +2147,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; SceneObjectGroupsByLocalID[part.LocalId] = sceneObject;
} }
return true; return updateResult;
} }
public void AddNewSceneObjectPart(SceneObjectPart newPart, SceneObjectGroup parentGroup) public void AddNewSceneObjectPart(SceneObjectPart newPart, SceneObjectGroup parentGroup)

View File

@ -1372,6 +1372,14 @@ namespace OpenSim.Region.Framework.Scenes
return; return;
} }
//SYMMETRIC SYNC
//if we are doing sync across different sync nodes, and are not told to persist the state, don't do anything (only persistence actor will do it)
if (m_scene.RegionSyncModule != null && !ToPersistObjectState)
{
return;
}
//end of SYMMETRIC SYNC
// Since this is the top of the section of call stack for backing up a particular scene object, don't let // Since this is the top of the section of call stack for backing up a particular scene object, don't let
// any exception propogate upwards. // any exception propogate upwards.
try try
@ -3556,6 +3564,13 @@ namespace OpenSim.Region.Framework.Scenes
#region SYMMETRIC SYNC #region SYMMETRIC SYNC
private bool m_toPersistObjectState = false;
public bool ToPersistObjectState
{
get { return m_toPersistObjectState; }
set { m_toPersistObjectState = value; }
}
//update the existing copy of the object with updated properties in 'updatedSog' //update the existing copy of the object with updated properties in 'updatedSog'
//NOTE: updates on script content are handled seperately (e.g. user edited the script and saved it) -- SESyncServerOnUpdateScript(), a handler of EventManager.OnUpdateScript //NOTE: updates on script content are handled seperately (e.g. user edited the script and saved it) -- SESyncServerOnUpdateScript(), a handler of EventManager.OnUpdateScript
//public void UpdateObjectProperties(SceneObjectGroup updatedSog) //public void UpdateObjectProperties(SceneObjectGroup updatedSog)
@ -3847,7 +3862,7 @@ namespace OpenSim.Region.Framework.Scenes
bool newGroupBySync = true; bool newGroupBySync = true;
SceneObjectGroup objectGroup = new SceneObjectGroup(delinkPart, newGroupBySync); SceneObjectGroup objectGroup = new SceneObjectGroup(delinkPart, newGroupBySync);
m_scene.AddNewSceneObjectBySync(objectGroup, true); m_scene.AddNewSceneObjectBySync(objectGroup);
if (sendEvents) if (sendEvents)
linkPart.TriggerScriptChangedEvent(Changed.LINK); linkPart.TriggerScriptChangedEvent(Changed.LINK);