Thanks, sempuki, for a patch that moves all grid plugins to new PluginLoader (issue 1763).

0.6.0-stable
Mike Mazur 2008-07-18 04:51:41 +00:00
parent 2558f8ac31
commit e0e0db3660
16 changed files with 313 additions and 207 deletions

View File

@ -29,19 +29,21 @@ using libsecondlife;
namespace OpenSim.Data
{
public abstract class GridDataBase : IGridData
public abstract class GridDataBase : IGridDataPlugin
{
public abstract RegionProfileData GetProfileByHandle(ulong regionHandle);
public abstract RegionProfileData GetProfileByLLUUID(LLUUID UUID);
public abstract RegionProfileData GetProfileByString(string regionName);
public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
public abstract bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey);
public abstract void Initialise(string connect);
public abstract void Close();
public abstract string getName();
public abstract string getVersion();
public abstract DataResponse AddProfile(RegionProfileData profile);
public abstract ReservationData GetReservationAtPoint(uint x, uint y);
public abstract DataResponse UpdateProfile(RegionProfileData profile);
public abstract void Initialise();
public abstract void Initialise(string connect);
public abstract void Dispose();
public abstract string Name { get; }
public abstract string Version { get; }
}
}

View File

@ -26,6 +26,10 @@
*/
using libsecondlife;
using Mono.Addins;
using OpenSim.Framework;
[assembly : AddinRoot("OpenSim.Data", "0.5")]
namespace OpenSim.Data
{
@ -40,8 +44,14 @@ namespace OpenSim.Data
/// <summary>
/// A standard grid interface
/// </summary>
public interface IGridData
[TypeExtensionPoint("/OpenSim/GridDataStore")]
public interface IGridDataPlugin : IPlugin
{
/// <summary>
/// Initialises the interface
/// </summary>
void Initialise(string connect);
/// <summary>
/// Returns a sim profile from a regionHandle
/// </summary>
@ -83,28 +93,6 @@ namespace OpenSim.Data
/// <returns>Whether the sim has been authenticated</returns>
bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey);
/// <summary>
/// Initialises the interface
/// </summary>
void Initialise(string connect);
/// <summary>
/// Closes the interface
/// </summary>
void Close();
/// <summary>
/// The plugin being loaded
/// </summary>
/// <returns>A string containing the plugin name</returns>
string getName();
/// <summary>
/// The plugins version
/// </summary>
/// <returns>A string containing the plugin version</returns>
string getVersion();
/// <summary>
/// Adds a new profile to the database
/// </summary>
@ -116,4 +104,15 @@ namespace OpenSim.Data
ReservationData GetReservationAtPoint(uint x, uint y);
}
public class GridDataStoreInitialiser : PluginInitialiserBase
{
private string connect;
public GridDataStoreInitialiser (string s) { connect = s; }
public override void Initialise (IPlugin plugin)
{
IGridDataPlugin p = plugin as IGridDataPlugin;
p.Initialise (connect);
}
}
}

View File

@ -25,6 +25,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Mono.Addins;
using OpenSim.Framework;
namespace OpenSim.Data
{
/// <summary>
@ -61,7 +64,8 @@ namespace OpenSim.Data
/// <summary>
/// An interface to a LogData storage system
/// </summary>
public interface ILogData
[TypeExtensionPoint("/OpenSim/GridLogData")]
public interface ILogDataPlugin : IPlugin
{
void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
string logMessage);
@ -70,22 +74,16 @@ namespace OpenSim.Data
/// Initialises the interface
/// </summary>
void Initialise(string connect);
/// <summary>
/// Closes the interface
/// </summary>
void Close();
/// <summary>
/// The plugin being loaded
/// </summary>
/// <returns>A string containing the plugin name</returns>
string getName();
/// <summary>
/// The plugins version
/// </summary>
/// <returns>A string containing the plugin version</returns>
string getVersion();
}
public class LogDataInitialiser : PluginInitialiserBase
{
private string connect;
public LogDataInitialiser (string s) { connect = s; }
public override void Initialise (IPlugin plugin)
{
ILogDataPlugin p = plugin as ILogDataPlugin;
p.Initialise (connect);
}
}
}

View File

