From 052af34a5205f9bf62424e7df600edea2f74ab36 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Mon, 7 Mar 2011 16:24:48 -0800 Subject: [PATCH 01/14] Added Shape as one of the properties just updated in MoapModule.SetMediaEntry. --- OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index fc493211ea..5eda422b16 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -252,7 +252,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap SetPartMediaFlags(part, face, me != null); //part.ScheduleFullUpdate(); - part.ScheduleFullUpdate(new List(){SceneObjectPartProperties.MediaUrl}); + part.ScheduleFullUpdate(new List() { SceneObjectPartProperties.MediaUrl, SceneObjectPartProperties.Shape}); part.TriggerScriptChangedEvent(Changed.MEDIA); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index d8461d4052..4bcef483d2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -5513,7 +5513,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart localPart = this; PhysicsActor pa = localPart.PhysActor; - m_log.DebugFormat("{0}: PhysicsBucketUpdateProcessor. pos={1}", "[SCENE OBJECT PART]", data["Position"].AsVector3().ToString()); + //m_log.DebugFormat("{0}: PhysicsBucketUpdateProcessor. pos={1}", "[SCENE OBJECT PART]", data["Position"].AsVector3().ToString()); lock (m_bucketUpdateLocks[bucketName]) { From ae258a21e4546a28b788d994d8d79c90df5a4c73 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Tue, 8 Mar 2011 11:00:52 -0800 Subject: [PATCH 02/14] Added code to propogate event OnChatBroadcast (llOwnerSay is handled by this), and consolidate code with events OnChatFromClient and OnChatFromWorld. --- .../SymmetricSync/RegionSyncModule.cs | 103 ++++++++++++++++-- .../SymmetricSync/SymmetricSyncMessage.cs | 1 + .../Region/Framework/Scenes/EventManager.cs | 20 +++- 3 files changed, 116 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 2a2698bc49..56b0fef8c8 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -522,20 +522,29 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule OnLocalScriptReset((uint)evArgs[0], (UUID)evArgs[1]); return; case EventManager.EventNames.ChatFromClient: - if (evArgs.Length < 2) + /*if (evArgs.Length < 2) { m_log.Error(LogHeader + " not enough event args for ChatFromClient"); return; } OnLocalChatFromClient(evArgs[0], (OSChatMessage)evArgs[1]); - return; + return;*/ case EventManager.EventNames.ChatFromWorld: - if (evArgs.Length < 2) + /*if (evArgs.Length < 2) { m_log.Error(LogHeader + " not enough event args for ChatFromWorld"); return; } OnLocalChatFromWorld(evArgs[0], (OSChatMessage)evArgs[1]); + return;*/ + case EventManager.EventNames.ChatBroadcast: + if (evArgs.Length < 2) + { + m_log.Error(LogHeader + " not enough event args for ChatFromWorld"); + return; + } + //OnLocalChatBroadcast(evArgs[0], (OSChatMessage)evArgs[1]); + OnLocalChatEvents(ev, evArgs[0], (OSChatMessage)evArgs[1]); return; case EventManager.EventNames.ObjectGrab: OnLocalGrabObject((uint)evArgs[0], (uint)evArgs[1], (Vector3)evArgs[2], (IClientAPI)evArgs[3], (SurfaceTouchEventArgs)evArgs[4]); @@ -1442,6 +1451,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule case SymmetricSyncMessage.MsgType.ScriptReset: case SymmetricSyncMessage.MsgType.ChatFromClient: case SymmetricSyncMessage.MsgType.ChatFromWorld: + case SymmetricSyncMessage.MsgType.ChatBroadcast: case SymmetricSyncMessage.MsgType.ObjectGrab: case SymmetricSyncMessage.MsgType.ObjectGrabbing: case SymmetricSyncMessage.MsgType.ObjectDeGrab: @@ -1767,10 +1777,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule HandleRemoteEvent_OnScriptReset(init_actorID, evSeqNum, data); break; case SymmetricSyncMessage.MsgType.ChatFromClient: - HandleRemoteEvent_OnChatFromClient(init_actorID, evSeqNum, data); - break; + //HandleRemoteEvent_OnChatFromClient(init_actorID, evSeqNum, data); + //break; case SymmetricSyncMessage.MsgType.ChatFromWorld: - HandleRemoteEvent_OnChatFromWorld(init_actorID, evSeqNum, data); + //HandleRemoteEvent_OnChatFromWorld(init_actorID, evSeqNum, data); + //break; + case SymmetricSyncMessage.MsgType.ChatBroadcast: + //HandleRemoteEvent_OnChatBroadcast(init_actorID, evSeqNum, data); + HandleRemoveEvent_OnChatEvents(msg.Type, init_actorID, evSeqNum, data); break; case SymmetricSyncMessage.MsgType.ObjectGrab: HandleRemoteEvent_OnObjectGrab(init_actorID, evSeqNum, data); @@ -1878,6 +1892,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_scene.EventManager.TriggerScriptResetLocally(part.LocalId, itemID); } + /* /// /// Special actions for remote event ChatFromClient /// @@ -1918,9 +1933,52 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //ScenePresence sp; //m_scene.TryGetScenePresence(id, out sp); + m_log.Debug(LogHeader + " TriggerOnChatFromWorldLocally "); + m_scene.EventManager.TriggerOnChatFromWorldLocally(m_scene, args); } + private void HandleRemoteEvent_OnChatBroadcast(string actorID, ulong evSeqNum, OSDMap data) + { + + } + * */ + + /// + /// Handlers for remote chat events: ChatFromClient, ChatFromWorld, ChatBroadcast + /// + /// + /// + /// + /// The args of the event + private void HandleRemoveEvent_OnChatEvents(SymmetricSyncMessage.MsgType msgType, string actorID, ulong evSeqNum, OSDMap data) + { + OSChatMessage args = new OSChatMessage(); + args.Channel = data["channel"].AsInteger(); + args.Message = data["msg"].AsString(); + args.Position = data["pos"].AsVector3(); + args.From = data["name"].AsString(); + UUID id = data["id"].AsUUID(); + args.Scene = m_scene; + args.Type = (ChatTypeEnum)data["type"].AsInteger(); + + switch (msgType) + { + case SymmetricSyncMessage.MsgType.ChatFromClient: + ScenePresence sp; + m_scene.TryGetScenePresence(id, out sp); + m_scene.EventManager.TriggerOnChatFromClientLocally(sp, args); //Let WorldCommModule and other modules to catch the event + m_scene.EventManager.TriggerOnChatFromWorldLocally(sp, args); //This is to let ChatModule to get the event and deliver it to avatars + break; + case SymmetricSyncMessage.MsgType.ChatFromWorld: + m_scene.EventManager.TriggerOnChatFromWorldLocally(m_scene, args); + break; + case SymmetricSyncMessage.MsgType.ChatBroadcast: + m_scene.EventManager.TriggerOnChatBroadcastLocally(m_scene, args); + break; + } + } + /// /// Special actions for remote event ChatFromClient /// @@ -2129,7 +2187,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptReset, data); } - + /* private void OnLocalChatFromClient(Object sender, OSChatMessage chat) { ScenePresence avatar = m_scene.GetScenePresence(chat.SenderUUID); @@ -2162,6 +2220,37 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule data["id"] = OSD.FromUUID(chat.SenderUUID); data["type"] = OSD.FromInteger((int)chat.Type); SendSceneEvent(SymmetricSyncMessage.MsgType.ChatFromWorld, data); + } + * */ + + private void OnLocalChatBroadcast(Object sender, OSChatMessage chat) + { + + } + + private void OnLocalChatEvents(EventManager.EventNames evType, Object sender, OSChatMessage chat) + { + OSDMap data = new OSDMap(); + data["channel"] = OSD.FromInteger(chat.Channel); + data["msg"] = OSD.FromString(chat.Message); + data["pos"] = OSD.FromVector3(chat.Position); + data["name"] = OSD.FromString(chat.From); //note this is different from OnLocalChatFromClient + data["id"] = OSD.FromUUID(chat.SenderUUID); + data["type"] = OSD.FromInteger((int)chat.Type); + + switch (evType) + { + case EventManager.EventNames.ChatFromClient: + SendSceneEvent(SymmetricSyncMessage.MsgType.ChatFromClient, data); + break; + case EventManager.EventNames.ChatFromWorld: + SendSceneEvent(SymmetricSyncMessage.MsgType.ChatFromWorld, data); + break; + case EventManager.EventNames.ChatBroadcast: + SendSceneEvent(SymmetricSyncMessage.MsgType.ChatBroadcast, data); + break; + } + } private void OnLocalAttach(uint localID, UUID itemID, UUID avatarID) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs index 522eb2d9a0..4775ca783c 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs @@ -42,6 +42,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule ScriptReset, ChatFromClient, ChatFromWorld, + ChatBroadcast, ObjectGrab, ObjectGrabbing, ObjectDeGrab, diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index ba02ca258e..9d83bba6b3 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -55,6 +55,7 @@ namespace OpenSim.Region.Framework.Scenes ScriptReset, ChatFromClient, //chats from avatars ChatFromWorld, //chats from objects + ChatBroadcast, //broadcast ObjectGrab, ObjectGrabbing, ObjectDeGrab, @@ -154,10 +155,26 @@ namespace OpenSim.Region.Framework.Scenes } #endregion //ChatFromClient +#region ChatBroadcast + + public override void TriggerOnChatBroadcast(Object sender, OSChatMessage chat) + { + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[2]; + eventArgs[0] = sender; + eventArgs[1] = (Object)chat; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.ChatBroadcast, eventArgs); + } + TriggerOnChatBroadcastLocally(sender, chat); + } + public void TriggerOnChatBroadcastLocally(Object sender, OSChatMessage chat) { base.TriggerOnChatBroadcast(sender, chat); } +#endregion + #region ChatFromWorld @@ -1874,7 +1891,8 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerOnChatBroadcast(Object sender, OSChatMessage chat) + //public void TriggerOnChatBroadcast(Object sender, OSChatMessage chat) + public virtual void TriggerOnChatBroadcast(Object sender, OSChatMessage chat) { ChatBroadcastEvent handlerChatBroadcast = OnChatBroadcast; if (handlerChatBroadcast != null) From e0f28ac5ba10f061446da51d61fbcd0bbb1a8a68 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 8 Mar 2011 12:59:46 -0800 Subject: [PATCH 03/14] Basic SyncConnector status for ssync status --- .../SymmetricSync/RegionSyncModule.cs | 7 ++-- .../SymmetricSync/ScriptEngineSyncModule.cs | 2 +- .../SymmetricSync/SyncConnector.cs | 33 ++++++++++++++++--- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index dd13272bcc..ff80d1ef9c 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -1163,8 +1163,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private void SyncStatus(Object[] args) { - //TO BE IMPLEMENTED - m_log.Warn("[REGION SYNC MODULE]: SyncStatus() TO BE IMPLEMENTED !!!"); + m_log.WarnFormat("[REGION SYNC MODULE]: Description: {0}", SyncConnector.StatusTitle()); + ForEachSyncConnector(delegate(SyncConnector connector) + { + m_log.WarnFormat("{0}: {1}: {2}", "[REGION SYNC MODULE}", connector.Description, connector.StatusLine()); + }); } private void SyncDebug(Object[] args) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs index e10292d5ec..30cda59a49 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs @@ -172,7 +172,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { if (entity is SceneObjectGroup) { - m_log.Warn(LogHeader + ": start script for obj " + entity.UUID); + m_log.Debug(LogHeader + ": start script for obj " + entity.UUID); SceneObjectGroup sog = (SceneObjectGroup)entity; sog.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0); sog.ResumeScripts(); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs index 93a5dab3c8..817a250d4a 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs @@ -33,7 +33,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private long msgsOut=0; private long bytesIn=0; private long bytesOut=0; - private int msgCount = 0; + private DateTime lastStatTime; // A queue for outgoing traffic. private BlockingUpdateQueue m_outQ = new BlockingUpdateQueue(); @@ -69,8 +69,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule get { if (m_syncOtherSideRegionName == null) - return String.Format("SyncConnector #{0}", m_connectorNum); - return String.Format("SyncConnector #{0} (Actor {2}, Region {1:10})", m_connectorNum, m_syncOtherSideRegionName, m_syncOtherSideActorID); + return String.Format("SyncConnector#{0}", m_connectorNum); + return String.Format("SyncConnector#{0}(A={2},R={1:10})", + m_connectorNum, m_syncOtherSideRegionName, m_syncOtherSideActorID); } } @@ -84,6 +85,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_tcpConnection = tcpclient; m_connectorNum = connectorNum; m_regionSyncModule = syncModule; + lastStatTime = DateTime.Now; m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); } @@ -97,6 +99,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_remoteListenerInfo = listenerInfo; m_connectorNum = connectorNum; m_regionSyncModule = syncModule; + lastStatTime = DateTime.Now; m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); } @@ -261,7 +264,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private void HandleMessage(SymmetricSyncMessage msg) { - msgCount++; + msgsIn++; + bytesIn += msg.Data.Length; switch (msg.Type) { case SymmetricSyncMessage.MsgType.RegionName: @@ -294,5 +298,26 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Later on, we may deliver messages to different modules, say sync message to RegionSyncModule and event message to ActorSyncModule. m_regionSyncModule.HandleIncomingMessage(msg, m_syncOtherSideActorID); } + + public string StatusLine() + { + string statLine = ""; + lock (stats) + { + double secondsSinceLastStats = DateTime.Now.Subtract(lastStatTime).TotalSeconds; + lastStatTime = DateTime.Now; + statLine = String.Format("{0},{1},{2},{3},{4},{5},{6}", + msgsIn, msgsOut, bytesIn, bytesOut, m_outQ.Count, + 8 * (bytesIn / secondsSinceLastStats / 1000000), + 8 * (bytesOut / secondsSinceLastStats / 1000000) ); + msgsIn = msgsOut = bytesIn = bytesOut = 0; + } + return statLine; + } + + public static string StatusTitle() + { + return "msgsIn,msgsOut,queueSize,Mbps In,Mbps Out"; + } } } \ No newline at end of file From e4bdaaaa832806cb23fe5121e34ab6fde2d8188c Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Wed, 9 Mar 2011 16:31:53 -0800 Subject: [PATCH 04/14] Added SyncStateReport function in RegionSyncModule to do some preliminary sync state comparison. --- .../SymmetricSync/RegionSyncModule.cs | 29 +++++++++++++++++++ .../Framework/Scenes/Scene.Inventory.cs | 5 +++- .../Shared/Api/Implementation/LSL_Api.cs | 6 ++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 56b0fef8c8..81c71ea2a2 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -590,10 +590,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //for debugging purpose Command cmdSyncDebug = new Command("debug", CommandIntentions.COMMAND_HAZARDOUS, SyncDebug, "Trigger some debugging functions"); + //for sync state comparison, + Command cmdSyncStateReport = new Command("state", CommandIntentions.COMMAND_HAZARDOUS, SyncStateReport, "Trigger synchronization state comparision functions"); + m_commander.RegisterCommand("start", cmdSyncStart); m_commander.RegisterCommand("stop", cmdSyncStop); m_commander.RegisterCommand("status", cmdSyncStatus); m_commander.RegisterCommand("debug", cmdSyncDebug); + m_commander.RegisterCommand("state", cmdSyncStateReport); lock (m_scene) { @@ -1174,6 +1178,29 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { //TO BE IMPLEMENTED m_log.Warn("[REGION SYNC MODULE]: SyncStatus() TO BE IMPLEMENTED !!!"); + + } + + private void SyncStateReport(Object[] args) + { + //Preliminary implementation + EntityBase[] entities = m_scene.GetEntities(); + List sogList = new List(); + foreach (EntityBase entity in entities) + { + if (entity is SceneObjectGroup) + { + sogList.Add((SceneObjectGroup)entity); + } + } + + int primCount = 0; + foreach (SceneObjectGroup sog in sogList) + { + primCount += sog.Parts.Length; + } + + m_log.WarnFormat("SyncStatus -- Object count: {0}, Prim Count {1} ", sogList.Count, primCount); } private void SyncDebug(Object[] args) @@ -1613,6 +1640,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule return data; } + /* private void HandleAddNewObject(SceneObjectGroup sog) { //RegionSyncModule only add object to SceneGraph. Any actor specific actions will be implemented @@ -1624,6 +1652,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_log.Debug(LogHeader + ": added obj " + sog.UUID); } } + * */ private void HandleRemovedObject(SymmetricSyncMessage msg, string senderActorID) { diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index f1d16f7c13..8aa7c363af 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2194,7 +2194,10 @@ namespace OpenSim.Region.Framework.Scenes } AddNewSceneObject(group, true, pos, rot, vel); - + + //SYNC DEBUG + m_log.DebugFormat("[SCENE] RezObject {0} with InvItem name {1} at pos {2}", group.UUID.ToString(), item.Name, group.RootPart.GroupPosition.ToString()); + // We can only call this after adding the scene object, since the scene object references the scene // to find out if scripts should be activated at all. group.CreateScriptInstances(param, true, DefaultScriptEngine, 3); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 22a18ed775..aaab3ba431 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3412,8 +3412,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api item = m_host.TaskInventory[invItemID]; } - if (agentID == UUID.Zero || perm == 0) // Releasing permissions - { + //if (agentID == UUID.Zero || perm == 0) // Releasing permissions + //{ llReleaseControls(); item.PermsGranter = UUID.Zero; @@ -3425,7 +3425,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api new DetectParams[0])); return; - } + //} if (item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) llReleaseControls(); From b848df2a3ad7e4503904fc39e4a63e40a8ab0118 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Wed, 9 Mar 2011 17:16:03 -0800 Subject: [PATCH 05/14] In LSL_Api.cs, no special checking of if ScriptEngineToSceneConnectorModule exist anymore -- async model is no longer used and we get rid of the old code. --- .../SymmetricSync/RegionSyncModule.cs | 2 +- .../Framework/Scenes/Scene.Inventory.cs | 2 + OpenSim/Region/Framework/Scenes/Scene.cs | 1 + .../Shared/Api/Implementation/LSL_Api.cs | 130 ++++++------------ 4 files changed, 44 insertions(+), 91 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 81c71ea2a2..854986508a 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -1200,7 +1200,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule primCount += sog.Parts.Length; } - m_log.WarnFormat("SyncStatus -- Object count: {0}, Prim Count {1} ", sogList.Count, primCount); + m_log.WarnFormat("SyncStateReport -- Object count: {0}, Prim Count {1} ", sogList.Count, primCount); } private void SyncDebug(Object[] args) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 8aa7c363af..e73c381545 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -333,11 +333,13 @@ namespace OpenSim.Region.Framework.Scenes ArrayList errors = new ArrayList(); //In the old async model, this function is supposed to be executed only on a remote script engine, not an authorative Scene + /* if (RegionSyncModule==null && !IsSyncedScriptEngine()) { m_log.Warn("This is not the script engine. Should not have received OnUpdateScript event."); return errors; } + * */ SceneObjectPart part = GetSceneObjectPart(primID); SceneObjectGroup group = part.ParentGroup; if (isScriptRunning) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c43bfd6349..59c7a0bc1c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -508,6 +508,7 @@ namespace OpenSim.Region.Framework.Scenes //Only Auth. Scene should trigger scritp rez by remote script engine. return IsSyncedServer(); } + /////////////////////////////////////////////////////////////////////////////////////////////// //RA: Physics Engine diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index aaab3ba431..7253a7fed9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1353,7 +1353,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api SetScale(m_host, scale); } - //REGION SYNC TOUCHED -- set via sync'ing with remote Scene protected void SetScale(SceneObjectPart part, LSL_Vector scale) { // TODO: this needs to trigger a persistance save as well @@ -1383,21 +1382,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (scale.z > World.m_maxNonphys) scale.z = World.m_maxNonphys; - if (World.ScriptEngineToSceneConnectorModule==null) - { - //If Script engine is local to Scene (REGION SYNC mode=server, and XEngine enabled=true, and no remote Script Engine connected) - Vector3 tmp = part.Scale; - tmp.X = (float)scale.x; - tmp.Y = (float)scale.y; - tmp.Z = (float)scale.z; - part.Scale = tmp; - part.SendFullUpdateToAllClients(); - } - else - { - //set via sync'ing with remote Scene - World.ScriptEngineToSceneConnectorModule.SendSetPrimProperties(part.ParentGroup.LocX, part.ParentGroup.LocY, part.UUID, "scale", scale); - } + Vector3 tmp = part.Scale; + tmp.X = (float)scale.x; + tmp.Y = (float)scale.y; + tmp.Z = (float)scale.z; + part.Scale = tmp; + part.SendFullUpdateToAllClients(); } public LSL_Vector llGetScale() @@ -1416,7 +1406,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } - //REGION SYNC TOUCHED -- set via sync'ing with remote Scene public void llSetColor(LSL_Vector color, int face) { m_host.AddScriptLPS(1); @@ -1424,22 +1413,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (face == ScriptBaseClass.ALL_SIDES) face = SceneObjectPart.ALL_SIDES; - // REGION SYNC - if (World.ScriptEngineToSceneConnectorModule == null) - { - m_host.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); - } - else - { - object[] valParams = new object[2]; - //valParams[0] = (object)color.x; - //valParams[1] = (object)color.y; - //valParams[2] = (object)color.z; - Vector3 vcolor = new Vector3((float)color.x, (float)color.y, (float)color.z); - valParams[0] = (object)vcolor; - valParams[1] = (object)face; - World.ScriptEngineToSceneConnectorModule.SendSetPrimProperties(m_host.ParentGroup.LocX, m_host.ParentGroup.LocY, m_host.UUID, "color", (object)valParams); - } + m_host.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); } public void SetTexGen(SceneObjectPart part, int face,int style) @@ -2766,7 +2740,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScriptSleep(100); } - //REGION SYNC TOUCHED -- set via sync'ing with remote Scene public void llRezAtRoot(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) { m_host.AddScriptLPS(1); @@ -2778,39 +2751,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (dist > m_ScriptDistanceFactor * 10.0f) return; - if (World.ScriptEngineToSceneConnectorModule == null) + TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); + + foreach (KeyValuePair inv in partInventory) { - //if Scene co-locates with Script Engine - - TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); - - foreach (KeyValuePair inv in partInventory) + if (inv.Value.Name == inventory) { - if (inv.Value.Name == inventory) + // make sure we're an object. + if (inv.Value.InvType != (int)InventoryType.Object) { - // make sure we're an object. - if (inv.Value.InvType != (int)InventoryType.Object) - { - llSay(0, "Unable to create requested object. Object is missing from database."); - return; - } + llSay(0, "Unable to create requested object. Object is missing from database."); + return; + } - Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); - Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); + Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); + Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); - // need the magnitude later - float velmag = (float)Util.GetMagnitude(llvel); + // need the magnitude later + float velmag = (float)Util.GetMagnitude(llvel); - SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param); + SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param); - // If either of these are null, then there was an unknown error. - if (new_group == null) - continue; - if (new_group.RootPart == null) - continue; + // If either of these are null, then there was an unknown error. + if (new_group == null) + continue; + if (new_group.RootPart == null) + continue; - // objects rezzed with this method are die_at_edge by default. - new_group.RootPart.SetDieAtEdge(true); + // objects rezzed with this method are die_at_edge by default. + new_group.RootPart.SetDieAtEdge(true); new_group.ResumeScripts(); @@ -2818,45 +2787,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api "object_rez", new Object[] { new LSL_String( new_group.RootPart.UUID.ToString()) }, - new DetectParams[0])); + new DetectParams[0])); - float groupmass = new_group.GetMass(); + float groupmass = new_group.GetMass(); - if (new_group.RootPart.PhysActor != null && new_group.RootPart.PhysActor.IsPhysical && llvel != Vector3.Zero) - { - //Recoil. - llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0); - } - // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) - ScriptSleep((int)((groupmass * velmag) / 10)); - ScriptSleep(100); - return; + if (new_group.RootPart.PhysActor != null && new_group.RootPart.PhysActor.IsPhysical && llvel != Vector3.Zero) + { + //Recoil. + llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0); } + // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) + ScriptSleep((int)((groupmass * velmag) / 10)); + ScriptSleep(100); + return; } - - llSay(0, "Could not find object " + inventory); } - else - { - //Scene does not co-locate with Script Engine - Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); - Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); - Quaternion llrot = Rot2Quaternion(rot); - object[] valParams = new object[5]; - valParams[0] = (object)inventory; - valParams[1] = (object)llpos; - valParams[2] = (object)llpos; - valParams[3] = (object)llrot; - valParams[4] = (object)param; - //we borrow the implementation SendSetPrimProperties to send the message to Scene - World.ScriptEngineToSceneConnectorModule.SendSetPrimProperties(m_host.ParentGroup.LocX, m_host.ParentGroup.LocY, m_host.UUID, "object_rez", (object)valParams); - // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) - //ScriptSleep((int)((groupmass * velmag) / 10)); - ScriptSleep(100); - } + llSay(0, "Could not find object " + inventory); } + public void llRezObject(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) { llRezAtRoot(inventory, pos, vel, rot, param); From cc2a679121df7255f2a0a31771ab1f254d7a788d Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 10 Mar 2011 14:04:10 -0800 Subject: [PATCH 06/14] Sync statistics to a file --- .../PhysEngineToSceneConnector.cs | 33 +++++++++++---- .../SceneToPhysEngineConnector.cs | 42 +++++++++---------- .../SceneToPhysEngineSyncServer.cs | 2 +- .../SymmetricSync/RegionSyncModule.cs | 13 +++++- .../SymmetricSync/SyncConnector.cs | 25 +++++++---- 5 files changed, 76 insertions(+), 39 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs index 543d17a055..6153bdca1f 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs @@ -64,10 +64,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule // The client connection to the RegionSyncServer private TcpClient m_client = new TcpClient(); - - //KittyL: Comment out m_statsTimer for now, will figure out whether we need it for PhysEngine later - //private System.Timers.Timer m_statsTimer = new System.Timers.Timer(30000); - // The queue of incoming messages which need handling //private Queue m_inQ = new Queue(); @@ -105,11 +101,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_addrString = addr; m_port = port; m_debugWithViewer = debugWithViewer; - //m_statsTimer.Elapsed += new System.Timers.ElapsedEventHandler(StatsTimerElapsed); m_sysConfig = sysConfig; - SceneToPhysEngineSyncServer.logEnabled = m_sysConfig.GetBoolean("LogEnabled", false); - SceneToPhysEngineSyncServer.logDir = m_sysConfig.GetString("LogDir", "."); + SceneToPhysEngineSyncServer.logEnabled = m_sysConfig.GetBoolean("PhysLogEnabled", false); + SceneToPhysEngineSyncServer.logDir = m_sysConfig.GetString("PhysLogDir", "."); //assume we are connecting to the whole scene as one big quark m_subscribedQuarks = new QuarkSubsriptionInfo(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize); @@ -534,5 +529,29 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule #endregion Handlers for events/updates from Scene + public string StatisticIdentifier() + { + return "PhysEngineToSceneConnector"; + } + + public string StatisticLine(bool clearFlag) + { + string ret = ""; + /* + lock (stats) + { + ret = String.Format("{0},{1},{2},{3},{4},{5}", + msgsIn, msgsOut, bytesIn, bytesOut + ); + if (clearFlag) + msgsIn = msgsOut = bytesIn = bytesOut = 0; + } + */ + return ret; + } + public string StatisticTitle() + { + return "msgsIn,msgsOut,bytesIn,bytesOut"; + } } } diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs index c2e0c0cf8f..399b35a11d 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs @@ -27,7 +27,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule // The SceneToPhysEngineConnector acts as a thread on the RegionSyncServer to handle incoming // messages from PhysEngineToSceneConnectors that run on Physics Engines. It connects the // authoratative Scene with remote script engines. - public class SceneToPhysEngineConnector + public class SceneToPhysEngineConnector : ISyncStatistics { #region SceneToPhysEngineConnector members @@ -38,9 +38,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private long bytesIn; private long bytesOut; private long pollBlocks; - private int lastTotalCount; - private int lastLocalCount; - private int lastRemoteCount; private int msgCount = 0; @@ -49,7 +46,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule // Set the addr and port for TcpListener private IPAddress m_addr; private Int32 m_port; - private int m_connection_number; + private static int m_connection_number = 0; private Scene m_scene; object m_syncRoot = new object(); @@ -93,32 +90,33 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule get { return m_connection_number; } } - public string GetStats() + public string StatisticIdentifier() { - string ret; - //lock (m_syncRoot) - // syncedAvCount = m_syncedAvatars.Count; + return "SceneToPhysEngineConnector" + ConnectionNum.ToString(); + } + + public string StatisticLine(bool clearFlag) + { + string ret = ""; lock (stats) { double secondsSinceLastStats = DateTime.Now.Subtract(lastStatTime).TotalSeconds; lastStatTime = DateTime.Now; - // ret = String.Format("[{0,4}/{1,4}], [{2,4}/{3,4}], [{4,4}/{5,4}], [{6,4} ({7,4})], [{8,8} ({9,8:00.00})], [{10,4} ({11,4})], [{12,8} ({13,8:00.00})], [{14,8} ({15,4}]", - ret = String.Format("[{0,4}/{1,4}], [{2,6}/{3,6}], [{4,4}/{5,4}], [{6,6} ({7,6})], [{8,4} ({9,4})]", - //lastTotalCount, totalAvCount, // TOTAL AVATARS - //lastLocalCount, syncedAvCount, // LOCAL TO THIS CLIENT VIEW - //lastRemoteCount, totalAvCount - syncedAvCount, // REMOTE (SHOULD = TOTAL - LOCAL) - msgsIn, (int)(msgsIn / secondsSinceLastStats), - bytesIn, 8 * (bytesIn / secondsSinceLastStats / 1000000), // IN - msgsOut, (int)(msgsOut / secondsSinceLastStats), - bytesOut, 8 * (bytesOut / secondsSinceLastStats / 1000000), // OUT - pollBlocks, (int)(pollBlocks / secondsSinceLastStats)); // NUMBER OF TIMES WE BLOCKED WRITING TO SOCKET - - msgsIn = msgsOut = bytesIn = bytesOut = pollBlocks = 0; + ret = String.Format("{0},{1},{2},{3},{4}", + msgsIn, msgsOut, bytesIn, bytesOut, pollBlocks + ); + if (clearFlag) + msgsIn = msgsOut = bytesIn = bytesOut = pollBlocks = 0; } return ret; } + public string StatisticTitle() + { + return "msgsIn,msgsOut,bytesIn,bytesOut,pollBlocks"; + } + // Check if the client is connected public bool Connected { get { return m_tcpclient.Connected; } } @@ -163,6 +161,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //m_log.WarnFormat("{0} Started thread: {1}", LogHeader, m_receive_loop.Name); m_receive_loop.Start(); + SyncStatisticCollector.Register(this); + //tell the remote script engine about the locX, locY of this authoritative scene // SendSceneLoc(); m_log.DebugFormat("{0}: SceneToPhysEngineConnector initialized", LogHeader); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs index a4cbb96c81..32262c0232 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs @@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_log.Warn(LogHeader + " Synchronized"); foreach (SceneToPhysEngineConnector pec in m_physEngineConnectors) { - m_log.Warn(pec.GetStats()); + m_log.Warn(pec.StatisticLine(true)); } } } diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index acac3c404b..c84c22452b 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -73,6 +73,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_log.Warn("[REGION SYNC MODULE] Initialised for actor "+ m_actorID); //The ActorType configuration will be read in and process by an ActorSyncModule, not here. + + // parameters for statistic logging + SyncStatisticCollector.LogEnabled = m_sysConfig.GetBoolean("SyncLogEnabled", false); + SyncStatisticCollector.LogDirectory = m_sysConfig.GetString("SyncLogDirectory", "."); + SyncStatisticCollector.LogInterval = m_sysConfig.GetInt("SyncLogInterval", 5000); + SyncStatisticCollector.LogMaxFileTimeMin = m_sysConfig.GetInt("SyncLogMaxFileTimeMin", 5); + SyncStatisticCollector.LogFileHeader = m_sysConfig.GetString("SyncLogFileHeader", "stats-"); } //Called after Initialise() @@ -1163,10 +1170,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private void SyncStatus(Object[] args) { - m_log.WarnFormat("[REGION SYNC MODULE]: Description: {0}", SyncConnector.StatusTitle()); + int connectorCount = 0; ForEachSyncConnector(delegate(SyncConnector connector) { - m_log.WarnFormat("{0}: {1}: {2}", "[REGION SYNC MODULE}", connector.Description, connector.StatusLine()); + if (connectorCount++ == 0) + m_log.WarnFormat("[REGION SYNC MODULE]: Description: {0}", connector.StatisticTitle()); + m_log.WarnFormat("{0}: {1}: {2}", "[REGION SYNC MODULE}", connector.Description, connector.StatisticLine(true)); }); } diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs index 817a250d4a..2ae9608991 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs @@ -14,7 +14,7 @@ using OpenMetaverse; namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { // For implementations, a lot was copied from RegionSyncClientView, especially the SendLoop/ReceiveLoop. - public class SyncConnector + public class SyncConnector : ISyncStatistics { private TcpClient m_tcpConnection = null; private RegionSyncListenerInfo m_remoteListenerInfo = null; @@ -39,7 +39,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private RegionSyncModule m_regionSyncModule = null; - private int m_connectorNum; + // unique connector number across all regions + private static int m_connectorNum = 0; public int ConnectorNum { get { return m_connectorNum; } @@ -69,8 +70,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule get { if (m_syncOtherSideRegionName == null) - return String.Format("SyncConnector#{0}", m_connectorNum); - return String.Format("SyncConnector#{0}(A={2},R={1:10})", + return String.Format("SyncConnector{0}", m_connectorNum); + return String.Format("SyncConnector{0}({2}/{1:10})", m_connectorNum, m_syncOtherSideRegionName, m_syncOtherSideActorID); } } @@ -86,6 +87,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_connectorNum = connectorNum; m_regionSyncModule = syncModule; lastStatTime = DateTime.Now; + SyncStatisticCollector.Register(this); m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); } @@ -100,6 +102,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_connectorNum = connectorNum; m_regionSyncModule = syncModule; lastStatTime = DateTime.Now; + SyncStatisticCollector.Register(this); m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); } @@ -299,7 +302,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_regionSyncModule.HandleIncomingMessage(msg, m_syncOtherSideActorID); } - public string StatusLine() + public string StatisticIdentifier() + { + return this.Description; + } + + public string StatisticLine(bool clearFlag) { string statLine = ""; lock (stats) @@ -310,14 +318,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule msgsIn, msgsOut, bytesIn, bytesOut, m_outQ.Count, 8 * (bytesIn / secondsSinceLastStats / 1000000), 8 * (bytesOut / secondsSinceLastStats / 1000000) ); - msgsIn = msgsOut = bytesIn = bytesOut = 0; + if (clearFlag) + msgsIn = msgsOut = bytesIn = bytesOut = 0; } return statLine; } - public static string StatusTitle() + public string StatisticTitle() { - return "msgsIn,msgsOut,queueSize,Mbps In,Mbps Out"; + return "msgsIn,msgsOut,bytesIn,bytesOut,queueSize,Mbps In,Mbps Out"; } } } \ No newline at end of file From a1fa5c28c3d9b15d6eff06a12f3e00e9184669a7 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 10 Mar 2011 14:05:59 -0800 Subject: [PATCH 07/14] Add sync statistics collector class --- .../SymmetricSync/SyncStatisticCollector.cs | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100755 OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncStatisticCollector.cs diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncStatisticCollector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncStatisticCollector.cs new file mode 100755 index 0000000000..fef5da262e --- /dev/null +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncStatisticCollector.cs @@ -0,0 +1,162 @@ +/* Copyright 2011 (c) Intel Corporation + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * The name of the copyright holder may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Timers; + +namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule +{ + public interface ISyncStatistics + { + // return an identifier for this statistics source + string StatisticIdentifier(); + // a line of comma separated values + string StatisticLine(bool clearFlag); + // a line of comma separated field descriptions (describes what StatisticLine returns) + string StatisticTitle(); + } + + public class SyncStatisticCollector + { + public static bool LogEnabled = false; + public static string LogDirectory = "."; + public static int LogInterval = 5000; + public static int LogMaxFileTimeMin = 5; // 5 minutes + public static string LogFileHeader = "stats-"; + + private static List s_staters = new List(); + private static object s_statersLock = new object(); + private static Timer s_timer = null; + + static SyncStatisticCollector() + { + } + + public SyncStatisticCollector() + { + } + + /// + /// Any implementor of ISyncStatistics will call Register to put themselves in + /// the list of routines to collect statistics from. This will run periodically + /// and suck statistics from the registered routines. + /// + /// + public static void Register(ISyncStatistics stat) + { + if (!LogEnabled) return; + lock (SyncStatisticCollector.s_statersLock) + { + // set up logging timer + if (SyncStatisticCollector.s_timer == null) + { + SyncStatisticCollector.s_timer = new Timer(); + SyncStatisticCollector.s_timer.Interval = LogInterval; + SyncStatisticCollector.s_timer.Enabled = true; + SyncStatisticCollector.s_timer.Elapsed += Tick; + + } + SyncStatisticCollector.s_staters.Add(stat); + } + return; + } + + public static void Close() + { + lock (SyncStatisticCollector.s_statersLock) + { + SyncStatisticCollector.LogEnabled = false; + if (SyncStatisticCollector.s_timer != null) + { + SyncStatisticCollector.s_timer.Enabled = false; + SyncStatisticCollector.s_timer.Dispose(); + SyncStatisticCollector.s_timer = null; + } + if (SyncStatisticCollector.LogFile != null) + { + SyncStatisticCollector.LogFile.Close(); + SyncStatisticCollector.LogFile.Dispose(); + SyncStatisticCollector.LogFile = null; + } + } + } + + + private static void Tick(object sender, EventArgs e) + { + if (!LogEnabled) return; + lock (SyncStatisticCollector.s_statersLock) + { + foreach (ISyncStatistics iss in s_staters) + { + LogWriter(iss.StatisticIdentifier() + "," + iss.StatisticLine(true)); + } + } + return; + } + + private static DateTime LogStartTime; + private static System.IO.TextWriter LogFile = null; + private static void LogWriter(string line) + { + try + { + DateTime now = DateTime.Now; + if (LogFile == null || (now > (LogStartTime + new TimeSpan(0, LogMaxFileTimeMin, 0)))) + { + if (LogFile != null) + { + LogFile.Close(); + LogFile.Dispose(); + LogFile = null; + } + + // First log file or time has expired, start writing to a new log file + LogStartTime = now; + string path = (LogDirectory.Length > 0 ? LogDirectory + + System.IO.Path.DirectorySeparatorChar.ToString() : "") + + String.Format("{0}{1}.log", LogFileHeader, now.ToString("yyyyMMddHHmmss")); + LogFile = new StreamWriter(File.Open(path, FileMode.Append, FileAccess.Write)); + } + if (LogFile != null) + { + StringBuilder buff = new StringBuilder(); + // buff.Append(now.ToString("yyyyMMddHHmmssfff")); + buff.Append(now.ToString("yyyyMMddHHmmss")); + buff.Append(","); + buff.Append(line); + buff.Append("\r\n"); + LogFile.Write(buff.ToString()); + } + } + catch (Exception e) + { + // m_log.ErrorFormat("{0}: FAILURE WRITING TO LOGFILE: {1}", LogHeader, e); + LogEnabled = false; + } + return; + } + } +} From 13798f9f7d0fee3320d297a9f76433719d51c1d5 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 11 Mar 2011 09:22:32 -0800 Subject: [PATCH 08/14] Fixed bugs in llCreateLink to sync LinkObject properly. Also, added logs for debug purposes. --- .../SymmetricSync/RegionSyncModule.cs | 20 +++++++++++++++ .../Framework/Scenes/Scene.Inventory.cs | 6 ++++- OpenSim/Region/Framework/Scenes/Scene.cs | 5 +++- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 4 ++- .../Framework/Scenes/SceneObjectGroup.cs | 1 + .../Framework/Scenes/SceneObjectPart.cs | 25 ++++++++++++++++++- .../Shared/Api/Implementation/LSL_Api.cs | 9 ++++++- .../Shared/Instance/ScriptInstance.cs | 2 +- 8 files changed, 66 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 854986508a..db453df85c 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -432,6 +432,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule partNum++; } + m_log.Debug(LogHeader + " to SendLinkObject to link " + children.Count + " parts to " + root.Name); + m_log.Debug("LinkedObject: "+sogxml); + SymmetricSyncMessage rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.LinkObject, OSDParser.SerializeJsonString(data)); SendObjectUpdateToRelevantSyncConnectors(linkedGroup, rsm); } @@ -764,6 +767,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule data["LastUpdateTimeStamp"] = OSD.FromLong(updatedPart.BucketSyncInfoList[bucketName].LastUpdateTimeStamp); data["LastUpdateActorID"] = OSD.FromString(updatedPart.BucketSyncInfoList[bucketName].LastUpdateActorID); + m_log.Debug(LogHeader + " Send out Physics Bucket updates for " + updatedPart.Name + ". GroupPosition: " + updatedPart.GroupPosition.ToString() + ", Position = " + pa.Position); + SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedBucketProperties, OSDParser.SerializeJsonString(data)); //m_log.DebugFormat("{0}: PhysBucketSender for {1}, pos={2}", LogHeader, updatedPart.UUID.ToString(), pa.Position.ToString()); SendObjectUpdateToRelevantSyncConnectors(updatedPart, syncMsg); @@ -838,6 +843,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { //string sogxml = SceneObjectSerializer.ToXml2Format(sog); //SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedObject, sogxml); + + m_log.Debug(LogHeader + " send " + syncMsg.Type.ToString() + " about "+sog.Name+"," + sog.UUID+ " to " + connector.OtherSideActorID); + connector.EnqueueOutgoingUpdate(sog.UUID, syncMsg.ToBytes()); } } @@ -1518,6 +1526,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule string sogxml = Encoding.ASCII.GetString(msg.Data, 0, msg.Length); SceneObjectGroup sog = SceneObjectSerializer.FromXml2Format(sogxml); + //SYNC DEBUG + string partnames = ""; + foreach (SceneObjectPart part in sog.Parts) + { + partnames += "(" + part.Name + ", " + part.UUID + ")"; + } + m_log.Debug(LogHeader+" received "+msg.Type.ToString()+" from "+senderActorID+" about obj "+sog.Name+", "+sog.UUID+"; parts -- "+partnames); + if (sog.IsDeleted) { SymmetricSyncMessage.HandleTrivial(LogHeader, msg, String.Format("Ignoring update on deleted object, UUID: {0}.", sog.UUID)); @@ -1696,6 +1712,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private void HandleLinkObject(SymmetricSyncMessage msg, string senderActorID) { + // Get the data from message and error check OSDMap data = DeserializeMessage(msg); if (data == null) @@ -1717,6 +1734,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule childrenIDs.Add(data[partTempID].AsUUID()); } + m_log.Debug(LogHeader + " received LinkObject from " + senderActorID); + //m_log.Debug("LinkedObject: " + sogxml); + m_scene.LinkObjectBySync(linkedGroup, rootID, childrenIDs); //if this is a relay node, forwards the event diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e73c381545..6d086d6844 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2198,7 +2198,11 @@ namespace OpenSim.Region.Framework.Scenes AddNewSceneObject(group, true, pos, rot, vel); //SYNC DEBUG - m_log.DebugFormat("[SCENE] RezObject {0} with InvItem name {1} at pos {2}", group.UUID.ToString(), item.Name, group.RootPart.GroupPosition.ToString()); + string partnames = ""; + foreach (SceneObjectPart part in group.Parts){ + partnames += "(" + part.Name + ", " + part.UUID + ")"; + } + m_log.DebugFormat("[SCENE] RezObject {0} with InvItem name {1} at pos {2} with parts {3}", group.UUID.ToString(), item.Name, group.RootPart.GroupPosition.ToString(), partnames); // We can only call this after adding the scene object, since the scene object references the scene // to find out if scripts should be activated at all. diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 59c7a0bc1c..eda4365930 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -791,11 +791,14 @@ namespace OpenSim.Region.Framework.Scenes continue; } - m_log.Debug("to link part " + part.DebugObjectPartProperties()); + //m_log.Debug("to link part " + part.DebugObjectPartProperties()); + m_log.Debug("to link part " + part.Name + "," + part.UUID + "; its SOG has " + part.ParentGroup.Parts + " parts"); children.Add(part); } + //m_log.Debug("to link " + children.Count + " parts with " + root.Name); + //Leverage the LinkObject implementation to get the book keeping of Group and Parts relations right m_sceneGraph.LinkObjectsBySync(root, children); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 13b0af51b8..e523e10f98 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -2018,7 +2018,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_log.Debug("AddSceneObjectByStateSynch to be called"); + m_log.Debug(updatedSog.Name+" "+updatedSog.UUID+" not found in Entities list. Need to add"); AddSceneObjectByStateSynch(updatedSog); updateResult = Scene.ObjectUpdateResult.New; } @@ -2062,6 +2062,8 @@ namespace OpenSim.Region.Framework.Scenes } m_numPrim += children.Length; + m_log.Debug("Attached obj " + sceneObject.Name + "," + sceneObject.UUID + " to Scene"); + sceneObject.AttachToScene(m_parentScene); //Take some special care of the case of this object being an attachment diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5120e90783..9f9f193360 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2909,6 +2909,7 @@ namespace OpenSim.Region.Framework.Scenes //we need to do a terse update even if the move wasn't allowed // so that the position is reset in the client (the object snaps back) //ScheduleGroupForTerseUpdate(); + m_log.Debug(this.Name + " GroupPosition changed to " + AbsolutePosition.ToString()); List updatedProperties = new List() { SceneObjectPartProperties.GroupPosition }; if (IsAttachment) { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4bcef483d2..3749ddc5b1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -5504,15 +5504,33 @@ namespace OpenSim.Region.Framework.Scenes //buckets may not be filled at all in "updatedPart". private void PhysicsBucketUpdateProcessor(Object updatedPartO, string bucketName) { + SceneObjectPart localPart = this; + + if (updatedPartO is SceneObjectPart) + { + SceneObjectPart updatedPart = (SceneObjectPart)updatedPartO; + + localPart.GroupPosition = updatedPart.GroupPosition; + localPart.OffsetPosition = updatedPart.OffsetPosition; + localPart.Scale = updatedPart.Scale; + localPart.Velocity = updatedPart.Velocity; + localPart.AngularVelocity = updatedPart.AngularVelocity; + localPart.RotationOffset = updatedPart.RotationOffset; + return; + } + if (!(updatedPartO is OSDMap)) return; OSDMap data = (OSDMap)updatedPartO; //If needed, we could define new set functions for these properties, and cast this SOP to SOPBase to //invoke the set functions in SOPBase //SceneObjectPartBase localPart = (SceneObjectPartBase)this; - SceneObjectPart localPart = this; + //SceneObjectPart localPart = this; PhysicsActor pa = localPart.PhysActor; + m_log.Debug("Received Physics Bucket updates for " + localPart.Name + ". GroupPosition: " + data["GroupPosition"].AsVector3().ToString() + + ", Position = " + data["Position"].AsVector3().ToString()); + //m_log.DebugFormat("{0}: PhysicsBucketUpdateProcessor. pos={1}", "[SCENE OBJECT PART]", data["Position"].AsVector3().ToString()); lock (m_bucketUpdateLocks[bucketName]) @@ -5618,6 +5636,9 @@ namespace OpenSim.Region.Framework.Scenes string bucketName = m_primPropertyBucketMap[property]; //m_bucketSyncTainted[bucketName] = true; m_bucketSyncInfoList[bucketName].TaintBucket(); + + m_log.Debug(this.Name + ": " + property.ToString() + " just changed. Tainted " + bucketName); + } } } @@ -5758,6 +5779,8 @@ namespace OpenSim.Region.Framework.Scenes //Second, if need to update local properties, call each bucket's update process if (m_bucketUpdateProcessors.ContainsKey(bucketName)) { + m_log.Debug("Update properties in " + bucketName + " buckets"); + m_bucketUpdateProcessors[bucketName](updatedPart, bucketName); partUpdateResult = Scene.ObjectUpdateResult.Updated; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 7253a7fed9..e693c25370 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3567,12 +3567,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api item = m_host.TaskInventory[invItemID]; } + /* if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 && !m_automaticLinkPermission) { ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); return; } + */ IClientAPI client = null; ScenePresence sp = World.GetScenePresence(item.PermsGranter); @@ -3585,6 +3587,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; // Fail silently if attached SceneObjectGroup parentPrim = null, childPrim = null; + //SYEMMETRIC SYNC + List children = new List(); + if (targetPart != null) { if (parent != 0) { @@ -3596,6 +3601,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api parentPrim = targetPart.ParentGroup; childPrim = m_host.ParentGroup; } + children.Add(childPrim.RootPart); + // byte uf = childPrim.RootPart.UpdateFlag; childPrim.RootPart.UpdateFlag = 0; parentPrim.LinkToGroup(childPrim); @@ -3614,7 +3621,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { //Tell other actors to link the SceneObjectParts together as a new group. //parentGroup.SyncInfoUpdate(); - World.RegionSyncModule.SendLinkObject(parentPrim, parentPrim.RootPart, new List(childPrim.Parts)); + World.RegionSyncModule.SendLinkObject(parentPrim, parentPrim.RootPart, children); } m_host.ScheduleFullUpdate(new List(){SceneObjectPartProperties.None}); //SendLinkObject above will synchronize the link operation, no need to taint updates here //end of SYMMETRIC SYNC diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 035442c88f..17513ecc34 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -741,7 +741,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance } catch (Exception e) { - m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); + m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); m_InEvent = false; m_CurrentEvent = String.Empty; From 1ab4df995401f380ed695ec3ba77f669545e6b69 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 11 Mar 2011 11:50:46 -0800 Subject: [PATCH 09/14] In RegionSyncModule.PrimUpdatesPhysicsBucketSender, if no PhysicsActor for the SOP, still sending out "GroupPosition" and a few other properties in physics bucket. Sync'ing of phantom objects now seems working fine. --- .../SymmetricSync/RegionSyncModule.cs | 47 ++++++++++--------- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 9 ++-- .../Framework/Scenes/SceneObjectGroup.cs | 2 +- .../Framework/Scenes/SceneObjectPart.cs | 11 +++-- 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index db453df85c..e7667cf875 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -202,6 +202,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { lock (m_primUpdateLocks[bucketName]) { + m_log.Debug("Queueing to bucket " + bucketName + " with part " + part.Name + ", " + part.UUID); m_primUpdates[bucketName][part.UUID] = part; } } @@ -245,6 +246,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { if (m_primUpdates[bucketName].Count > 0) { + m_log.Debug(m_primUpdates[bucketName].Count + " updated parts in bucket " + bucketName); lock (m_primUpdateLocks[bucketName]) { updated = true; @@ -299,6 +301,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } } * */ + m_log.Debug(LogHeader + " calling update sender for bucket " + bucketName); m_primUpdatesPerBucketSender[bucketName](bucketName, primUpdates[bucketName]); } } @@ -734,14 +737,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { updatedPart.UpdateTaintedBucketSyncInfo(bucketName, DateTime.Now.Ticks); - Physics.Manager.PhysicsActor pa = updatedPart.PhysActor; - if (pa == null) - return; - OSDMap data = new OSDMap(); - // data["UUID"] = OSD.FromUUID(updatedPart.UUID); - data["UUID"] = OSD.FromUUID(pa.UUID); + data["UUID"] = OSD.FromUUID(updatedPart.UUID); + //data["UUID"] = OSD.FromUUID(pa.UUID); data["Bucket"] = OSD.FromString(bucketName); data["GroupPosition"] = OSD.FromVector3(updatedPart.GroupPosition); @@ -749,25 +748,31 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule data["Scale"] = OSD.FromVector3(updatedPart.Scale); data["AngularVelocity"] = OSD.FromVector3(updatedPart.AngularVelocity); data["RotationOffset"] = OSD.FromQuaternion(updatedPart.RotationOffset); - data["Size"] = OSD.FromVector3(pa.Size); - data["Position"] = OSD.FromVector3(pa.Position); - data["Force"] = OSD.FromVector3(pa.Force); - data["Velocity"] = OSD.FromVector3(pa.Velocity); - data["RotationalVelocity"] = OSD.FromVector3(pa.RotationalVelocity); - data["PA_Acceleration"] = OSD.FromVector3(pa.Acceleration); - data["Torque"] = OSD.FromVector3(pa.Torque); - data["Orientation"] = OSD.FromQuaternion(pa.Orientation); - data["IsPhysical"] = OSD.FromBoolean(pa.IsPhysical); - data["Flying"] = OSD.FromBoolean(pa.Flying); - data["Kinematic"] = OSD.FromBoolean(pa.Kinematic); - data["Buoyancy"] = OSD.FromReal(pa.Buoyancy); - data["CollidingGround"] = OSD.FromBoolean(pa.CollidingGround); - data["IsColliding"] = OSD.FromBoolean(pa.IsColliding); + + Physics.Manager.PhysicsActor pa = updatedPart.PhysActor; + if (pa != null) + { + + data["Size"] = OSD.FromVector3(pa.Size); + data["Position"] = OSD.FromVector3(pa.Position); + data["Force"] = OSD.FromVector3(pa.Force); + data["Velocity"] = OSD.FromVector3(pa.Velocity); + data["RotationalVelocity"] = OSD.FromVector3(pa.RotationalVelocity); + data["PA_Acceleration"] = OSD.FromVector3(pa.Acceleration); + data["Torque"] = OSD.FromVector3(pa.Torque); + data["Orientation"] = OSD.FromQuaternion(pa.Orientation); + data["IsPhysical"] = OSD.FromBoolean(pa.IsPhysical); + data["Flying"] = OSD.FromBoolean(pa.Flying); + data["Kinematic"] = OSD.FromBoolean(pa.Kinematic); + data["Buoyancy"] = OSD.FromReal(pa.Buoyancy); + data["CollidingGround"] = OSD.FromBoolean(pa.CollidingGround); + data["IsColliding"] = OSD.FromBoolean(pa.IsColliding); + } data["LastUpdateTimeStamp"] = OSD.FromLong(updatedPart.BucketSyncInfoList[bucketName].LastUpdateTimeStamp); data["LastUpdateActorID"] = OSD.FromString(updatedPart.BucketSyncInfoList[bucketName].LastUpdateActorID); - m_log.Debug(LogHeader + " Send out Physics Bucket updates for " + updatedPart.Name + ". GroupPosition: " + updatedPart.GroupPosition.ToString() + ", Position = " + pa.Position); + m_log.Debug(LogHeader + " Send out Physics Bucket updates for " + updatedPart.Name + ". GroupPosition: " + updatedPart.GroupPosition.ToString()); SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedBucketProperties, OSDParser.SerializeJsonString(data)); //m_log.DebugFormat("{0}: PhysBucketSender for {1}, pos={2}", LogHeader, updatedPart.UUID.ToString(), pa.Position.ToString()); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index e523e10f98..f915ea368e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -468,7 +468,7 @@ namespace OpenSim.Region.Framework.Scenes lock (m_updateList) { m_updateList[obj.UUID] = obj; - //m_log.Debug("added " + obj.UUID + " to m_updateList"); + m_log.Debug("added " + obj.Name+","+ obj.UUID + " to m_updateList"); } } @@ -489,12 +489,12 @@ namespace OpenSim.Region.Framework.Scenes { updates = new List(m_updateList.Values); - /* + if (updates.Count > 0) { - m_log.Debug("SceneGraph: " + updates.Count + " objects to send updates for"); + m_log.Debug("SceneGraph.UpdateObjectGroups: " + updates.Count + " objects to send updates for"); } - * */ + m_updateList.Clear(); @@ -508,6 +508,7 @@ namespace OpenSim.Region.Framework.Scenes // Don't abort the whole update if one entity happens to give us an exception. try { + m_log.Debug("SceneGraph: calling update for obj " + sog.Name + "," + sog.UUID); sog.Update(); } catch (Exception e) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 9f9f193360..68372cd129 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1950,7 +1950,7 @@ namespace OpenSim.Region.Framework.Scenes //public void ScheduleGroupForTerseUpdate() public void ScheduleGroupForTerseUpdate(List updatedProperties) { -// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); + m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 3749ddc5b1..a053a46f01 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2980,9 +2980,9 @@ namespace OpenSim.Region.Framework.Scenes TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); m_updateFlag = 1; - // m_log.DebugFormat( - // "[SCENE OBJECT PART]: Scheduling terse update for {0}, {1} at {2}", - // UUID, Name, TimeStampTerse); + m_log.DebugFormat( + "[SCENE OBJECT PART]: Scheduling terse update for {0}, {1} at {2}", + UUID, Name, TimeStampTerse); } } @@ -3204,6 +3204,7 @@ namespace OpenSim.Region.Framework.Scenes //SYMMETRIC SYNC if (m_parentGroup.Scene.RegionSyncModule != null) { + m_log.Debug("SOP.SendScheduledUpdates: Calling RegionSyncModule.QueueSceneObjectPartForUpdate"); m_parentGroup.Scene.RegionSyncModule.QueueSceneObjectPartForUpdate((SceneObjectPart)this); } //end of SYMMETRIC SYNC @@ -5854,8 +5855,8 @@ namespace OpenSim.Region.Framework.Scenes { if (updatedProperties != null && updatedProperties.Count > 0) { - //m_log.DebugFormat("{0}: Tainting bucket for properties {1}", - // "[SCENE OBJECT PART]", updatedProperties.ToString()); + m_log.DebugFormat("{0}: Tainting bucket for properties {1}", + "[SCENE OBJECT PART]", updatedProperties.ToString()); foreach (SceneObjectPartProperties property in updatedProperties) { TaintBucketSyncInfo(property); From 48ad2010e5a55ff3a578e287d643d7ea71009a4b Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 11 Mar 2011 13:54:09 -0800 Subject: [PATCH 10/14] removed some debug message. --- .../SymmetricSync/RegionSyncModule.cs | 4 ++-- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 5 ++--- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 3 +-- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 13 ++++++------- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index e7667cf875..4fef5b16ac 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -202,7 +202,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { lock (m_primUpdateLocks[bucketName]) { - m_log.Debug("Queueing to bucket " + bucketName + " with part " + part.Name + ", " + part.UUID); + //m_log.Debug("Queueing to bucket " + bucketName + " with part " + part.Name + ", " + part.UUID); m_primUpdates[bucketName][part.UUID] = part; } } @@ -301,7 +301,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } } * */ - m_log.Debug(LogHeader + " calling update sender for bucket " + bucketName); + //m_log.Debug(LogHeader + " calling update sender for bucket " + bucketName); m_primUpdatesPerBucketSender[bucketName](bucketName, primUpdates[bucketName]); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index f915ea368e..13bc6cd303 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -468,7 +468,7 @@ namespace OpenSim.Region.Framework.Scenes lock (m_updateList) { m_updateList[obj.UUID] = obj; - m_log.Debug("added " + obj.Name+","+ obj.UUID + " to m_updateList"); + //m_log.Debug("added " + obj.Name+","+ obj.UUID + " to m_updateList"); } } @@ -492,7 +492,7 @@ namespace OpenSim.Region.Framework.Scenes if (updates.Count > 0) { - m_log.Debug("SceneGraph.UpdateObjectGroups: " + updates.Count + " objects to send updates for"); + //m_log.Debug("SceneGraph.UpdateObjectGroups: " + updates.Count + " objects to send updates for"); } @@ -508,7 +508,6 @@ namespace OpenSim.Region.Framework.Scenes // Don't abort the whole update if one entity happens to give us an exception. try { - m_log.Debug("SceneGraph: calling update for obj " + sog.Name + "," + sog.UUID); sog.Update(); } catch (Exception e) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 68372cd129..a3ec2ecedf 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1950,7 +1950,7 @@ namespace OpenSim.Region.Framework.Scenes //public void ScheduleGroupForTerseUpdate() public void ScheduleGroupForTerseUpdate(List updatedProperties) { - m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); + // m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) @@ -2909,7 +2909,6 @@ namespace OpenSim.Region.Framework.Scenes //we need to do a terse update even if the move wasn't allowed // so that the position is reset in the client (the object snaps back) //ScheduleGroupForTerseUpdate(); - m_log.Debug(this.Name + " GroupPosition changed to " + AbsolutePosition.ToString()); List updatedProperties = new List() { SceneObjectPartProperties.GroupPosition }; if (IsAttachment) { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a053a46f01..18218e43cd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2980,9 +2980,9 @@ namespace OpenSim.Region.Framework.Scenes TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); m_updateFlag = 1; - m_log.DebugFormat( - "[SCENE OBJECT PART]: Scheduling terse update for {0}, {1} at {2}", - UUID, Name, TimeStampTerse); + //m_log.DebugFormat( + // "[SCENE OBJECT PART]: Scheduling terse update for {0}, {1} at {2}", + // UUID, Name, TimeStampTerse); } } @@ -3203,8 +3203,7 @@ namespace OpenSim.Region.Framework.Scenes //SYMMETRIC SYNC if (m_parentGroup.Scene.RegionSyncModule != null) - { - m_log.Debug("SOP.SendScheduledUpdates: Calling RegionSyncModule.QueueSceneObjectPartForUpdate"); + { m_parentGroup.Scene.RegionSyncModule.QueueSceneObjectPartForUpdate((SceneObjectPart)this); } //end of SYMMETRIC SYNC @@ -5855,8 +5854,8 @@ namespace OpenSim.Region.Framework.Scenes { if (updatedProperties != null && updatedProperties.Count > 0) { - m_log.DebugFormat("{0}: Tainting bucket for properties {1}", - "[SCENE OBJECT PART]", updatedProperties.ToString()); + //m_log.DebugFormat("{0}: Tainting bucket for properties {1}", + // "[SCENE OBJECT PART]", updatedProperties.ToString()); foreach (SceneObjectPartProperties property in updatedProperties) { TaintBucketSyncInfo(property); From 37dd39fd5d54071b0c5ce8ccaaaca63a0fc84a06 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 11 Mar 2011 15:39:06 -0800 Subject: [PATCH 11/14] Added SendNewObject to explicitly send out NewObject sync message when new objects are added. --- .../SymmetricSync/RegionSyncModule.cs | 44 ++++++++++++++++--- .../Framework/Interfaces/IRegionSyncModule.cs | 1 + OpenSim/Region/Framework/Scenes/Scene.cs | 5 ++- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 16 +++++-- .../Framework/Scenes/SceneObjectPart.cs | 6 +-- .../Shared/Api/Implementation/LSL_Api.cs | 2 - 6 files changed, 57 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 4fef5b16ac..f95b53f3d7 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -246,7 +246,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { if (m_primUpdates[bucketName].Count > 0) { - m_log.Debug(m_primUpdates[bucketName].Count + " updated parts in bucket " + bucketName); + //m_log.Debug(m_primUpdates[bucketName].Count + " updated parts in bucket " + bucketName); lock (m_primUpdateLocks[bucketName]) { updated = true; @@ -376,6 +376,24 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } } + /// + /// Send a sync message to add the given object to other sync nodes. + /// + /// + public void SendNewObject(SceneObjectGroup sog) + { + if (!IsSyncingWithOtherActors()) + { + //no SyncConnector connected. Do nothing. + return; + } + m_log.DebugFormat(LogHeader + "SendNewObject called for object {0}, {1}", sog.Name, sog.UUID); + + string sogxml = SceneObjectSerializer.ToXml2Format(sog); + SymmetricSyncMessage rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.NewObject, sogxml); + SendObjectUpdateToRelevantSyncConnectors(sog, rsm); + } + /// /// Send a sync message to remove the given objects in all connected actors. /// UUID is used for identified a removed object. This function now should @@ -772,7 +790,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule data["LastUpdateTimeStamp"] = OSD.FromLong(updatedPart.BucketSyncInfoList[bucketName].LastUpdateTimeStamp); data["LastUpdateActorID"] = OSD.FromString(updatedPart.BucketSyncInfoList[bucketName].LastUpdateActorID); - m_log.Debug(LogHeader + " Send out Physics Bucket updates for " + updatedPart.Name + ". GroupPosition: " + updatedPart.GroupPosition.ToString()); + //m_log.Debug(LogHeader + " Send out Physics Bucket updates for " + updatedPart.Name + ". GroupPosition: " + updatedPart.GroupPosition.ToString()); SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedBucketProperties, OSDParser.SerializeJsonString(data)); //m_log.DebugFormat("{0}: PhysBucketSender for {1}, pos={2}", LogHeader, updatedPart.UUID.ToString(), pa.Position.ToString()); @@ -849,8 +867,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //string sogxml = SceneObjectSerializer.ToXml2Format(sog); //SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedObject, sogxml); - m_log.Debug(LogHeader + " send " + syncMsg.Type.ToString() + " about "+sog.Name+"," + sog.UUID+ " to " + connector.OtherSideActorID); - connector.EnqueueOutgoingUpdate(sog.UUID, syncMsg.ToBytes()); } } @@ -1459,6 +1475,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule return; } case SymmetricSyncMessage.MsgType.NewObject: + HandleAddNewObject(msg, senderActorID); + break; case SymmetricSyncMessage.MsgType.UpdatedObject: { HandleAddOrUpdateObjectBySynchronization(msg, senderActorID); @@ -1526,18 +1544,30 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_log.Debug(LogHeader + ": Synchronized terrain"); } + private void HandleAddNewObject(SymmetricSyncMessage msg, string senderActorID) + { + string sogxml = Encoding.ASCII.GetString(msg.Data, 0, msg.Length); + SceneObjectGroup sog = SceneObjectSerializer.FromXml2Format(sogxml); + + m_log.DebugFormat("{0}: received NewObject sync message from {1}, for object {1}, {2}", LogHeader, senderActorID, sog.Name, sog.UUID); + + Scene.ObjectUpdateResult updateResult = m_scene.AddOrUpdateObjectBySynchronization(sog); + } + private void HandleAddOrUpdateObjectBySynchronization(SymmetricSyncMessage msg, string senderActorID) { string sogxml = Encoding.ASCII.GetString(msg.Data, 0, msg.Length); SceneObjectGroup sog = SceneObjectSerializer.FromXml2Format(sogxml); //SYNC DEBUG + /* string partnames = ""; foreach (SceneObjectPart part in sog.Parts) { partnames += "(" + part.Name + ", " + part.UUID + ")"; } m_log.Debug(LogHeader+" received "+msg.Type.ToString()+" from "+senderActorID+" about obj "+sog.Name+", "+sog.UUID+"; parts -- "+partnames); + * */ if (sog.IsDeleted) { @@ -2039,7 +2069,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule /// OSDMap data of event args private void HandleRemoteEvent_OnObjectGrab(string actorID, ulong evSeqNum, OSDMap data) { - m_log.Debug(LogHeader + ", " + m_actorID + ": received GrabObject from " + actorID + ", seq " + evSeqNum); + // m_log.Debug(LogHeader + ", " + m_actorID + ": received GrabObject from " + actorID + ", seq " + evSeqNum); UUID agentID = data["agentID"].AsUUID(); @@ -2076,7 +2106,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private void HandleRemoteEvent_OnObjectGrabbing(string actorID, ulong evSeqNum, OSDMap data) { - m_log.Debug(LogHeader + ", " + m_actorID + ": received GrabObject from " + actorID + ", seq " + evSeqNum); + // m_log.Debug(LogHeader + ", " + m_actorID + ": received GrabObject from " + actorID + ", seq " + evSeqNum); UUID agentID = data["agentID"].AsUUID(); UUID primID = data["primID"].AsUUID(); @@ -2113,7 +2143,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private void HandleRemoteEvent_OnObjectDeGrab(string actorID, ulong evSeqNum, OSDMap data) { - m_log.Debug(LogHeader + ", " + m_actorID + ": received GrabObject from " + actorID + ", seq " + evSeqNum); + // m_log.Debug(LogHeader + ", " + m_actorID + ": received GrabObject from " + actorID + ", seq " + evSeqNum); UUID agentID = data["agentID"].AsUUID(); UUID primID = data["primID"].AsUUID(); diff --git a/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs index d6634db0da..b6aac1d6a8 100755 --- a/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs @@ -72,6 +72,7 @@ namespace OpenSim.Region.Framework.Interfaces //The folloiwng calls deal with object updates, and will insert each update into an outgoing queue of each SyncConnector void SendSceneUpdates(); + void SendNewObject(SceneObjectGroup sog); void SendDeleteObject(SceneObjectGroup sog, bool softDelete); void SendLinkObject(SceneObjectGroup linkedGroup, SceneObjectPart root, List children); void SendDeLinkObject(List prims, List beforeDelinkGroups, List afterDelinkGroups); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index eda4365930..941988f750 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -544,12 +544,15 @@ namespace OpenSim.Region.Framework.Scenes /////////////////////////////////////////////////////////////////////////////////////////////// + //!!! Obsolete function. Shouldn't be used anymore. + //This function should only be called by an actor who's local Scene is just a cache of the authorative Scene. //If the object already exists, use the new copy to replace it. //Return true if added, false if just updated public bool AddOrUpdateObjectInLocalScene(SceneObjectGroup sog, bool debugWithViewer) { - return m_sceneGraph.AddOrUpdateObjectInScene(sog, debugWithViewer); + return false; + //return m_sceneGraph.AddOrUpdateObjectInScene(sog, debugWithViewer); } diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 13bc6cd303..52913f66a1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -382,10 +382,6 @@ namespace OpenSim.Region.Framework.Scenes m_numPrim += children.Length; sceneObject.AttachToScene(m_parentScene); - - if (sendClientUpdates) - //sceneObject.ScheduleGroupForFullUpdate(); - sceneObject.ScheduleGroupForFullUpdate(new List(){SceneObjectPartProperties.None}); Entities.Add(sceneObject); @@ -409,6 +405,16 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; } + //SYMMETRIC SYNC: sending NewObject event, and sending it before calling ScheduleGroupForFullUpdate + if (m_parentScene.RegionSyncModule != null) + { + m_parentScene.RegionSyncModule.SendNewObject(sceneObject); + } + + if (sendClientUpdates) + //sceneObject.ScheduleGroupForFullUpdate(); + sceneObject.ScheduleGroupForFullUpdate(new List() { SceneObjectPartProperties.None }); + return true; } @@ -1948,6 +1954,7 @@ namespace OpenSim.Region.Framework.Scenes //Return false if the entity with the UUID is not a SceneObjectGroup, //otherwise, return true. + /* protected internal bool AddOrUpdateObjectInScene(SceneObjectGroup updatedSog, bool debugWithViewer) { UUID sogID = updatedSog.UUID; @@ -1989,6 +1996,7 @@ namespace OpenSim.Region.Framework.Scenes } } + * */ #endregion // REGION SYNC diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 18218e43cd..bcb57d4562 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -5528,8 +5528,8 @@ namespace OpenSim.Region.Framework.Scenes //SceneObjectPart localPart = this; PhysicsActor pa = localPart.PhysActor; - m_log.Debug("Received Physics Bucket updates for " + localPart.Name + ". GroupPosition: " + data["GroupPosition"].AsVector3().ToString() - + ", Position = " + data["Position"].AsVector3().ToString()); + //m_log.Debug("Received Physics Bucket updates for " + localPart.Name + ". GroupPosition: " + data["GroupPosition"].AsVector3().ToString() + // + ", Position = " + data["Position"].AsVector3().ToString()); //m_log.DebugFormat("{0}: PhysicsBucketUpdateProcessor. pos={1}", "[SCENE OBJECT PART]", data["Position"].AsVector3().ToString()); @@ -5779,7 +5779,7 @@ namespace OpenSim.Region.Framework.Scenes //Second, if need to update local properties, call each bucket's update process if (m_bucketUpdateProcessors.ContainsKey(bucketName)) { - m_log.Debug("Update properties in " + bucketName + " buckets"); + //m_log.Debug("Update properties in " + bucketName + " buckets"); m_bucketUpdateProcessors[bucketName](updatedPart, bucketName); partUpdateResult = Scene.ObjectUpdateResult.Updated; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index e693c25370..a3bd4cad64 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3567,14 +3567,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api item = m_host.TaskInventory[invItemID]; } - /* if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 && !m_automaticLinkPermission) { ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); return; } - */ IClientAPI client = null; ScenePresence sp = World.GetScenePresence(item.PermsGranter); From 9edbbf2728a24d2e8c95bf7f7cc8d3a778285fb0 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 11 Mar 2011 15:42:39 -0800 Subject: [PATCH 12/14] sync logging added to RegionSyncModule --- .../SymmetricSync/RegionSyncModule.cs | 64 +++++++++++++++++-- .../Framework/Scenes/SceneObjectPart.cs | 7 +- 2 files changed, 64 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 7a49ccde05..a782d4b19b 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -31,7 +31,7 @@ using OpenMetaverse.StructuredData; namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AttachmentsModule")] - public class RegionSyncModule : INonSharedRegionModule, IRegionSyncModule, ICommandableModule + public class RegionSyncModule : INonSharedRegionModule, IRegionSyncModule, ICommandableModule, ISyncStatistics //public class RegionSyncModule : IRegionModule, IRegionSyncModule, ICommandableModule { #region INonSharedRegionModule @@ -79,7 +79,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule SyncStatisticCollector.LogDirectory = m_sysConfig.GetString("SyncLogDirectory", "."); SyncStatisticCollector.LogInterval = m_sysConfig.GetInt("SyncLogInterval", 5000); SyncStatisticCollector.LogMaxFileTimeMin = m_sysConfig.GetInt("SyncLogMaxFileTimeMin", 5); - SyncStatisticCollector.LogFileHeader = m_sysConfig.GetString("SyncLogFileHeader", "stats-"); + SyncStatisticCollector.LogFileHeader = m_sysConfig.GetString("SyncLogFileHeader", "sync-"); } //Called after Initialise() @@ -129,6 +129,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Start symmetric synchronization initialization automatically //SyncStart(null); + + // connect to statistics system + SyncStatisticCollector.Register(this); } @@ -724,6 +727,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule sog.UpdateTaintedBucketSyncInfo(bucketName, DateTime.Now.Ticks); //this update the timestamp and clear the taint info of the bucket string sogxml = SceneObjectSerializer.ToXml2Format(sog); SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedObject, sogxml); + lock (m_stats) m_statSOGBucketOut++; SendObjectUpdateToRelevantSyncConnectors(sog, syncMsg); } } @@ -769,6 +773,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedBucketProperties, OSDParser.SerializeJsonString(data)); //m_log.DebugFormat("{0}: PhysBucketSender for {1}, pos={2}", LogHeader, updatedPart.UUID.ToString(), pa.Position.ToString()); + lock (m_stats) m_statPhysBucketOut++; SendObjectUpdateToRelevantSyncConnectors(updatedPart, syncMsg); } } @@ -1172,14 +1177,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_scene.EventManager.TriggerOnSymmetricSyncStop(); } } - - - } private void SyncStatus(Object[] args) { int connectorCount = 0; + m_log.Warn(LogHeader + ": " + this.StatisticTitle()); + m_log.Warn(LogHeader + ": " + this.StatisticLine(true)); ForEachSyncConnector(delegate(SyncConnector connector) { if (connectorCount++ == 0) @@ -1395,6 +1399,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule /// ActorID of the sender public void HandleIncomingMessage(SymmetricSyncMessage msg, string senderActorID) { + lock (m_stats) m_statMsgsIn++; //Added senderActorID, so that we don't have to include actorID in sync messages -- TODO switch (msg.Type) { @@ -1502,6 +1507,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { string sogxml = Encoding.ASCII.GetString(msg.Data, 0, msg.Length); SceneObjectGroup sog = SceneObjectSerializer.FromXml2Format(sogxml); + lock (m_stats) m_statSOGBucketIn++; if (sog.IsDeleted) { @@ -1542,6 +1548,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule return; } + lock (m_stats) m_statPhysBucketIn++; + UUID partUUID = data["UUID"].AsUUID(); string bucketName = data["Bucket"].AsString(); @@ -1774,6 +1782,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule return; } + lock (m_stats) m_statEventIn++; string init_actorID = data["actorID"].AsString(); ulong evSeqNum = data["seqNum"].AsULong(); @@ -2401,6 +2410,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule SymmetricSyncMessage rsm = new SymmetricSyncMessage(msgType, OSDParser.SerializeJsonString(data)); //send to actors who are interested in the event + lock (m_stats) m_statEventOut++; SendSceneEventToRelevantSyncConnectors(m_actorID, rsm); } @@ -2422,6 +2432,50 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule #endregion //RegionSyncModule members and functions + #region ISyncStatistics + private object m_stats = new object(); + private int m_statMsgsIn = 0; + private int m_statMsgsOut = 0; + private int m_statSOGBucketIn = 0; + private int m_statSOGBucketOut = 0; + private int m_statPhysBucketIn = 0; + private int m_statPhysBucketOut = 0; + private int m_statEventIn = 0; + private int m_statEventOut = 0; + public string StatisticIdentifier() + { + // RegionSyncModule(actor/region) + return "RegionSyncModule" + "(" + ActorID + "/" + m_scene.RegionInfo.RegionName + ")"; + } + + public string StatisticLine(bool clearFlag) + { + string statLine = ""; + lock (m_stats) + { + statLine = String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", + m_statMsgsIn, m_statMsgsOut, + m_statSOGBucketIn, m_statSOGBucketOut, + m_statPhysBucketIn, m_statPhysBucketOut, + m_statEventIn, m_statEventOut + ); + if (clearFlag) + { + m_statMsgsIn = m_statMsgsOut = 0; + m_statSOGBucketIn = m_statSOGBucketOut = 0; + m_statPhysBucketIn = m_statPhysBucketOut = 0; + m_statEventIn = m_statEventOut = 0; + } + } + return statLine; + } + + public string StatisticTitle() + { + return "MsgsIn,MsgsOut,SOGIn,SOGOut,PhysIn,PhysOut,EventIn,EventOut"; + } + #endregion ISyncStatistics + } public class RegionSyncListenerInfo diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4bcef483d2..a890ffda60 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2795,7 +2795,7 @@ namespace OpenSim.Region.Framework.Scenes m_parentGroup.AbsolutePosition = newpos; return; } - m_log.DebugFormat("[PHYSICS]: TerseUpdate: UUID={0}, newpos={1}", PhysActor.UUID.ToString(), newpos.ToString()); + // m_log.DebugFormat("[PHYSICS]: TerseUpdate: UUID={0}, newpos={1}", PhysActor.UUID.ToString(), newpos.ToString()); //m_parentGroup.RootPart.m_groupPosition = newpos; } //ScheduleTerseUpdate(); @@ -5513,7 +5513,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart localPart = this; PhysicsActor pa = localPart.PhysActor; - //m_log.DebugFormat("{0}: PhysicsBucketUpdateProcessor. pos={1}", "[SCENE OBJECT PART]", data["Position"].AsVector3().ToString()); + // m_log.DebugFormat("{0}: PhysicsBucketUpdateProcessor. pos={1}", "[SCENE OBJECT PART]", data["Position"].AsVector3().ToString()); lock (m_bucketUpdateLocks[bucketName]) { @@ -5612,12 +5612,15 @@ namespace OpenSim.Region.Framework.Scenes { bucketSynInfo.TaintBucket(); } + // m_log.DebugFormat("{0}: TaintBucketSyncInfo: FullUpdate", "[SCENE OBJECT PART]"); } else { string bucketName = m_primPropertyBucketMap[property]; //m_bucketSyncTainted[bucketName] = true; m_bucketSyncInfoList[bucketName].TaintBucket(); + // m_log.DebugFormat("{0}: TaintBucketSyncInfo: tainting bucket {1} for {2}", + // "[SCENE OBJECT PART]", bucketName, property.ToString()); } } } From e72f08e02a0f49254d51350bae65236a0e6b2e01 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 11 Mar 2011 15:56:33 -0800 Subject: [PATCH 13/14] Default physics logging to off --- .../RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs index 32262c0232..a4e34b5166 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs @@ -681,7 +681,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule #region Message Logging public static bool logInput = false; public static bool logOutput = true; - public static bool logEnabled = true; + public static bool logEnabled = false; private class PhysMsgLogger { public DateTime startTime; From 4803745c0d726cdd1d5b1fd78350dce7c51db87c Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 11 Mar 2011 16:29:10 -0800 Subject: [PATCH 14/14] Added logic in RegionSyncModule so that a SyncRelay node (e.g. PSA) only sends out updates for a bucket that has properties updated in the last update interval. --- .../SymmetricSync/RegionSyncModule.cs | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index f95b53f3d7..bd33b5aaec 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -198,16 +198,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule foreach (string bucketName in m_propertyBucketNames) { - if (m_isSyncRelay || part.HasPropertyUpdatedLocallyInGivenBucket(bucketName)) + //if (m_isSyncRelay || part.HasPropertyUpdatedLocallyInGivenBucket(bucketName)) + if(ToSendoutUpdate(part, bucketName)) { lock (m_primUpdateLocks[bucketName]) { - //m_log.Debug("Queueing to bucket " + bucketName + " with part " + part.Name + ", " + part.UUID); + m_log.Debug("Queueing to bucket " + bucketName + " with part " + part.Name + ", " + part.UUID); m_primUpdates[bucketName][part.UUID] = part; } } - } - + } } @@ -708,6 +708,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private delegate void PrimUpdatePerBucketSender(string bucketName, List primUpdates); private Dictionary m_primUpdatesPerBucketSender = new Dictionary(); + //Timestamps that record the last time each any updates have been sent out for a given bucket + private Dictionary m_lastUpdateSentTime = new Dictionary(); private object m_updateScenePresenceLock = new object(); private Dictionary m_presenceUpdates = new Dictionary(); @@ -735,6 +737,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Going forward, we may serialize the properties differently, e.g. using OSDMap private void PrimUpdatesGeneralBucketSender(string bucketName, List primUpdates) { + UpdateBucektLastSentTime(bucketName); + Dictionary updatedObjects = new Dictionary(); foreach (SceneObjectPart part in primUpdates) { @@ -747,10 +751,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedObject, sogxml); SendObjectUpdateToRelevantSyncConnectors(sog, syncMsg); } + } private void PrimUpdatesPhysicsBucketSender(string bucketName, List primUpdates) { + UpdateBucektLastSentTime(bucketName); + foreach (SceneObjectPart updatedPart in primUpdates) { updatedPart.UpdateTaintedBucketSyncInfo(bucketName, DateTime.Now.Ticks); @@ -796,7 +803,39 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //m_log.DebugFormat("{0}: PhysBucketSender for {1}, pos={2}", LogHeader, updatedPart.UUID.ToString(), pa.Position.ToString()); SendObjectUpdateToRelevantSyncConnectors(updatedPart, syncMsg); } + } + + private void UpdateBucektLastSentTime(string bucketName) + { + long timeStamp = DateTime.Now.Ticks; + /* + if (m_lastUpdateSentTime.ContainsKey(bucketName)) + { + m_lastUpdateSentTime[bucketName] = timeStamp; + } + else + { + m_lastUpdateSentTime.Add(bucketName, timeStamp); + } + * */ + m_lastUpdateSentTime[bucketName] = timeStamp; + } + + private bool ToSendoutUpdate(SceneObjectPart part, string bucketName) + { + if (!m_isSyncRelay) + { + return part.HasPropertyUpdatedLocallyInGivenBucket(bucketName); + } + + //if this is a relay node, forward out the updates that have not been sent out since lastUpdateSentTime + if (m_lastUpdateSentTime[bucketName] <= part.BucketSyncInfoList[bucketName].LastUpdateTimeStamp) + return true; + else + return false; + } + //If nothing configured in the config file, this is the default settings for grouping properties into different bucket private void PopulatePropertyBuketMapByDefault() { @@ -811,6 +850,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_primUpdatesPerBucketSender.Add("General", PrimUpdatesGeneralBucketSender); m_primUpdatesPerBucketSender.Add("Physics", PrimUpdatesPhysicsBucketSender); + m_lastUpdateSentTime.Add("General", 0); + m_lastUpdateSentTime.Add("Physics", 0); + //Mapping properties to buckets. foreach (SceneObjectPartProperties property in Enum.GetValues(typeof(SceneObjectPartProperties))) {