- change AssetInventoryServer config from XML to INI

- convert AssetInventoryServer logging to OpenSim's log4net
- updated AssetInventoryServer.ini.example file
0.6.3-post-fixes
Mike Mazur 2009-02-16 02:27:43 +00:00
parent 529dd66ed0
commit 5277fc64c0
19 changed files with 368 additions and 373 deletions

View File

@ -1,146 +0,0 @@
/*
* 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 OpenSim 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;
namespace OpenSim.Framework
{
/// <summary>
/// AssetInventoryConfig -- For AssetInventory Server Configuration
/// </summary>
public class AssetInventoryConfig
{
private ConfigurationMember configMember;
public const uint DefaultHttpPort = 8003;
public uint HttpPort = DefaultHttpPort;
public string AssetStorageProvider = "OpenSimAssetStorage";
public string AssetDatabaseConnect = String.Empty;
public string InventoryStorageProvider = "OpenSimInventoryStorage";
public string InventoryDatabaseConnect = String.Empty;
public string AuthenticationProvider = "NullAuthentication";
public string AuthorizationProvider = "AuthorizeAll";
public string MetricsProvider = "NullMetrics";
public string Frontends = "OpenSimAssetFrontend,OpenSimInventoryFrontend";
public AssetInventoryConfig(string description, string filename)
{
configMember = new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, true);
configMember.performConfigurationRetrieve();
}
public void loadConfigurationOptions()
{
configMember.addConfigurationOption("listen_port",
ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
"HTTP listener port",
DefaultHttpPort.ToString(),
false);
configMember.addConfigurationOption("asset_storage_provider",
ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Asset storage provider",
AssetStorageProvider,
false);
configMember.addConfigurationOption("asset_database_connect",
ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Asset database connection string",
AssetDatabaseConnect,
false);
configMember.addConfigurationOption("inventory_storage_provider",
ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Inventory storage provider",
InventoryStorageProvider,
false);
configMember.addConfigurationOption("inventory_database_connect",
ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Inventory database connection string",
InventoryDatabaseConnect,
false);
configMember.addConfigurationOption("authentication_provider",
ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Authentication provider",
AuthenticationProvider,
false);
configMember.addConfigurationOption("authorization_provider",
ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Authentication provider",
AuthorizationProvider,
false);
configMember.addConfigurationOption("metrics_provider",
ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Metrics provider",
MetricsProvider,
false);
configMember.addConfigurationOption("frontends",
ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Comma-separated list of frontends",
Frontends,
false);
}
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
{
switch (configuration_key)
{
case "listen_port":
HttpPort = (uint) configuration_result;
break;
case "asset_storage_provider":
AssetStorageProvider = (string) configuration_result;
break;
case "asset_database_connect":
AssetDatabaseConnect = (string) configuration_result;
break;
case "inventory_storage_provider":
InventoryStorageProvider = (string) configuration_result;
break;
case "inventory_database_connect":
InventoryDatabaseConnect = (string) configuration_result;
break;
case "authentication_provider":
AuthenticationProvider = (string) configuration_result;
break;
case "authorization_provider":
AuthorizationProvider = (string) configuration_result;
break;
case "metrics_provider":
MetricsProvider = (string) configuration_result;
break;
case "frontends":
Frontends = (string) configuration_result;
break;
}
return true;
}
}
}

View File

@ -0,0 +1,97 @@
/*
* 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.IO;
using System.Reflection;
using OpenSim.Framework;
using log4net;
using Nini.Config;
namespace OpenSim.Grid.AssetInventoryServer
{
public static class AssetInventoryConfig
{
public const string CONFIG_FILE = "AssetInventoryServer.ini";
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static IConfigSource LoadConfig()
{
IConfigSource configSource = new IniConfigSource();
configSource.AddConfig("Startup");
return LoadConfig(configSource);
}
public static IConfigSource LoadConfig(IConfigSource source)
{
string iniFileName = source.Configs["Startup"].GetString("inifile", CONFIG_FILE);
string iniFilePath = Path.Combine(Util.configDir(), iniFileName);
source.Merge(DefaultConfig());
if (!File.Exists(iniFilePath))
{
m_log.FatalFormat("[CONFIG] File {0} not found, could not load any configuration.", iniFilePath);
m_log.FatalFormat("[CONFIG] Did you copy the AssetInventoryServer.ini.example file to AssetInventoryServer.ini?");
Environment.Exit(1);
}
source.Merge(new IniConfigSource(iniFilePath));
return source;
}
private static IConfigSource DefaultConfig()
{
IConfigSource result = new IniConfigSource();
{
IConfig config = result.AddConfig("Config");
config.Set("listen_port", 8003);
}
{
IConfig config = result.AddConfig("Plugins");
config.Set("asset_storage_provider", "OpenSimAssetStorage");
config.Set("inventory_storage_provider", "OpenSimInventoryStorage");
config.Set("authentication_provider", "NullAuthentication");
config.Set("authorization_provider", "AuthorizeAll");
config.Set("metrics_provider", "NullMetrics");
config.Set("frontends", "ReferenceFrontend,OpenSimAssetFrontend,OpenSimInventoryFrontend,BrowseFrontend");
}
{
IConfig config = result.AddConfig("OpenSim");
config.Set("asset_database_provider", "OpenSim.Data.MySQL.dll");
config.Set("inventory_database_provider", "OpenSim.Data.MySQL.dll");
config.Set("asset_database_connect", String.Empty);
config.Set("inventory_database_connect", String.Empty);
}
return result;
}
}
}

View File

@ -32,18 +32,18 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using log4net;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using Nini.Config;
using log4net;
namespace OpenSim.Grid.AssetInventoryServer namespace OpenSim.Grid.AssetInventoryServer
{ {
public class AssetInventoryServer : BaseOpenSimServer public class AssetInventoryServer : BaseOpenSimServer
{ {
public const string CONFIG_FILE = "AssetInventoryServer.ini"; private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public IConfigSource ConfigFile;
public AssetInventoryConfig ConfigFile;
public IAssetStorageProvider StorageProvider; public IAssetStorageProvider StorageProvider;
public IInventoryStorageProvider InventoryProvider; public IInventoryStorageProvider InventoryProvider;
@ -54,51 +54,58 @@ namespace OpenSim.Grid.AssetInventoryServer
private List<IAssetInventoryServerPlugin> m_frontends = new List<IAssetInventoryServerPlugin>(); private List<IAssetInventoryServerPlugin> m_frontends = new List<IAssetInventoryServerPlugin>();
private List<IAssetInventoryServerPlugin> m_backends = new List<IAssetInventoryServerPlugin>(); private List<IAssetInventoryServerPlugin> m_backends = new List<IAssetInventoryServerPlugin>();
public AssetInventoryServer() public AssetInventoryServer(IConfigSource config)
{ {
m_console = new ConsoleBase("Asset"); ConfigFile = config;
m_console = new ConsoleBase("AssetInventory");
MainConsole.Instance = m_console; MainConsole.Instance = m_console;
} }
public bool Start() public bool Start()
{ {
Logger.Log.Info("Starting Asset Server"); Startup();
uint port = 0; m_log.Info("[ASSETINVENTORY] Starting AssetInventory Server");
try { ConfigFile = new AssetInventoryConfig("AssetInventory Server", (Path.Combine(Util.configDir(), "AssetInventoryServer.ini"))); } try
{
ConfigFile = AssetInventoryConfig.LoadConfig(ConfigFile);
}
catch (Exception) catch (Exception)
{ {
Logger.Log.Error("Failed to load the config file " + CONFIG_FILE); m_log.Error("[ASSETINVENTORY] Failed to load the config.");
return false; return false;
} }
StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/StorageProvider", ConfigFile.AssetStorageProvider) as IAssetStorageProvider; IConfig pluginConfig = ConfigFile.Configs["Plugins"];
StorageProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/StorageProvider", pluginConfig.GetString("asset_storage_provider")) as IAssetStorageProvider;
m_backends.Add(StorageProvider); m_backends.Add(StorageProvider);
InventoryProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/InventoryProvider", ConfigFile.InventoryStorageProvider) as IInventoryStorageProvider; InventoryProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/InventoryProvider", pluginConfig.GetString("inventory_storage_provider")) as IInventoryStorageProvider;
m_backends.Add(InventoryProvider); m_backends.Add(InventoryProvider);
MetricsProvider = LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/MetricsProvider", ConfigFile.MetricsProvider) as IMetricsProvider; MetricsProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/MetricsProvider", pluginConfig.GetString("metrics_provider")) as IMetricsProvider;
m_backends.Add(MetricsProvider); m_backends.Add(MetricsProvider);
try try
{ {
InitHttpServer(ConfigFile.HttpPort); InitHttpServer((uint) ConfigFile.Configs["Config"].GetInt("listen_port"));
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.Error("Initializing the HTTP server failed, shutting down: " + ex.Message); m_log.Error("[ASSETINVENTORY] Initializing the HTTP server failed, shutting down: " + ex.Message);
Shutdown(); Shutdown();
return false; return false;
} }
AuthenticationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthenticationProvider", ConfigFile.AuthenticationProvider) as IAuthenticationProvider; AuthenticationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthenticationProvider", pluginConfig.GetString("authentication_provider")) as IAuthenticationProvider;
m_backends.Add(AuthenticationProvider); m_backends.Add(AuthenticationProvider);
AuthorizationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthorizationProvider", ConfigFile.AuthorizationProvider) as IAuthorizationProvider; AuthorizationProvider = LoadAssetInventoryServerPlugin("/OpenSim/AssetInventoryServer/AuthorizationProvider", pluginConfig.GetString("authorization_provider")) as IAuthorizationProvider;
m_backends.Add(AuthorizationProvider); m_backends.Add(AuthorizationProvider);
m_frontends.AddRange(LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/Frontend", ConfigFile.Frontends)); m_frontends.AddRange(LoadAssetInventoryServerPlugins("/OpenSim/AssetInventoryServer/Frontend", pluginConfig.GetString("frontends")));
return true; return true;
} }
@ -117,18 +124,18 @@ namespace OpenSim.Grid.AssetInventoryServer
{ {
foreach (IAssetInventoryServerPlugin plugin in m_frontends) foreach (IAssetInventoryServerPlugin plugin in m_frontends)
{ {
Logger.Log.Debug("Disposing plugin " + plugin.Name); m_log.Debug("[ASSETINVENTORY] Disposing plugin " + plugin.Name);
try { plugin.Dispose(); } try { plugin.Dispose(); }
catch (Exception ex) catch (Exception ex)
{ Logger.Log.ErrorFormat("Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); } { m_log.ErrorFormat("[ASSETINVENTORY] Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); }
} }
foreach (IAssetInventoryServerPlugin plugin in m_backends) foreach (IAssetInventoryServerPlugin plugin in m_backends)
{ {
Logger.Log.Debug("Disposing plugin " + plugin.Name); m_log.Debug("[ASSETINVENTORY] Disposing plugin " + plugin.Name);
try { plugin.Dispose(); } try { plugin.Dispose(); }
catch (Exception ex) catch (Exception ex)
{ Logger.Log.ErrorFormat("Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); } { m_log.ErrorFormat("[ASSETINVENTORY] Failure shutting down plugin {0}: {1}", plugin.Name, ex.Message); }
} }
if (HttpServer != null) if (HttpServer != null)
@ -140,7 +147,7 @@ namespace OpenSim.Grid.AssetInventoryServer
m_httpServer = new BaseHttpServer(port); m_httpServer = new BaseHttpServer(port);
m_httpServer.Start(); m_httpServer.Start();
Logger.Log.Info("Asset server is listening on port " + port); m_log.Info("[ASSETINVENTORY] AssetInventory server is listening on port " + port);
} }
private IAssetInventoryServerPlugin LoadAssetInventoryServerPlugin(string addinPath, string provider) private IAssetInventoryServerPlugin LoadAssetInventoryServerPlugin(string addinPath, string provider)

View File

@ -1,62 +0,0 @@
/*
* Copyright (c) 2008 Intel Corporation
* All rights reserved.
* 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 Intel Corporation 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``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 INTEL OR ITS
* 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 log4net;
using log4net.Config;
[assembly: log4net.Config.XmlConfigurator(ConfigFileExtension = "log4net")]
namespace OpenSim.Grid.AssetInventoryServer
{
/// <summary>
/// Singleton logging class for the entire library
/// </summary>
public static class Logger
{
/// <summary>log4net logging engine</summary>
public static ILog Log;
static Logger()
{
Log = LogManager.GetLogger(System.Reflection.Assembly.GetExecutingAssembly().FullName);
// If error level reporting isn't enabled we assume no logger is configured and initialize a default
// ConsoleAppender
if (!Log.Logger.IsEnabledFor(log4net.Core.Level.Error))
{
log4net.Appender.ConsoleAppender appender = new log4net.Appender.ConsoleAppender();
appender.Layout = new log4net.Layout.PatternLayout("%timestamp [%thread] %-5level - %message%newline");
BasicConfigurator.Configure(appender);
Log.Info("No log configuration found, defaulting to console logging");
}
}
}
}

View File

@ -28,7 +28,8 @@
*/ */
using System; using System;
using System.ServiceProcess; using Nini.Config;
using log4net.Config;
namespace OpenSim.Grid.AssetInventoryServer namespace OpenSim.Grid.AssetInventoryServer
{ {
@ -36,28 +37,24 @@ namespace OpenSim.Grid.AssetInventoryServer
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
#if DEBUG XmlConfigurator.Configure();
AssetInventoryServer server = new AssetInventoryServer();
ArgvConfigSource configSource = new ArgvConfigSource(args);
configSource.AddSwitch("Startup", "inifile");
AssetInventoryServer server = new AssetInventoryServer(configSource);
if (server.Start()) if (server.Start())
{ {
Console.WriteLine("Asset server is running. Press CTRL+C to quit");
Console.CancelKeyPress += Console.CancelKeyPress +=
delegate(object sender, ConsoleCancelEventArgs e) delegate(object sender, ConsoleCancelEventArgs e)
{ {
Console.WriteLine("Asset server is shutting down..."); Console.WriteLine("AssetInventory server is shutting down...");
server.Shutdown(); server.Shutdown();
Environment.Exit(0); Environment.Exit(0);
}; };
server.Work(); server.Work();
//while (true)
// Console.ReadLine();
} }
#else
ServiceBase[] servicesToRun = new ServiceBase[] { new AssetInventoryServer() };
ServiceBase.Run(servicesToRun);
#endif
} }
} }
} }