@ -33,12 +33,18 @@ using System.Security.Cryptography;
using System.Text;
using libsecondlife;
using log4net;
using Mono.Addins;
using OpenSim.Framework;
[assembly : Addin]
[assembly : AddinDependency("OpenSim.Data", "0.5")]
namespace OpenSim.Data.MSSQL
{
/// <summary>
/// A grid data interface for MSSQL Server
/// </summary>
[Extension("/OpenSim/GridDataStore")]
public class MSSQLGridData : GridDataBase
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -50,6 +56,12 @@ namespace OpenSim.Data.MSSQL
private string m_regionsTableName;
override public void Initialise()
{
m_log.Info("[MSSQLGridData]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name);
}
/// <summary>
/// Initialises the Grid Interface
/// </summary>
@ -101,7 +113,7 @@ namespace OpenSim.Data.MSSQL
/// <summary>
/// Shuts down the grid interface
/// </summary>
override public void Close()
override public void Dispose()
{
// nothing to close
}
@ -110,18 +122,18 @@ namespace OpenSim.Data.MSSQL
/// The name of this DB provider.
/// </summary>
/// <returns>A string containing the storage system name</returns>
override public string getName()
override public string Name
{
return "Sql OpenGridData";
get { return "Sql OpenGridData"; }
}
/// <summary>
/// Database provider version.
/// </summary>
/// <returns>A string containing the storage system version</returns>
override public string getVersion()
override public string Version
{
return "0.1";
get { return "0.1"; }
}
/// <summary>

View File

@ -25,21 +25,39 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Reflection;
using System.Collections.Generic;
using System.Data;
using log4net;
using Mono.Addins;
using OpenSim.Framework;
// Only one attribute per assembly. See: *GridData.cs
// [assembly : Addin]
// [assembly : AddinDependency("OpenSim.Data", "0.5")]
namespace OpenSim.Data.MSSQL
{
/// <summary>
/// An interface to the log database for MSSQL
/// </summary>
internal class MSSQLLogData : ILogData
[Extension("/OpenSim/GridLogData")]
internal class MSSQLLogData : ILogDataPlugin
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// The database manager
/// </summary>
public MSSQLManager database;
public void Initialise()
{
m_log.Info("[MSSQLLogData]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name);
}
/// <summary>
/// Artificial constructor called when the plugin is loaded
/// </summary>
@ -97,15 +115,15 @@ namespace OpenSim.Data.MSSQL
/// Returns the name of this DB provider
/// </summary>
/// <returns>A string containing the DB provider name</returns>
public string getName()
public string Name
{
return "MSSQL Logdata Interface";
get { return "MSSQL Logdata Interface"; }
}
/// <summary>
/// Closes the database provider
/// </summary>
public void Close()
public void Dispose()
{
// Do nothing.
}
@ -114,9 +132,9 @@ namespace OpenSim.Data.MSSQL
/// Returns the version of this DB provider
/// </summary>
/// <returns>A string containing the provider version</returns>
public string getVersion()
public string Version
{
return "0.1";
get { return "0.1"; }
}
}
}

View File

@ -34,6 +34,7 @@ using log4net;
using MySql.Data.MySqlClient;
using OpenSim.Framework;
namespace OpenSim.Data.MySQL
{
/// <summary>

View File

@ -33,12 +33,18 @@ using System.Security.Cryptography;
using System.Text;
using libsecondlife;
using log4net;
using Mono.Addins;
using OpenSim.Framework;
[assembly : Addin]
[assembly : AddinDependency("OpenSim.Data", "0.5")]
namespace OpenSim.Data.MySQL
{
/// <summary>
/// A MySQL Interface for the Grid Server
/// </summary>
[Extension("/OpenSim/GridDataStore")]
public class MySQLGridData : GridDataBase
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -48,6 +54,12 @@ namespace OpenSim.Data.MySQL
/// </summary>
private MySQLManager database;
override public void Initialise()
{
m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name);
}
/// <summary>
/// <para>Initialises Grid interface</para>
/// <para>
@ -144,7 +156,7 @@ namespace OpenSim.Data.MySQL
/// <summary>
/// Shuts down the grid interface
/// </summary>
override public void Close()
override public void Dispose()
{
database.Close();
}
@ -153,18 +165,18 @@ namespace OpenSim.Data.MySQL
/// Returns the plugin name
/// </summary>
/// <returns>Plugin name</returns>
override public string getName()
override public string Name
{
return "MySql OpenGridData";
get { return "MySql OpenGridData"; }
}
/// <summary>
/// Returns the plugin version
/// </summary>
/// <returns>Plugin version</returns>
override public string getVersion()
override public string Version
{
return "0.1";
get { return "0.1"; }
}
/// <summary>

View File

@ -28,20 +28,34 @@ using System;
using System.Reflection;
using System.Collections.Generic;
using log4net;
using Mono.Addins;
using OpenSim.Framework;
// Only one attribute per assembly. See: *GridData.cs
// [assembly : Addin]
// [assembly : AddinDependency("OpenSim.Data", "0.5")]
namespace OpenSim.Data.MySQL
{
/// <summary>
/// An interface to the log database for MySQL
/// </summary>
internal class MySQLLogData : ILogData
[Extension("/OpenSim/GridLogData")]
internal class MySQLLogData : ILogDataPlugin
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// The database manager
/// </summary>
public MySQLManager database;
public void Initialise()
{
m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name);
}
/// <summary>
/// Artificial constructor called when the plugin is loaded
/// Uses the obsolete mysql_connection.ini if connect string is empty.
@ -128,16 +142,16 @@ namespace OpenSim.Data.MySQL
/// Returns the name of this DB provider
/// </summary>
/// <returns>A string containing the DB provider name</returns>
public string getName()
public string Name
{
return "MySQL Logdata Interface";
get { return "MySQL Logdata Interface";}
}
/// <summary>
/// Closes the database provider
/// </summary>
/// <remarks>do nothing</remarks>
public void Close()
public void Dispose()
{
// Do nothing.
}
@ -146,9 +160,9 @@ namespace OpenSim.Data.MySQL
/// Returns the version of this DB provider
/// </summary>
/// <returns>A string containing the provider version</returns>
public string getVersion()
public string Version
{
return "0.1";
get { return "0.1"; }
}
}
}

View File

@ -227,7 +227,7 @@ namespace OpenSim.Data.MySQL
return
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
dllVersion.Revision);
dllVersion.Revision);
}
/// <summary>

