Fixed code in SyncDeLinkObject and HandleSyncDelinkObject. Delinking a few linked objects seems working.

dsg
Huaiyu (Kitty) Liu 2011-04-19 15:55:04 -07:00
parent 3676b5fbef
commit a5ebd04d9d
3 changed files with 62 additions and 36 deletions

View File

@ -609,9 +609,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
return; return;
} }
//First, make sure the linked group has updated timestamp info for synchronization
linkedGroup.BucketSyncInfoUpdate();
OSDMap data = new OSDMap(); OSDMap data = new OSDMap();
OSDMap encodedSOG = SceneObjectEncoder(linkedGroup); OSDMap encodedSOG = SceneObjectEncoder(linkedGroup);
data["linkedGroup"] = encodedSOG; data["linkedGroup"] = encodedSOG;
@ -669,17 +666,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
foreach (SceneObjectGroup afterGroup in afterDelinkGroups) foreach (SceneObjectGroup afterGroup in afterDelinkGroups)
{ {
string groupTempID = "afterGroup" + groupNum; string groupTempID = "afterGroup" + groupNum;
string sogxml = SceneObjectSerializer.ToXml2Format(afterGroup); //string sogxml = SceneObjectSerializer.ToXml2Format(afterGroup);
data[groupTempID] = OSD.FromString(sogxml); //data[groupTempID] = OSD.FromString(sogxml);
OSDMap encodedSOG = SceneObjectEncoder(afterGroup);
data[groupTempID] = encodedSOG;
groupNum++; groupNum++;
} }
//make sure the newly delinked objects have the updated timestamp information
foreach (SceneObjectGroup sog in afterDelinkGroups)
{
sog.BucketSyncInfoUpdate();
}
SymmetricSyncMessage rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.DelinkObject, OSDParser.SerializeJsonString(data)); SymmetricSyncMessage rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.DelinkObject, OSDParser.SerializeJsonString(data));
SendDelinkObjectToRelevantSyncConnectors(m_actorID, beforeDelinkGroups, rsm); SendDelinkObjectToRelevantSyncConnectors(m_actorID, beforeDelinkGroups, rsm);
} }
@ -2420,7 +2413,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
OSDMap encodedSOG = (OSDMap)data["linkedGroup"]; OSDMap encodedSOG = (OSDMap)data["linkedGroup"];
SceneObjectGroup linkedGroup; SceneObjectGroup linkedGroup;
Dictionary<UUID, PrimSyncInfo> primsSyncInfo; Dictionary<UUID, PrimSyncInfo> primsSyncInfo;
SceneObjectDecoder(encodedSOG, out linkedGroup, out primsSyncInfo); SceneObjectDecoder(encodedSOG, out linkedGroup, out primsSyncInfo);
if (linkedGroup == null) if (linkedGroup == null)
@ -2433,6 +2425,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
int partCount = data["partCount"].AsInteger(); int partCount = data["partCount"].AsInteger();
List<UUID> childrenIDs = new List<UUID>(); List<UUID> childrenIDs = new List<UUID>();
for (int i = 0; i < partCount; i++)
{
string partTempID = "part" + i;
childrenIDs.Add(data[partTempID].AsUUID());
}
//if this is a relay node, forwards the event //if this is a relay node, forwards the event
if (m_isSyncRelay) if (m_isSyncRelay)
@ -2441,12 +2438,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
SendSpecialObjectUpdateToRelevantSyncConnectors(senderActorID, linkedGroup, msg); SendSpecialObjectUpdateToRelevantSyncConnectors(senderActorID, linkedGroup, msg);
} }
for (int i = 0; i < partCount; i++)
{
string partTempID = "part" + i;
childrenIDs.Add(data[partTempID].AsUUID());
}
//TEMP SYNC DEBUG //TEMP SYNC DEBUG
//m_log.DebugFormat("{0}: received LinkObject from {1}", LogHeader, senderActorID); //m_log.DebugFormat("{0}: received LinkObject from {1}", LogHeader, senderActorID);
@ -2472,8 +2463,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private void HandleSyncDelinkObject(SymmetricSyncMessage msg, string senderActorID) private void HandleSyncDelinkObject(SymmetricSyncMessage msg, string senderActorID)
{ {
OSDMap data = DeserializeMessage(msg); OSDMap data = DeserializeMessage(msg);
if (data == null) if (data == null)
{ {
@ -2485,6 +2474,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
List<UUID> delinkPrimIDs = new List<UUID>(); List<UUID> delinkPrimIDs = new List<UUID>();
List<UUID> beforeDelinkGroupIDs = new List<UUID>(); List<UUID> beforeDelinkGroupIDs = new List<UUID>();
List<SceneObjectGroup> incomingAfterDelinkGroups = new List<SceneObjectGroup>(); List<SceneObjectGroup> incomingAfterDelinkGroups = new List<SceneObjectGroup>();
List<Dictionary<UUID, PrimSyncInfo>> incomingPrimSyncInfo = new List<Dictionary<UUID, PrimSyncInfo>>();
int partCount = data["partCount"].AsInteger(); int partCount = data["partCount"].AsInteger();
for (int i = 0; i < partCount; i++) for (int i = 0; i < partCount; i++)
@ -2508,10 +2498,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
for (int i = 0; i < afterGroupsCount; i++) for (int i = 0; i < afterGroupsCount; i++)
{ {
string groupTempID = "afterGroup" + i; string groupTempID = "afterGroup" + i;
string sogxml = data[groupTempID].AsString(); //string sogxml = data[groupTempID].AsString();
//SceneObjectGroup afterGroup = SceneObjectSerializer.FromXml2Format(sogxml); SceneObjectGroup afterGroup;
SceneObjectGroup afterGroup = DecodeSceneObjectGroup(sogxml); OSDMap encodedSOG = (OSDMap)data[groupTempID];
Dictionary<UUID, PrimSyncInfo> primsSyncInfo;
SceneObjectDecoder(encodedSOG, out afterGroup, out primsSyncInfo);
incomingAfterDelinkGroups.Add(afterGroup); incomingAfterDelinkGroups.Add(afterGroup);
incomingPrimSyncInfo.Add(primsSyncInfo);
} }
//if this is a relay node, forwards the event //if this is a relay node, forwards the event
@ -2528,6 +2521,26 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_scene.DelinkObjectsBySync(delinkPrimIDs, beforeDelinkGroupIDs, incomingAfterDelinkGroups); m_scene.DelinkObjectsBySync(delinkPrimIDs, beforeDelinkGroupIDs, incomingAfterDelinkGroups);
//Sync properties
//Update properties, for each prim in each deLinked-Object
foreach (Dictionary<UUID, PrimSyncInfo> primsSyncInfo in incomingPrimSyncInfo)
{
foreach (KeyValuePair<UUID, PrimSyncInfo> inPrimSyncInfo in primsSyncInfo)
{
UUID primUUID = inPrimSyncInfo.Key;
PrimSyncInfo updatedPrimSyncInfo = inPrimSyncInfo.Value;
SceneObjectPart part = m_scene.GetSceneObjectPart(primUUID);
if (part == null)
{
m_log.WarnFormat("{0}: HandleSyncDelinkObject, prim {1} not in local Scene Graph after DelinkObjectsBySync is called", LogHeader, primUUID);
}
else
{
m_primSyncInfoManager.UpdatePrimSyncInfoBySync(part, updatedPrimSyncInfo);
}
}
}
} }

View File

@ -846,6 +846,14 @@ namespace OpenSim.Region.Framework.Scenes
* */ * */
} }
/// <summary>
/// Delink objects after receiving DelinkObject sync message.
/// Assumption: the actor whichever initiates the DelinkObject
/// operation has already done premission checking.
/// </summary>
/// <param name="delinkPrimIDs"></param>
/// <param name="beforeDelinkGroupIDs"></param>
/// <param name="incomingAfterDelinkGroups"></param>
public void DelinkObjectsBySync(List<UUID> delinkPrimIDs, List<UUID> beforeDelinkGroupIDs, List<SceneObjectGroup> incomingAfterDelinkGroups) public void DelinkObjectsBySync(List<UUID> delinkPrimIDs, List<UUID> beforeDelinkGroupIDs, List<SceneObjectGroup> incomingAfterDelinkGroups)
{ {
m_sceneGraph.DelinkObjectsBySync(delinkPrimIDs, beforeDelinkGroupIDs, incomingAfterDelinkGroups); m_sceneGraph.DelinkObjectsBySync(delinkPrimIDs, beforeDelinkGroupIDs, incomingAfterDelinkGroups);

View File

@ -1643,7 +1643,7 @@ namespace OpenSim.Region.Framework.Scenes
//Schedule updates as in legacy OpenSim code, to send updates to viewers connected to this actor (at least needed for client managers). //Schedule updates as in legacy OpenSim code, to send updates to viewers connected to this actor (at least needed for client managers).
//But timestamp won't be changed, so that when other actors get the update, they's simple ignore the updates since they already get them //But timestamp won't be changed, so that when other actors get the update, they's simple ignore the updates since they already get them
//via the LinkObject message sent above. //via the LinkObject message sent above.
parentGroup.ScheduleGroupForFullUpdate_SyncInfoUnchanged(); parentGroup.ScheduleGroupForFullUpdate(null);
//end of DSG SYNC //end of DSG SYNC
@ -1782,19 +1782,19 @@ namespace OpenSim.Region.Framework.Scenes
afterDelinkGroups.Add(g); afterDelinkGroups.Add(g);
} }
//SYMMETRIC SYNC //DSG SYNC
//Send out DelinkObject message to other actors to sychronize their object list //Send out DelinkObject message to other actors to sychronize their object list
if (m_parentScene.RegionSyncModule != null) if (m_parentScene.RegionSyncModule != null)
{ {
m_parentScene.RegionSyncModule.SendDeLinkObject(prims, beforeDelinkGroups, afterDelinkGroups); m_parentScene.RegionSyncModule.SyncDeLinkObject(prims, beforeDelinkGroups, afterDelinkGroups);
} }
//Schedule updates as in legacy OpenSim code, to send updates to viewers connected to this actor (at least needed for client managers). //Schedule updates as in legacy OpenSim code, to send updates
//But timestamp won't be changed, so that when other actors get the update, they's simple ignore the updates since they already get them //to viewers connected to this actor (at least needed for client managers).
foreach (SceneObjectGroup sog in afterDelinkGroups) foreach (SceneObjectGroup sog in afterDelinkGroups)
{ {
sog.ScheduleGroupForFullUpdate_SyncInfoUnchanged(); sog.ScheduleGroupForFullUpdate(null);
} }
//end of SYMMETRIC SYNC //end of DSG SYNC
} }
finally finally
{ {
@ -2174,7 +2174,7 @@ namespace OpenSim.Region.Framework.Scenes
//NewObject is sent via a specific sync message, not through updates; //NewObject is sent via a specific sync message, not through updates;
//hence not passing any property list here in calling //hence not passing any property list here in calling
//ScheduleGroupForFullUpdate(). //ScheduleGroupForFullUpdate().
sceneObject.ScheduleGroupForFullUpdate_SyncInfoUnchanged(); sceneObject.ScheduleGroupForFullUpdate(null);
//end of DSG SYNC, //end of DSG SYNC,
Entities.Add(sceneObject); Entities.Add(sceneObject);
@ -2283,7 +2283,7 @@ namespace OpenSim.Region.Framework.Scenes
parentGroup.TriggerScriptChangedEvent(Changed.LINK); parentGroup.TriggerScriptChangedEvent(Changed.LINK);
parentGroup.HasGroupChanged = true; parentGroup.HasGroupChanged = true;
//Do not change the timestamp and actorID values //Do not change the timestamp and actorID values
parentGroup.ScheduleGroupForFullUpdate_SyncInfoUnchanged(); parentGroup.ScheduleGroupForFullUpdate(null);
} }
finally finally
@ -2302,6 +2302,7 @@ namespace OpenSim.Region.Framework.Scenes
public void DelinkObjectsBySync(List<UUID> delinkPrimIDs, List<UUID> beforeDelinkGroupIDs, List<SceneObjectGroup> incomingAfterDelinkGroups) public void DelinkObjectsBySync(List<UUID> delinkPrimIDs, List<UUID> beforeDelinkGroupIDs, List<SceneObjectGroup> incomingAfterDelinkGroups)
{ {
Dictionary<UUID, SceneObjectGroup> localBeforeDelinkGroups = new Dictionary<UUID, SceneObjectGroup>(); Dictionary<UUID, SceneObjectGroup> localBeforeDelinkGroups = new Dictionary<UUID, SceneObjectGroup>();
List<SceneObjectGroup> localAfterDelinkGroups = new List<SceneObjectGroup>();
Dictionary<UUID, SceneObjectPart> delinkPrims = new Dictionary<UUID, SceneObjectPart>(); Dictionary<UUID, SceneObjectPart> delinkPrims = new Dictionary<UUID, SceneObjectPart>();
bool beforeStateConsistent = true; bool beforeStateConsistent = true;
bool afterStateConsistent = true; bool afterStateConsistent = true;
@ -2383,8 +2384,7 @@ namespace OpenSim.Region.Framework.Scenes
m_log.Warn("DelinkObjectsBySync: before-delink state not consistent in local copy and the incoming copy. Return without further operations."); m_log.Warn("DelinkObjectsBySync: before-delink state not consistent in local copy and the incoming copy. Return without further operations.");
}else{ }else{
//Next, apply the delink operation locally. //Next, apply the delink operation locally.
List<SceneObjectGroup> localAfterDelinkGroups = DelinkObjectsBySync(new List<SceneObjectPart>(delinkPrims.Values)); localAfterDelinkGroups = DelinkObjectsBySync(new List<SceneObjectPart>(delinkPrims.Values));
//Check if local after-state agrees with that in the remote copy, and update the groups' properties //Check if local after-state agrees with that in the remote copy, and update the groups' properties
if (localAfterDelinkGroups.Count != incomingAfterDelinkGroups.Count) if (localAfterDelinkGroups.Count != incomingAfterDelinkGroups.Count)
@ -2407,11 +2407,16 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
localAfterGroup.UpdateObjectGroupBySync(incomingAfterDelinkGroupsDictionary[localAfterGroup.UUID]); //localAfterGroup.UpdateObjectGroupBySync(incomingAfterDelinkGroupsDictionary[localAfterGroup.UUID]);
} }
} }
} }
} }
foreach (SceneObjectGroup sog in localAfterDelinkGroups)
{
sog.ScheduleGroupForFullUpdate(null);
}
} }
finally finally
{ {
@ -2423,7 +2428,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
//Similar to DelinkObjects(), w/o triggering any ScheduleFullUpdate(), //Similar to DelinkObjects(), but calling DelinkFromGroupBySync instead
private List<SceneObjectGroup> DelinkObjectsBySync(List<SceneObjectPart> prims) private List<SceneObjectGroup> DelinkObjectsBySync(List<SceneObjectPart> prims)
{ {
//!!!Caller of this function should already lock on m_updateLock, so no locking here !!! //!!!Caller of this function should already lock on m_updateLock, so no locking here !!!