View File

@ -28,13 +28,16 @@
*/ */
using System; using System;
using System.Reflection;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using log4net;
namespace OpenSim.Grid.AssetInventoryServer.Plugins namespace OpenSim.Grid.AssetInventoryServer.Plugins
{ {
public class AuthorizeAllPlugin : IAuthorizationProvider public class AuthorizeAllPlugin : IAuthorizationProvider
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
AssetInventoryServer server; AssetInventoryServer server;
public AuthorizeAllPlugin() public AuthorizeAllPlugin()
@ -47,7 +50,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
{ {
this.server = server; this.server = server;
Logger.Log.Info("[ASSET] Authorize All loaded."); m_log.Info("[ASSET] Authorize All loaded.");
} }
/// <summary> /// <summary>
@ -55,7 +58,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
/// </summary> /// </summary>
public void Initialise() public void Initialise()
{ {
Logger.Log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name); m_log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name);
throw new PluginNotInitialisedException(Name); throw new PluginNotInitialisedException(Name);
} }

View File

@ -29,6 +29,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Net; using System.Net;
@ -37,11 +38,13 @@ using System.Web;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using log4net;
namespace OpenSim.Grid.AssetInventoryServer.Plugins namespace OpenSim.Grid.AssetInventoryServer.Plugins
{ {
public class BrowseFrontendPlugin : IAssetInventoryServerPlugin public class BrowseFrontendPlugin : IAssetInventoryServerPlugin
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
AssetInventoryServer m_server; AssetInventoryServer m_server;
public BrowseFrontendPlugin() public BrowseFrontendPlugin()
@ -58,7 +61,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
//server.HttpServer.AddHandler("get", null, @"(^/$)|(^/\?.*)", BrowseRequestHandler); //server.HttpServer.AddHandler("get", null, @"(^/$)|(^/\?.*)", BrowseRequestHandler);
m_server.HttpServer.AddStreamHandler(new BrowseRequestHandler(server)); m_server.HttpServer.AddStreamHandler(new BrowseRequestHandler(server));
Logger.Log.Info("[ASSET] Browser Frontend loaded."); m_log.Info("[ASSET] Browser Frontend loaded.");
} }
/// <summary> /// <summary>
@ -66,7 +69,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
/// </summary> /// </summary>
public void Initialise() public void Initialise()
{ {
Logger.Log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name); m_log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name);
throw new PluginNotInitialisedException(Name); throw new PluginNotInitialisedException(Name);
} }

