Merge branch 'master' into newmultiattach

Conflicts:
	OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
This commit is contained in:
Melanie
2013-03-18 23:31:27 +00:00
88 changed files with 2112 additions and 9616 deletions

View File

@@ -140,9 +140,12 @@ public class ServerStats : ISharedRegionModule
}
#endregion ISharedRegionModule
private void MakeStat(string pName, string pUnit, string pContainer, Action<Stat> act)
private void MakeStat(string pName, string pDesc, string pUnit, string pContainer, Action<Stat> act)
{
Stat stat = new Stat(pName, pName, "", pUnit, CategoryServer, pContainer, StatType.Pull, act, StatVerbosity.Info);
string desc = pDesc;
if (desc == null)
desc = pName;
Stat stat = new Stat(pName, pName, desc, pUnit, CategoryServer, pContainer, StatType.Pull, act, StatVerbosity.Info);
StatsManager.RegisterStat(stat);
RegisteredStats.Add(pName, stat);
}
@@ -166,16 +169,16 @@ public class ServerStats : ISharedRegionModule
StatsManager.RegisterStat(tempStat);
RegisteredStats.Add(tempName, tempStat);
MakeStat("TotalProcessorTime", "sec", ContainerProcessor,
MakeStat("TotalProcessorTime", null, "sec", ContainerProcessor,
(s) => { s.Value = Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds; });
MakeStat("UserProcessorTime", "sec", ContainerProcessor,
MakeStat("UserProcessorTime", null, "sec", ContainerProcessor,
(s) => { s.Value = Process.GetCurrentProcess().UserProcessorTime.TotalSeconds; });
MakeStat("PrivilegedProcessorTime", "sec", ContainerProcessor,
MakeStat("PrivilegedProcessorTime", null, "sec", ContainerProcessor,
(s) => { s.Value = Process.GetCurrentProcess().PrivilegedProcessorTime.TotalSeconds; });
MakeStat("Threads", "threads", ContainerProcessor,
MakeStat("Threads", null, "threads", ContainerProcessor,
(s) => { s.Value = Process.GetCurrentProcess().Threads.Count; });
}
catch (Exception e)
@@ -196,8 +199,10 @@ public class ServerStats : ISharedRegionModule
string nicInterfaceType = nic.NetworkInterfaceType.ToString();
if (!okInterfaceTypes.Contains(nicInterfaceType))
{
m_log.DebugFormat("{0} Not including stats for network interface '{1}' of type '{2}'. To include, add to [Monitoring]NetworkInterfaceTypes='Ethernet,Loopback'",
m_log.DebugFormat("{0} Not including stats for network interface '{1}' of type '{2}'.",
LogHeader, nic.Name, nicInterfaceType);
m_log.DebugFormat("{0} To include, add to comma separated list in [Monitoring]NetworkInterfaceTypes={1}",
LogHeader, NetworkInterfaceTypes);
continue;
}
@@ -206,14 +211,15 @@ public class ServerStats : ISharedRegionModule
IPv4InterfaceStatistics nicStats = nic.GetIPv4Statistics();
if (nicStats != null)
{
MakeStat("BytesRcvd/" + nic.Name, "KB", ContainerNetwork,
MakeStat("BytesRcvd/" + nic.Name, nic.Name, "KB", ContainerNetwork,
(s) => { LookupNic(s, (ns) => { return ns.BytesReceived; }, 1024.0); });
MakeStat("BytesSent/" + nic.Name, "KB", ContainerNetwork,
MakeStat("BytesSent/" + nic.Name, nic.Name, "KB", ContainerNetwork,
(s) => { LookupNic(s, (ns) => { return ns.BytesSent; }, 1024.0); });
MakeStat("TotalBytes/" + nic.Name, "KB", ContainerNetwork,
MakeStat("TotalBytes/" + nic.Name, nic.Name, "KB", ContainerNetwork,
(s) => { LookupNic(s, (ns) => { return ns.BytesSent + ns.BytesReceived; }, 1024.0); });
}
}
// TODO: add IPv6 (it may actually happen someday)
}
}
catch (Exception e)
@@ -221,13 +227,13 @@ public class ServerStats : ISharedRegionModule
m_log.ErrorFormat("{0} Exception creating 'Network Interface': {1}", LogHeader, e);
}
MakeStat("ProcessMemory", "MB", ContainerMemory,
MakeStat("ProcessMemory", null, "MB", ContainerMemory,
(s) => { s.Value = Process.GetCurrentProcess().WorkingSet64 / 1024d / 1024d; });
MakeStat("ObjectMemory", "MB", ContainerMemory,
MakeStat("ObjectMemory", null, "MB", ContainerMemory,
(s) => { s.Value = GC.GetTotalMemory(false) / 1024d / 1024d; });
MakeStat("LastMemoryChurn", "MB/sec", ContainerMemory,
MakeStat("LastMemoryChurn", null, "MB/sec", ContainerMemory,
(s) => { s.Value = Math.Round(MemoryWatchdog.LastMemoryChurn * 1000d / 1024d / 1024d, 3); });
MakeStat("AverageMemoryChurn", "MB/sec", ContainerMemory,
MakeStat("AverageMemoryChurn", null, "MB/sec", ContainerMemory,
(s) => { s.Value = Math.Round(MemoryWatchdog.AverageMemoryChurn * 1000d / 1024d / 1024d, 3); });
}
@@ -263,6 +269,8 @@ public class ServerStats : ISharedRegionModule
}
}
// Lookup the nic that goes with this stat and set the value by using a fetch action.
// Not sure about closure with delegates inside delegates.
private delegate double GetIPv4StatValue(IPv4InterfaceStatistics interfaceStat);
private void LookupNic(Stat stat, GetIPv4StatValue getter, double factor)
{
@@ -275,7 +283,10 @@ public class ServerStats : ISharedRegionModule
{
IPv4InterfaceStatistics intrStats = nic.GetIPv4Statistics();
if (intrStats != null)
stat.Value = Math.Round(getter(intrStats) / factor, 3);
{
double newVal = Math.Round(getter(intrStats) / factor, 3);
stat.Value = newVal;
}
break;
}
}

View File

@@ -145,7 +145,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
///
/// </summary>
// -----------------------------------------------------------------
public JsonStoreNodeType PathType(string expr)
public JsonStoreNodeType GetNodeType(string expr)
{
Stack<string> path;
if (! ParsePathExpression(expr,out path))
@@ -168,6 +168,43 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
return JsonStoreNodeType.Undefined;
}
// -----------------------------------------------------------------
/// <summary>
///
/// </summary>
// -----------------------------------------------------------------
public JsonStoreValueType GetValueType(string expr)
{
Stack<string> path;
if (! ParsePathExpression(expr,out path))
return JsonStoreValueType.Undefined;
OSD result = ProcessPathExpression(ValueStore,path);
if (result == null)
return JsonStoreValueType.Undefined;
if (result is OSDMap)
return JsonStoreValueType.Undefined;
if (result is OSDArray)
return JsonStoreValueType.Undefined;
if (result is OSDBoolean)
return JsonStoreValueType.Boolean;
if (result is OSDInteger)
return JsonStoreValueType.Integer;
if (result is OSDReal)
return JsonStoreValueType.Float;
if (result is OSDString)
return JsonStoreValueType.String;
return JsonStoreValueType.Undefined;
}
// -----------------------------------------------------------------
/// <summary>
///

View File

@@ -270,7 +270,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
///
/// </summary>
// -----------------------------------------------------------------
public JsonStoreNodeType GetPathType(UUID storeID, string path)
public JsonStoreNodeType GetNodeType(UUID storeID, string path)
{
if (! m_enabled) return JsonStoreNodeType.Undefined;
@@ -287,7 +287,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
try
{
lock (map)
return map.PathType(path);
return map.GetNodeType(path);
}
catch (Exception e)
{
@@ -297,6 +297,38 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
return JsonStoreNodeType.Undefined;
}
// -----------------------------------------------------------------
/// <summary>
///
/// </summary>
// -----------------------------------------------------------------
public JsonStoreValueType GetValueType(UUID storeID, string path)
{
if (! m_enabled) return JsonStoreValueType.Undefined;
JsonStore map = null;
lock (m_JsonValueStore)
{
if (! m_JsonValueStore.TryGetValue(storeID,out map))
{
m_log.InfoFormat("[JsonStore] Missing store {0}",storeID);
return JsonStoreValueType.Undefined;
}
}
try
{
lock (map)
return map.GetValueType(path);
}
catch (Exception e)
{
m_log.Error(string.Format("[JsonStore]: Path test failed for {0} in {1}", path, storeID), e);
}
return JsonStoreValueType.Undefined;
}
// -----------------------------------------------------------------
/// <summary>
///

View File

@@ -192,16 +192,32 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
#region ScriptConstantsInterface
[ScriptConstant]
public static readonly int JSON_TYPE_UNDEF = (int)JsonStoreNodeType.Undefined;
public static readonly int JSON_NODETYPE_UNDEF = (int)JsonStoreNodeType.Undefined;
[ScriptConstant]
public static readonly int JSON_TYPE_OBJECT = (int)JsonStoreNodeType.Object;
public static readonly int JSON_NODETYPE_OBJECT = (int)JsonStoreNodeType.Object;
[ScriptConstant]
public static readonly int JSON_TYPE_ARRAY = (int)JsonStoreNodeType.Array;
public static readonly int JSON_NODETYPE_ARRAY = (int)JsonStoreNodeType.Array;
[ScriptConstant]
public static readonly int JSON_TYPE_VALUE = (int)JsonStoreNodeType.Value;
public static readonly int JSON_NODETYPE_VALUE = (int)JsonStoreNodeType.Value;
[ScriptConstant]
public static readonly int JSON_VALUETYPE_UNDEF = (int)JsonStoreValueType.Undefined;
[ScriptConstant]
public static readonly int JSON_VALUETYPE_BOOLEAN = (int)JsonStoreValueType.Boolean;
[ScriptConstant]
public static readonly int JSON_VALUETYPE_INTEGER = (int)JsonStoreValueType.Integer;
[ScriptConstant]
public static readonly int JSON_VALUETYPE_FLOAT = (int)JsonStoreValueType.Float;
[ScriptConstant]
public static readonly int JSON_VALUETYPE_STRING = (int)JsonStoreValueType.String;
#endregion
@@ -310,9 +326,20 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
/// </summary>
// -----------------------------------------------------------------
[ScriptInvocation]
public int JsonGetPathType(UUID hostID, UUID scriptID, UUID storeID, string path)
public int JsonGetNodeType(UUID hostID, UUID scriptID, UUID storeID, string path)
{
return (int)m_store.GetPathType(storeID,path);
return (int)m_store.GetNodeType(storeID,path);
}
// -----------------------------------------------------------------
/// <summary>
///
/// </summary>
// -----------------------------------------------------------------
[ScriptInvocation]
public int JsonGetValueType(UUID hostID, UUID scriptID, UUID storeID, string path)
{
return (int)m_store.GetValueType(storeID,path);
}
// -----------------------------------------------------------------

View File

@@ -158,8 +158,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
Assert.That(dsrv, Is.EqualTo(1));
int tprv = (int)InvokeOp("JsonGetPathType", storeId, "Hello");
Assert.That(tprv, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
int tprv = (int)InvokeOp("JsonGetNodeType", storeId, "Hello");
Assert.That(tprv, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_UNDEF));
}
[Test]
@@ -277,8 +277,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello");
Assert.That(returnValue, Is.EqualTo(1));
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_UNDEF));
string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello");
Assert.That(returnValue2, Is.EqualTo(""));
@@ -291,8 +291,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello");
Assert.That(returnValue, Is.EqualTo(1));
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_UNDEF));
string returnValue2 = (string)InvokeOp("JsonGetJson", storeId, "Hello");
Assert.That(returnValue2, Is.EqualTo(""));
@@ -306,11 +306,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello[0]");
Assert.That(returnValue, Is.EqualTo(1));
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello[0]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE));
int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello[0]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_VALUE));
result = (int)InvokeOp("JsonGetPathType", storeId, "Hello[1]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello[1]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_UNDEF));
string stringReturnValue = (string)InvokeOp("JsonGetValue", storeId, "Hello[0]");
Assert.That(stringReturnValue, Is.EqualTo("value2"));
@@ -433,7 +433,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
}
[Test]
public void TestJsonGetPathType()
public void TestJsonGetNodeType()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
@@ -441,41 +441,41 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }");
{
int result = (int)InvokeOp("JsonGetPathType", storeId, ".");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT));
int result = (int)InvokeOp("JsonGetNodeType", storeId, ".");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_OBJECT));
}
{
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT));
int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_OBJECT));
}
{
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_ARRAY));
int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello.World");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_ARRAY));
}
{
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[0]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE));
int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello.World[0]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_VALUE));
}
{
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[1]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE));
int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello.World[1]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_VALUE));
}
// Test for non-existant path
{
int result = (int)InvokeOp("JsonGetPathType", storeId, "foo");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
int result = (int)InvokeOp("JsonGetNodeType", storeId, "foo");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_UNDEF));
}
// Test for non-existant store
{
UUID fakeStoreId = TestHelpers.ParseTail(0x500);
int result = (int)InvokeOp("JsonGetPathType", fakeStoreId, ".");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
int result = (int)InvokeOp("JsonGetNodeType", fakeStoreId, ".");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_UNDEF));
}
}