View File

@ -28,23 +28,38 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using libsecondlife;
using log4net;
using Mono.Addins;
using OpenSim.Framework;
[assembly : Addin]
[assembly : AddinDependency("OpenSim.Data", "0.5")]
namespace OpenSim.Data.SQLite
{
/// <summary>
/// A Grid Interface to the SQLite database
/// </summary>
[Extension("/OpenSim/GridDataStore")]
public class SQLiteGridData : GridDataBase
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// SQLite database manager
/// </summary>
private SQLiteManager database;
override public void Initialise()
{
m_log.Info("[SQLite]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name);
}
/// <summary>
/// <list type="bullet">
/// <item>Initialises Inventory interface</item>
@ -61,7 +76,7 @@ namespace OpenSim.Data.SQLite
/// <summary>
/// Shuts down the grid interface
/// </summary>
override public void Close()
override public void Dispose()
{
database.Close();
}
@ -70,18 +85,18 @@ namespace OpenSim.Data.SQLite
/// Returns the name of this grid interface
/// </summary>
/// <returns>A string containing the grid interface</returns>
override public string getName()
override public string Name
{
return "SQLite OpenGridData";
get { return "SQLite OpenGridData"; }
}
/// <summary>
/// Returns the version of this grid interface
/// </summary>
/// <returns>A string containing the version</returns>
override public string getVersion()
override public string Version
{
return "0.1";
get { return "0.1"; }
}
/// <summary>

View File

@ -32,6 +32,7 @@ using System.Reflection;
using log4net;
using Mono.Addins;
namespace OpenSim.Framework
{
/// <summary>
@ -50,8 +51,17 @@ namespace OpenSim.Framework
/// </summary>
public interface IPluginConstraint
{
bool Fail (string extpoint);
string Message { get; }
bool Apply (string extpoint);
}
/// <summary>
/// Classes wishing to select specific plugins from a range of possible options
/// must implement this class and pass it to PluginLoader Load()
/// </summary>
public interface IPluginFilter
{
bool Apply (ExtensionNode plugin);
}
/// <summary>
@ -64,18 +74,22 @@ namespace OpenSim.Framework
private List<T> loaded = new List<T>();
private List<string> extpoints = new List<string>();
private PluginInitialiserBase initialiser;
private Dictionary<string,IPluginConstraint> constraints
= new Dictionary<string,IPluginConstraint>();
private Dictionary<string,IPluginFilter> filters
= new Dictionary<string,IPluginFilter>();
private static readonly ILog log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public PluginInitialiserBase Initialiser
{
set { initialiser = value; }
get { return initialiser; }
}
public List<T> Plugins
{
get { return loaded; }
@ -84,25 +98,19 @@ namespace OpenSim.Framework
public PluginLoader ()
{
Initialiser = new PluginInitialiserBase();
initialise_plugin_dir_ (".");
}
public PluginLoader (PluginInitialiserBase init)
{
Initialiser = init;
Initialiser = init;
initialise_plugin_dir_ (".");
}
public PluginLoader (PluginInitialiserBase init, string dir)
{
Initialiser = init;
AddPluginDir (dir);
}
public void AddPluginDir (string dir)
{
suppress_console_output_ (true);
AddinManager.Initialize (dir);
AddinManager.Registry.Update (null);
suppress_console_output_ (false);
Initialiser = init;
initialise_plugin_dir_ (dir);
}
public void AddExtensionPoint (string extpoint)
@ -114,50 +122,88 @@ namespace OpenSim.Framework
{
constraints.Add (extpoint, cons);
}
public void Load (string extpoint, string dir)
public void AddFilter (string extpoint, IPluginFilter filter)
{
filters.Add (extpoint, filter);
}
public void Load (string extpoint)
{
AddPluginDir (dir);
AddExtensionPoint (extpoint);
Load();
}
public void Load ()
{
suppress_console_output_ (true);
AddinManager.Registry.Update (null);
suppress_console_output_ (false);
foreach (string ext in extpoints)
{
log.Info("[PLUGINS]: Loading extension point " + ext);
if (constraints.ContainsKey (ext))
{
IPluginConstraint cons = constraints [ext];
if (cons.Fail (ext))
throw new PluginConstraintViolatedException (cons.Message);
if (cons.Apply (ext))
log.Error ("[PLUGINS]: " + ext + " failed constraint: " + cons.Message);
}
ExtensionNodeList ns = AddinManager.GetExtensionNodes (ext);
foreach (TypeExtensionNode n in ns)
{
T p = (T) n.CreateInstance();
Initialiser.Initialise (p);
Plugins.Add (p);
IPluginFilter filter = null;
if (filters.ContainsKey (ext))
filter = filters [ext];
log.Info("[PLUGINS]: Loading plugin " + n.Path);
foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes (ext))
{
log.Info("[PLUGINS]: Trying plugin " + node.Path);
if ((filter != null) && (filter.Apply (node) == false))
continue;
T plugin = (T) node.CreateInstance();
Initialiser.Initialise (plugin);
Plugins.Add (plugin);
}
}
}
public void Dispose ()
{
foreach (T p in Plugins)
p.Dispose ();
foreach (T plugin in Plugins)
plugin.Dispose ();
}
public void ClearCache()
private void initialise_plugin_dir_ (string dir)
{
// The Mono addin manager (in Mono.Addins.dll version 0.2.0.0) occasionally seems to corrupt its addin cache
if (AddinManager.IsInitialized == true)
return;
log.Info("[PLUGINS]: Initialzing");
AddinManager.AddinLoadError += on_addinloaderror_;
AddinManager.AddinLoaded += on_addinloaded_;
clear_registry_();
suppress_console_output_ (true);
AddinManager.Initialize (dir);
AddinManager.Registry.Update (null);
suppress_console_output_ (false);
}
private void on_addinloaded_(object sender, AddinEventArgs args)
{
log.Info ("[PLUGINS]: Plugin Loaded: " + args.AddinId);
}
private void on_addinloaderror_(object sender, AddinErrorEventArgs args)
{
log.Error ("[PLUGINS]: Plugin Error: " + args.Message);
}
private void clear_registry_ ()
{
// The Mono addin manager (in Mono.Addins.dll version 0.2.0.0)
// occasionally seems to corrupt its addin cache
// Hence, as a temporary solution we'll remove it before each startup
if (Directory.Exists("addin-db-000"))
Directory.Delete("addin-db-000", true);
@ -182,6 +228,9 @@ namespace OpenSim.Framework
}
}
/// <summary>
/// Constraint that bounds the number of plugins to be loaded.
/// </summary>
public class PluginCountConstraint : IPluginConstraint
{
private int min;
@ -208,45 +257,32 @@ namespace OpenSim.Framework
}
}
public bool Fail (string extpoint)
public bool Apply (string extpoint)
{
ExtensionNodeList ns = AddinManager.GetExtensionNodes (extpoint);
if ((ns.Count < min) || (ns.Count > max))
return true;
else
return false;
}
}
int count = AddinManager.GetExtensionNodes (extpoint).Count;
public class PluginFilenameConstraint : IPluginConstraint
{
private string filename;
if ((count < min) || (count > max))
throw new PluginConstraintViolatedException (Message);
public PluginFilenameConstraint (string name)
{
filename = name;
}
public string Message
{
get
{
return "The plugin must have the following name: " + filename;
}
}
public bool Fail (string extpoint)
{
ExtensionNodeList ns = AddinManager.GetExtensionNodes (extpoint);
if (ns.Count != 1)
return true;
string[] path = ns[0].Path.Split('/');
if (path [path.Length-1] == filename)
return false;
return true;
}
}
/// <summary>
/// Filters out which plugin to load based on its "Id", which is name given by the namespace or by Mono.Addins.
/// </summary>
public class PluginIdFilter : IPluginFilter
{
private string id;
public PluginIdFilter (string id)
{
this.id = id;
}
public bool Apply (ExtensionNode plugin)
{
return (plugin.Id == id);
}
}
}