View File

@ -28,13 +28,16 @@
*/ */
using System; using System;
using System.Reflection;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using log4net;
namespace OpenSim.Grid.AssetInventoryServer.Plugins namespace OpenSim.Grid.AssetInventoryServer.Plugins
{ {
public class NullAuthenticationPlugin : IAuthenticationProvider public class NullAuthenticationPlugin : IAuthenticationProvider
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
AssetInventoryServer server; AssetInventoryServer server;
public NullAuthenticationPlugin() public NullAuthenticationPlugin()
@ -47,7 +50,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
{ {
this.server = server; this.server = server;
Logger.Log.Info("[ASSET] Null Authentication loaded."); m_log.Info("[ASSET] Null Authentication loaded.");
} }
/// <summary> /// <summary>
@ -55,7 +58,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
/// </summary> /// </summary>
public void Initialise() public void Initialise()
{ {
Logger.Log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name); m_log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name);
throw new PluginNotInitialisedException(Name); throw new PluginNotInitialisedException(Name);
} }

View File

@ -28,12 +28,15 @@
*/ */
using System; using System;
using System.Reflection;
using OpenMetaverse; using OpenMetaverse;
using log4net;
namespace OpenSim.Grid.AssetInventoryServer.Plugins namespace OpenSim.Grid.AssetInventoryServer.Plugins
{ {
public class NullMetricsPlugin : IMetricsProvider public class NullMetricsPlugin : IMetricsProvider
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
AssetInventoryServer server; AssetInventoryServer server;
public NullMetricsPlugin() public NullMetricsPlugin()
@ -44,72 +47,72 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
public void LogAssetMetadataFetch(string extension, BackendResponse response, UUID assetID, DateTime time) public void LogAssetMetadataFetch(string extension, BackendResponse response, UUID assetID, DateTime time)
{ {
Logger.Log.DebugFormat("[{0}] AssetMetadataFetch(): AssetID: {1}, Response: {2}", extension, assetID, response); m_log.DebugFormat("[{0}] AssetMetadataFetch(): AssetID: {1}, Response: {2}", extension, assetID, response);
} }
public void LogAssetDataFetch(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time) public void LogAssetDataFetch(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time)
{ {
Logger.Log.DebugFormat("[{0}] AssetDataFetch(): AssetID: {1}, DataSize: {2}, Response: {3}", extension, assetID, m_log.DebugFormat("[{0}] AssetDataFetch(): AssetID: {1}, DataSize: {2}, Response: {3}", extension, assetID,
dataSize, response); dataSize, response);
} }
public void LogAssetCreate(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time) public void LogAssetCreate(string extension, BackendResponse response, UUID assetID, int dataSize, DateTime time)
{ {
Logger.Log.DebugFormat("[{0}] AssetCreate(): AssetID: {1}, DataSize: {2}, Response: {3}", extension, assetID, m_log.DebugFormat("[{0}] AssetCreate(): AssetID: {1}, DataSize: {2}, Response: {3}", extension, assetID,
dataSize, response); dataSize, response);
} }
public void LogInventoryFetch(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time) public void LogInventoryFetch(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time)
{ {
Logger.Log.DebugFormat("[{0}] InventoryFetch(): ObjID: {1}, Folder: {2}, OwnerID: {3}, Response: {4}", extension, m_log.DebugFormat("[{0}] InventoryFetch(): ObjID: {1}, Folder: {2}, OwnerID: {3}, Response: {4}", extension,
objID, folder, owner, response); objID, folder, owner, response);
} }
public void LogInventoryFetchFolderContents(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time) public void LogInventoryFetchFolderContents(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time)
{ {
Logger.Log.DebugFormat("[{0}] InventoryFetchFolderContents(): FolderID: {1}, OwnerID: {2}, Response: {3}", extension, m_log.DebugFormat("[{0}] InventoryFetchFolderContents(): FolderID: {1}, OwnerID: {2}, Response: {3}", extension,
folderID, owner, response); folderID, owner, response);
} }
public void LogInventoryFetchFolderList(string extension, BackendResponse response, Uri owner, DateTime time) public void LogInventoryFetchFolderList(string extension, BackendResponse response, Uri owner, DateTime time)
{ {
Logger.Log.DebugFormat("[{0}] InventoryFetchFolderList(): OwnerID: {1}, Response: {2}", extension, m_log.DebugFormat("[{0}] InventoryFetchFolderList(): OwnerID: {1}, Response: {2}", extension,
owner, response); owner, response);
} }
public void LogInventoryFetchInventory(string extension, BackendResponse response, Uri owner, DateTime time) public void LogInventoryFetchInventory(string extension, BackendResponse response, Uri owner, DateTime time)
{ {
Logger.Log.DebugFormat("[{0}] InventoryFetchInventory(): OwnerID: {1}, Response: {2}", extension, m_log.DebugFormat("[{0}] InventoryFetchInventory(): OwnerID: {1}, Response: {2}", extension,
owner, response); owner, response);
} }
public void LogInventoryFetchActiveGestures(string extension, BackendResponse response, Uri owner, DateTime time) public void LogInventoryFetchActiveGestures(string extension, BackendResponse response, Uri owner, DateTime time)
{ {
Logger.Log.DebugFormat("[{0}] InventoryFetchActiveGestures(): OwnerID: {1}, Response: {2}", extension, m_log.DebugFormat("[{0}] InventoryFetchActiveGestures(): OwnerID: {1}, Response: {2}", extension,
owner, response); owner, response);
} }
public void LogInventoryCreate(string extension, BackendResponse response, Uri owner, bool folder, DateTime time) public void LogInventoryCreate(string extension, BackendResponse response, Uri owner, bool folder, DateTime time)
{ {
Logger.Log.DebugFormat("[{0}] InventoryCreate(): OwnerID: {1}, Response: {2}", extension, m_log.DebugFormat("[{0}] InventoryCreate(): OwnerID: {1}, Response: {2}", extension,
owner, response); owner, response);
} }
public void LogInventoryCreateInventory(string extension, BackendResponse response, DateTime time) public void LogInventoryCreateInventory(string extension, BackendResponse response, DateTime time)
{ {
Logger.Log.DebugFormat("[{0}] InventoryCreateInventory(): Response: {1}", extension, m_log.DebugFormat("[{0}] InventoryCreateInventory(): Response: {1}", extension,
response); response);
} }
public void LogInventoryDelete(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time) public void LogInventoryDelete(string extension, BackendResponse response, Uri owner, UUID objID, bool folder, DateTime time)
{ {
Logger.Log.DebugFormat("[{0}] InventoryDelete(): OwnerID: {1}, Folder: {2}, Response: {3}", extension, m_log.DebugFormat("[{0}] InventoryDelete(): OwnerID: {1}, Folder: {2}, Response: {3}", extension,
owner, folder, response); owner, folder, response);
} }
public void LogInventoryPurgeFolder(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time) public void LogInventoryPurgeFolder(string extension, BackendResponse response, Uri owner, UUID folderID, DateTime time)
{ {
Logger.Log.DebugFormat("[{0}] InventoryPurgeFolder(): OwnerID: {1}, FolderID: {2}, Response: {3}", extension, m_log.DebugFormat("[{0}] InventoryPurgeFolder(): OwnerID: {1}, FolderID: {2}, Response: {3}", extension,
owner, response); owner, response);
} }
@ -128,6 +131,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
public void Initialise() public void Initialise()
{ {
this.server = null; this.server = null;
m_log.Info("[ASSET] Null metrics loaded.");
} }
public void Dispose() public void Dispose()

View File

@ -28,6 +28,7 @@
*/ */
using System; using System;
using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.IO; using System.IO;
@ -38,11 +39,13 @@ using OpenMetaverse;
using HttpServer; using HttpServer;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using log4net;
namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
{ {
public class OpenSimAssetFrontendPlugin : IAssetInventoryServerPlugin public class OpenSimAssetFrontendPlugin : IAssetInventoryServerPlugin
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private AssetInventoryServer m_server; private AssetInventoryServer m_server;
public OpenSimAssetFrontendPlugin() public OpenSimAssetFrontendPlugin()
@ -61,7 +64,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
// Asset creation // Asset creation
m_server.HttpServer.AddStreamHandler(new AssetPostHandler(server)); m_server.HttpServer.AddStreamHandler(new AssetPostHandler(server));
Logger.Log.Info("[ASSET] OpenSim Asset Frontend loaded."); m_log.Info("[ASSET] OpenSim Asset Frontend loaded.");
} }
/// <summary> /// <summary>
@ -69,7 +72,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
/// </summary> /// </summary>
public void Initialise() public void Initialise()
{ {
Logger.Log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name); m_log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name);
throw new PluginNotInitialisedException(Name); throw new PluginNotInitialisedException(Name);
} }
@ -97,7 +100,6 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
//public AssetRequestHandler(AssetInventoryServer server) : base("GET", "^/assets") //public AssetRequestHandler(AssetInventoryServer server) : base("GET", "^/assets")
public AssetRequestHandler(AssetInventoryServer server) : base("GET", "/assets") public AssetRequestHandler(AssetInventoryServer server) : base("GET", "/assets")
{ {
Logger.Log.Info("[REST]: In Get Request");
m_server = server; m_server = server;
} }
@ -128,13 +130,13 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
else else
{ {
Logger.Log.WarnFormat("Failed to fetch asset data or metadata for {0}: {1}", assetID, dataResponse); m_log.WarnFormat("Failed to fetch asset data or metadata for {0}: {1}", assetID, dataResponse);
httpResponse.StatusCode = (int) HttpStatusCode.NotFound; httpResponse.StatusCode = (int) HttpStatusCode.NotFound;
} }
} }
else else
{ {
Logger.Log.Warn("Unrecognized OpenSim asset request: " + httpRequest.Url.PathAndQuery); m_log.Warn("Unrecognized OpenSim asset request: " + httpRequest.Url.PathAndQuery);
} }
return buffer; return buffer;
@ -181,13 +183,13 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
else else
{ {
Logger.Log.Warn("AssetPostHandler called with no asset data"); m_log.Warn("AssetPostHandler called with no asset data");
httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; httpResponse.StatusCode = (int) HttpStatusCode.BadRequest;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.Warn("Failed to parse POST data (expecting AssetBase): " + ex.Message); m_log.Warn("Failed to parse POST data (expecting AssetBase): " + ex.Message);
httpResponse.StatusCode = (int) HttpStatusCode.BadRequest; httpResponse.StatusCode = (int) HttpStatusCode.BadRequest;
} }

