Remove chatty debug messages. Damp update value checking. Physics sync message logging.

dsg
Robert Adams 2010-12-20 14:06:14 -08:00
parent 420aeb9b6a
commit e1c3650634
8 changed files with 114 additions and 17 deletions

View File

@ -108,6 +108,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//m_statsTimer.Elapsed += new System.Timers.ElapsedEventHandler(StatsTimerElapsed); //m_statsTimer.Elapsed += new System.Timers.ElapsedEventHandler(StatsTimerElapsed);
m_sysConfig = sysConfig; m_sysConfig = sysConfig;
logEnabled = m_sysConfig.GetBoolean("LogEnabled", false);
logDir = m_sysConfig.GetString("LogDir", ".");
//assume we are connecting to the whole scene as one big quark //assume we are connecting to the whole scene as one big quark
m_subscribedQuarks = new QuarkSubsriptionInfo(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize); m_subscribedQuarks = new QuarkSubsriptionInfo(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize);
} }
@ -255,7 +258,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_client.Client.Close(); m_client.Client.Close();
m_client.Close(); m_client.Close();
} }
LogMessageClose();
} }
// Listen for messages from a RegionSyncServer // Listen for messages from a RegionSyncServer
@ -298,12 +301,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
// Send a message to a single connected RegionSyncServer // Send a message to a single connected RegionSyncServer
private void Send(string msg) private void Send(string msg)
{ {
LogMessage(logOutput, msg);
byte[] bmsg = System.Text.Encoding.ASCII.GetBytes(msg + System.Environment.NewLine); byte[] bmsg = System.Text.Encoding.ASCII.GetBytes(msg + System.Environment.NewLine);
Send(bmsg); Send(bmsg);
} }
private void Send(RegionSyncMessage msg) private void Send(RegionSyncMessage msg)
{ {
LogMessage(logOutput, msg);
Send(msg.ToBytes()); Send(msg.ToBytes());
//m_log.WarnFormat("{0} Sent {1}", LogHeader, msg.ToString()); //m_log.WarnFormat("{0} Sent {1}", LogHeader, msg.ToString());
} }
@ -342,6 +347,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{ {
//TO FINISH: //TO FINISH:
LogMessage(logInput, msg);
switch (msg.Type) switch (msg.Type)
{ {
case RegionSyncMessage.MsgType.RegionName: case RegionSyncMessage.MsgType.RegionName:
@ -378,7 +384,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
PhysicsActor pa = FindPhysicsActor(localID); PhysicsActor pa = FindPhysicsActor(localID);
if (pa != null) if (pa != null)
{ {
pa.Size = data["size"].AsVector3(); Vector3 sizeTemp = data["size"].AsVector3();
if (sizeTemp.Z != 0)
{
// pa.Size = sizeTemp;
}
pa.Position = data["position"].AsVector3(); pa.Position = data["position"].AsVector3();
pa.Force = data["force"].AsVector3(); pa.Force = data["force"].AsVector3();
pa.Velocity = data["velocity"].AsVector3(); pa.Velocity = data["velocity"].AsVector3();
@ -509,7 +519,84 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
} }
#endregion Handlers for events/updates from Scene #endregion Handlers for events/updates from Scene
#region Message Logging
private bool logInput = false;
private bool logOutput = true;
private bool logEnabled = true;
private class MsgLogger
{
public DateTime startTime;
public string path = null;
public System.IO.TextWriter Log = null;
}
private MsgLogger logWriter = null;
private TimeSpan logMaxFileTime = new TimeSpan(0, 5, 0); // (h,m,s) => 5 minutes
private string logDir = "/stats/stats";
private object logLocker = new Object();
private void LogMessage(bool direction, RegionSyncMessage rsm)
{
if (!logEnabled) return; // save to work of the ToStringFull if not enabled
LogMessage(direction, rsm.ToStringFull());
}
private void LogMessage(bool direction, string msg)
{
if (!logEnabled) return;
lock (logLocker)
{
try
{
DateTime now = DateTime.Now;
if (logWriter == null || (now > logWriter.startTime + logMaxFileTime))
{
if (logWriter != null && logWriter.Log != null)
{
logWriter.Log.Close();
logWriter.Log.Dispose();
logWriter.Log = null;
}
// First log file or time has expired, start writing to a new log file
logWriter = new MsgLogger();
logWriter.startTime = now;
logWriter.path = (logDir.Length > 0 ? logDir + System.IO.Path.DirectorySeparatorChar.ToString() : "")
+ String.Format("physics-{0}.log", now.ToString("yyyyMMddHHmmss"));
logWriter.Log = new StreamWriter(File.Open(logWriter.path, FileMode.Append, FileAccess.Write));
}
if (logWriter != null && logWriter.Log != null)
{
StringBuilder buff = new StringBuilder();
buff.Append(now.ToString("yyyyMMddHHmmss"));
buff.Append(" ");
buff.Append(direction ? "A->S:" : "S->A:");
buff.Append(msg);
buff.Append("\r\n");
logWriter.Log.Write(buff.ToString());
}
}
catch (Exception e)
{
m_log.ErrorFormat("{0}: FAILURE WRITING TO LOGFILE: {1}", LogHeader, e);
logEnabled = false;
}
}
return;
}
private void LogMessageClose()
{
if (logWriter != null && logWriter.Log != null)
{
logWriter.Log.Close();
logWriter.Log.Dispose();
logWriter.Log = null;
logWriter = null;
}
logEnabled = false;
}
#endregion Message Logging
} }
} }