View File

@ -26,6 +26,7 @@
*/
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.IO;
@ -46,8 +47,8 @@ namespace OpenSim.Grid.GridServer
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<string, IGridData> _plugins = new Dictionary<string, IGridData>();
private Dictionary<string, ILogData> _logplugins = new Dictionary<string, ILogData>();
private List<IGridDataPlugin> _plugins = new List<IGridDataPlugin>();
private List<ILogDataPlugin> _logplugins = new List<ILogDataPlugin>();
// This is here so that the grid server can hand out MessageServer settings to regions on registration
private List<MessageServerInfo> _MessageServers = new List<MessageServerInfo>();
@ -57,42 +58,39 @@ namespace OpenSim.Grid.GridServer
/// <summary>
/// Adds a new grid server plugin - grid servers will be requested in the order they were loaded.
/// </summary>
/// <param name="FileName">The filename to the grid server plugin DLL</param>
public void AddPlugin(string FileName, string Connect)
/// <param name="provider">The name of the grid server plugin DLL</param>
public void AddPlugin(string provider, string connect)
{
m_log.Info("[DATA]: Attempting to load " + FileName);
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
// FIXME: convert "provider" DLL file name to Mono.Addins "id",
// which unless it is changed in the source code, is the .NET namespace.
// In the future, the "provider" should be changed to "id" in the
// config files, and is independent of filenames or namespaces.
string[] s = provider.Split ('.');
int len = s.Length;
if ((len >= 2) && (s [len-1] == "dll"))
s [len-1] = s [len-2];
m_log.Info("[DATA]: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (!pluginType.IsAbstract)
{
// Regions go here
Type typeInterface = pluginType.GetInterface("IGridData", true);
provider = String.Join (".", s);
if (typeInterface != null)
{
IGridData plug =
(IGridData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Initialise(Connect);
_plugins.Add(plug.getName(), plug);
m_log.Info("[DATA]: Added IGridData Interface");
}
PluginLoader<IGridDataPlugin> gridloader =
new PluginLoader<IGridDataPlugin> (new GridDataStoreInitialiser (connect));
// Logs go here
typeInterface = pluginType.GetInterface("ILogData", true);
PluginLoader<ILogDataPlugin> logloader =
new PluginLoader<ILogDataPlugin> (new LogDataInitialiser (connect));
if (typeInterface != null)
{
ILogData plug =
(ILogData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Initialise(Connect);
_logplugins.Add(plug.getName(), plug);
m_log.Info("[DATA]: Added ILogData Interface");
}
}
}
gridloader.AddExtensionPoint ("/OpenSim/GridDataStore");
logloader.AddExtensionPoint ("/OpenSim/GridLogData");
// loader will try to load all providers (MySQL, MSSQL, etc)
// unless it is constrainted to the correct "id"
gridloader.AddFilter ("/OpenSim/GridDataStore", new PluginIdFilter (provider + "GridData"));
logloader.AddFilter ("/OpenSim/GridLogData", new PluginIdFilter (provider + "LogData"));
gridloader.Load();
logloader.Load();
_plugins = gridloader.Plugins;
_logplugins = logloader.Plugins;
}
/// <summary>
@ -105,15 +103,15 @@ namespace OpenSim.Grid.GridServer
/// <param name="message">The message to log</param>
private void logToDB(string target, string method, string args, int priority, string message)
{
foreach (KeyValuePair<string, ILogData> kvp in _logplugins)
foreach (ILogDataPlugin plugin in _logplugins)
{
try
{
kvp.Value.saveLog("Gridserver", target, method, args, priority, message);
plugin.saveLog("Gridserver", target, method, args, priority, message);
}
catch (Exception)
{
m_log.Warn("[storage]: Unable to write log via " + kvp.Key);
m_log.Warn("[storage]: Unable to write log via ");
}
}
}
@ -125,11 +123,11 @@ namespace OpenSim.Grid.GridServer
/// <returns>A SimProfileData for the region</returns>
public RegionProfileData GetRegion(LLUUID uuid)
{
foreach (KeyValuePair<string, IGridData> kvp in _plugins)
foreach (IGridDataPlugin plugin in _plugins)
{
try
{
return kvp.Value.GetProfileByLLUUID(uuid);
return plugin.GetProfileByLLUUID(uuid);
}
catch (Exception e)
{
@ -146,15 +144,15 @@ namespace OpenSim.Grid.GridServer
/// <returns>A SimProfileData for the region</returns>
public RegionProfileData GetRegion(ulong handle)
{
foreach (KeyValuePair<string, IGridData> kvp in _plugins)
foreach (IGridDataPlugin plugin in _plugins)
{
try
{
return kvp.Value.GetProfileByHandle(handle);
return plugin.GetProfileByHandle(handle);
}
catch
{
m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + kvp.Key);
m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + plugin.Name);
}
}
return null;
@ -167,15 +165,15 @@ namespace OpenSim.Grid.GridServer
/// <returns>A SimProfileData for the region</returns>
public RegionProfileData GetRegion(string regionName)
{
foreach (KeyValuePair<string, IGridData> kvp in _plugins)
foreach (IGridDataPlugin plugin in _plugins)
{
try
{
return kvp.Value.GetProfileByString(regionName);
return plugin.GetProfileByString(regionName);
}
catch
{
m_log.Warn("[storage]: Unable to find region " + regionName + " via " + kvp.Key);
m_log.Warn("[storage]: Unable to find region " + regionName + " via " + plugin.Name);
}
}
return null;
@ -185,11 +183,11 @@ namespace OpenSim.Grid.GridServer
{
Dictionary<ulong, RegionProfileData> regions = new Dictionary<ulong, RegionProfileData>();
foreach (KeyValuePair<string, IGridData> kvp in _plugins)
foreach (IGridDataPlugin plugin in _plugins)
{
try
{
RegionProfileData[] neighbours = kvp.Value.GetProfilesInRange(xmin, ymin, xmax, ymax);
RegionProfileData[] neighbours = plugin.GetProfilesInRange(xmin, ymin, xmax, ymax);
foreach (RegionProfileData neighbour in neighbours)
{
regions[neighbour.regionHandle] = neighbour;
@ -197,7 +195,7 @@ namespace OpenSim.Grid.GridServer
}
catch
{
m_log.Warn("[storage]: Unable to query regionblock via " + kvp.Key);
m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name);
}
}
@ -404,7 +402,7 @@ namespace OpenSim.Grid.GridServer
return e.XmlRpcErrorResponse;
}
foreach (KeyValuePair<string, IGridData> kvp in _plugins)
foreach (IGridDataPlugin plugin in _plugins)
{
try
{
@ -412,11 +410,11 @@ namespace OpenSim.Grid.GridServer
if (existingSim == null)
{
insertResponse = kvp.Value.AddProfile(sim);
insertResponse = plugin.AddProfile(sim);
}
else
{
insertResponse = kvp.Value.UpdateProfile(sim);
insertResponse = plugin.UpdateProfile(sim);
}
switch (insertResponse)
@ -441,7 +439,7 @@ namespace OpenSim.Grid.GridServer
catch (Exception e)
{
m_log.Warn("[LOGIN END]: " +
"Unable to login region " + sim.UUID.ToString() + " via " + kvp.Key);
"Unable to login region " + sim.UUID.ToString() + " via " + plugin.Name);
m_log.Warn("[LOGIN END]: " + e.ToString());
}
}
@ -682,12 +680,12 @@ namespace OpenSim.Grid.GridServer
return response;
}
foreach (KeyValuePair<string, IGridData> kvp in _plugins)
foreach (IGridDataPlugin plugin in _plugins)
{
//OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData();
try
{
MySQLGridData mysqldata = (MySQLGridData)(kvp.Value);
MySQLGridData mysqldata = (MySQLGridData)(plugin);
//DataResponse insertResponse = mysqldata.DeleteProfile(TheSim);
DataResponse insertResponse = mysqldata.DeleteProfile(uuid);
switch (insertResponse)
@ -1053,17 +1051,17 @@ namespace OpenSim.Grid.GridServer
m_log.Info("[DATA]: " +
"Updating / adding via " + _plugins.Count + " storage provider(s) registered.");
foreach (KeyValuePair<string, IGridData> kvp in _plugins)
foreach (IGridDataPlugin plugin in _plugins)
{
try
{
//Check reservations
ReservationData reserveData =
kvp.Value.GetReservationAtPoint(theSim.regionLocX, theSim.regionLocY);
plugin.GetReservationAtPoint(theSim.regionLocX, theSim.regionLocY);
if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) ||
(reserveData == null && authkeynode.InnerText != theSim.regionRecvKey))
{
kvp.Value.AddProfile(theSim);
plugin.AddProfile(theSim);
m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")");
logToDB(theSim.UUID.ToString(), "RestSetSimMethod", String.Empty, 5,
"Region successfully updated and connected to grid.");
@ -1078,7 +1076,7 @@ namespace OpenSim.Grid.GridServer
}
catch (Exception e)
{
m_log.Warn("[GRID]: GetRegionPlugin Handle " + kvp.Key + " unable to add new sim: " +
m_log.Warn("[GRID]: GetRegionPlugin Handle " + plugin.Name + " unable to add new sim: " +
e.ToString());
}
}

View File

@ -31,7 +31,6 @@ using System.IO;
using System.Reflection;
using System.Timers;
using log4net;
using Mono.Addins;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
@ -121,7 +120,7 @@ namespace OpenSim.Grid.GridServer
PluginLoader<IGridPlugin> loader =
new PluginLoader<IGridPlugin> (new GridPluginInitialiser (this));
loader.Load ("/OpenSim/GridServer", ".");
loader.Load ("/OpenSim/GridServer");
m_plugins = loader.Plugins;
}

View File

@ -29,7 +29,7 @@
using Mono.Addins;
using OpenSim.Framework;
[assembly : AddinRoot("OpenSim", "0.5")]
[assembly : AddinRoot("OpenSim.Grid.GridServer", "0.5")]
namespace OpenSim.Grid.GridServer
{
@ -37,7 +37,6 @@ namespace OpenSim.Grid.GridServer
public interface IGridPlugin : IPlugin
{
void Initialise(GridServerBase gridServer);
void Close();
}
public class GridPluginInitialiser : PluginInitialiserBase

View File

@ -34,7 +34,6 @@ using System.Text;
using System.Threading;
using libsecondlife;
using log4net;
using Mono.Addins;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
@ -338,7 +337,7 @@ namespace OpenSim
PluginLoader<IApplicationPlugin> loader =
new PluginLoader<IApplicationPlugin> (new ApplicationPluginInitialiser (this));
loader.Load ("/OpenSim/Startup", ".");
loader.Load ("/OpenSim/Startup");
m_plugins = loader.Plugins;
}

View File

@ -218,6 +218,7 @@
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Data.Base"/>
<Reference name="log4net.dll"/>
<Reference name="Mono.Addins.dll" />
<Files>
<Match pattern="*.cs" recurse="false"/>
<Match pattern="Properties/*.cs" recurse="false"/>
@ -1293,6 +1294,7 @@
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Region.Environment"/>
<Reference name="log4net.dll"/>
<Reference name="Mono.Addins.dll" />
<Files>
<Match pattern="*.cs" recurse="true"/>
@ -1322,6 +1324,7 @@
<Reference name="OpenSim.Framework.Console"/>
<Reference name="libsecondlife.dll"/>
<Reference name="log4net.dll"/>
<Reference name="Mono.Addins.dll" />
<Files>
<Match pattern="*.cs" recurse="true"/>
@ -1352,6 +1355,7 @@
<Reference name="OpenSim.Region.Environment"/>
<Reference name="libsecondlife.dll"/>
<Reference name="Mono.Data.SqliteClient"/>
<Reference name="Mono.Addins.dll" />
<Reference name="log4net.dll"/>
<Files>