View File

@ -28,6 +28,7 @@
*/ */
using System; using System;
using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.Data; using System.Data;
@ -36,15 +37,19 @@ using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Data; using OpenSim.Data;
using Nini.Config;
using log4net;
namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
{ {
public class OpenSimAssetStoragePlugin : IAssetStorageProvider public class OpenSimAssetStoragePlugin : IAssetStorageProvider
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
const string EXTENSION_NAME = "OpenSimAssetStorage"; // Used in metrics reporting const string EXTENSION_NAME = "OpenSimAssetStorage"; // Used in metrics reporting
private AssetInventoryServer server; private AssetInventoryServer m_server;
private IAssetDataPlugin m_assetProvider; private IAssetDataPlugin m_assetProvider;
private IConfig m_openSimConfig;
public OpenSimAssetStoragePlugin() public OpenSimAssetStoragePlugin()
{ {
@ -57,7 +62,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
metadata = null; metadata = null;
BackendResponse ret; BackendResponse ret;
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.AssetDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("asset_database_connect")))
{ {
IDataReader reader; IDataReader reader;
@ -89,12 +94,12 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now); m_server.MetricsProvider.LogAssetMetadataFetch(EXTENSION_NAME, ret, assetID, DateTime.Now);
return ret; return ret;
} }
@ -103,7 +108,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
assetData = null; assetData = null;
BackendResponse ret; BackendResponse ret;
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.AssetDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("asset_database_connect")))
{ {
IDataReader reader; IDataReader reader;
@ -127,12 +132,12 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (assetData != null ? assetData.Length : 0), DateTime.Now); m_server.MetricsProvider.LogAssetDataFetch(EXTENSION_NAME, ret, assetID, (assetData != null ? assetData.Length : 0), DateTime.Now);
return ret; return ret;
} }
@ -155,7 +160,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
{ {
BackendResponse ret; BackendResponse ret;
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.AssetDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("asset_database_connect")))
{ {
try try
{ {
@ -180,23 +185,23 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
else if (rowsAffected == 2) else if (rowsAffected == 2)
{ {
Logger.Log.Info("Replaced asset " + metadata.ID.ToString()); m_log.Info("Replaced asset " + metadata.ID.ToString());
ret = BackendResponse.Success; ret = BackendResponse.Success;
} }
else else
{ {
Logger.Log.ErrorFormat("MySQL REPLACE query affected {0} rows", rowsAffected); m_log.ErrorFormat("MySQL REPLACE query affected {0} rows", rowsAffected);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
server.MetricsProvider.LogAssetCreate(EXTENSION_NAME, ret, metadata.ID, assetData.Length, DateTime.Now); m_server.MetricsProvider.LogAssetCreate(EXTENSION_NAME, ret, metadata.ID, assetData.Length, DateTime.Now);
return ret; return ret;
} }
@ -204,7 +209,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
{ {
int rowCount = 0; int rowCount = 0;
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.AssetDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("asset_database_connect")))
{ {
MySqlDataReader reader; MySqlDataReader reader;
@ -219,7 +224,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
return 0; return 0;
} }
@ -250,22 +255,24 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
public void Initialise(AssetInventoryServer server) public void Initialise(AssetInventoryServer server)
{ {
this.server = server; m_server = server;
m_openSimConfig = server.ConfigFile.Configs["OpenSim"];
try try
{ {
m_assetProvider = DataPluginFactory.LoadDataPlugin<IAssetDataPlugin>("OpenSim.Data.MySQL.dll", server.ConfigFile.AssetDatabaseConnect); m_assetProvider = DataPluginFactory.LoadDataPlugin<IAssetDataPlugin>(m_openSimConfig.GetString("asset_database_provider"),
m_openSimConfig.GetString("asset_database_connect"));
if (m_assetProvider == null) if (m_assetProvider == null)
{ {
Logger.Log.Error("[ASSET]: Failed to load a database plugin, server halting."); m_log.Error("[ASSET]: Failed to load a database plugin, server halting.");
Environment.Exit(-1); Environment.Exit(-1);
} }
else else
Logger.Log.InfoFormat("[ASSET]: Loaded storage backend: {0}", Version); m_log.InfoFormat("[ASSET]: Loaded storage backend: {0}", Version);
} }
catch (Exception e) catch (Exception e)
{ {
Logger.Log.WarnFormat("[ASSET]: Failure loading data plugin: {0}", e.ToString()); m_log.WarnFormat("[ASSET]: Failure loading data plugin: {0}", e.ToString());
} }
} }
@ -274,7 +281,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
/// </summary> /// </summary>
public void Initialise() public void Initialise()
{ {
Logger.Log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name); m_log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name);
throw new PluginNotInitialisedException(Name); throw new PluginNotInitialisedException(Name);
} }

View File

@ -28,6 +28,7 @@
*/ */
using System; using System;
using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.IO; using System.IO;
@ -36,11 +37,13 @@ using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using HttpServer; using HttpServer;
using OpenSim.Framework; using OpenSim.Framework;
using log4net;
namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
{ {
public class OpenSimInventoryFrontendPlugin : IAssetInventoryServerPlugin public class OpenSimInventoryFrontendPlugin : IAssetInventoryServerPlugin
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private AssetInventoryServer server; private AssetInventoryServer server;
private Utils.InventoryItemSerializer itemSerializer = new Utils.InventoryItemSerializer(); private Utils.InventoryItemSerializer itemSerializer = new Utils.InventoryItemSerializer();
private Utils.InventoryFolderSerializer folderSerializer = new Utils.InventoryFolderSerializer(); private Utils.InventoryFolderSerializer folderSerializer = new Utils.InventoryFolderSerializer();
@ -67,7 +70,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
//server.HttpServer.AddHandler("post", null, @"^/RootFolders/", RootFoldersHandler); //server.HttpServer.AddHandler("post", null, @"^/RootFolders/", RootFoldersHandler);
//server.HttpServer.AddHandler("post", null, @"^/ActiveGestures/", ActiveGesturesHandler); //server.HttpServer.AddHandler("post", null, @"^/ActiveGestures/", ActiveGesturesHandler);
Logger.Log.Info("[INVENTORY] OpenSim Inventory Frontend loaded."); m_log.Info("[INVENTORY] OpenSim Inventory Frontend loaded.");
} }
/// <summary> /// <summary>
@ -75,7 +78,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
/// </summary> /// </summary>
public void Initialise() public void Initialise()
{ {
Logger.Log.InfoFormat("[INVENTORY]: {0} cannot be default-initialized!", Name); m_log.InfoFormat("[INVENTORY]: {0} cannot be default-initialized!", Name);
throw new PluginNotInitialisedException(Name); throw new PluginNotInitialisedException(Name);
} }
@ -103,7 +106,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
// if (ownerID != UUID.Zero) // if (ownerID != UUID.Zero)
// { // {
// Logger.Log.Warn("GetInventory is not scalable on some inventory backends, avoid calling it wherever possible"); // m_log.Warn("GetInventory is not scalable on some inventory backends, avoid calling it wherever possible");
// Uri owner = Utils.GetOpenSimUri(ownerID); // Uri owner = Utils.GetOpenSimUri(ownerID);
// InventoryCollection inventory; // InventoryCollection inventory;
@ -144,7 +147,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
// if (ownerID != UUID.Zero) // if (ownerID != UUID.Zero)
// { // {
// Uri owner = Utils.GetOpenSimUri(ownerID); // Uri owner = Utils.GetOpenSimUri(ownerID);
// Logger.Log.DebugFormat("Created URI {0} for inventory creation", owner); // m_log.DebugFormat("Created URI {0} for inventory creation", owner);
// InventoryFolder rootFolder = new InventoryFolder("My Inventory", ownerID, UUID.Zero, (short)AssetType.Folder); // InventoryFolder rootFolder = new InventoryFolder("My Inventory", ownerID, UUID.Zero, (short)AssetType.Folder);
// BackendResponse storageResponse = server.InventoryProvider.TryCreateInventory(owner, rootFolder); // BackendResponse storageResponse = server.InventoryProvider.TryCreateInventory(owner, rootFolder);
@ -365,7 +368,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.Warn("Failed to parse POST data (expecting guid): " + ex.Message); m_log.Warn("Failed to parse POST data (expecting guid): " + ex.Message);
} }
return id; return id;
@ -389,7 +392,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.Warn("Failed to parse GetInventory POST data: " + ex.Message); m_log.Warn("Failed to parse GetInventory POST data: " + ex.Message);
agentID = UUID.Zero; agentID = UUID.Zero;
sessionID = UUID.Zero; sessionID = UUID.Zero;
return UUID.Zero; return UUID.Zero;
@ -426,7 +429,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.Warn("Failed to parse POST data (expecting InventoryFolderBase): " + ex.Message); m_log.Warn("Failed to parse POST data (expecting InventoryFolderBase): " + ex.Message);
agentID = UUID.Zero; agentID = UUID.Zero;
sessionID = UUID.Zero; sessionID = UUID.Zero;
return null; return null;
@ -474,7 +477,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.Warn("Failed to parse POST data (expecting InventoryItemBase): " + ex.Message); m_log.Warn("Failed to parse POST data (expecting InventoryItemBase): " + ex.Message);
agentID = UUID.Zero; agentID = UUID.Zero;
sessionID = UUID.Zero; sessionID = UUID.Zero;
return null; return null;

