From c1e19ead74197a980d5d71f0158cf5d11ad01c8e Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Wed, 12 Jan 2011 17:20:17 -0800 Subject: [PATCH 1/4] Added ScheduleFullUpdate() in SceneObjectPart.AddInventoryItem(), to enable synchronization across actors. --- .../Framework/Scenes/Scene.Inventory.cs | 21 +++++++++++++++++++ .../Scenes/SceneObjectPartInventory.cs | 3 +++ 2 files changed, 24 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 900b19ce2f..2c6ab2ee6b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -376,6 +376,17 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = GetSceneObjectPart(primID); SceneObjectGroup group = part.ParentGroup; + + if (null == group) + { + m_log.ErrorFormat( + "[PRIM INVENTORY]: " + + "Prim inventory update requested for item ID {0} in prim ID {1} but this prim does not exist", + itemID, primID); + + return new ArrayList(); + } + if (isScriptRunning) { m_log.Debug("To RemoveScriptInstance"); @@ -385,6 +396,16 @@ namespace OpenSim.Region.Framework.Scenes // Retrieve item TaskInventoryItem item = group.GetInventoryItem(part.LocalId, itemID); + if (null == item) + { + m_log.ErrorFormat( + "[PRIM INVENTORY]: Tried to retrieve item ID {0} from prim {1}, {2} for caps script update " + + " but the item does not exist in this inventory", + itemID, part.Name, part.UUID); + + return new ArrayList(); + } + // Update item with new asset item.AssetID = newAssetID; group.UpdateInventoryItem(item); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 7a0cc5a8fe..d3d2d73979 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -539,6 +539,9 @@ namespace OpenSim.Region.Framework.Scenes //m_inventorySerial += 2; HasInventoryChanged = true; m_part.ParentGroup.HasGroupChanged = true; + + //SYMMETRIC SYNC: add ScheduleFullUpdate to enable synchronization across actors + m_part.ScheduleFullUpdate(); } /// From 0be2fe7f1341ad744378005c8c2f32ef4345cc3a Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Thu, 13 Jan 2011 15:36:44 -0800 Subject: [PATCH 2/4] Changed the way RemoveObject is handled: now Scene.DeleteSceneObject() calls RegionSyncModule to send RemovedObject message to other actors for synchronization. --- .../SymmetricSync/RegionSyncModule.cs | 5 +++-- .../Framework/Interfaces/IRegionSyncModule.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 16 +++++++++++++--- .../Region/Framework/Scenes/SceneObjectGroup.cs | 3 ++- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 52212d87d5..860b80b708 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -89,7 +89,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Register for local Scene events m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation; - m_scene.EventManager.OnObjectBeingRemovedFromScene += new EventManager.ObjectBeingRemovedFromScene(RegionSyncModule_OnObjectBeingRemovedFromScene); + //m_scene.EventManager.OnObjectBeingRemovedFromScene += new EventManager.ObjectBeingRemovedFromScene(RegionSyncModule_OnObjectBeingRemovedFromScene); } @@ -1273,7 +1273,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule /// only be triggered by an object removal that is initiated locally. /// /// - private void RegionSyncModule_OnObjectBeingRemovedFromScene(SceneObjectGroup sog) + //private void RegionSyncModule_OnObjectBeingRemovedFromScene(SceneObjectGroup sog) + public void SendDeleteObject(SceneObjectGroup sog) { //m_log.DebugFormat("RegionSyncModule_OnObjectBeingRemovedFromScene called at time {0}:{1}:{2}", DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond); diff --git a/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs index 8733f8ec6d..8709d4cd46 100755 --- a/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs @@ -63,7 +63,7 @@ namespace OpenSim.Region.Framework.Interfaces //void SendUpdatesToSynchronizeState(List sog); void SendSceneUpdates(); void SendTerrainUpdates(string lastUpdateActorID); - //void SendDeleteObject(SceneObjectGroup sog); + void SendDeleteObject(SceneObjectGroup sog); //For propogating scene events to other actors void PublishSceneEvent(EventManager.EventNames ev, Object[] evArgs); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 07c5d70d6c..721feda63d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -662,8 +662,7 @@ namespace OpenSim.Region.Framework.Scenes if (UnlinkSceneObject(group, false)) { - //For object removals caused by remote events (by other actors), do not trigger local event ObjectBeingRemovedFromScene - //EventManager.TriggerObjectBeingRemovedFromScene(group); + EventManager.TriggerObjectBeingRemovedFromScene(group); EventManager.TriggerParcelPrimCountTainted(); } @@ -2430,8 +2429,16 @@ namespace OpenSim.Region.Framework.Scenes { part.SyncInfoUpdate(); } - //end of SYMMETRIC SYNC + * * */ + + //Propagate the RemovedObject message + if (RegionSyncModule != null) + { + RegionSyncModule.SendDeleteObject(group); + } + //end of SYMMETRIC SYNC + } /// @@ -3592,9 +3599,12 @@ namespace OpenSim.Region.Framework.Scenes ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); + //SYMMETRIC SYNC: object remove should be handled through RegionSyncModule // REGION SYNC + /* if( IsSyncedServer() ) RegionSyncServerModule.DeleteObject(m_regionHandle, localID, part); + * */ } #endregion diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 2a8f2990b6..1b0c0fcd7b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1163,7 +1163,8 @@ namespace OpenSim.Region.Framework.Scenes Scene.RegionSyncServerModule.DeleteObject(part.RegionHandle, part.LocalId, part); //return; } - * */ + * */ + //end of SYMMETRIC SYNC Scene.ForEachScenePresence(delegate(ScenePresence avatar) { From 719f59db3f1ec12198e6f8dece524f4599f05987 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 14 Jan 2011 16:58:06 -0800 Subject: [PATCH 3/4] Added code to propagate OnNewScript event, when client sends in RezScript request (e.g. add new script to a prim). --- .../SymmetricSync/RegionSyncModule.cs | 87 ++++++++++++++++++- .../SymmetricSync/ScriptEngineSyncModule.cs | 10 +++ .../SymmetricSync/SymmetricSyncMessage.cs | 1 + .../Region/Framework/Scenes/EventManager.cs | 55 +++++++++++- .../Framework/Scenes/Scene.Inventory.cs | 55 +++++++++++- .../Framework/Scenes/Scene.PacketHandlers.cs | 2 - 6 files changed, 199 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 860b80b708..33f9c76776 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -91,6 +91,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation; //m_scene.EventManager.OnObjectBeingRemovedFromScene += new EventManager.ObjectBeingRemovedFromScene(RegionSyncModule_OnObjectBeingRemovedFromScene); + LogHeader += "-" + scene.RegionInfo.RegionName; } //Called after AddRegion() has been called for all region modules of the scene @@ -882,6 +883,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule return; } //EVENTS PROCESSING + case SymmetricSyncMessage.MsgType.NewScript: case SymmetricSyncMessage.MsgType.UpdateScript: case SymmetricSyncMessage.MsgType.ScriptReset: case SymmetricSyncMessage.MsgType.ChatFromClient: @@ -1040,6 +1042,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule switch (msg.Type) { + case SymmetricSyncMessage.MsgType.NewScript: + HandleRemoteEvent_OnNewScript(init_actorID, evSeqNum, data); + break; case SymmetricSyncMessage.MsgType.UpdateScript: HandleRemoteEvent_OnUpdateScript(init_actorID, evSeqNum, data); break; @@ -1070,9 +1075,54 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } } + /// + /// + /// + /// the ID of the actor that initiates the event + /// sequence num of the event from the actor + /// OSDMap data of event args + private void HandleRemoteEvent_OnNewScript(string actorID, ulong evSeqNum, OSDMap data) + { + m_log.Debug(LogHeader + ", " + m_actorID + ": received NewScript"); + + UUID agentID = data["agentID"].AsUUID(); + UUID primID = data["primID"].AsUUID(); + UUID itemID = data["itemID"].AsUUID(); + + string sogXml = data["sog"].AsString(); + SceneObjectGroup sog = SceneObjectSerializer.FromXml2Format(sogXml); + SceneObjectPart part = null; + + foreach (SceneObjectPart prim in sog.Parts) + { + if(prim.UUID.Equals(primID)){ + part = prim; + break; + } + } + if(part == null) + { + m_log.Warn(LogHeader+": part "+primID+" not exist in the serialized object, do nothing"); + return; + } + //Update the object first + Scene.ObjectUpdateResult updateResult = m_scene.AddOrUpdateObjectBySynchronization(sog); + + if (updateResult == Scene.ObjectUpdateResult.Updated || updateResult == Scene.ObjectUpdateResult.New) + { + m_log.Debug(LogHeader + ": TriggerNewScriptLocally"); + //Next, trigger creating the new script + SceneObjectPart localPart = m_scene.GetSceneObjectPart(primID); + m_scene.EventManager.TriggerNewScriptLocally(agentID, localPart, itemID); + } + } + + /// /// Special actions for remote event UpdateScript /// + /// the ID of the actor that initiates the event + /// sequence num of the event from the actor /// OSDMap data of event args private void HandleRemoteEvent_OnUpdateScript(string actorID, ulong evSeqNum, OSDMap data) { @@ -1089,7 +1139,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } /// - /// Special actions for remote event UpdateScript + /// Special actions for remote event ScriptReset /// /// OSDMap data of event args private void HandleRemoteEvent_OnScriptReset(string actorID, ulong evSeqNum, OSDMap data) @@ -1296,13 +1346,20 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { switch (ev) { + case EventManager.EventNames.NewScript: + if (evArgs.Length < 3) + { + m_log.Error(LogHeader + " not enough event args for NewScript"); + return; + } + OnLocalNewScript((UUID)evArgs[0], (SceneObjectPart)evArgs[1], (UUID)evArgs[2]); + return; case EventManager.EventNames.UpdateScript: if (evArgs.Length < 5) { m_log.Error(LogHeader + " not enough event args for UpdateScript"); return; } - m_log.Debug(LogHeader + " PublishSceneEvent UpdateScript"); OnLocalUpdateScript((UUID)evArgs[0], (UUID)evArgs[1], (UUID)evArgs[2], (bool)evArgs[3], (UUID)evArgs[4]); return; case EventManager.EventNames.ScriptReset: @@ -1343,6 +1400,32 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } } + /// + /// The handler for (locally initiated) event OnNewScript: triggered by client's RezSript packet, publish it to other actors. + /// + /// ID of the client who creates the new script + /// the prim that contains the new script + private void OnLocalNewScript(UUID clientID, SceneObjectPart part, UUID itemID) + { + m_log.Debug(LogHeader + " RegionSyncModule_OnLocalNewScript"); + + SceneObjectGroup sog = part.ParentGroup; + if(sog==null){ + m_log.Warn(LogHeader + ": part " + part.UUID + " not in an SceneObjectGroup yet. Will not propagating new script event"); + //sog = new SceneObjectGroup(part); + return; + } + //For simplicity, we just leverage a SOP's serialization method to transmit the information of new inventory item for the script). + //This can certainly be optimized later (e.g. only sending serialization of the inventory item) + OSDMap data = new OSDMap(); + data["agentID"] = OSD.FromUUID(clientID); + data["primID"] = OSD.FromUUID(part.UUID); + data["itemID"] = OSD.FromUUID(itemID); //id of the new inventory item of the part + data["sog"] = OSD.FromString(SceneObjectSerializer.ToXml2Format(sog)); + + SendSceneEvent(SymmetricSyncMessage.MsgType.NewScript, data); + } + /// /// The handler for (locally initiated) event OnUpdateScript: publish it to other actors. /// diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs index cc9213b722..ee6ab985bc 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs @@ -89,8 +89,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //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. + m_scene.EventManager.OnNewScript += ScriptEngine_OnNewScript; m_scene.EventManager.OnUpdateScript += ScriptEngine_OnUpdateScript; //m_scene.EventManager.OnUpdateScriptBySync += ScriptEngine_OnUpdateScript; + + LogHeader += "-" + m_actorID + "-" + m_scene.RegionInfo.RegionName; } //Called after AddRegion() has been called for all region modules of the scene. @@ -182,6 +185,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_scene.DeleteAllSceneObjects(); } + public void ScriptEngine_OnNewScript(UUID agentID, SceneObjectPart part, UUID itemID) + { + m_log.Debug(LogHeader + " ScriptEngine_OnUpdateScript"); + + m_scene.SymSync_OnNewScript(agentID, itemID, part); + } + //Assumption, when this function is triggered, the new script asset has already been saved. public void ScriptEngine_OnUpdateScript(UUID agentID, UUID itemID, UUID primID, bool isScriptRunning, UUID newAssetID) { diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs index b093a16702..8e5f09bb8f 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs @@ -34,6 +34,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //RegionStatus, ActorID, //events + NewScript, UpdateScript, ScriptReset, ChatFromClient, diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index f3b5e17677..0d5d3a749e 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -50,6 +50,7 @@ namespace OpenSim.Region.Framework.Scenes //the events that we'll handle specially in sym-sync public enum EventNames { + NewScript, UpdateScript, ScriptReset, ChatFromClient, //chats from avatars @@ -65,6 +66,30 @@ namespace OpenSim.Region.Framework.Scenes m_scene = scene; } + #region UpdateScript + //triggered by client.OnRezScript + public override void TriggerNewScript(UUID clientID, SceneObjectPart part, UUID itemID) + { + //publish the event to other actors who are intersted in it + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[3]; + eventArgs[0] = (Object)clientID; + eventArgs[1] = (Object)part; + eventArgs[2] = (Object)itemID; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.NewScript, eventArgs); + } + + //trigger event locally, + TriggerNewScriptLocally(clientID, part, itemID); + } + //public void TriggerNewScriptLocally(UUID clientID, UUID itemId, UUID primId, UUID newAssetID) + public void TriggerNewScriptLocally(UUID clientID, SceneObjectPart part, UUID itemID) + { + base.TriggerNewScript(clientID, part, itemID); + } + #endregion //UpdateScript + #region UpdateScript public override void TriggerUpdateScript(UUID clientId, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID) { @@ -80,7 +105,7 @@ namespace OpenSim.Region.Framework.Scenes m_scene.RegionSyncModule.PublishSceneEvent(EventNames.UpdateScript, eventArgs); } - //trigger event locally, as the legacy code does + //trigger event locally, TriggerUpdateScriptLocally(clientId, itemId, primId, isScriptRunning, newAssetID); } public void TriggerUpdateScriptLocally(UUID clientId, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID) @@ -2378,8 +2403,32 @@ namespace OpenSim.Region.Framework.Scenes } } } - - //OnUpdateTaskInventoryScriptAsset: triggered after Scene receives client's upload of updated script and stores it as asset + + public delegate void NewScript(UUID clientID, SceneObjectPart part, UUID itemID); + public event NewScript OnNewScript; + public virtual void TriggerNewScript(UUID clientID, SceneObjectPart part, UUID itemID) + { + NewScript handlerNewScript = OnNewScript; + if (handlerNewScript != null) + { + foreach (NewScript d in handlerNewScript.GetInvocationList()) + { + try + { + d(clientID, part, itemID); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerNewScript failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } + + + //TriggerUpdateScript: triggered after Scene receives client's upload of updated script and stores it as asset public delegate void UpdateScript(UUID clientID, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID); public event UpdateScript OnUpdateScript; public virtual void TriggerUpdateScript(UUID clientId, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 2c6ab2ee6b..9f1a31e7d8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -310,7 +310,7 @@ namespace OpenSim.Region.Framework.Scenes * */ //SYMMETRIC SYNC: Distributed Scene Graph implementation - m_log.Debug("Scene.Inventory: to call EventManager.TriggerUpdateTaskInventoryScriptAsset, agentID: " + remoteClient.AgentId); + m_log.Debug("Scene.Inventory: to call EventManager.TriggerUpdateScript, agentID: " + remoteClient.AgentId); //Trigger OnUpdateScript event. EventManager.TriggerUpdateScript(remoteClient.AgentId, itemId, primId, isScriptRunning, item.AssetID); @@ -369,6 +369,14 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region SYMMETRIC SYNC + public void SymSync_OnNewScript(UUID avatarID, UUID itemID, SceneObjectPart part) + { + TaskInventoryItem item = part.Inventory.GetInventoryItem(itemID); + + part.Inventory.CreateScriptInstance(item, 0, false, DefaultScriptEngine, 0); + part.ParentGroup.ResumeScripts(); + } + //only a script engine actor is supposed to call this function public ArrayList SymSync_OnUpdateScript(UUID avatarID, UUID itemID, UUID primID, bool isScriptRunning, UUID newAssetID) { @@ -1663,6 +1671,10 @@ namespace OpenSim.Region.Framework.Scenes return; part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); + part.GetProperties(remoteClient); + + //SYMMETRIC SYNC + /* Original OpenSim code, commented out // TODO: switch to posting on_rez here when scripts // have state in inventory part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); @@ -1670,8 +1682,26 @@ namespace OpenSim.Region.Framework.Scenes // m_log.InfoFormat("[PRIMINVENTORY]: " + // "Rezzed script {0} into prim local ID {1} for user {2}", // item.inventoryName, localID, remoteClient.Name); - part.GetProperties(remoteClient); + //part.GetProperties(remoteClient); part.ParentGroup.ResumeScripts(); + * */ + if (RegionSyncModule != null) + { + part.SyncInfoUpdate(); + EventManager.TriggerNewScript(remoteClient.AgentId, part, copyID); + } + else + { + part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); + + // m_log.InfoFormat("[PRIMINVENTORY]: " + + // "Rezzed script {0} into prim local ID {1} for user {2}", + // item.inventoryName, localID, remoteClient.Name); + //part.GetProperties(remoteClient); + part.ParentGroup.ResumeScripts(); + } + //end of SYMMETRIC SYNC + } else { @@ -1730,8 +1760,25 @@ namespace OpenSim.Region.Framework.Scenes part.Inventory.AddInventoryItem(taskItem, false); part.GetProperties(remoteClient); - part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); - part.ParentGroup.ResumeScripts(); + //SYMMETRIC SYNC + //part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); + //part.ParentGroup.ResumeScripts(); + if (RegionSyncModule != null) + { + part.SyncInfoUpdate(); + EventManager.TriggerNewScript(remoteClient.AgentId, part, taskItem.ItemID); + } + else + { + part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); + + // m_log.InfoFormat("[PRIMINVENTORY]: " + + // "Rezzed script {0} into prim local ID {1} for user {2}", + // item.inventoryName, localID, remoteClient.Name); + //part.GetProperties(remoteClient); + part.ParentGroup.ResumeScripts(); + } + //end of SYMMETRIC SYNC } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 52611df715..ab567fbcb0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -69,8 +69,6 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnChatBroadcast(this, args); else EventManager.TriggerOnChatFromWorld(this, args); - - m_log.Debug("end of SimChat"); } /// From c8dc14fb01d4d87b6ef72f12a604b38a467b1f7d Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Mon, 17 Jan 2011 17:13:15 -0800 Subject: [PATCH 4/4] Configuration of SyncListenerIPAddress, SyncListenerPort, ServerIPAddress, and ServerPort is moved to Regions.ini. --- OpenSim/Framework/RegionInfo.cs | 42 +++++++++++++++++++ .../RegionSyncClientModule.cs | 21 +++++++--- .../RegionSyncServerModule.cs | 14 +++++-- .../SymmetricSync/RegionSyncModule.cs | 17 +++++--- 4 files changed, 80 insertions(+), 14 deletions(-) diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 680e702a11..857d811d23 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -386,6 +386,14 @@ namespace OpenSim.Framework public string RemotingAddress; public UUID ScopeID = UUID.Zero; + //SYMMETRIC SYNC + //IP:port for the symmetric sync listener this actor is configured to connect to + private string m_syncListenerAddr = String.Empty; + private int m_syncListenerPort; + //IP:port for the avatar sync server this actor is configured to connect to + private string m_serverAddr = String.Empty; + private int m_serverPort; + //end of SYMMETRIC SYNC // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. @@ -676,6 +684,25 @@ namespace OpenSim.Framework get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); } } + //SYMMETRIC SYNC + public string SyncListenerAddress + { + get { return m_syncListenerAddr; } + } + public int SyncListenerPort + { + get { return m_syncListenerPort; } + } + public string ServerIPAddress + { + get { return m_serverAddr; } + } + public int ServerPort + { + get { return m_serverPort; } + } + //end of SYMMETRIC SYNC + public void SetEndPoint(string ipaddr, int port) { IPAddress tmpIP = IPAddress.Parse(ipaddr); @@ -830,6 +857,21 @@ namespace OpenSim.Framework // Multi-tenancy // ScopeID = new UUID(config.GetString("ScopeID", UUID.Zero.ToString())); + + // SYMMETRIC SYNC + m_syncListenerAddr = config.GetString("SyncListenerIPAddress", String.Empty); + m_syncListenerPort = config.GetInt("SyncListenerPort", -1); + //if either IP or port is not configured, we set IP to empty to raise warning later + if (m_syncListenerPort == -1) + m_syncListenerAddr = String.Empty; + + m_serverAddr = config.GetString("ServerIPAddress", String.Empty); + m_serverPort = config.GetInt("ServerPort", -1); + if (m_serverPort == -1) + m_serverAddr = String.Empty; + + // end of SYMMETRIC SYNC + } private void WriteNiniConfig(IConfigSource source) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs index a065be3002..c0bd54ca56 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs @@ -69,10 +69,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_active = true; m_scene.RegionSyncEnabled = true; m_scene.RegionSyncMode = "client"; - string serverAddrDefault = syncConfig.GetString("ServerIPAddress", "127.0.0.1"); - m_serveraddr = syncConfig.GetString(scene.RegionInfo.RegionName+"_ServerIPAddress", serverAddrDefault); - int serverPortDefault = syncConfig.GetInt("ServerPort", 13000); - m_serverport = syncConfig.GetInt(scene.RegionInfo.RegionName+"_ServerPort", serverPortDefault); + + //string serverAddrDefault = syncConfig.GetString("ServerIPAddress", "127.0.0.1"); + //m_serveraddr = syncConfig.GetString(scene.RegionInfo.RegionName+"_ServerIPAddress", serverAddrDefault); + //int serverPortDefault = syncConfig.GetInt("ServerPort", 13000); + //m_serverport = syncConfig.GetInt(scene.RegionInfo.RegionName+"_ServerPort", serverPortDefault); + m_scene.RegisterModuleInterface(this); m_symsync = syncConfig.GetBoolean("SymSync", false); @@ -230,7 +232,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private void Start() { - + m_serveraddr = m_scene.RegionInfo.ServerIPAddress; + m_serverport = m_scene.RegionInfo.ServerPort; + + if (m_serveraddr.Equals(String.Empty) || m_serverport == -1) + { + m_log.Warn("[REGION SYNC CLIENT MODULE] No IP or port of RegionSyncServer has been configured. Shut down."); + m_active = false; + return; + } + lock (m_client_lock) { if (m_client != null) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs index d408e87202..49753fe399 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs @@ -97,10 +97,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_statsWriter = File.AppendText(syncstats); //Get sync server info for Client Manager actors - string serverAddr = scene.RegionInfo.RegionName + "_ServerIPAddress"; - m_serveraddr = syncConfig.GetString(serverAddr, IPAddrUnknown); - string serverPort = scene.RegionInfo.RegionName + "_ServerPort"; - m_serverport = syncConfig.GetInt(serverPort, PortUnknown); + //string serverAddr = scene.RegionInfo.RegionName + "_ServerIPAddress"; + //m_serveraddr = syncConfig.GetString(serverAddr, IPAddrUnknown); + //string serverPort = scene.RegionInfo.RegionName + "_ServerPort"; + //m_serverport = syncConfig.GetInt(serverPort, PortUnknown); + // Client manager load balancing m_maxClientsPerManager = syncConfig.GetInt("MaxClientsPerManager", 100); DefaultPort++; @@ -154,6 +155,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } //end of SYMMETRIC SYNC // Start the server and listen for RegionSyncClients + m_serveraddr = m_scene.RegionInfo.ServerIPAddress; + m_serverport = m_scene.RegionInfo.ServerPort; + + m_log.Debug("[REGION SYNC SERVER MODULE] to start server on " + m_serveraddr + ":" + m_serverport); + if (!m_serveraddr.Equals(IPAddrUnknown) && m_serverport != PortUnknown) { m_log.Warn("[REGION SYNC SERVER MODULE] Starting RegionSyncServer"); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 33f9c76776..a4972d05d6 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -377,7 +377,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule ///////////////////////////////////////////////////////////////////////////////////////// private static int PortUnknown = -1; - private static string IPAddrUnknown = ""; + private static string IPAddrUnknown = String.Empty; private ILog m_log; //private bool m_active = true; @@ -563,8 +563,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { m_log.Debug("reading in " + m_scene.RegionInfo.RegionName + "_SyncListenerIPAddress" + " and " + m_scene.RegionInfo.RegionName + "_SyncListenerPort"); - string addr = m_sysConfig.GetString(m_scene.RegionInfo.RegionName+"_SyncListenerIPAddress", IPAddrUnknown); - int port = m_sysConfig.GetInt(m_scene.RegionInfo.RegionName+"_SyncListenerPort", PortUnknown); + //string addr = m_sysConfig.GetString(m_scene.RegionInfo.RegionName+"_SyncListenerIPAddress", IPAddrUnknown); + //int port = m_sysConfig.GetInt(m_scene.RegionInfo.RegionName+"_SyncListenerPort", PortUnknown); + + string addr = m_scene.RegionInfo.SyncListenerAddress; + int port = m_scene.RegionInfo.SyncListenerPort; m_log.Warn(LogHeader + ", listener addr: " + addr + ", port: " + port); @@ -586,8 +589,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { //For now, we assume there is only one remote listener to connect to. Later on, //we may need to modify the code to read in multiple listeners. - string addr = m_sysConfig.GetString(m_scene.RegionInfo.RegionName + "_SyncListenerIPAddress", IPAddrUnknown); - int port = m_sysConfig.GetInt(m_scene.RegionInfo.RegionName + "_SyncListenerPort", PortUnknown); + //string addr = m_sysConfig.GetString(m_scene.RegionInfo.RegionName + "_SyncListenerIPAddress", IPAddrUnknown); + //int port = m_sysConfig.GetInt(m_scene.RegionInfo.RegionName + "_SyncListenerPort", PortUnknown); + + string addr = m_scene.RegionInfo.SyncListenerAddress; + int port = m_scene.RegionInfo.SyncListenerPort; + if (!addr.Equals(IPAddrUnknown) && port != PortUnknown) { RegionSyncListenerInfo info = new RegionSyncListenerInfo(addr, port);