From 74a2bd237aed26b49d88045fe6afa526ed19c00d Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 16 Feb 2009 02:26:27 +0000 Subject: [PATCH] Add OpenSim & Simple inventory storage plugins and Null metrics plugin. --- .../AssetInventoryServer.cs | 7 +- .../Grid/AssetInventoryServer/Interfaces.cs | 2 +- .../{NullMetrics.cs => NullMetricsPlugin.cs} | 4 +- .../OpenSim/OpenSimInventoryStoragePlugin.cs} | 85 +++++++++++++------ ...setInventoryServerOpenSimPlugins.addin.xml | 3 + .../AssetInventoryServerPlugins.addin.xml | 2 +- ...ssetInventoryServerSimplePlugins.addin.xml | 3 + .../Simple/SimpleInventoryStoragePlugin.cs} | 61 +++++++++---- ...penSim.Grid.AssetInventoryServer.addin.xml | 2 +- prebuild.xml | 1 + 10 files changed, 117 insertions(+), 53 deletions(-) rename OpenSim/Grid/AssetInventoryServer/Plugins/{NullMetrics.cs => NullMetricsPlugin.cs} (98%) rename OpenSim/Grid/AssetInventoryServer/{Extensions/OpenSimMySQLInventory.cs => Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs} (95%) rename OpenSim/Grid/AssetInventoryServer/{Extensions/SimpleInventory.cs => Plugins/Simple/SimpleInventoryStoragePlugin.cs} (95%) diff --git a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs index e51f5597fa..e100377509 100644 --- a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs +++ b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs @@ -50,7 +50,7 @@ namespace OpenSim.Grid.AssetInventoryServer public IniConfigSource ConfigFile; public IAssetStorageProvider StorageProvider; - public IInventoryProvider InventoryProvider; + public IInventoryStorageProvider InventoryProvider; public IAuthenticationProvider AuthenticationProvider; public IAuthorizationProvider AuthorizationProvider; public IMetricsProvider MetricsProvider; @@ -107,7 +107,8 @@ namespace OpenSim.Grid.AssetInventoryServer } StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/StorageProvider", "OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim.dll") as IAssetStorageProvider; - MetricsProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/MetricsProvider", "") as IMetricsProvider; + InventoryProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/InventoryProvider", "OpenSim.Grid.AssetInventoryServer.Plugins.Simple.dll") as IInventoryStorageProvider; + MetricsProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/MetricsProvider", String.Empty) as IMetricsProvider; try { @@ -120,7 +121,7 @@ namespace OpenSim.Grid.AssetInventoryServer return false; } - frontend = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/Frontend", ""); + frontend = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/Frontend", String.Empty); return true; } diff --git a/OpenSim/Grid/AssetInventoryServer/Interfaces.cs b/OpenSim/Grid/AssetInventoryServer/Interfaces.cs index 870cf893c8..c4aa7ac8c3 100644 --- a/OpenSim/Grid/AssetInventoryServer/Interfaces.cs +++ b/OpenSim/Grid/AssetInventoryServer/Interfaces.cs @@ -83,7 +83,7 @@ namespace OpenSim.Grid.AssetInventoryServer int ForEach(Action action, int start, int count); } - public interface IInventoryProvider + public interface IInventoryStorageProvider : IAssetInventoryServerPlugin { BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItem item); BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolder folder); diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetrics.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs similarity index 98% rename from OpenSim/Grid/AssetInventoryServer/Plugins/NullMetrics.cs rename to OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs index 86ae5cd623..caa4efdff0 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetrics.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/NullMetricsPlugin.cs @@ -32,11 +32,11 @@ using OpenMetaverse; namespace OpenSim.Grid.AssetInventoryServer.Plugins { - public class NullMetrics : IMetricsProvider + public class NullMetricsPlugin : IMetricsProvider { AssetInventoryServer server; - public NullMetrics() + public NullMetricsPlugin() { } diff --git a/OpenSim/Grid/AssetInventoryServer/Extensions/OpenSimMySQLInventory.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs similarity index 95% rename from OpenSim/Grid/AssetInventoryServer/Extensions/OpenSimMySQLInventory.cs rename to OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs index 07bf92feb2..3fd06c0f03 100644 --- a/OpenSim/Grid/AssetInventoryServer/Extensions/OpenSimMySQLInventory.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs @@ -36,43 +36,25 @@ using ExtensionLoader; using ExtensionLoader.Config; using OpenMetaverse; using OpenMetaverse.StructuredData; +using OpenSim.Framework; +using OpenSim.Grid.AssetInventoryServer.Extensions; +using OpenSim.Data; -namespace OpenSim.Grid.AssetInventoryServer.Extensions +namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim { - public class OpenSimMySQLInventory : IExtension, IInventoryProvider + public class OpenSimInventoryStoragePlugin : IInventoryStorageProvider { - const string EXTENSION_NAME = "OpenSimMySQLInventory"; // Used in metrics reporting + const string EXTENSION_NAME = "OpenSimInventoryStorage"; // Used in metrics reporting - AssetInventoryServer server; + private AssetInventoryServer server; + private IInventoryDataPlugin m_inventoryProvider; - public OpenSimMySQLInventory() + public OpenSimInventoryStoragePlugin() { } #region Required Interfaces - public void Start(AssetInventoryServer server) - { - this.server = server; - - using (MySqlConnection dbConnection = new MySqlConnection(DBConnString.GetConnectionString(server.ConfigFile))) - { - try - { - dbConnection.Open(); - Logger.Log.Info("Connected to MySQL inventory backend: " + dbConnection.ServerVersion); - } - catch (MySqlException ex) - { - Logger.Log.Error("Connection to MySQL inventory backend failed: " + ex.Message); - } - } - } - - public void Stop() - { - } - public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItem item) { item = null; @@ -800,5 +782,54 @@ namespace OpenSim.Grid.AssetInventoryServer.Extensions } #endregion Required Interfaces + + #region IPlugin implementation + + public void Initialise(AssetInventoryServer server) + { + this.server = server; + + try + { + m_inventoryProvider = DataPluginFactory.LoadInventoryDataPlugin("OpenSim.Data.MySQL.dll", server.ConfigFile.Configs["MySQL"].GetString("database_connect", null)); + if (m_inventoryProvider == null) + { + Logger.Log.Error("[INVENTORY]: Failed to load a database plugin, server halting."); + Environment.Exit(-1); + } + else + Logger.Log.InfoFormat("[INVENTORY]: Loaded storage backend: {0}", Version); + } + catch (Exception e) + { + Logger.Log.WarnFormat("[INVENTORY]: Failure loading data plugin: {0}", e.ToString()); + } + } + + public void Stop() + { + } + + public void Initialise() + { + Logger.Log.InfoFormat("[INVENTORY]: {0} cannot be default-initialized!", Name); + throw new PluginNotInitialisedException(Name); + } + + public void Dispose() + { + } + + public string Version + { + get { return m_inventoryProvider.Version; } + } + + public string Name + { + get { return "AssetInventoryServer OpenSim inventory storage provider"; } + } + + #endregion IPlugin implementation } } diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/Resources/AssetInventoryServerOpenSimPlugins.addin.xml b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/Resources/AssetInventoryServerOpenSimPlugins.addin.xml index f458909410..6d21327e8d 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/Resources/AssetInventoryServerOpenSimPlugins.addin.xml +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/Resources/AssetInventoryServerOpenSimPlugins.addin.xml @@ -15,6 +15,9 @@ + + + diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml b/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml index bca7ee1b43..089c6a2f36 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Resources/AssetInventoryServerPlugins.addin.xml @@ -8,6 +8,6 @@ - + diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml index 53534c4a48..f898145b35 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/Resources/AssetInventoryServerSimplePlugins.addin.xml @@ -10,4 +10,7 @@ + + + diff --git a/OpenSim/Grid/AssetInventoryServer/Extensions/SimpleInventory.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs similarity index 95% rename from OpenSim/Grid/AssetInventoryServer/Extensions/SimpleInventory.cs rename to OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs index c140965583..78dae3536d 100644 --- a/OpenSim/Grid/AssetInventoryServer/Extensions/SimpleInventory.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs @@ -35,12 +35,13 @@ using System.Text; using ExtensionLoader; using OpenMetaverse; using OpenMetaverse.StructuredData; +using OpenSim.Framework; -namespace OpenSim.Grid.AssetInventoryServer.Extensions +namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple { - public class SimpleInventory : IExtension, IInventoryProvider + public class SimpleInventoryStoragePlugin : IInventoryStorageProvider { - const string EXTENSION_NAME = "SimpleInventory"; // Used for metrics reporting + const string EXTENSION_NAME = "SimpleInventoryStorage"; // Used for metrics reporting const string DEFAULT_INVENTORY_DIR = "SimpleInventory"; AssetInventoryServer server; @@ -49,26 +50,12 @@ namespace OpenSim.Grid.AssetInventoryServer.Extensions Utils.InventoryItemSerializer itemSerializer = new Utils.InventoryItemSerializer(); Utils.InventoryFolderSerializer folderSerializer = new Utils.InventoryFolderSerializer(); - public SimpleInventory() + public SimpleInventoryStoragePlugin() { } #region Required Interfaces - public void Start(AssetInventoryServer server) - { - this.server = server; - - LoadFiles(DEFAULT_INVENTORY_DIR); - - Logger.Log.InfoFormat("Initialized the inventory index with data for {0} avatars", - inventories.Count); - } - - public void Stop() - { - } - public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItem item) { item = null; @@ -598,5 +585,43 @@ namespace OpenSim.Grid.AssetInventoryServer.Extensions Logger.Log.ErrorFormat("Failed loading inventory from {0}: {1}", folder, ex.Message); } } + + #region IPlugin implementation + + public void Initialise(AssetInventoryServer server) + { + this.server = server; + + LoadFiles(DEFAULT_INVENTORY_DIR); + + Logger.Log.InfoFormat("Initialized the inventory index with data for {0} avatars", + inventories.Count); + } + + /// + /// Initialises asset interface + /// + public void Initialise() + { + Logger.Log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name); + throw new PluginNotInitialisedException(Name); + } + + public void Dispose() + { + } + + public string Version + { + // TODO: this should be something meaningful and not hardcoded? + get { return "0.1"; } + } + + public string Name + { + get { return "AssetInventoryServer Simple inventory storage provider"; } + } + + #endregion IPlugin implementation } } diff --git a/bin/OpenSim.Grid.AssetInventoryServer.addin.xml b/bin/OpenSim.Grid.AssetInventoryServer.addin.xml index 603ba85604..1ba5c8d5cc 100644 --- a/bin/OpenSim.Grid.AssetInventoryServer.addin.xml +++ b/bin/OpenSim.Grid.AssetInventoryServer.addin.xml @@ -10,7 +10,7 @@ - + diff --git a/prebuild.xml b/prebuild.xml index 715e8d5b88..cfa2b92a13 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -824,6 +824,7 @@ +