View File

@ -28,6 +28,7 @@
*/ */
using System; using System;
using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.Data; using System.Data;
@ -36,15 +37,19 @@ using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Data; using OpenSim.Data;
using Nini.Config;
using log4net;
namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
{ {
public class OpenSimInventoryStoragePlugin : IInventoryStorageProvider public class OpenSimInventoryStoragePlugin : IInventoryStorageProvider
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
const string EXTENSION_NAME = "OpenSimInventoryStorage"; // Used in metrics reporting const string EXTENSION_NAME = "OpenSimInventoryStorage"; // Used in metrics reporting
private AssetInventoryServer server; private AssetInventoryServer m_server;
private IInventoryDataPlugin m_inventoryProvider; private IInventoryDataPlugin m_inventoryProvider;
private IConfig m_openSimConfig;
public OpenSimInventoryStoragePlugin() public OpenSimInventoryStoragePlugin()
{ {
@ -57,7 +62,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
item = null; item = null;
BackendResponse ret; BackendResponse ret;
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
{ {
IDataReader reader; IDataReader reader;
@ -105,12 +110,12 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now); m_server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now);
return ret; return ret;
} }
@ -119,7 +124,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
folder = null; folder = null;
BackendResponse ret; BackendResponse ret;
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
{ {
IDataReader reader; IDataReader reader;
@ -152,12 +157,12 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now); m_server.MetricsProvider.LogInventoryFetch(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now);
return ret; return ret;
} }
@ -166,7 +171,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
contents = null; contents = null;
BackendResponse ret; BackendResponse ret;
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
{ {
IDataReader reader; IDataReader reader;
@ -249,12 +254,12 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
server.MetricsProvider.LogInventoryFetchFolderContents(EXTENSION_NAME, ret, owner, folderID, DateTime.Now); m_server.MetricsProvider.LogInventoryFetchFolderContents(EXTENSION_NAME, ret, owner, folderID, DateTime.Now);
return ret; return ret;
} }
@ -266,7 +271,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
if (Utils.TryGetOpenSimUUID(owner, out ownerID)) if (Utils.TryGetOpenSimUUID(owner, out ownerID))
{ {
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
{ {
IDataReader reader; IDataReader reader;
@ -298,7 +303,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
@ -308,7 +313,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
ret = BackendResponse.NotFound; ret = BackendResponse.NotFound;
} }
server.MetricsProvider.LogInventoryFetchFolderList(EXTENSION_NAME, ret, owner, DateTime.Now); m_server.MetricsProvider.LogInventoryFetchFolderList(EXTENSION_NAME, ret, owner, DateTime.Now);
return ret; return ret;
} }
@ -332,7 +337,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
// Fetch inventory items // Fetch inventory items
if (Utils.TryGetOpenSimUUID(owner, out ownerID)) if (Utils.TryGetOpenSimUUID(owner, out ownerID))
{ {
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
{ {
IDataReader reader; IDataReader reader;
@ -381,7 +386,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
@ -392,7 +397,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
} }
server.MetricsProvider.LogInventoryFetchInventory(EXTENSION_NAME, ret, owner, DateTime.Now); m_server.MetricsProvider.LogInventoryFetchInventory(EXTENSION_NAME, ret, owner, DateTime.Now);
return ret; return ret;
} }
@ -404,7 +409,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
if (Utils.TryGetOpenSimUUID(owner, out ownerID)) if (Utils.TryGetOpenSimUUID(owner, out ownerID))
{ {
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
{ {
IDataReader reader; IDataReader reader;
@ -451,7 +456,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
@ -461,7 +466,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
ret = BackendResponse.NotFound; ret = BackendResponse.NotFound;
} }
server.MetricsProvider.LogInventoryFetchActiveGestures(EXTENSION_NAME, ret, owner, DateTime.Now); m_server.MetricsProvider.LogInventoryFetchActiveGestures(EXTENSION_NAME, ret, owner, DateTime.Now);
return ret; return ret;
} }
@ -469,7 +474,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
{ {
BackendResponse ret; BackendResponse ret;
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
{ {
try try
{ {
@ -512,23 +517,23 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
else if (rowsAffected == 2) else if (rowsAffected == 2)
{ {
Logger.Log.Info("Replaced inventory item " + item.ID.ToString()); m_log.Info("Replaced inventory item " + item.ID.ToString());
ret = BackendResponse.Success; ret = BackendResponse.Success;
} }
else else
{ {
Logger.Log.ErrorFormat("MySQL REPLACE query affected {0} rows", rowsAffected); m_log.ErrorFormat("MySQL REPLACE query affected {0} rows", rowsAffected);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, false, DateTime.Now); m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, false, DateTime.Now);
return ret; return ret;
} }
@ -536,7 +541,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
{ {
BackendResponse ret; BackendResponse ret;
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
{ {
try try
{ {
@ -560,23 +565,23 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
else if (rowsAffected == 2) else if (rowsAffected == 2)
{ {
Logger.Log.Info("Replaced inventory folder " + folder.ID.ToString()); m_log.Info("Replaced inventory folder " + folder.ID.ToString());
ret = BackendResponse.Success; ret = BackendResponse.Success;
} }
else else
{ {
Logger.Log.ErrorFormat("MySQL REPLACE query affected {0} rows", rowsAffected); m_log.ErrorFormat("MySQL REPLACE query affected {0} rows", rowsAffected);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, true, DateTime.Now); m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, true, DateTime.Now);
return ret; return ret;
} }
@ -592,7 +597,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
if (Utils.TryGetOpenSimUUID(owner, out ownerID)) if (Utils.TryGetOpenSimUUID(owner, out ownerID))
{ {
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
{ {
try try
{ {
@ -611,13 +616,13 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
else else
{ {
Logger.Log.ErrorFormat("MySQL DELETE query affected {0} rows", rowsAffected); m_log.ErrorFormat("MySQL DELETE query affected {0} rows", rowsAffected);
ret = BackendResponse.NotFound; ret = BackendResponse.NotFound;
} }
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
@ -627,7 +632,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
ret = BackendResponse.NotFound; ret = BackendResponse.NotFound;
} }
server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now); m_server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, itemID, false, DateTime.Now);
return ret; return ret;
} }
@ -638,7 +643,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
if (Utils.TryGetOpenSimUUID(owner, out ownerID)) if (Utils.TryGetOpenSimUUID(owner, out ownerID))
{ {
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
{ {
try try
{ {
@ -657,13 +662,13 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
else else
{ {
Logger.Log.ErrorFormat("MySQL DELETE query affected {0} rows", rowsAffected); m_log.ErrorFormat("MySQL DELETE query affected {0} rows", rowsAffected);
ret = BackendResponse.NotFound; ret = BackendResponse.NotFound;
} }
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
@ -673,7 +678,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
ret = BackendResponse.NotFound; ret = BackendResponse.NotFound;
} }
server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now); m_server.MetricsProvider.LogInventoryDelete(EXTENSION_NAME, ret, owner, folderID, true, DateTime.Now);
return ret; return ret;
} }
@ -684,7 +689,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
if (Utils.TryGetOpenSimUUID(owner, out ownerID)) if (Utils.TryGetOpenSimUUID(owner, out ownerID))
{ {
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
{ {
try try
{ {
@ -714,13 +719,13 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
#endregion Delete folders #endregion Delete folders
Logger.Log.DebugFormat("Deleted {0} inventory objects from MySQL in a folder purge", rowsAffected); m_log.DebugFormat("Deleted {0} inventory objects from MySQL in a folder purge", rowsAffected);
ret = BackendResponse.Success; ret = BackendResponse.Success;
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
@ -730,7 +735,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
ret = BackendResponse.NotFound; ret = BackendResponse.NotFound;
} }
server.MetricsProvider.LogInventoryPurgeFolder(EXTENSION_NAME, ret, owner, folderID, DateTime.Now); m_server.MetricsProvider.LogInventoryPurgeFolder(EXTENSION_NAME, ret, owner, folderID, DateTime.Now);
return ret; return ret;
} }
@ -738,7 +743,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
{ {
int rowCount = 0; int rowCount = 0;
using (MySqlConnection dbConnection = new MySqlConnection(server.ConfigFile.InventoryDatabaseConnect)) using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
{ {
MySqlDataReader reader; MySqlDataReader reader;
@ -753,7 +758,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
Logger.Log.Error("Connection to MySQL backend failed: " + ex.Message); m_log.Error("Connection to MySQL backend failed: " + ex.Message);
return 0; return 0;
} }
@ -784,22 +789,24 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
public void Initialise(AssetInventoryServer server) public void Initialise(AssetInventoryServer server)
{ {
this.server = server; m_server = server;
m_openSimConfig = server.ConfigFile.Configs["OpenSim"];
try try
{ {
m_inventoryProvider = DataPluginFactory.LoadDataPlugin<IInventoryDataPlugin>("OpenSim.Data.MySQL.dll", server.ConfigFile.InventoryDatabaseConnect); m_inventoryProvider = DataPluginFactory.LoadDataPlugin<IInventoryDataPlugin>(m_openSimConfig.GetString("inventory_database_provider"),
m_openSimConfig.GetString("inventory_database_connect"));
if (m_inventoryProvider == null) if (m_inventoryProvider == null)
{ {
Logger.Log.Error("[INVENTORY]: Failed to load a database plugin, server halting."); m_log.Error("[INVENTORY]: Failed to load a database plugin, server halting.");
Environment.Exit(-1); Environment.Exit(-1);
} }
else else
Logger.Log.InfoFormat("[INVENTORY]: Loaded storage backend: {0}", Version); m_log.InfoFormat("[INVENTORY]: Loaded storage backend: {0}", Version);
} }
catch (Exception e) catch (Exception e)
{ {
Logger.Log.WarnFormat("[INVENTORY]: Failure loading data plugin: {0}", e.ToString()); m_log.WarnFormat("[INVENTORY]: Failure loading data plugin: {0}", e.ToString());
} }
} }
@ -809,7 +816,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
public void Initialise() public void Initialise()
{ {
Logger.Log.InfoFormat("[INVENTORY]: {0} cannot be default-initialized!", Name); m_log.InfoFormat("[INVENTORY]: {0} cannot be default-initialized!", Name);
throw new PluginNotInitialisedException(Name); throw new PluginNotInitialisedException(Name);
} }

View File

@ -29,6 +29,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.Xml; using System.Xml;
@ -37,11 +38,13 @@ using OpenMetaverse.StructuredData;
using HttpServer; using HttpServer;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using log4net;
namespace OpenSim.Grid.AssetInventoryServer.Plugins namespace OpenSim.Grid.AssetInventoryServer.Plugins
{ {
public class ReferenceFrontendPlugin : IAssetInventoryServerPlugin public class ReferenceFrontendPlugin : IAssetInventoryServerPlugin
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
AssetInventoryServer m_server; AssetInventoryServer m_server;
public ReferenceFrontendPlugin() public ReferenceFrontendPlugin()
@ -63,7 +66,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
// Asset creation // Asset creation
m_server.HttpServer.AddStreamHandler(new CreateRequestHandler(server)); m_server.HttpServer.AddStreamHandler(new CreateRequestHandler(server));
Logger.Log.Info("[ASSET] Reference Frontend loaded."); m_log.Info("[ASSET] Reference Frontend loaded.");
} }
/// <summary> /// <summary>
@ -71,7 +74,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
/// </summary> /// </summary>
public void Initialise() public void Initialise()
{ {
Logger.Log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name); m_log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name);
throw new PluginNotInitialisedException(Name); throw new PluginNotInitialisedException(Name);
} }
@ -159,7 +162,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
} }
else if (storageResponse == BackendResponse.NotFound) else if (storageResponse == BackendResponse.NotFound)
{ {
Logger.Log.Warn("Could not find metadata for asset " + assetID.ToString()); m_log.Warn("Could not find metadata for asset " + assetID.ToString());
httpResponse.StatusCode = (int) HttpStatusCode.NotFound; httpResponse.StatusCode = (int) HttpStatusCode.NotFound;
} }
else else

View File

@ -28,12 +28,14 @@
*/ */
using System; using System;
using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.IO; using System.IO;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using OpenSim.Framework; using OpenSim.Framework;
using log4net;
namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
{ {
@ -43,6 +45,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
const string DEFAULT_DATA_DIR = "SimpleAssets"; const string DEFAULT_DATA_DIR = "SimpleAssets";
const string TEMP_DATA_DIR = "SimpleAssetsTemp"; const string TEMP_DATA_DIR = "SimpleAssetsTemp";
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
AssetInventoryServer server; AssetInventoryServer server;
Dictionary<UUID, Metadata> metadataStorage; Dictionary<UUID, Metadata> metadataStorage;
Dictionary<UUID, string> filenames; Dictionary<UUID, string> filenames;
@ -82,7 +85,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.ErrorFormat("Failed reading data for asset {0} from {1}: {2}", assetID, filename, ex.Message); m_log.ErrorFormat("Failed reading data for asset {0} from {1}: {2}", assetID, filename, ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
@ -112,7 +115,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.ErrorFormat("Failed reading data for asset {0} from {1}: {2}", assetID, filename, ex.Message); m_log.ErrorFormat("Failed reading data for asset {0} from {1}: {2}", assetID, filename, ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
@ -169,7 +172,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.ErrorFormat("Failed writing data for asset {0} to {1}: {2}", metadata.ID, filename, ex.Message); m_log.ErrorFormat("Failed writing data for asset {0} to {1}: {2}", metadata.ID, filename, ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
@ -207,7 +210,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
LoadFiles(DEFAULT_DATA_DIR, false); LoadFiles(DEFAULT_DATA_DIR, false);
LoadFiles(TEMP_DATA_DIR, true); LoadFiles(TEMP_DATA_DIR, true);
Logger.Log.InfoFormat("Initialized the store index with metadata for {0} assets", m_log.InfoFormat("Initialized the store index with metadata for {0} assets",
metadataStorage.Count); metadataStorage.Count);
} }
@ -216,7 +219,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
/// </summary> /// </summary>
public void Initialise() public void Initialise()
{ {
Logger.Log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name); m_log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name);
throw new PluginNotInitialisedException(Name); throw new PluginNotInitialisedException(Name);
} }
@ -243,7 +246,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
if (Directory.Exists(TEMP_DATA_DIR)) if (Directory.Exists(TEMP_DATA_DIR))
{ {
try { Directory.Delete(TEMP_DATA_DIR); } try { Directory.Delete(TEMP_DATA_DIR); }
catch (Exception ex) { Logger.Log.Error(ex.Message); } catch (Exception ex) { m_log.Error(ex.Message); }
} }
} }
@ -255,7 +258,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
try { Directory.CreateDirectory(folder); } try { Directory.CreateDirectory(folder); }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.Warn(ex.Message); m_log.Warn(ex.Message);
return; return;
} }
} }
@ -287,7 +290,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.Warn(ex.Message); m_log.Warn(ex.Message);
} }
} }
} }