View File

@ -1023,7 +1023,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
public void HandleGrabObject(uint localID, Vector3 offsetPos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs) public void HandleGrabObject(uint localID, Vector3 offsetPos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
{ {
m_log.DebugFormat("[REGION SYNC CLIENT] HandleGrabObject for {0}", remoteClient.AgentId.ToString()); // m_log.DebugFormat("[REGION SYNC CLIENT] HandleGrabObject for {0}", remoteClient.AgentId.ToString());
OSDMap data = new OSDMap(4); OSDMap data = new OSDMap(4);
data["agentID"] = OSD.FromUUID(remoteClient.AgentId); data["agentID"] = OSD.FromUUID(remoteClient.AgentId);
data["localID"] = OSD.FromUInteger(localID); data["localID"] = OSD.FromUInteger(localID);
@ -1034,7 +1034,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
public void HandleGrabUpdate(UUID objectID, Vector3 offset, Vector3 pos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs) public void HandleGrabUpdate(UUID objectID, Vector3 offset, Vector3 pos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
{ {
m_log.DebugFormat("[REGION SYNC CLIENT] HandleGrabUpdate for {0}", remoteClient.AgentId.ToString()); // m_log.DebugFormat("[REGION SYNC CLIENT] HandleGrabUpdate for {0}", remoteClient.AgentId.ToString());
OSDMap data = new OSDMap(5); OSDMap data = new OSDMap(5);
data["agentID"] = OSD.FromUUID(remoteClient.AgentId); data["agentID"] = OSD.FromUUID(remoteClient.AgentId);
data["objectID"] = OSD.FromUUID(objectID); data["objectID"] = OSD.FromUUID(objectID);
@ -1046,7 +1046,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
public void HandleDeGrabObject(uint localID, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs) public void HandleDeGrabObject(uint localID, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
{ {
m_log.DebugFormat("[REGION SYNC CLIENT] HandleDeGrabObject for {0}", remoteClient.AgentId.ToString()); // m_log.DebugFormat("[REGION SYNC CLIENT] HandleDeGrabObject for {0}", remoteClient.AgentId.ToString());
OSDMap data = new OSDMap(3); OSDMap data = new OSDMap(3);
data["agentID"] = OSD.FromUUID(remoteClient.AgentId); data["agentID"] = OSD.FromUUID(remoteClient.AgentId);
data["localID"] = OSD.FromUInteger(localID); data["localID"] = OSD.FromUInteger(localID);

View File

@ -656,8 +656,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
} }
UUID agentID = data["agentID"].AsUUID(); UUID agentID = data["agentID"].AsUUID();
UUID objectID = data["objectID"].AsUUID(); UUID objectID = data["objectID"].AsUUID();
m_log.DebugFormat("{0} GrabUpdate for {1}. ObjectID={2}", // m_log.DebugFormat("{0} GrabUpdate for {1}. ObjectID={2}",
LogHeader, agentID.ToString(), objectID.ToString()); // LogHeader, agentID.ToString(), objectID.ToString());
Vector3 offset = data["offset"].AsVector3(); Vector3 offset = data["offset"].AsVector3();
Vector3 pos = data["pos"].AsVector3(); Vector3 pos = data["pos"].AsVector3();
OSDArray surfaceArray = (OSDArray)data["surfaceArgs"]; OSDArray surfaceArray = (OSDArray)data["surfaceArgs"];

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Text;
using System.IO; using System.IO;
using OpenMetaverse; using OpenMetaverse;
using log4net; using log4net;
@ -205,6 +206,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{ {
return String.Format("{0} ({1} bytes)", m_type.ToString(), m_data.Length.ToString()); return String.Format("{0} ({1} bytes)", m_type.ToString(), m_data.Length.ToString());
} }
public string ToStringFull()
{
return String.Format("{0}:{1})", m_type.ToString(), Encoding.ASCII.GetString(m_data));
}
#endregion #endregion
public static void HandleSuccess(string header, RegionSyncMessage msg, string message) public static void HandleSuccess(string header, RegionSyncMessage msg, string message)

View File

@ -156,6 +156,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//m_scene.EventManager.OnRezScript += SEConnectorOnRezScript; //m_scene.EventManager.OnRezScript += SEConnectorOnRezScript;
//m_scene.EventManager.OnScriptReset += SEConnectorOnScriptReset; //m_scene.EventManager.OnScriptReset += SEConnectorOnScriptReset;
//m_scene.EventManager.OnUpdateScript += SEConnectorOnUpdateScript; //m_scene.EventManager.OnUpdateScript += SEConnectorOnUpdateScript;
// Create a thread for the receive loop // Create a thread for the receive loop
m_receive_loop = new Thread(new ThreadStart(delegate() { ReceiveLoop(); })); m_receive_loop = new Thread(new ThreadStart(delegate() { ReceiveLoop(); }));
m_receive_loop.Name = Description; m_receive_loop.Name = Description;

View File

@ -273,10 +273,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
public void SendUpdate(PhysicsActor pa) public void SendUpdate(PhysicsActor pa)
{ {
// m_log.DebugFormat("{0}: SendUpdate for {1}", LogHeader, pa.LocalID); // m_log.DebugFormat("{0}: SendUpdate for {1}", LogHeader, pa.LocalID);
if (pa.lastValues.Changed(pa)) this.m_sceneToPhysEngineConnector.SendPhysUpdateAttributes(pa);
{
this.m_sceneToPhysEngineConnector.SendPhysUpdateAttributes(pa);
}
} }
#endregion #endregion

View File

@ -137,16 +137,23 @@ namespace OpenSim.Region.Physics.Manager
bool ret = false; bool ret = false;
if (localID != pa.LocalID) { localID = pa.LocalID; ret = true; } if (localID != pa.LocalID) { localID = pa.LocalID; ret = true; }
if (size != pa.Size) { size = pa.Size; ret = true; } if (size != pa.Size) { size = pa.Size; ret = true; }
if (position != pa.Position) { position = pa.Position; ret = true; } if (!AlmostEqual(position, pa.Position)) { position = pa.Position; ret = true; }
if (force != pa.Force) { force = pa.Force; ret = true; } if (!AlmostEqual(force, pa.Force)) { force = pa.Force; ret = true; }
if (velocity != pa.Velocity) { velocity = pa.Velocity; ret = true; } if (!AlmostEqual(velocity, pa.Velocity)) { velocity = pa.Velocity; ret = true; }
if (torque != pa.Torque) { torque = pa.Torque; ret = true; } if (!AlmostEqual(torque, pa.Torque)) { torque = pa.Torque; ret = true; }
if (orientation != pa.Orientation) { orientation = pa.Orientation; ret = true; } if (orientation != pa.Orientation) { orientation = pa.Orientation; ret = true; }
if (isPhysical != pa.IsPhysical) { isPhysical = pa.IsPhysical; ret = true; } if (isPhysical != pa.IsPhysical) { isPhysical = pa.IsPhysical; ret = true; }
if (flying != pa.Flying) { flying = pa.Flying; ret = true; } if (flying != pa.Flying) { flying = pa.Flying; ret = true; }
if (buoyancy != pa.Buoyancy) { buoyancy = pa.Buoyancy; ret = true; } if (buoyancy != pa.Buoyancy) { buoyancy = pa.Buoyancy; ret = true; }
return ret; return ret;
} }
private bool AlmostEqual(Vector3 a, Vector3 b)
{
if (Math.Abs(a.X - b.X) > 0.001) return false;
if (Math.Abs(a.Y - b.Y) > 0.001) return false;
if (Math.Abs(a.Z - b.Z) > 0.001) return false;
return true;
}
} }
public abstract class PhysicsActor public abstract class PhysicsActor

View File

@ -102,7 +102,7 @@ public sealed class PEPrim : PhysicsActor
} }
public override uint LocalID { public override uint LocalID {
set { _localID = value; set { _localID = value;
m_log.Debug("[RPE] PEPrim set LocalID"); // m_log.Debug("[RPE] PEPrim set LocalID");
Prop.Set(_localID, PropType.LocalID, _localID); Prop.Set(_localID, PropType.LocalID, _localID);
} }
get { return _localID; } get { return _localID; }