diff --git a/.nant/local.include b/.nant/local.include
index 35f00589e8..5185717cbc 100644
--- a/.nant/local.include
+++ b/.nant/local.include
@@ -132,6 +132,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -235,6 +245,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -245,6 +265,7 @@
+
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index e5a6d49413..43dea0bd3b 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -93,6 +93,7 @@ what it is today.
* Garmin Kawaguichi
* Gryc Ueusp
* Hiro Lecker
+* Iain Oliver
* Imaze Rhiano
* Intimidated
* Jeremy Bongio (IBM)
diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
index cda4a94d13..1190bdcf55 100644
--- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
+++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
@@ -141,8 +141,6 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
// PostInilise can fire before the region is loaded, so need to
// track down the cause of that
Thread.Sleep(300);
- m_openSim.ModuleLoader.PostInitialise();
- m_openSim.ModuleLoader.ClearCache();
}
public void Dispose()
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 15fbdddb28..a75d10d417 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -2314,7 +2314,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
destinationItem.Description = item.Description;
destinationItem.InvType = item.InvType;
destinationItem.CreatorId = item.CreatorId;
- destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
destinationItem.CreatorData = item.CreatorData;
destinationItem.NextPermissions = item.NextPermissions;
destinationItem.CurrentPermissions = item.CurrentPermissions;
@@ -2369,7 +2368,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
destinationItem.Description = item.Description;
destinationItem.InvType = item.InvType;
destinationItem.CreatorId = item.CreatorId;
- destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
destinationItem.CreatorData = item.CreatorData;
destinationItem.NextPermissions = item.NextPermissions;
destinationItem.CurrentPermissions = item.CurrentPermissions;
@@ -2482,7 +2480,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
destinationItem.Description = item.Description;
destinationItem.InvType = item.InvType;
destinationItem.CreatorId = item.CreatorId;
- destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
destinationItem.CreatorData = item.CreatorData;
destinationItem.NextPermissions = item.NextPermissions;
destinationItem.CurrentPermissions = item.CurrentPermissions;
@@ -2788,7 +2785,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
inventoryItem.Description = GetStringAttribute(item,"desc","");
inventoryItem.InvType = GetIntegerAttribute(item,"invtype",-1);
inventoryItem.CreatorId = GetStringAttribute(item,"creatorid","");
- inventoryItem.CreatorIdAsUuid = (UUID)GetStringAttribute(item,"creatoruuid","");
inventoryItem.CreatorData = GetStringAttribute(item, "creatordata", "");
inventoryItem.NextPermissions = GetUnsignedAttribute(perms, "next", 0x7fffffff);
inventoryItem.CurrentPermissions = GetUnsignedAttribute(perms,"current",0x7fffffff);
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs
index 761e4e7564..d4d6d10d83 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs
@@ -42,7 +42,7 @@ using OpenSim.Tests.Common.Mock;
namespace OpenSim.Capabilities.Handlers.GetTexture.Tests
{
[TestFixture]
- public class GetTextureHandlerTests
+ public class GetTextureHandlerTests : OpenSimTestCase
{
[Test]
public void TestTextureNotFound()
diff --git a/OpenSim/Data/IXGroupData.cs b/OpenSim/Data/IXGroupData.cs
new file mode 100644
index 0000000000..2965e8cc3d
--- /dev/null
+++ b/OpenSim/Data/IXGroupData.cs
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * 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.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may 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 OpenMetaverse;
+using OpenSim.Framework;
+
+namespace OpenSim.Data
+{
+ public class XGroup
+ {
+ public UUID groupID;
+ public UUID ownerRoleID;
+ public string name;
+ public string charter;
+ public bool showInList;
+ public UUID insigniaID;
+ public int membershipFee;
+ public bool openEnrollment;
+ public bool allowPublish;
+ public bool maturePublish;
+ public UUID founderID;
+ public ulong everyonePowers;
+ public ulong ownersPowers;
+
+ public XGroup Clone()
+ {
+ return (XGroup)MemberwiseClone();
+ }
+ }
+
+ ///
+ /// Early stub interface for groups data, not final.
+ ///
+ ///
+ /// Currently in-use only for regression test purposes. Needs to be filled out over time.
+ ///
+ public interface IXGroupData
+ {
+ bool StoreGroup(XGroup group);
+ XGroup[] GetGroups(string field, string val);
+ XGroup[] GetGroups(string[] fields, string[] vals);
+ bool DeleteGroups(string field, string val);
+ bool DeleteGroups(string[] fields, string[] vals);
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
index 7ab0ebbe7b..9164ffe4e3 100644
--- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
@@ -122,7 +122,7 @@ namespace OpenSim.Data.MSSQL
}
}
- public class MSSQLItemHandler : MSSQLGenericTableHandler
+ public class MSSQLItemHandler : MSSQLInventoryHandler
{
public MSSQLItemHandler(string c, string t, string m) :
base(c, t, m)
@@ -131,6 +131,12 @@ namespace OpenSim.Data.MSSQL
public bool MoveItem(string id, string newParent)
{
+ XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id });
+ if (retrievedItems.Length == 0)
+ return false;
+
+ UUID oldParent = retrievedItems[0].parentFolderID;
+
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
{
using (SqlCommand cmd = new SqlCommand())
@@ -141,9 +147,16 @@ namespace OpenSim.Data.MSSQL
cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id));
cmd.Connection = conn;
conn.Open();
- return cmd.ExecuteNonQuery() == 0 ? false : true;
+
+ if (cmd.ExecuteNonQuery() == 0)
+ return false;
}
}
+
+ IncrementFolderVersion(oldParent);
+ IncrementFolderVersion(newParent);
+
+ return true;
}
public XInventoryItem[] GetActiveGestures(UUID principalID)
@@ -196,30 +209,13 @@ namespace OpenSim.Data.MSSQL
if (!base.Store(item))
return false;
- string sql = "update inventoryfolders set version=version+1 where folderID = @folderID";
- using (SqlConnection conn = new SqlConnection(m_ConnectionString))
- {
- using (SqlCommand cmd = new SqlCommand(sql, conn))
- {
- conn.Open();
+ IncrementFolderVersion(item.parentFolderID);
- cmd.Parameters.AddWithValue("@folderID", item.parentFolderID.ToString());
- try
- {
- cmd.ExecuteNonQuery();
- }
- catch (Exception)
- {
- return false;
- }
- }
-
- return true;
- }
+ return true;
}
}
- public class MSSQLFolderHandler : MSSQLGenericTableHandler
+ public class MSSQLFolderHandler : MSSQLInventoryHandler
{
public MSSQLFolderHandler(string c, string t, string m) :
base(c, t, m)
@@ -228,6 +224,13 @@ namespace OpenSim.Data.MSSQL
public bool MoveFolder(string id, string newParentFolderID)
{
+ XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id });
+
+ if (folders.Length == 0)
+ return false;
+
+ UUID oldParentFolderUUID = folders[0].parentFolderID;
+
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
{
using (SqlCommand cmd = new SqlCommand())
@@ -238,9 +241,65 @@ namespace OpenSim.Data.MSSQL
cmd.Parameters.Add(m_database.CreateParameter("@folderID", id));
cmd.Connection = conn;
conn.Open();
- return cmd.ExecuteNonQuery() == 0 ? false : true;
+
+ if (cmd.ExecuteNonQuery() == 0)
+ return false;
}
}
+
+ IncrementFolderVersion(oldParentFolderUUID);
+ IncrementFolderVersion(newParentFolderID);
+
+ return true;
+ }
+
+ public override bool Store(XInventoryFolder folder)
+ {
+ if (!base.Store(folder))
+ return false;
+
+ IncrementFolderVersion(folder.parentFolderID);
+
+ return true;
+ }
+ }
+
+ public class MSSQLInventoryHandler : MSSQLGenericTableHandler where T: class, new()
+ {
+ public MSSQLInventoryHandler(string c, string t, string m) : base(c, t, m) {}
+
+ protected bool IncrementFolderVersion(UUID folderID)
+ {
+ return IncrementFolderVersion(folderID.ToString());
+ }
+
+ protected bool IncrementFolderVersion(string folderID)
+ {
+// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
+// Util.PrintCallStack();
+
+ string sql = "update inventoryfolders set version=version+1 where folderID = ?folderID";
+
+ using (SqlConnection conn = new SqlConnection(m_ConnectionString))
+ {
+ using (SqlCommand cmd = new SqlCommand(sql, conn))
+ {
+ conn.Open();
+
+ cmd.Parameters.AddWithValue("@folderID", folderID);
+
+ try
+ {
+ cmd.ExecuteNonQuery();
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
}
}
}
\ No newline at end of file
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
index 7a3b5b4084..c74033eefc 100644
--- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
@@ -122,7 +122,7 @@ namespace OpenSim.Data.MySQL
}
}
- public class MySqlItemHandler : MySQLGenericTableHandler
+ public class MySqlItemHandler : MySqlInventoryHandler
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -241,47 +241,9 @@ namespace OpenSim.Data.MySQL
return true;
}
-
- private bool IncrementFolderVersion(UUID folderID)
- {
- return IncrementFolderVersion(folderID.ToString());
- }
-
- private bool IncrementFolderVersion(string folderID)
- {
-// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
-// Util.PrintCallStack();
-
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
- {
- dbcon.Open();
-
- using (MySqlCommand cmd = new MySqlCommand())
- {
- cmd.Connection = dbcon;
-
- cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID");
- cmd.Parameters.AddWithValue("?folderID", folderID);
-
- try
- {
- cmd.ExecuteNonQuery();
- }
- catch (Exception)
- {
- return false;
- }
- cmd.Dispose();
- }
-
- dbcon.Close();
- }
-
- return true;
- }
}
- public class MySqlFolderHandler : MySQLGenericTableHandler
+ public class MySqlFolderHandler : MySqlInventoryHandler
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -326,13 +288,18 @@ namespace OpenSim.Data.MySQL
return true;
}
+ }
- private bool IncrementFolderVersion(UUID folderID)
+ public class MySqlInventoryHandler : MySQLGenericTableHandler where T: class, new()
+ {
+ public MySqlInventoryHandler(string c, string t, string m) : base(c, t, m) {}
+
+ protected bool IncrementFolderVersion(UUID folderID)
{
return IncrementFolderVersion(folderID.ToString());
}
- private bool IncrementFolderVersion(string folderID)
+ protected bool IncrementFolderVersion(string folderID)
{
// m_log.DebugFormat("[MYSQL FOLDER HANDLER]: Incrementing version on folder {0}", folderID);
// Util.PrintCallStack();
diff --git a/OpenSim/Data/Null/NullGenericDataHandler.cs b/OpenSim/Data/Null/NullGenericDataHandler.cs
new file mode 100644
index 0000000000..dd9d190910
--- /dev/null
+++ b/OpenSim/Data/Null/NullGenericDataHandler.cs
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * 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.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may 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.Linq;
+using System.Reflection;
+using log4net;
+using OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Data;
+
+namespace OpenSim.Data.Null
+{
+ ///
+ /// Not a proper generic data handler yet - probably needs to actually store the data as well instead of relying
+ /// on descendent classes
+ ///
+ public class NullGenericDataHandler
+ {
+ protected List Get(string[] fields, string[] vals, List inputEntities)
+ {
+ List entities = inputEntities;
+
+ for (int i = 0; i < fields.Length; i++)
+ {
+ entities
+ = entities.Where(
+ e =>
+ {
+ FieldInfo fi = typeof(T).GetField(fields[i]);
+ if (fi == null)
+ throw new NotImplementedException(string.Format("No field {0} for val {1}", fields[i], vals[i]));
+
+ return fi.GetValue(e).ToString() == vals[i];
+ }
+ ).ToList();
+ }
+
+ return entities;
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Services/InventoryService/InventoryServiceBase.cs b/OpenSim/Data/Null/NullXGroupData.cs
similarity index 52%
rename from OpenSim/Services/InventoryService/InventoryServiceBase.cs
rename to OpenSim/Data/Null/NullXGroupData.cs
index 456e4557db..7a86b9f230 100644
--- a/OpenSim/Services/InventoryService/InventoryServiceBase.cs
+++ b/OpenSim/Data/Null/NullXGroupData.cs
@@ -26,57 +26,65 @@
*/
using System;
+using System.Collections;
using System.Collections.Generic;
+using System.Linq;
using System.Reflection;
-using Nini.Config;
+using System.Threading;
+using log4net;
+using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Data;
-using OpenSim.Services.Interfaces;
-using OpenSim.Services.Base;
-namespace OpenSim.Services.InventoryService
+namespace OpenSim.Data.Null
{
- public class InventoryServiceBase : ServiceBase
+ public class NullXGroupData : NullGenericDataHandler, IXGroupData
{
- protected IInventoryDataPlugin m_Database = null;
+// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- public InventoryServiceBase(IConfigSource config) : base(config)
+ private Dictionary m_groups = new Dictionary();
+
+ public NullXGroupData(string connectionString, string realm) {}
+
+ public bool StoreGroup(XGroup group)
{
- string dllName = String.Empty;
- string connString = String.Empty;
-
- //
- // Try reading the [DatabaseService] section first, if it exists
- //
- IConfig dbConfig = config.Configs["DatabaseService"];
- if (dbConfig != null)
+ lock (m_groups)
{
- dllName = dbConfig.GetString("StorageProvider", String.Empty);
- connString = dbConfig.GetString("ConnectionString", String.Empty);
+ m_groups[group.groupID] = group.Clone();
}
- //
- // Try reading the more specific [InventoryService] section, if it exists
- //
- IConfig inventoryConfig = config.Configs["InventoryService"];
- if (inventoryConfig != null)
- {
- dllName = inventoryConfig.GetString("StorageProvider", dllName);
- connString = inventoryConfig.GetString("ConnectionString", connString);
- }
-
- //
- // We tried, but this doesn't exist. We can't proceed.
- //
- if (dllName.Equals(String.Empty))
- throw new Exception("No InventoryService configuration");
-
- m_Database = LoadPlugin(dllName);
- if (m_Database == null)
- throw new Exception("Could not find a storage interface in the given module");
-
- m_Database.Initialise(connString);
+ return true;
}
+ public XGroup[] GetGroups(string field, string val)
+ {
+ return GetGroups(new string[] { field }, new string[] { val });
+ }
+
+ public XGroup[] GetGroups(string[] fields, string[] vals)
+ {
+ lock (m_groups)
+ {
+ List origGroups = Get(fields, vals, m_groups.Values.ToList());
+
+ return origGroups.Select(g => g.Clone()).ToArray();
+ }
+ }
+
+ public bool DeleteGroups(string field, string val)
+ {
+ return DeleteGroups(new string[] { field }, new string[] { val });
+ }
+
+ public bool DeleteGroups(string[] fields, string[] vals)
+ {
+ lock (m_groups)
+ {
+ XGroup[] groupsToDelete = GetGroups(fields, vals);
+ Array.ForEach(groupsToDelete, g => m_groups.Remove(g.groupID));
+ }
+
+ return true;
+ }
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
index 917a0a1504..9fbeb100ce 100644
--- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
+++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
@@ -120,12 +120,12 @@ namespace OpenSim.Data.SQLite
}
}
- public T[] Get(string field, string key)
+ public virtual T[] Get(string field, string key)
{
return Get(new string[] { field }, new string[] { key });
}
- public T[] Get(string[] fields, string[] keys)
+ public virtual T[] Get(string[] fields, string[] keys)
{
if (fields.Length != keys.Length)
return new T[0];
@@ -213,7 +213,7 @@ namespace OpenSim.Data.SQLite
return result.ToArray();
}
- public T[] Get(string where)
+ public virtual T[] Get(string where)
{
using (SqliteCommand cmd = new SqliteCommand())
{
@@ -226,7 +226,7 @@ namespace OpenSim.Data.SQLite
}
}
- public bool Store(T row)
+ public virtual bool Store(T row)
{
using (SqliteCommand cmd = new SqliteCommand())
{
@@ -270,7 +270,7 @@ namespace OpenSim.Data.SQLite
return Delete(new string[] { field }, new string[] { key });
}
- public bool Delete(string[] fields, string[] keys)
+ public virtual bool Delete(string[] fields, string[] keys)
{
if (fields.Length != keys.Length)
return false;
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
index 8eb1a63996..2a0a8f6cc9 100644
--- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
+++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
@@ -130,23 +130,79 @@ namespace OpenSim.Data.SQLite
}
}
- public class SqliteItemHandler : SQLiteGenericTableHandler
+ public class SqliteItemHandler : SqliteInventoryHandler
{
public SqliteItemHandler(string c, string t, string m) :
base(c, t, m)
{
}
+ public override bool Store(XInventoryItem item)
+ {
+ if (!base.Store(item))
+ return false;
+
+ IncrementFolderVersion(item.parentFolderID);
+
+ return true;
+ }
+
+ public override bool Delete(string field, string val)
+ {
+ XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val });
+ if (retrievedItems.Length == 0)
+ return false;
+
+ if (!base.Delete(field, val))
+ return false;
+
+ // Don't increment folder version here since Delete(string, string) calls Delete(string[], string[])
+// IncrementFolderVersion(retrievedItems[0].parentFolderID);
+
+ return true;
+ }
+
+ public override bool Delete(string[] fields, string[] vals)
+ {
+ XInventoryItem[] retrievedItems = Get(fields, vals);
+ if (retrievedItems.Length == 0)
+ return false;
+
+ if (!base.Delete(fields, vals))
+ return false;
+
+ HashSet deletedItemFolderUUIDs = new HashSet();
+
+ Array.ForEach(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID));
+
+ foreach (UUID deletedItemFolderUUID in deletedItemFolderUUIDs)
+ IncrementFolderVersion(deletedItemFolderUUID);
+
+ return true;
+ }
+
public bool MoveItem(string id, string newParent)
{
+ XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id });
+ if (retrievedItems.Length == 0)
+ return false;
+
+ UUID oldParent = retrievedItems[0].parentFolderID;
+
using (SqliteCommand cmd = new SqliteCommand())
{
cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm);
cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent));
cmd.Parameters.Add(new SqliteParameter(":InventoryID", id));
- return ExecuteNonQuery(cmd, m_Connection) == 0 ? false : true;
+ if (ExecuteNonQuery(cmd, m_Connection) == 0)
+ return false;
}
+
+ IncrementFolderVersion(oldParent);
+ IncrementFolderVersion(newParent);
+
+ return true;
}
public XInventoryItem[] GetActiveGestures(UUID principalID)
@@ -189,23 +245,80 @@ namespace OpenSim.Data.SQLite
}
}
- public class SqliteFolderHandler : SQLiteGenericTableHandler
+ public class SqliteFolderHandler : SqliteInventoryHandler
{
public SqliteFolderHandler(string c, string t, string m) :
base(c, t, m)
{
}
+ public override bool Store(XInventoryFolder folder)
+ {
+ if (!base.Store(folder))
+ return false;
+
+ IncrementFolderVersion(folder.parentFolderID);
+
+ return true;
+ }
+
public bool MoveFolder(string id, string newParentFolderID)
{
+ XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id });
+
+ if (folders.Length == 0)
+ return false;
+
+ UUID oldParentFolderUUID = folders[0].parentFolderID;
+
using (SqliteCommand cmd = new SqliteCommand())
{
cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where folderID = :FolderID", m_Realm);
cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParentFolderID));
cmd.Parameters.Add(new SqliteParameter(":FolderID", id));
- return ExecuteNonQuery(cmd, m_Connection) == 0 ? false : true;
+ if (ExecuteNonQuery(cmd, m_Connection) == 0)
+ return false;
}
+
+ IncrementFolderVersion(oldParentFolderUUID);
+ IncrementFolderVersion(newParentFolderID);
+
+ return true;
+ }
+
+ }
+
+ public class SqliteInventoryHandler : SQLiteGenericTableHandler where T: class, new()
+ {
+ public SqliteInventoryHandler(string c, string t, string m) : base(c, t, m) {}
+
+ protected bool IncrementFolderVersion(UUID folderID)
+ {
+ return IncrementFolderVersion(folderID.ToString());
+ }
+
+ protected bool IncrementFolderVersion(string folderID)
+ {
+// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
+// Util.PrintCallStack();
+
+ using (SqliteCommand cmd = new SqliteCommand())
+ {
+ cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = ?folderID";
+ cmd.Parameters.Add(new SqliteParameter(":folderID", folderID));
+
+ try
+ {
+ cmd.ExecuteNonQuery();
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ }
+
+ return true;
}
}
}
\ No newline at end of file
diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs
index 1174e2f302..8cb2ee083d 100644
--- a/OpenSim/Data/Tests/AssetTests.cs
+++ b/OpenSim/Data/Tests/AssetTests.cs
@@ -49,7 +49,7 @@ using OpenSim.Data.SQLite;
namespace OpenSim.Data.Tests
{
[TestFixture(Description = "Asset store tests (SQLite)")]
- public class SQLiteAssetTests : AssetTests
+ public class SQLiteAssetTests : AssetTests
{
}
diff --git a/OpenSim/Data/Tests/BasicDataServiceTest.cs b/OpenSim/Data/Tests/BasicDataServiceTest.cs
index 7d85f0c8eb..d8019ba9b4 100644
--- a/OpenSim/Data/Tests/BasicDataServiceTest.cs
+++ b/OpenSim/Data/Tests/BasicDataServiceTest.cs
@@ -33,6 +33,7 @@ using NUnit.Framework;
using NUnit.Framework.Constraints;
using OpenMetaverse;
using OpenSim.Framework;
+using OpenSim.Tests.Common;
using log4net;
using System.Data;
using System.Data.Common;
@@ -45,7 +46,7 @@ namespace OpenSim.Data.Tests
///
///
///
- public class BasicDataServiceTest
+ public class BasicDataServiceTest : OpenSimTestCase
where TConn : DbConnection, new()
where TService : class, new()
{
diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
index 6c79bda9ec..b99525a74a 100644
--- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs
+++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
@@ -36,6 +36,7 @@ using NUnit.Framework;
using NUnit.Framework.Constraints;
using OpenMetaverse;
using OpenSim.Framework;
+using OpenSim.Tests.Common;
namespace OpenSim.Data.Tests
{
@@ -254,7 +255,7 @@ namespace OpenSim.Data.Tests
}
[TestFixture]
- public class PropertyCompareConstraintTest
+ public class PropertyCompareConstraintTest : OpenSimTestCase
{
public class HasInt
{
diff --git a/OpenSim/Data/Tests/PropertyScrambler.cs b/OpenSim/Data/Tests/PropertyScrambler.cs
index c5d40c2373..e0f5862b93 100644
--- a/OpenSim/Data/Tests/PropertyScrambler.cs
+++ b/OpenSim/Data/Tests/PropertyScrambler.cs
@@ -34,6 +34,7 @@ using System.Text;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
+using OpenSim.Tests.Common;
namespace OpenSim.Data.Tests
{
@@ -158,7 +159,7 @@ namespace OpenSim.Data.Tests
}
[TestFixture]
- public class PropertyScramblerTests
+ public class PropertyScramblerTests : OpenSimTestCase
{
[Test]
public void TestScramble()
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs
index bd23d1cb62..de30414cb3 100644
--- a/OpenSim/Framework/Console/CommandConsole.cs
+++ b/OpenSim/Framework/Console/CommandConsole.cs
@@ -83,7 +83,8 @@ namespace OpenSim.Framework.Console
= "To enter an argument that contains spaces, surround the argument with double quotes.\nFor example, show object name \"My long object name\"\n";
public const string ItemHelpText
- = "For more information, type 'help - ' where
- is one of the following:";
+= @"For more information, type 'help all' to get a list of all commands,
+ or type help
- ' where
- is one of the following:";
///
/// Commands organized by keyword in a tree
@@ -117,6 +118,10 @@ namespace OpenSim.Framework.Console
help.Add(ItemHelpText);
help.AddRange(CollectModulesHelp(tree));
}
+ else if (helpParts.Count == 1 && helpParts[0] == "all")
+ {
+ help.AddRange(CollectAllCommandsHelp());
+ }
else
{
help.AddRange(CollectHelp(helpParts));
@@ -124,6 +129,28 @@ namespace OpenSim.Framework.Console
return help;
}
+
+ ///
+ /// Collects the help from all commands and return in alphabetical order.
+ ///
+ ///
+ private List CollectAllCommandsHelp()
+ {
+ List help = new List();
+
+ lock (m_modulesCommands)
+ {
+ foreach (List commands in m_modulesCommands.Values)
+ {
+ var ourHelpText = commands.ConvertAll(c => string.Format("{0} - {1}", c.help_text, c.long_help));
+ help.AddRange(ourHelpText);
+ }
+ }
+
+ help.Sort();
+
+ return help;
+ }
///
/// See if we can find the requested command in order to display longer help
@@ -711,7 +738,7 @@ namespace OpenSim.Framework.Console
///
public void Prompt()
{
- string line = ReadLine(m_defaultPrompt + "# ", true, true);
+ string line = ReadLine(DefaultPrompt + "# ", true, true);
if (line != String.Empty)
Output("Invalid command");
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs
index 4b375d9963..2d8e723af2 100755
--- a/OpenSim/Framework/Console/ConsoleBase.cs
+++ b/OpenSim/Framework/Console/ConsoleBase.cs
@@ -43,15 +43,7 @@ namespace OpenSim.Framework.Console
public object ConsoleScene { get; set; }
- ///
- /// The default prompt text.
- ///
- public string DefaultPrompt
- {
- set { m_defaultPrompt = value; }
- get { return m_defaultPrompt; }
- }
- protected string m_defaultPrompt;
+ public string DefaultPrompt { get; set; }
public ConsoleBase(string defaultPrompt)
{
diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs
index b489f93b69..8ba58e4cc6 100644
--- a/OpenSim/Framework/Console/MockConsole.cs
+++ b/OpenSim/Framework/Console/MockConsole.cs
@@ -46,13 +46,18 @@ namespace OpenSim.Framework.Console
public ICommands Commands { get { return m_commands; } }
+ public string DefaultPrompt { get; set; }
+
public void Prompt() {}
public void RunCommand(string cmd) {}
public string ReadLine(string p, bool isCommand, bool e) { return ""; }
- public object ConsoleScene { get { return null; } }
+ public object ConsoleScene {
+ get { return null; }
+ set {}
+ }
public void Output(string text, string level) {}
public void Output(string text) {}
diff --git a/OpenSim/Framework/ICommandConsole.cs b/OpenSim/Framework/ICommandConsole.cs
index 8cd20da4ee..a6573f8843 100644
--- a/OpenSim/Framework/ICommandConsole.cs
+++ b/OpenSim/Framework/ICommandConsole.cs
@@ -82,6 +82,11 @@ namespace OpenSim.Framework
ICommands Commands { get; }
+ ///
+ /// The default prompt text.
+ ///
+ string DefaultPrompt { get; set; }
+
///
/// Display a command prompt on the console and wait for user input
///
diff --git a/OpenSim/Framework/IConsole.cs b/OpenSim/Framework/IConsole.cs
index 33024b2076..79560d805b 100644
--- a/OpenSim/Framework/IConsole.cs
+++ b/OpenSim/Framework/IConsole.cs
@@ -32,7 +32,7 @@ namespace OpenSim.Framework
{
public interface IConsole
{
- object ConsoleScene { get; }
+ object ConsoleScene { get; set; }
void Output(string text, string level);
void Output(string text);
diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs
index a663680a78..3d45e76698 100644
--- a/OpenSim/Framework/InventoryItemBase.cs
+++ b/OpenSim/Framework/InventoryItemBase.cs
@@ -87,16 +87,7 @@ namespace OpenSim.Framework
protected string m_creatorId;
///
- /// The UUID for the creator. This may be different from the canonical CreatorId. This property is used
- /// for communication with the client over the Second Life protocol, since that protocol can only understand
- /// UUIDs. As this is a basic framework class, this means that both the string creator id and the uuid
- /// reference have to be settable separately
- ///
- /// Database plugins don't need to set this, it will be set by
- /// upstream code (or set by the get accessor if left unset).
- ///
- /// XXX: An alternative to having a separate uuid property would be to hash the CreatorId appropriately
- /// every time there was communication with a UUID-only client. This may be much more expensive.
+ /// The CreatorId expressed as a UUID.tely
///
public UUID CreatorIdAsUuid
{
@@ -109,20 +100,18 @@ namespace OpenSim.Framework
return m_creatorIdAsUuid;
}
-
- set
- {
- m_creatorIdAsUuid = value;
- }
}
protected UUID m_creatorIdAsUuid = UUID.Zero;
- protected string m_creatorData = string.Empty;
+ ///
+ /// Extended creator information of the form ;
+ ///
public string CreatorData // = ;
{
get { return m_creatorData; }
set { m_creatorData = value; }
}
+ protected string m_creatorData = string.Empty;
///
/// Used by the DB layer to retrieve / store the entire user identification.
@@ -162,7 +151,6 @@ namespace OpenSim.Framework
name = parts[2];
m_creatorData += ';' + name;
-
}
}
}
diff --git a/OpenSim/Framework/Monitoring/Stats/PercentageStat.cs b/OpenSim/Framework/Monitoring/Stats/PercentageStat.cs
new file mode 100644
index 0000000000..60bed55500
--- /dev/null
+++ b/OpenSim/Framework/Monitoring/Stats/PercentageStat.cs
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * 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.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may 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.Text;
+
+namespace OpenSim.Framework.Monitoring
+{
+ public class PercentageStat : Stat
+ {
+ public long Antecedent { get; set; }
+ public long Consequent { get; set; }
+
+ public override double Value
+ {
+ get
+ {
+ // Asking for an update here means that the updater cannot access this value without infinite recursion.
+ // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being
+ // called by the pull action and just return the value.
+ if (StatType == StatType.Pull)
+ PullAction(this);
+
+ long c = Consequent;
+
+ // Avoid any chance of a multi-threaded divide-by-zero
+ if (c == 0)
+ return 0;
+
+ return (double)Antecedent / c * 100;
+ }
+
+ set
+ {
+ throw new InvalidOperationException("Cannot set value on a PercentageStat");
+ }
+ }
+
+ public PercentageStat(
+ string shortName,
+ string name,
+ string description,
+ string category,
+ string container,
+ StatType type,
+ Action pullAction,
+ StatVerbosity verbosity)
+ : base(shortName, name, description, "%", category, container, type, pullAction, verbosity) {}
+
+ public override string ToConsoleString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.AppendFormat(
+ "{0}.{1}.{2} : {3:0.##}{4} ({5}/{6})",
+ Category, Container, ShortName, Value, UnitName, Antecedent, Consequent);
+
+ AppendMeasuresOfInterest(sb);
+
+ return sb.ToString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs
new file mode 100644
index 0000000000..f91251b6ea
--- /dev/null
+++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs
@@ -0,0 +1,238 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * 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.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may 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.Text;
+
+namespace OpenSim.Framework.Monitoring
+{
+ ///
+ /// Holds individual statistic details
+ ///
+ public class Stat
+ {
+ ///
+ /// Category of this stat (e.g. cache, scene, etc).
+ ///
+ public string Category { get; private set; }
+
+ ///
+ /// Containing name for this stat.
+ /// FIXME: In the case of a scene, this is currently the scene name (though this leaves
+ /// us with a to-be-resolved problem of non-unique region names).
+ ///
+ ///
+ /// The container.
+ ///
+ public string Container { get; private set; }
+
+ public StatType StatType { get; private set; }
+
+ public MeasuresOfInterest MeasuresOfInterest { get; private set; }
+
+ ///
+ /// Action used to update this stat when the value is requested if it's a pull type.
+ ///
+ public Action PullAction { get; private set; }
+
+ public StatVerbosity Verbosity { get; private set; }
+ public string ShortName { get; private set; }
+ public string Name { get; private set; }
+ public string Description { get; private set; }
+ public virtual string UnitName { get; private set; }
+
+ public virtual double Value
+ {
+ get
+ {
+ // Asking for an update here means that the updater cannot access this value without infinite recursion.
+ // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being
+ // called by the pull action and just return the value.
+ if (StatType == StatType.Pull)
+ PullAction(this);
+
+ return m_value;
+ }
+
+ set
+ {
+ m_value = value;
+ }
+ }
+
+ private double m_value;
+
+ ///
+ /// Historical samples for calculating measures of interest average.
+ ///
+ ///
+ /// Will be null if no measures of interest require samples.
+ ///
+ private static Queue m_samples;
+
+ ///
+ /// Maximum number of statistical samples.
+ ///
+ ///
+ /// At the moment this corresponds to 1 minute since the sampling rate is every 2.5 seconds as triggered from
+ /// the main Watchdog.
+ ///
+ private static int m_maxSamples = 24;
+
+ public Stat(
+ string shortName,
+ string name,
+ string description,
+ string unitName,
+ string category,
+ string container,
+ StatType type,
+ Action pullAction,
+ StatVerbosity verbosity)
+ : this(
+ shortName,
+ name,
+ description,
+ unitName,
+ category,
+ container,
+ type,
+ MeasuresOfInterest.None,
+ pullAction,
+ verbosity)
+ {
+ }
+
+ ///
+ /// Constructor
+ ///
+ /// Short name for the stat. Must not contain spaces. e.g. "LongFrames"
+ /// Human readable name for the stat. e.g. "Long frames"
+ /// Description of stat
+ ///
+ /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value.
+ /// e.g. " frames"
+ ///
+ /// Category under which this stat should appear, e.g. "scene". Do not capitalize.
+ /// Entity to which this stat relates. e.g. scene name if this is a per scene stat.
+ /// Push or pull
+ /// Pull stats need an action to update the stat on request. Push stats should set null here.
+ /// Measures of interest
+ /// Verbosity of stat. Controls whether it will appear in short stat display or only full display.
+ public Stat(
+ string shortName,
+ string name,
+ string description,
+ string unitName,
+ string category,
+ string container,
+ StatType type,
+ MeasuresOfInterest moi,
+ Action pullAction,
+ StatVerbosity verbosity)
+ {
+ if (StatsManager.SubCommands.Contains(category))
+ throw new Exception(
+ string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category));
+
+ ShortName = shortName;
+ Name = name;
+ Description = description;
+ UnitName = unitName;
+ Category = category;
+ Container = container;
+ StatType = type;
+
+ if (StatType == StatType.Push && pullAction != null)
+ throw new Exception("A push stat cannot have a pull action");
+ else
+ PullAction = pullAction;
+
+ MeasuresOfInterest = moi;
+
+ if ((moi & MeasuresOfInterest.AverageChangeOverTime) == MeasuresOfInterest.AverageChangeOverTime)
+ m_samples = new Queue(m_maxSamples);
+
+ Verbosity = verbosity;
+ }
+
+ ///
+ /// Record a value in the sample set.
+ ///
+ ///
+ /// Do not call this if MeasuresOfInterest.None
+ ///
+ public void RecordValue()
+ {
+ double newValue = Value;
+
+ lock (m_samples)
+ {
+ if (m_samples.Count >= m_maxSamples)
+ m_samples.Dequeue();
+
+ m_samples.Enqueue(newValue);
+ }
+ }
+
+ public virtual string ToConsoleString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.AppendFormat("{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName);
+
+ AppendMeasuresOfInterest(sb);
+
+ return sb.ToString();
+ }
+
+ protected void AppendMeasuresOfInterest(StringBuilder sb)
+ {
+ if ((MeasuresOfInterest & MeasuresOfInterest.AverageChangeOverTime)
+ == MeasuresOfInterest.AverageChangeOverTime)
+ {
+ double totalChange = 0;
+ double? lastSample = null;
+
+ lock (m_samples)
+ {
+ foreach (double s in m_samples)
+ {
+ if (lastSample != null)
+ totalChange += s - (double)lastSample;
+
+ lastSample = s;
+ }
+ }
+
+ int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1;
+
+ sb.AppendFormat(", {0:0.##}{1}/s", totalChange / divisor / (Watchdog.WATCHDOG_INTERVAL_MS / 1000), UnitName);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs
index 4844336e31..0762b01c7d 100644
--- a/OpenSim/Framework/Monitoring/StatsManager.cs
+++ b/OpenSim/Framework/Monitoring/StatsManager.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.Text;
namespace OpenSim.Framework.Monitoring
{
@@ -246,6 +247,24 @@ namespace OpenSim.Framework.Monitoring
return false;
}
+
+ public static void RecordStats()
+ {
+ lock (RegisteredStats)
+ {
+ foreach (Dictionary> category in RegisteredStats.Values)
+ {
+ foreach (Dictionary container in category.Values)
+ {
+ foreach (Stat stat in container.Values)
+ {
+ if (stat.MeasuresOfInterest != MeasuresOfInterest.None)
+ stat.RecordValue();
+ }
+ }
+ }
+ }
+ }
}
///
@@ -261,6 +280,16 @@ namespace OpenSim.Framework.Monitoring
Pull
}
+ ///
+ /// Measures of interest for this stat.
+ ///
+ [Flags]
+ public enum MeasuresOfInterest
+ {
+ None,
+ AverageChangeOverTime
+ }
+
///
/// Verbosity of stat.
///
@@ -272,154 +301,4 @@ namespace OpenSim.Framework.Monitoring
Debug,
Info
}
-
- ///
- /// Holds individual static details
- ///
- public class Stat
- {
- ///
- /// Category of this stat (e.g. cache, scene, etc).
- ///
- public string Category { get; private set; }
-
- ///
- /// Containing name for this stat.
- /// FIXME: In the case of a scene, this is currently the scene name (though this leaves
- /// us with a to-be-resolved problem of non-unique region names).
- ///
- ///
- /// The container.
- ///
- public string Container { get; private set; }
-
- public StatType StatType { get; private set; }
-
- ///
- /// Action used to update this stat when the value is requested if it's a pull type.
- ///
- public Action PullAction { get; private set; }
-
- public StatVerbosity Verbosity { get; private set; }
- public string ShortName { get; private set; }
- public string Name { get; private set; }
- public string Description { get; private set; }
- public virtual string UnitName { get; private set; }
-
- public virtual double Value
- {
- get
- {
- // Asking for an update here means that the updater cannot access this value without infinite recursion.
- // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being
- // called by the pull action and just return the value.
- if (StatType == StatType.Pull)
- PullAction(this);
-
- return m_value;
- }
-
- set
- {
- m_value = value;
- }
- }
-
- private double m_value;
-
- ///
- /// Constructor
- ///
- /// Short name for the stat. Must not contain spaces. e.g. "LongFrames"
- /// Human readable name for the stat. e.g. "Long frames"
- /// Description of stat
- ///
- /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value.
- /// e.g. " frames"
- ///
- /// Category under which this stat should appear, e.g. "scene". Do not capitalize.
- /// Entity to which this stat relates. e.g. scene name if this is a per scene stat.
- /// Push or pull
- /// Pull stats need an action to update the stat on request. Push stats should set null here.
- /// Verbosity of stat. Controls whether it will appear in short stat display or only full display.
- public Stat(
- string shortName,
- string name,
- string description,
- string unitName,
- string category,
- string container,
- StatType type,
- Action pullAction,
- StatVerbosity verbosity)
- {
- if (StatsManager.SubCommands.Contains(category))
- throw new Exception(
- string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category));
-
- ShortName = shortName;
- Name = name;
- Description = description;
- UnitName = unitName;
- Category = category;
- Container = container;
- StatType = type;
-
- if (StatType == StatType.Push && pullAction != null)
- throw new Exception("A push stat cannot have a pull action");
- else
- PullAction = pullAction;
-
- Verbosity = verbosity;
- }
-
- public virtual string ToConsoleString()
- {
- return string.Format(
- "{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName);
- }
- }
-
- public class PercentageStat : Stat
- {
- public int Antecedent { get; set; }
- public int Consequent { get; set; }
-
- public override double Value
- {
- get
- {
- int c = Consequent;
-
- // Avoid any chance of a multi-threaded divide-by-zero
- if (c == 0)
- return 0;
-
- return (double)Antecedent / c * 100;
- }
-
- set
- {
- throw new Exception("Cannot set value on a PercentageStat");
- }
- }
-
- public PercentageStat(
- string shortName,
- string name,
- string description,
- string category,
- string container,
- StatType type,
- Action pullAction,
- StatVerbosity verbosity)
- : base(shortName, name, description, "%", category, container, type, pullAction, verbosity) {}
-
- public override string ToConsoleString()
- {
- return string.Format(
- "{0}.{1}.{2} : {3:0.##}{4} ({5}/{6})",
- Category, Container, ShortName, Value, UnitName, Antecedent, Consequent);
- }
- }
}
\ No newline at end of file
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs
index a20326dbd8..3f992b1e3b 100644
--- a/OpenSim/Framework/Monitoring/Watchdog.cs
+++ b/OpenSim/Framework/Monitoring/Watchdog.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Framework.Monitoring
public static class Watchdog
{
/// Timer interval in milliseconds for the watchdog timer
- const double WATCHDOG_INTERVAL_MS = 2500.0d;
+ public const double WATCHDOG_INTERVAL_MS = 2500.0d;
/// Default timeout in milliseconds before a thread is considered dead
public const int DEFAULT_WATCHDOG_TIMEOUT_MS = 5000;
@@ -380,6 +380,8 @@ namespace OpenSim.Framework.Monitoring
if (MemoryWatchdog.Enabled)
MemoryWatchdog.Update();
+ StatsManager.RecordStats();
+
m_watchdogTimer.Start();
}
}
diff --git a/OpenSim/Framework/Serialization/ArchiveConstants.cs b/OpenSim/Framework/Serialization/ArchiveConstants.cs
index 48f1c4f94f..0c12787882 100644
--- a/OpenSim/Framework/Serialization/ArchiveConstants.cs
+++ b/OpenSim/Framework/Serialization/ArchiveConstants.cs
@@ -154,6 +154,11 @@ namespace OpenSim.Framework.Serialization
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"] = (sbyte)AssetType.TrashFolder;
}
+ public static string CreateOarLandDataPath(LandData ld)
+ {
+ return string.Format("{0}{1}.xml", ArchiveConstants.LANDDATA_PATH, ld.GlobalID);
+ }
+
///
/// Create the filename used to store an object in an OpenSim Archive.
///
diff --git a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs
index 8b9756b11d..ea100ee71c 100644
--- a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs
+++ b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs
@@ -37,7 +37,7 @@ using OpenSim.Tests.Common;
namespace OpenSim.Framework.Serialization.Tests
{
[TestFixture]
- public class LandDataSerializerTest
+ public class LandDataSerializerTest : OpenSimTestCase
{
private LandData land;
private LandData landWithParcelAccessList;
diff --git a/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs
index 09b6f6ddad..142726bbe7 100644
--- a/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs
+++ b/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs
@@ -37,7 +37,7 @@ using OpenSim.Tests.Common;
namespace OpenSim.Framework.Serialization.Tests
{
[TestFixture]
- public class RegionSettingsSerializerTests
+ public class RegionSettingsSerializerTests : OpenSimTestCase
{
private string m_serializedRs = @"
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 5b2d7dc6d8..c0dc907ddc 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -27,7 +27,6 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
@@ -38,6 +37,8 @@ using log4net;
using log4net.Appender;
using log4net.Core;
using log4net.Repository;
+using OpenMetaverse;
+using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Monitoring;
@@ -45,16 +46,12 @@ using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using Timer=System.Timers.Timer;
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-
-
namespace OpenSim.Framework.Servers
{
///
/// Common base for the main OpenSimServers (user, grid, inventory, region, etc)
///
- public abstract class BaseOpenSimServer
+ public abstract class BaseOpenSimServer : ServerBase
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -63,27 +60,6 @@ namespace OpenSim.Framework.Servers
/// server.
///
private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000);
-
- protected CommandConsole m_console;
- protected OpenSimAppender m_consoleAppender;
- protected IAppender m_logFileAppender = null;
-
- ///
- /// Time at which this server was started
- ///
- protected DateTime m_startuptime;
-
- ///
- /// Record the initial startup directory for info purposes
- ///
- protected string m_startupDirectory = Environment.CurrentDirectory;
-
- ///
- /// Server version information. Usually VersionInfo + information about git commit, operating system, etc.
- ///
- protected string m_version;
-
- protected string m_pidFile = String.Empty;
///
/// Random uuid for private data
@@ -96,30 +72,13 @@ namespace OpenSim.Framework.Servers
get { return m_httpServer; }
}
- public BaseOpenSimServer()
+ public BaseOpenSimServer() : base()
{
- m_startuptime = DateTime.Now;
- m_version = VersionInfo.Version;
-
// Random uuid for private data
m_osSecret = UUID.Random().ToString();
m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics);
m_periodicDiagnosticsTimer.Enabled = true;
-
- // This thread will go on to become the console listening thread
- Thread.CurrentThread.Name = "ConsoleThread";
-
- ILoggerRepository repository = LogManager.GetRepository();
- IAppender[] appenders = repository.GetAppenders();
-
- foreach (IAppender appender in appenders)
- {
- if (appender.Name == "LogFileAppender")
- {
- m_logFileAppender = appender;
- }
- }
}
///
@@ -127,83 +86,18 @@ namespace OpenSim.Framework.Servers
///
protected virtual void StartupSpecific()
{
- if (m_console != null)
- {
- ILoggerRepository repository = LogManager.GetRepository();
- IAppender[] appenders = repository.GetAppenders();
+ if (m_console == null)
+ return;
- foreach (IAppender appender in appenders)
- {
- if (appender.Name == "Console")
- {
- m_consoleAppender = (OpenSimAppender)appender;
- break;
- }
- }
+ RegisterCommonCommands();
+
+ m_console.Commands.AddCommand("General", false, "quit",
+ "quit",
+ "Quit the application", HandleQuit);
- if (null == m_consoleAppender)
- {
- Notice("No appender named Console found (see the log4net config file for this executable)!");
- }
- else
- {
- m_consoleAppender.Console = m_console;
-
- // If there is no threshold set then the threshold is effectively everything.
- if (null == m_consoleAppender.Threshold)
- m_consoleAppender.Threshold = Level.All;
-
- Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
- }
-
- m_console.Commands.AddCommand("General", false, "quit",
- "quit",
- "Quit the application", HandleQuit);
-
- m_console.Commands.AddCommand("General", false, "shutdown",
- "shutdown",
- "Quit the application", HandleQuit);
-
- m_console.Commands.AddCommand("General", false, "set log level",
- "set log level ",
- "Set the console logging level", HandleLogLevel);
-
- m_console.Commands.AddCommand("General", false, "show info",
- "show info",
- "Show general information about the server", HandleShow);
-
- m_console.Commands.AddCommand("General", false, "show threads",
- "show threads",
- "Show thread status", HandleShow);
-
- m_console.Commands.AddCommand("General", false, "show uptime",
- "show uptime",
- "Show server uptime", HandleShow);
-
- m_console.Commands.AddCommand("General", false, "show version",
- "show version",
- "Show server version", HandleShow);
-
- m_console.Commands.AddCommand("General", false, "threads abort",
- "threads abort ",
- "Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort);
-
- m_console.Commands.AddCommand("General", false, "threads show",
- "threads show",
- "Show thread status. Synonym for \"show threads\"",
- (string module, string[] args) => Notice(GetThreadsReport()));
-
- m_console.Commands.AddCommand("General", false, "force gc",
- "force gc",
- "Manually invoke runtime garbage collection. For debugging purposes",
- HandleForceGc);
- }
- }
-
- private void HandleForceGc(string module, string[] args)
- {
- MainConsole.Instance.Output("Manually invoking runtime garbage collection");
- GC.Collect();
+ m_console.Commands.AddCommand("General", false, "shutdown",
+ "shutdown",
+ "Quit the application", HandleQuit);
}
///
@@ -235,75 +129,12 @@ namespace OpenSim.Framework.Servers
m_log.Debug(sb);
}
- ///
- /// Get a report about the registered threads in this server.
- ///
- protected string GetThreadsReport()
- {
- // This should be a constant field.
- string reportFormat = "{0,6} {1,35} {2,16} {3,13} {4,10} {5,30}";
-
- StringBuilder sb = new StringBuilder();
- Watchdog.ThreadWatchdogInfo[] threads = Watchdog.GetThreadsInfo();
-
- sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine);
-
- int timeNow = Environment.TickCount & Int32.MaxValue;
-
- sb.AppendFormat(reportFormat, "ID", "NAME", "LAST UPDATE (MS)", "LIFETIME (MS)", "PRIORITY", "STATE");
- sb.Append(Environment.NewLine);
-
- foreach (Watchdog.ThreadWatchdogInfo twi in threads)
- {
- Thread t = twi.Thread;
-
- sb.AppendFormat(
- reportFormat,
- t.ManagedThreadId,
- t.Name,
- timeNow - twi.LastTick,
- timeNow - twi.FirstTick,
- t.Priority,
- t.ThreadState);
-
- sb.Append("\n");
- }
-
- sb.Append("\n");
-
- // For some reason mono 2.6.7 returns an empty threads set! Not going to confuse people by reporting
- // zero active threads.
- int totalThreads = Process.GetCurrentProcess().Threads.Count;
- if (totalThreads > 0)
- sb.AppendFormat("Total threads active: {0}\n\n", totalThreads);
-
- sb.Append("Main threadpool (excluding script engine pools)\n");
- sb.Append(Util.GetThreadPoolReport());
-
- return sb.ToString();
- }
-
- ///
- /// Return a report about the uptime of this server
- ///
- ///
- protected string GetUptimeReport()
- {
- StringBuilder sb = new StringBuilder(String.Format("Time now is {0}\n", DateTime.Now));
- sb.Append(String.Format("Server has been running since {0}, {1}\n", m_startuptime.DayOfWeek, m_startuptime));
- sb.Append(String.Format("That is an elapsed time of {0}\n", DateTime.Now - m_startuptime));
-
- return sb.ToString();
- }
-
///
/// Performs initialisation of the scene, such as loading configuration from disk.
///
public virtual void Startup()
{
m_log.Info("[STARTUP]: Beginning startup processing");
-
- EnhanceVersionInformation();
m_log.Info("[STARTUP]: OpenSimulator version: " + m_version + Environment.NewLine);
// clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and
@@ -338,257 +169,7 @@ namespace OpenSim.Framework.Servers
private void HandleQuit(string module, string[] args)
{
Shutdown();
- }
-
- private void HandleLogLevel(string module, string[] cmd)
- {
- if (null == m_consoleAppender)
- {
- Notice("No appender named Console found (see the log4net config file for this executable)!");
- return;
- }
-
- if (cmd.Length > 3)
- {
- string rawLevel = cmd[3];
-
- ILoggerRepository repository = LogManager.GetRepository();
- Level consoleLevel = repository.LevelMap[rawLevel];
-
- if (consoleLevel != null)
- m_consoleAppender.Threshold = consoleLevel;
- else
- Notice(
- String.Format(
- "{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF",
- rawLevel));
- }
-
- Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
- }
-
- ///
- /// Show help information
- ///
- ///
- protected virtual void ShowHelp(string[] helpArgs)
- {
- Notice("");
-
- if (helpArgs.Length == 0)
- {
- Notice("set log level [level] - change the console logging level only. For example, off or debug.");
- Notice("show info - show server information (e.g. startup path).");
- Notice("show threads - list tracked threads");
- Notice("show uptime - show server startup time and uptime.");
- Notice("show version - show server version.");
- Notice("");
-
- return;
- }
- }
-
- public virtual void HandleShow(string module, string[] cmd)
- {
- List args = new List(cmd);
-
- args.RemoveAt(0);
-
- string[] showParams = args.ToArray();
-
- switch (showParams[0])
- {
- case "info":
- ShowInfo();
- break;
-
- case "threads":
- Notice(GetThreadsReport());
- break;
-
- case "uptime":
- Notice(GetUptimeReport());
- break;
-
- case "version":
- Notice(GetVersionText());
- break;
- }
- }
-
- public virtual void HandleThreadsAbort(string module, string[] cmd)
- {
- if (cmd.Length != 3)
- {
- MainConsole.Instance.Output("Usage: threads abort ");
- return;
- }
-
- int threadId;
- if (!int.TryParse(cmd[2], out threadId))
- {
- MainConsole.Instance.Output("ERROR: Thread id must be an integer");
- return;
- }
-
- if (Watchdog.AbortThread(threadId))
- MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId);
- else
- MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId);
- }
-
- protected void ShowInfo()
- {
- Notice(GetVersionText());
- Notice("Startup directory: " + m_startupDirectory);
- if (null != m_consoleAppender)
- Notice(String.Format("Console log level: {0}", m_consoleAppender.Threshold));
- }
-
- protected string GetVersionText()
- {
- return String.Format("Version: {0} (interface version {1})", m_version, VersionInfo.MajorInterfaceVersion);
- }
-
- ///
- /// Console output is only possible if a console has been established.
- /// That is something that cannot be determined within this class. So
- /// all attempts to use the console MUST be verified.
- ///
- ///
- protected void Notice(string msg)
- {
- if (m_console != null)
- {
- m_console.Output(msg);
- }
- }
-
- ///
- /// Console output is only possible if a console has been established.
- /// That is something that cannot be determined within this class. So
- /// all attempts to use the console MUST be verified.
- ///
- ///
- ///
- protected void Notice(string format, params string[] components)
- {
- if (m_console != null)
- m_console.OutputFormat(format, components);
- }
-
- ///
- /// Enhance the version string with extra information if it's available.
- ///
- protected void EnhanceVersionInformation()
- {
- string buildVersion = string.Empty;
-
- // The subversion information is deprecated and will be removed at a later date
- // Add subversion revision information if available
- // Try file "svn_revision" in the current directory first, then the .svn info.
- // This allows to make the revision available in simulators not running from the source tree.
- // FIXME: Making an assumption about the directory we're currently in - we do this all over the place
- // elsewhere as well
- string gitDir = "../.git/";
- string gitRefPointerPath = gitDir + "HEAD";
-
- string svnRevisionFileName = "svn_revision";
- string svnFileName = ".svn/entries";
- string manualVersionFileName = ".version";
- string inputLine;
- int strcmp;
-
- if (File.Exists(manualVersionFileName))
- {
- using (StreamReader CommitFile = File.OpenText(manualVersionFileName))
- buildVersion = CommitFile.ReadLine();
-
- m_version += buildVersion ?? "";
- }
- else if (File.Exists(gitRefPointerPath))
- {
-// m_log.DebugFormat("[OPENSIM]: Found {0}", gitRefPointerPath);
-
- string rawPointer = "";
-
- using (StreamReader pointerFile = File.OpenText(gitRefPointerPath))
- rawPointer = pointerFile.ReadLine();
-
-// m_log.DebugFormat("[OPENSIM]: rawPointer [{0}]", rawPointer);
-
- Match m = Regex.Match(rawPointer, "^ref: (.+)$");
-
- if (m.Success)
- {
-// m_log.DebugFormat("[OPENSIM]: Matched [{0}]", m.Groups[1].Value);
-
- string gitRef = m.Groups[1].Value;
- string gitRefPath = gitDir + gitRef;
- if (File.Exists(gitRefPath))
- {
-// m_log.DebugFormat("[OPENSIM]: Found gitRefPath [{0}]", gitRefPath);
-
- using (StreamReader refFile = File.OpenText(gitRefPath))
- {
- string gitHash = refFile.ReadLine();
- m_version += gitHash.Substring(0, 7);
- }
- }
- }
- }
- else
- {
- // Remove the else logic when subversion mirror is no longer used
- if (File.Exists(svnRevisionFileName))
- {
- StreamReader RevisionFile = File.OpenText(svnRevisionFileName);
- buildVersion = RevisionFile.ReadLine();
- buildVersion.Trim();
- RevisionFile.Close();
- }
-
- if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName))
- {
- StreamReader EntriesFile = File.OpenText(svnFileName);
- inputLine = EntriesFile.ReadLine();
- while (inputLine != null)
- {
- // using the dir svn revision at the top of entries file
- strcmp = String.Compare(inputLine, "dir");
- if (strcmp == 0)
- {
- buildVersion = EntriesFile.ReadLine();
- break;
- }
- else
- {
- inputLine = EntriesFile.ReadLine();
- }
- }
- EntriesFile.Close();
- }
-
- m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6);
- }
- }
-
- protected void CreatePIDFile(string path)
- {
- try
- {
- string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
- FileStream fs = File.Create(path);
-
- Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
- fs.Write(buf, 0, buf.Length);
- fs.Close();
- m_pidFile = path;
- }
- catch (Exception)
- {
- }
- }
+ }
public string osSecret {
// Secret uuid for the simulator
@@ -607,20 +188,5 @@ namespace OpenSim.Framework.Servers
return StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version);
}
}
-
- protected void RemovePIDFile()
- {
- if (m_pidFile != String.Empty)
- {
- try
- {
- File.Delete(m_pidFile);
- m_pidFile = String.Empty;
- }
- catch (Exception)
- {
- }
- }
- }
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 410a76a798..2cd626fa44 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -719,8 +719,11 @@ namespace OpenSim.Framework.Servers.HttpServer
if (DebugLevel == 5)
{
const int sampleLength = 80;
- char[] sampleChars = new char[sampleLength];
+ char[] sampleChars = new char[sampleLength + 3];
reader.Read(sampleChars, 0, sampleLength);
+ sampleChars[80] = '.';
+ sampleChars[81] = '.';
+ sampleChars[82] = '.';
output = new string(sampleChars);
}
else
@@ -728,7 +731,7 @@ namespace OpenSim.Framework.Servers.HttpServer
output = reader.ReadToEnd();
}
- m_log.DebugFormat("[BASE HTTP SERVER]: {0}...", output.Replace("\n", @"\n"));
+ m_log.DebugFormat("[BASE HTTP SERVER]: {0}", output.Replace("\n", @"\n"));
}
}
@@ -1279,59 +1282,6 @@ namespace OpenSim.Framework.Servers.HttpServer
map["login"] = OSD.FromString("false");
return map;
}
- ///
- /// A specific agent handler was provided. Such a handler is expecetd to have an
- /// intimate, and highly specific relationship with the client. Consequently,
- /// nothing is done here.
- ///
- ///
- ///
- ///
-
- private bool HandleAgentRequest(IHttpAgentHandler handler, OSHttpRequest request, OSHttpResponse response)
- {
- // In the case of REST, then handler is responsible for ALL aspects of
- // the request/response handling. Nothing is done here, not even encoding.
-
- try
- {
- return handler.Handle(request, response);
- }
- catch (Exception e)
- {
- // If the handler did in fact close the stream, then this will blow
- // chunks. So that that doesn't disturb anybody we throw away any
- // and all exceptions raised. We've done our best to release the
- // client.
- try
- {
- m_log.Warn("[HTTP-AGENT]: Error - " + e.Message);
- response.SendChunked = false;
- response.KeepAlive = true;
- response.StatusCode = (int)OSHttpStatusCode.ServerErrorInternalError;
- //response.OutputStream.Close();
- try
- {
- response.Send();
- //response.FreeContext();
- }
- catch (SocketException f)
- {
- // This has to be here to prevent a Linux/Mono crash
- m_log.Warn(
- String.Format("[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux. ", f.Message), f);
- }
- }
- catch(Exception)
- {
- }
- }
-
- // Indicate that the request has been "handled"
-
- return true;
-
- }
public byte[] HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response)
{
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs
new file mode 100644
index 0000000000..47baac8022
--- /dev/null
+++ b/OpenSim/Framework/Servers/ServerBase.cs
@@ -0,0 +1,677 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * 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.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may 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.Diagnostics;
+using System.IO;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading;
+using log4net;
+using log4net.Appender;
+using log4net.Core;
+using log4net.Repository;
+using Nini.Config;
+using OpenSim.Framework.Console;
+using OpenSim.Framework.Monitoring;
+
+namespace OpenSim.Framework.Servers
+{
+ public class ServerBase
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ public IConfigSource Config { get; protected set; }
+
+ ///
+ /// Console to be used for any command line output. Can be null, in which case there should be no output.
+ ///
+ protected ICommandConsole m_console;
+
+ protected OpenSimAppender m_consoleAppender;
+ protected FileAppender m_logFileAppender;
+
+ protected DateTime m_startuptime;
+ protected string m_startupDirectory = Environment.CurrentDirectory;
+
+ protected string m_pidFile = String.Empty;
+
+ ///
+ /// Server version information. Usually VersionInfo + information about git commit, operating system, etc.
+ ///
+ protected string m_version;
+
+ public ServerBase()
+ {
+ m_startuptime = DateTime.Now;
+ m_version = VersionInfo.Version;
+ EnhanceVersionInformation();
+ }
+
+ protected void CreatePIDFile(string path)
+ {
+ try
+ {
+ string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
+
+ using (FileStream fs = File.Create(path))
+ {
+ Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
+ fs.Write(buf, 0, buf.Length);
+ }
+
+ m_pidFile = path;
+
+ m_log.InfoFormat("[SERVER BASE]: Created pid file {0}", m_pidFile);
+ }
+ catch (Exception e)
+ {
+ m_log.Warn(string.Format("[SERVER BASE]: Could not create PID file at {0} ", path), e);
+ }
+ }
+
+ protected void RemovePIDFile()
+ {
+ if (m_pidFile != String.Empty)
+ {
+ try
+ {
+ File.Delete(m_pidFile);
+ }
+ catch (Exception e)
+ {
+ m_log.Error(string.Format("[SERVER BASE]: Error whilst removing {0} ", m_pidFile), e);
+ }
+
+ m_pidFile = String.Empty;
+ }
+ }
+
+ public void RegisterCommonAppenders(IConfig startupConfig)
+ {
+ ILoggerRepository repository = LogManager.GetRepository();
+ IAppender[] appenders = repository.GetAppenders();
+
+ foreach (IAppender appender in appenders)
+ {
+ if (appender.Name == "Console")
+ {
+ m_consoleAppender = (OpenSimAppender)appender;
+ }
+ else if (appender.Name == "LogFileAppender")
+ {
+ m_logFileAppender = (FileAppender)appender;
+ }
+ }
+
+ if (null == m_consoleAppender)
+ {
+ Notice("No appender named Console found (see the log4net config file for this executable)!");
+ }
+ else
+ {
+ // FIXME: This should be done through an interface rather than casting.
+ m_consoleAppender.Console = (ConsoleBase)m_console;
+
+ // If there is no threshold set then the threshold is effectively everything.
+ if (null == m_consoleAppender.Threshold)
+ m_consoleAppender.Threshold = Level.All;
+
+ Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
+ }
+
+ if (m_logFileAppender != null && startupConfig != null)
+ {
+ string cfgFileName = startupConfig.GetString("LogFile", null);
+ if (cfgFileName != null)
+ {
+ m_logFileAppender.File = cfgFileName;
+ m_logFileAppender.ActivateOptions();
+ }
+
+ m_log.InfoFormat("[SERVER BASE]: Logging started to file {0}", m_logFileAppender.File);
+ }
+ }
+
+ ///
+ /// Register common commands once m_console has been set if it is going to be set
+ ///
+ public void RegisterCommonCommands()
+ {
+ if (m_console == null)
+ return;
+
+ m_console.Commands.AddCommand(
+ "General", false, "show info", "show info", "Show general information about the server", HandleShow);
+
+ m_console.Commands.AddCommand(
+ "General", false, "show version", "show version", "Show server version", HandleShow);
+
+ m_console.Commands.AddCommand(
+ "General", false, "show uptime", "show uptime", "Show server uptime", HandleShow);
+
+ m_console.Commands.AddCommand(
+ "General", false, "get log level", "get log level", "Get the current console logging level",
+ (mod, cmd) => ShowLogLevel());
+
+ m_console.Commands.AddCommand(
+ "General", false, "set log level", "set log level ",
+ "Set the console logging level for this session.", HandleSetLogLevel);
+
+ m_console.Commands.AddCommand(
+ "General", false, "config set",
+ "config set ",
+ "Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig);
+
+ m_console.Commands.AddCommand(
+ "General", false, "config get",
+ "config get [] []",
+ "Synonym for config show",
+ HandleConfig);
+
+ m_console.Commands.AddCommand(
+ "General", false, "config show",
+ "config show [] []",
+ "Show config information",
+ "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine
+ + "If a section is given but not a field, then all fields in that section are printed.",
+ HandleConfig);
+
+ m_console.Commands.AddCommand(
+ "General", false, "config save",
+ "config save ",
+ "Save current configuration to a file at the given path", HandleConfig);
+
+ m_console.Commands.AddCommand(
+ "General", false, "command-script",
+ "command-script