View File

@ -28,6 +28,7 @@
*/ */
using System; using System;
using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.IO; using System.IO;
@ -35,6 +36,7 @@ using System.Text;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using OpenSim.Framework; using OpenSim.Framework;
using log4net;
namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
{ {
@ -43,6 +45,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
const string EXTENSION_NAME = "SimpleInventoryStorage"; // Used for metrics reporting const string EXTENSION_NAME = "SimpleInventoryStorage"; // Used for metrics reporting
const string DEFAULT_INVENTORY_DIR = "SimpleInventory"; const string DEFAULT_INVENTORY_DIR = "SimpleInventory";
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
AssetInventoryServer server; AssetInventoryServer server;
Dictionary<Uri, InventoryCollection> inventories = new Dictionary<Uri, InventoryCollection>(); Dictionary<Uri, InventoryCollection> inventories = new Dictionary<Uri, InventoryCollection>();
Dictionary<Uri, List<InventoryItem>> activeGestures = new Dictionary<Uri, List<InventoryItem>>(); Dictionary<Uri, List<InventoryItem>> activeGestures = new Dictionary<Uri, List<InventoryItem>>();
@ -209,7 +212,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.Error(ex.Message); m_log.Error(ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
@ -251,7 +254,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.Error(ex.Message); m_log.Error(ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
@ -305,7 +308,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.Error(ex.Message); m_log.Error(ex.Message);
ret = BackendResponse.Failure; ret = BackendResponse.Failure;
} }
} }
@ -353,7 +356,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
foreach (string match in matches) foreach (string match in matches)
{ {
try { File.Delete(match); } try { File.Delete(match); }
catch (Exception ex) { Logger.Log.ErrorFormat("Failed to delete file {0}: {1}", match, ex.Message); } catch (Exception ex) { m_log.ErrorFormat("Failed to delete file {0}: {1}", match, ex.Message); }
} }
ret = BackendResponse.Success; ret = BackendResponse.Success;
@ -390,7 +393,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
foreach (string match in matches) foreach (string match in matches)
{ {
try { File.Delete(match); } try { File.Delete(match); }
catch (Exception ex) { Logger.Log.ErrorFormat("Failed to delete folder file {0}: {1}", match, ex.Message); } catch (Exception ex) { m_log.ErrorFormat("Failed to delete folder file {0}: {1}", match, ex.Message); }
} }
ret = BackendResponse.Success; ret = BackendResponse.Success;
@ -501,7 +504,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
try { Directory.CreateDirectory(folder); } try { Directory.CreateDirectory(folder); }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.Warn(ex.Message); m_log.Warn(ex.Message);
return; return;
} }
} }
@ -525,7 +528,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.WarnFormat("Failed loading the index file {0}: {1}", indexPath, ex.Message); m_log.WarnFormat("Failed loading the index file {0}: {1}", indexPath, ex.Message);
} }
if (ownerID != UUID.Zero && owner != null) if (ownerID != UUID.Zero && owner != null)
@ -581,7 +584,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log.ErrorFormat("Failed loading inventory from {0}: {1}", folder, ex.Message); m_log.ErrorFormat("Failed loading inventory from {0}: {1}", folder, ex.Message);
} }
} }
@ -593,7 +596,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
LoadFiles(DEFAULT_INVENTORY_DIR); LoadFiles(DEFAULT_INVENTORY_DIR);
Logger.Log.InfoFormat("Initialized the inventory index with data for {0} avatars", m_log.InfoFormat("Initialized the inventory index with data for {0} avatars",
inventories.Count); inventories.Count);
} }
@ -602,7 +605,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
/// </summary> /// </summary>
public void Initialise() public void Initialise()
{ {
Logger.Log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name); m_log.InfoFormat("[ASSET]: {0} cannot be default-initialized!", Name);
throw new PluginNotInitialisedException(Name); throw new PluginNotInitialisedException(Name);
} }

View File

@ -1,9 +1,9 @@
;[Config] [Config]
; The port number for the asset server to listen on. ; The port number for the asset server to listen on.
listen_port = 8003 listen_port = 8003
;[Extensions] [Plugins]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Asset Storage Provider ; Asset Storage Provider
@ -31,7 +31,7 @@ asset_storage_provider = OpenSimAssetStorage
; illustrating an inventory backend example. The inventory is stored in ; illustrating an inventory backend example. The inventory is stored in
; SimpleInventory/ by creating a folder for each agent that contains all of the ; SimpleInventory/ by creating a folder for each agent that contains all of the
; inventory items and folders serialized as XML files. ; inventory items and folders serialized as XML files.
;inventory_asset_provider = SimpleInventoryStorage ;inventory_storage_provider = SimpleInventoryStorage
; OpenSimMySQL inventory connects to a MySQL server that has an inventory table ; OpenSimMySQL inventory connects to a MySQL server that has an inventory table
; created by OpenSim. If the OpenSimMySQLStorage backend is also being used, the ; created by OpenSim. If the OpenSimMySQLStorage backend is also being used, the
@ -40,7 +40,7 @@ asset_storage_provider = OpenSimAssetStorage
; database. This backend combined with the OpenSimInventoryFrontend will allow ; database. This backend combined with the OpenSimInventoryFrontend will allow
; the server to be used as a drop-in replacement for ; the server to be used as a drop-in replacement for
; OpenSim.Grid.InventoryServer.exe, while also allowing other frontends to run. ; OpenSim.Grid.InventoryServer.exe, while also allowing other frontends to run.
inventory_asset_provider = OpenSimInventoryStorage inventory_storage_provider = OpenSimInventoryStorage
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Authentication Provider ; Authentication Provider
@ -56,7 +56,7 @@ authentication_provider = NullAuthentication
; Authorize all is a dummy authorization module that allows all requests for ; Authorize all is a dummy authorization module that allows all requests for
; metadata, data, and asset creation. Use this extension if your primary ; metadata, data, and asset creation. Use this extension if your primary
; storage provider or front-end interface does not support authentication. ; storage provider or front-end interface does not support authentication.
authroization_provider = AuthorizeAll authorization_provider = AuthorizeAll
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Metrics Provider ; Metrics Provider
@ -95,7 +95,19 @@ metrics_provider = NullMetrics
frontends = ReferenceFrontend,OpenSimAssetFrontend,OpenSimInventoryFrontend,BrowseFrontend frontends = ReferenceFrontend,OpenSimAssetFrontend,OpenSimInventoryFrontend,BrowseFrontend
;[MySQL] ; The OpenSim section applies to the OpenSim plugin (OpenSimAssetStorage,
; OpenSimInventoryStorage, OpenSimAssetFronend, OpenSimInventoryFrontend).
[OpenSim]
; The database provider determines which database to use. Any database backend
; supported by OpenSim is supported.
;asset_database_provider = "OpenSim.Data.SQLite.dll"
asset_database_provider = "OpenSim.Data.MySQL.dll"
;asset_database_provider = "OpenSim.Data.NHibernate.dll"
;inventory_database_provider = "OpenSim.Data.SQLite.dll"
inventory_database_provider = "OpenSim.Data.MySQL.dll"
;inventory_database_provider = "OpenSim.Data.NHibernate.dll"
; Database connection string used by the OpenSim MySQL backend. If these lines ; Database connection string used by the OpenSim MySQL backend. If these lines
; are commented out or missing, the server will look for an ; are commented out or missing, the server will look for an
@ -103,5 +115,15 @@ frontends = ReferenceFrontend,OpenSimAssetFrontend,OpenSimInventoryFrontend,Brow
; working directory. These files are generated by OpenSim.Grid.AssetServer.exe ; working directory. These files are generated by OpenSim.Grid.AssetServer.exe
; and OpenSim.Grid.InventoryServer.exe, respectively, and can be used without ; and OpenSim.Grid.InventoryServer.exe, respectively, and can be used without
; modification. ; modification.
; For SQLite
;asset_database_connect = "URI:file:Asset.db,version=3"
;inventory_database_connect = "URI:file:Inventory.db,version=3"
; For MySQL
asset_database_connect = "Server=localhost; Database=opensim; User=changeme; Password=changeme;" asset_database_connect = "Server=localhost; Database=opensim; User=changeme; Password=changeme;"
inventory_database_connect = "Server=localhost; Database=opensim; User=changeme; Password=changeme;" inventory_database_connect = "Server=localhost; Database=opensim; User=changeme; Password=changeme;"
; For NHibernate
;asset_database_connect = "SQLiteDialect;SQLite20Driver;Data Source=file:Asset.db;Version=3"
;inventory_database_connect = "SQLiteDialect;SQLite20Driver;Data Source=file:Asset.db;Version=3"

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<appSettings>
</appSettings>
<log4net>
<appender name="Console" type="OpenSim.Framework.Console.OpenSimAppender, OpenSim.Framework.Console">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{HH:mm:ss} - %message%newline" />
</layout>
</appender>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<file value="OpenSim.Grid.AssetInventoryServer.log" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level - %logger %message%newline" />
</layout>
</appender>
<!-- if you'd like to know what NHibernate is doing more set value="DEBUG" -->
<logger name="NHibernate" additivity="false">
<level value="INFO"/>
<appender-ref ref="NHibernateFileLog"/>
</logger>
<root>
<level value="DEBUG" />
<appender-ref ref="Console" />
<appender-ref ref="LogFileAppender" />
</root>
</log4net>
</configuration>

View File

@ -766,10 +766,11 @@
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers"/> <Reference name="OpenSim.Framework.Servers"/>
<Reference name="log4net2"/> <Reference name="log4net"/>
<Reference name="OpenMetaverseTypes"/> <Reference name="OpenMetaverseTypes"/>
<Reference name="OpenMetaverse.StructuredData2"/> <Reference name="OpenMetaverse.StructuredData2"/>
<Reference name="HttpServer"/> <Reference name="HttpServer"/>
<Reference name="Nini.dll" />
<!-- for Simple Storage and MySQL storage --> <!-- for Simple Storage and MySQL storage -->
<Reference name="System.Data"/> <Reference name="System.Data"/>
@ -805,6 +806,7 @@
<Reference name="OpenMetaverseTypes"/> <Reference name="OpenMetaverseTypes"/>
<Reference name="OpenMetaverse.StructuredData2"/> <Reference name="OpenMetaverse.StructuredData2"/>
<Reference name="HttpServer"/> <Reference name="HttpServer"/>
<Reference name="log4net"/>
<Files> <Files>
<Match pattern="*.cs" recurse="false" /> <Match pattern="*.cs" recurse="false" />
@ -834,6 +836,7 @@
<Reference name="OpenMetaverseTypes"/> <Reference name="OpenMetaverseTypes"/>
<Reference name="OpenMetaverse.StructuredData2" /> <Reference name="OpenMetaverse.StructuredData2" />
<Reference name="HttpServer"/> <Reference name="HttpServer"/>
<Reference name="log4net"/>
<!-- Remove these eventually --> <!-- Remove these eventually -->
<Reference name="MySql.Data" /> <Reference name="MySql.Data" />
@ -866,6 +869,8 @@
<Reference name="OpenMetaverseTypes"/> <Reference name="OpenMetaverseTypes"/>
<Reference name="OpenMetaverse.StructuredData2" /> <Reference name="OpenMetaverse.StructuredData2" />
<Reference name="HttpServer"/> <Reference name="HttpServer"/>
<Reference name="Nini.dll" />
<Reference name="log4net"/>
<!-- Remove these eventually --> <!-- Remove these eventually -->
<Reference name="MySql.Data" /> <Reference name="MySql.Data" />