From: Alan Webb <awebb@linux.vnet.ibm.com>

The change makes two principal implementation changes:

[1] It removes the hard coded set of possible asset server client
implementations, allowing any arbitrary implementation that has been
identified to the PluginLoader as an appropriate extension. The
extension point for asset server client extension
is /OpenSim/AssetServerClient. All of the old configuration rules have
been preserved, and any of the legacy configuration values will still
work as they did before, except the implementation is now loaded as a
plug-in, rather than as a hard-coded instantiation of a specific class.
The re-hashing of IAssetServer as an extension of IPlugin made upgrading
of the implementation classes a necessity.

Caveat: I have not been able to meaningfully test the crypto-grid
clients. I believe they should work correctly, but the refactoring
necessary to handle plug-in based initialization (vs constructor-based
initialisation) admits the possibility of a problem.

[2] The asset cache implementation, previously introduce as a hard-code
class instantiation is now implemented as an IPlugin. Once again the
previous (configurationless) behavior has been preserved. But now it is
possible for those interested in experimenting with cache technologies
to do so simply by introducing a new extension for the asset cache
extension point (/OpenSim/AssetCache).

I've tested all of the configuration settings, after applying the patch
to a newly extracted tree, and they seem to work OK.
0.6.3-post-fixes
Sean Dague 2009-02-16 12:20:31 +00:00
parent 81bb87168f
commit f4bec00057
15 changed files with 544 additions and 61 deletions

View File

@ -48,8 +48,67 @@ namespace OpenSim.Framework.Communications.Cache
/// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and
/// AssetNotFound(), which means they do share the same asset and texture caches.I agr /// AssetNotFound(), which means they do share the same asset and texture caches.I agr
public class AssetCache : IAssetCache, IAssetReceiver public class AssetCache : IAssetCache
{ {
#region IPlugin
/// <summary>
/// The methods and properties in this section are needed to
/// support the IPlugin interface. They cann all be overridden
/// as needed by a derived class.
/// </summary>
public virtual string Name
{
get { return "OpenSim.Framework.Communications.Cache.AssetCache"; }
}
public virtual string Version
{
get { return "1.0"; }
}
public virtual void Initialise()
{
m_log.Debug("[ASSET CACHE]: Asset cache null initialisation");
}
public virtual void Initialise(IAssetServer assetServer)
{
m_log.Debug("[ASSET CACHE]: Asset cache server-specified initialisation");
m_log.InfoFormat("[ASSET CACHE]: Asset cache initialisation [{0}/{1}]", Name, Version);
Initialize();
m_assetServer = assetServer;
m_assetServer.SetReceiver(this);
Thread assetCacheThread = new Thread(RunAssetManager);
assetCacheThread.Name = "AssetCacheThread";
assetCacheThread.IsBackground = true;
assetCacheThread.Start();
ThreadTracker.Add(assetCacheThread);
}
public virtual void Initialise(ConfigSettings settings, IAssetServer assetServer)
{
m_log.Debug("[ASSET CACHE]: Asset cache configured initialisation");
Initialise(assetServer);
}
public AssetCache()
{
m_log.Debug("[ASSET CACHE]: Asset cache (plugin constructor)");
}
public void Dispose()
{
}
#endregion
protected ICache m_memcache = new SimpleMemoryCache(); protected ICache m_memcache = new SimpleMemoryCache();
private static readonly ILog m_log private static readonly ILog m_log
@ -83,7 +142,7 @@ namespace OpenSim.Framework.Communications.Cache
/// <summary> /// <summary>
/// The 'server' from which assets can be requested and to which assets are persisted. /// The 'server' from which assets can be requested and to which assets are persisted.
/// </summary> /// </summary>
private readonly IAssetServer m_assetServer; private IAssetServer m_assetServer;
public IAssetServer AssetServer public IAssetServer AssetServer
{ {
@ -132,17 +191,8 @@ namespace OpenSim.Framework.Communications.Cache
/// <param name="assetServer"></param> /// <param name="assetServer"></param>
public AssetCache(IAssetServer assetServer) public AssetCache(IAssetServer assetServer)
{ {
m_log.Info("[ASSET CACHE]: Creating Asset cache"); m_log.Info("[ASSET CACHE]: Asset cache direct constructor");
Initialize(); Initialise(assetServer);
m_assetServer = assetServer;
m_assetServer.SetReceiver(this);
Thread assetCacheThread = new Thread(RunAssetManager);
assetCacheThread.Name = "AssetCacheThread";
assetCacheThread.IsBackground = true;
assetCacheThread.Start();
ThreadTracker.Add(assetCacheThread);
} }
/// <summary> /// <summary>
@ -342,7 +392,7 @@ namespace OpenSim.Framework.Communications.Cache
} }
// See IAssetReceiver // See IAssetReceiver
public void AssetReceived(AssetBase asset, bool IsTexture) public virtual void AssetReceived(AssetBase asset, bool IsTexture)
{ {
AssetInfo assetInf = new AssetInfo(asset); AssetInfo assetInf = new AssetInfo(asset);
@ -393,7 +443,7 @@ namespace OpenSim.Framework.Communications.Cache
} }
// See IAssetReceiver // See IAssetReceiver
public void AssetNotFound(UUID assetID, bool IsTexture) public virtual void AssetNotFound(UUID assetID, bool IsTexture)
{ {
// m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); // m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID);

View File

@ -46,6 +46,61 @@ namespace OpenSim.Framework.Communications.Cache
protected Thread m_localAssetServerThread; protected Thread m_localAssetServerThread;
protected IAssetDataPlugin m_assetProvider; protected IAssetDataPlugin m_assetProvider;
#region IPlugin
/// <summary>
/// The methods and properties in this region are needed to implement
/// the IPlugin interface and its local extensions.
/// These can all be overridden as appropriate by a derived class.
/// These methods are only applicable when a class is loaded by the
/// IPlugin mechanism.
///
/// Note that in the case of AssetServerBase, all initialization is
/// performed by the default constructor, so nothing additional is
/// required here. A derived class may wish to do more.
/// </summary>
public virtual string Name
{
// get { return "OpenSim.Framework.Communications.Cache.AssetServerBase"; }
get { return "AssetServerBase"; }
}
public virtual string Version
{
get { return "1.0"; }
}
public virtual void Initialise()
{
m_log.Debug("[ASSET SERVER]: IPlugin null initialization");
}
public virtual void Initialise(ConfigSettings settings)
{
m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(1)");
m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version);
}
public virtual void Initialise(ConfigSettings settings, string p_url)
{
m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(2)");
m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version);
}
public virtual void Initialise(ConfigSettings settings, string p_url, string p_dir, bool p_t)
{
m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(3)");
m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version);
}
public virtual void Dispose()
{
m_log.Debug("[ASSET SERVER]: dispose");
}
#endregion
public IAssetDataPlugin AssetProviderPlugin public IAssetDataPlugin AssetProviderPlugin
{ {
get { return m_assetProvider; } get { return m_assetProvider; }

View File

@ -44,9 +44,37 @@ namespace OpenSim.Framework.Communications.Cache
{ {
public class CryptoGridAssetClient : AssetServerBase public class CryptoGridAssetClient : AssetServerBase
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string _assetServerUrl;
private bool m_encryptOnUpload;
private RjinKeyfile m_encryptKey;
private readonly Dictionary<string,RjinKeyfile> m_keyfiles = new Dictionary<string, RjinKeyfile>();
#region IPlugin
public override string Name
{
get { return "Crypto"; }
}
public override string Version
{
get { return "1.0"; }
}
public override void Initialise(ConfigSettings p_set, string p_url, string p_dir, bool p_t)
{
m_log.Debug("[CRYPTOGRID] Plugin configured initialisation");
Initialise(p_url, p_dir, p_t);
}
#endregion
#region Keyfile Classes #region Keyfile Classes
[Serializable] [Serializable]
private class RjinKeyfile public class RjinKeyfile
{ {
public string Secret; public string Secret;
public string AlsoKnownAs; public string AlsoKnownAs;
@ -94,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache
/// this may not be the most efficient way of handling encryption, so - as /// this may not be the most efficient way of handling encryption, so - as
/// soon as you feel comfortable with it - you may want to redesign this class. /// soon as you feel comfortable with it - you may want to redesign this class.
/// </summary> /// </summary>
private class UtilRijndael public class UtilRijndael
{ {
/// <summary> /// <summary>
/// Encrypts specified plaintext using Rijndael symmetric key algorithm /// Encrypts specified plaintext using Rijndael symmetric key algorithm
@ -332,15 +360,19 @@ namespace OpenSim.Framework.Communications.Cache
} }
#endregion #endregion
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public CryptoGridAssetClient() {}
private readonly string _assetServerUrl;
private readonly bool m_encryptOnUpload;
private readonly RjinKeyfile m_encryptKey;
private readonly Dictionary<string,RjinKeyfile> m_keyfiles = new Dictionary<string, RjinKeyfile>();
public CryptoGridAssetClient(string serverUrl, string keydir, bool decOnly) public CryptoGridAssetClient(string serverUrl, string keydir, bool decOnly)
{ {
m_log.Debug("[CRYPTOGRID] Direct constructor");
Initialise(serverUrl, keydir, decOnly);
}
public void Initialise(string serverUrl, string keydir, bool decOnly)
{
m_log.Debug("[CRYPTOGRID] Common constructor");
_assetServerUrl = serverUrl; _assetServerUrl = serverUrl;
string[] keys = Directory.GetFiles(keydir, "*.deckey"); string[] keys = Directory.GetFiles(keydir, "*.deckey");

View File

@ -26,16 +26,49 @@
*/ */
using System.IO; using System.IO;
using System.Reflection;
using log4net;
using System.Xml.Serialization; using System.Xml.Serialization;
namespace OpenSim.Framework.Communications.Cache namespace OpenSim.Framework.Communications.Cache
{ {
public class FileAssetClient : AssetServerBase public class FileAssetClient : AssetServerBase
{ {
private readonly string m_dir;
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
#region IPlugin
public override string Name
{
get { return "File"; }
}
public override string Version
{
get { return "1.0"; }
}
public override void Initialise(ConfigSettings p_set, string p_url)
{
m_log.Debug("[FILEASSET] Plugin configured initialisation");
Initialise(p_url);
}
#endregion
private string m_dir;
private readonly XmlSerializer m_xs = new XmlSerializer(typeof(AssetBase)); private readonly XmlSerializer m_xs = new XmlSerializer(typeof(AssetBase));
public FileAssetClient(string dir) public FileAssetClient() {}
public FileAssetClient(string p_url)
{
m_log.Debug("[FILEASSET] Direct constructor");
Initialise(p_url);
}
public void Initialise(string dir)
{ {
if (!Directory.Exists(dir)) if (!Directory.Exists(dir))
{ {

View File

@ -36,11 +36,40 @@ namespace OpenSim.Framework.Communications.Cache
{ {
public class GridAssetClient : AssetServerBase public class GridAssetClient : AssetServerBase
{ {
#region IPlugin
public override string Name
{
get { return "Grid"; }
}
public override string Version
{
get { return "1.0"; }
}
public override void Initialise(ConfigSettings p_set, string p_url)
{
m_log.Debug("[GRIDASSET] Plugin configured initialisation");
Initialise(p_url);
}
#endregion
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string _assetServerUrl; private string _assetServerUrl;
public GridAssetClient(string serverUrl) public GridAssetClient() {}
public GridAssetClient(string p_url)
{
m_log.Debug("[GRIDASSET] Direct constructor");
Initialise(p_url);
}
public void Initialise(string serverUrl)
{ {
_assetServerUrl = serverUrl; _assetServerUrl = serverUrl;
} }

View File

@ -34,9 +34,38 @@ namespace OpenSim.Framework.Communications.Cache
{ {
public class SQLAssetServer : AssetServerBase public class SQLAssetServer : AssetServerBase
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
#region IPlugin
public override string Name
{
get { return "SQL"; }
}
public override string Version
{
get { return "1.0"; }
}
public override void Initialise(ConfigSettings p_set)
{
m_log.Debug("[SQLASSET] Plugin configured initialisation");
Initialise(p_set.StandaloneAssetPlugin,p_set.StandaloneAssetSource);
}
#endregion
public SQLAssetServer() {}
public SQLAssetServer(string pluginName, string connect) public SQLAssetServer(string pluginName, string connect)
{
m_log.Debug("[SQLASSET] Direct constructor");
Initialise(pluginName, connect);
}
public void Initialise(string pluginName, string connect)
{ {
AddPlugin(pluginName, connect); AddPlugin(pluginName, connect);
} }

View File

@ -0,0 +1,17 @@
<Addin id="OpenSim.Framework.Communications" version="1.0">
<Runtime>
<Import assembly="OpenSim.Framework.Communications.dll"/>
</Runtime>
<Dependencies>
<Addin id="OpenSim" version="0.5" />
</Dependencies>
<Extension path="/OpenSim/AssetCache">
<Cache id="Default" provider="Default" type="OpenSim.Framework.Communications.Cache.AssetCache" />
</Extension>
<Extension path="/OpenSim/AssetServerClient">
<ServerClient id="Crypto" provider="Crypto" type="OpenSim.Framework.Communications.Cache.CryptoGridAssetClient" />
<ServerClient id="Grid" provider="Grid" type="OpenSim.Framework.Communications.Cache.GridAssetClient" />
<ServerClient id="File" provider="File" type="OpenSim.Framework.Communications.Cache.FileAssetClient" />
<ServerClient id="SQL" provider="SQL" type="OpenSim.Framework.Communications.Cache.SQLAssetServer" />
</Extension>
</Addin>

View File

@ -156,6 +156,14 @@ namespace OpenSim.Framework
set { m_assetStorage = value; } set { m_assetStorage = value; }
} }
private string m_assetCache;
public string AssetCache
{
get { return m_assetCache; }
set { m_assetCache = value; }
}
protected string m_storageConnectionString; protected string m_storageConnectionString;
public string StorageConnectionString public string StorageConnectionString

View File

@ -33,7 +33,7 @@ namespace OpenSim.Framework
public delegate void AssetRequestCallback(UUID assetId, AssetBase asset); public delegate void AssetRequestCallback(UUID assetId, AssetBase asset);
public interface IAssetCache : IAssetReceiver public interface IAssetCache : IAssetReceiver, IPlugin
{ {
IAssetServer AssetServer { get; } IAssetServer AssetServer { get; }
@ -47,5 +47,25 @@ namespace OpenSim.Framework
void ExpireAsset(UUID assetID); void ExpireAsset(UUID assetID);
void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest); void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest);
void Initialise(ConfigSettings cs, IAssetServer server);
} }
public class AssetCachePluginInitialiser : PluginInitialiserBase
{
private ConfigSettings config;
private IAssetServer server;
public AssetCachePluginInitialiser (ConfigSettings p_sv, IAssetServer p_as)
{
config = p_sv;
server = p_as;
}
public override void Initialise (IPlugin plugin)
{
IAssetCache p = plugin as IAssetCache;
p.Initialise (config, server);
}
}
} }

View File

@ -32,8 +32,11 @@ namespace OpenSim.Framework
/// <summary> /// <summary>
/// Description of IAssetServer. /// Description of IAssetServer.
/// </summary> /// </summary>
public interface IAssetServer public interface IAssetServer : IPlugin
{ {
void Initialise(ConfigSettings settings);
void Initialise(ConfigSettings settings, string url, string dir, bool test);
void Initialise(ConfigSettings settings, string url);
void SetReceiver(IAssetReceiver receiver); void SetReceiver(IAssetReceiver receiver);
void RequestAsset(UUID assetID, bool isTexture); void RequestAsset(UUID assetID, bool isTexture);
void StoreAsset(AssetBase asset); void StoreAsset(AssetBase asset);
@ -62,8 +65,62 @@ namespace OpenSim.Framework
void AssetNotFound(UUID assetID, bool IsTexture); void AssetNotFound(UUID assetID, bool IsTexture);
} }
public class AssetServerClientPluginInitialiser : PluginInitialiserBase
{
private ConfigSettings config;
public AssetServerClientPluginInitialiser (ConfigSettings p_sv)
{
config = p_sv;
}
public override void Initialise (IPlugin plugin)
{
IAssetServer p = plugin as IAssetServer;
p.Initialise (config);
}
}
public class LegacyAssetServerClientPluginInitialiser : PluginInitialiserBase
{
private ConfigSettings config;
private string assetURL;
public LegacyAssetServerClientPluginInitialiser (ConfigSettings p_sv, string p_url)
{
config = p_sv;
assetURL = p_url;
}
public override void Initialise (IPlugin plugin)
{
IAssetServer p = plugin as IAssetServer;
p.Initialise (config, assetURL);
}
}
public class CryptoAssetServerClientPluginInitialiser : PluginInitialiserBase
{
private ConfigSettings config;
private string assetURL;
private string currdir;
private bool test;
public CryptoAssetServerClientPluginInitialiser (ConfigSettings p_sv, string p_url, string p_dir, bool p_test)
{
config = p_sv;
assetURL = p_url;
currdir = p_dir;
test = p_test;
}
public override void Initialise (IPlugin plugin)
{
IAssetServer p = plugin as IAssetServer;
p.Initialise (config, assetURL, currdir, test);
}
}
public interface IAssetPlugin public interface IAssetPlugin
{ {
IAssetServer GetAssetServer(); IAssetServer GetAssetServer();
} }
} }

View File

@ -268,6 +268,7 @@ namespace OpenSim
m_configSettings.StorageConnectionString = startupConfig.GetString("storage_connection_string"); m_configSettings.StorageConnectionString = startupConfig.GetString("storage_connection_string");
m_configSettings.EstateConnectionString = startupConfig.GetString("estate_connection_string", m_configSettings.StorageConnectionString); m_configSettings.EstateConnectionString = startupConfig.GetString("estate_connection_string", m_configSettings.StorageConnectionString);
m_configSettings.AssetStorage = startupConfig.GetString("asset_database"); m_configSettings.AssetStorage = startupConfig.GetString("asset_database");
m_configSettings.AssetCache = startupConfig.GetString("AssetCache");
m_configSettings.ClientstackDll = startupConfig.GetString("clientstack_plugin"); m_configSettings.ClientstackDll = startupConfig.GetString("clientstack_plugin");
} }

View File

@ -55,6 +55,12 @@ namespace OpenSim
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// These are the names of the plugin-points extended by this
// class during system startup.
private const string PLUGIN_ASSET_CACHE = "/OpenSim/AssetCache";
private const string PLUGIN_ASSET_SERVER_CLIENT = "/OpenSim/AssetServerClient";
protected string proxyUrl; protected string proxyUrl;
protected int proxyOffset = 0; protected int proxyOffset = 0;
@ -309,57 +315,183 @@ namespace OpenSim
} }
/// <summary> /// <summary>
/// Initialises the assetcache /// Initialises the asset cache. This supports legacy configuration values
/// to ensure consistent operation, but values outside of that namespace
/// are handled by the more generic resolution mechanism provided by
/// the ResolveAssetServer virtual method. If extended resolution fails,
/// then the normal default action is taken.
/// Creation of the AssetCache is handled by ResolveAssetCache. This
/// function accepts a reference to the instantiated AssetServer and
/// returns an IAssetCache implementation, if possible. This is a virtual
/// method.
/// </summary> /// </summary>
protected virtual void InitialiseAssetCache() protected virtual void InitialiseAssetCache()
{ {
LegacyAssetServerClientPluginInitialiser linit = null;
CryptoAssetServerClientPluginInitialiser cinit = null;
AssetServerClientPluginInitialiser init = null;
IAssetServer assetServer = null; IAssetServer assetServer = null;
string mode = m_configSettings.AssetStorage; string mode = m_configSettings.AssetStorage;
if (m_configSettings.Standalone == false && if (mode == null | mode == String.Empty)
m_configSettings.AssetStorage == "default") mode = "default";
mode = "grid";
switch (mode) // If "default" is specified, then the value is adjusted
// according to whether or not the server is running in
// standalone mode.
if (mode.ToLower() == "default")
{ {
case "grid" : if (m_configSettings.Standalone == false)
assetServer = new GridAssetClient(m_networkServersInfo.AssetURL); mode = "grid";
break; else
case "cryptogrid" : mode = "local";
assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL,
Environment.CurrentDirectory, true);
break;
case "cryptogrid_eou" :
assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL,
Environment.CurrentDirectory, false);
break;
case "file" :
assetServer = new FileAssetClient(m_networkServersInfo.AssetURL);
break;
default :
if (!ResolveAssetServer(out assetServer))
{
SQLAssetServer sqlAssetServer = new SQLAssetServer(m_configSettings.StandaloneAssetPlugin, m_configSettings.StandaloneAssetSource);
sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile);
assetServer = sqlAssetServer;
}
break;
} }
switch (mode.ToLower())
{
// If grid is specified then the grid server is chose regardless
// of whether the server is standalone.
case "grid" :
linit = new LegacyAssetServerClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL);
assetServer = loadAssetServer("Grid", linit);
break;
// If cryptogrid is specified then the cryptogrid server is chose regardless
// of whether the server is standalone.
case "cryptogrid" :
cinit = new CryptoAssetServerClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL,
Environment.CurrentDirectory, true);
assetServer = loadAssetServer("Crypto", cinit);
break;
// If cryptogrid_eou is specified then the cryptogrid_eou server is chose regardless
// of whether the server is standalone.
case "cryptogrid_eou" :
cinit = new CryptoAssetServerClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL,
Environment.CurrentDirectory, false);
assetServer = loadAssetServer("Crypto", cinit);
break;
// If file is specified then the file server is chose regardless
// of whether the server is standalone.
case "file" :
linit = new LegacyAssetServerClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL);
assetServer = loadAssetServer("File", linit);
break;
// If local is specified then we're going to use the local SQL server
// implementation. We drop through, because that will be the fallback
// for the following default clause too.
case "local" :
break;
// If the asset_database value is none of the previously mentioned strings, then we
// try to load a turnkey plugin that matches this value. If not we drop through to
// a local default.
default :
try
{
init = new AssetServerClientPluginInitialiser(m_configSettings);
assetServer = loadAssetServer(m_configSettings.AssetStorage, init);
break;
}
catch {}
m_log.Info("[OPENSIMBASE] Default assetserver will be used");
break;
}
// Open the local SQL-based database asset server
if (assetServer == null)
{
init = new AssetServerClientPluginInitialiser(m_configSettings);
SQLAssetServer sqlAssetServer = (SQLAssetServer) loadAssetServer("SQL", init);
sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile);
assetServer = sqlAssetServer;
}
// Initialize the asset cache, passing a reference to the selected
// asset server interface.
m_assetCache = ResolveAssetCache(assetServer); m_assetCache = ResolveAssetCache(assetServer);
} }
private bool ResolveAssetServer(out IAssetServer assetServer) // This method loads the identified asset server, passing an approrpiately
// initialized Initialise wrapper. There should to be exactly one match,
// if not, then the first match is used.
private IAssetServer loadAssetServer(string id, PluginInitialiserBase pi)
{ {
assetServer = null;
return false; m_log.DebugFormat("[OPENSIMBASE] Attempting to load asset server id={0}", id);
PluginLoader<IAssetServer> loader = new PluginLoader<IAssetServer>(pi);
loader.AddFilter(PLUGIN_ASSET_SERVER_CLIENT, new PluginProviderFilter(id));
loader.Load(PLUGIN_ASSET_SERVER_CLIENT);
if (loader.Plugins.Count > 0)
return (IAssetServer) loader.Plugins[0];
else
return null;
} }
private IAssetCache ResolveAssetCache(IAssetServer assetServer) /// <summary>
/// Attempt to instantiate an IAssetCache implementation, using the
/// provided IAssetServer reference.
/// An asset cache implementation must provide a constructor that
/// accepts two parameters;
/// [1] A ConfigSettings reference.
/// [2] An IAssetServer reference.
/// The AssetCache value is obtained from the
/// [StartUp]/AssetCache value in the configuration file.
/// </summary>
protected virtual IAssetCache ResolveAssetCache(IAssetServer assetServer)
{ {
return new AssetCache(assetServer);
IAssetCache assetCache = null;
m_log.DebugFormat("[OPENSIMBASE] Attempting to load asset cache id={0}", m_configSettings.AssetCache);
if (m_configSettings.AssetCache != null && m_configSettings.AssetCache != String.Empty)
{
try
{
PluginInitialiserBase init = new AssetCachePluginInitialiser(m_configSettings, assetServer);
PluginLoader<IAssetCache> loader = new PluginLoader<IAssetCache>(init);
loader.AddFilter(PLUGIN_ASSET_SERVER_CLIENT, new PluginProviderFilter(m_configSettings.AssetCache));
loader.Load(PLUGIN_ASSET_CACHE);
if (loader.Plugins.Count > 0)
assetCache = (IAssetCache) loader.Plugins[0];
}
catch (Exception e)
{
m_log.Debug("[OPENSIMBASE] ResolveAssetCache completed");
m_log.Debug(e);
}
}
// If everything else fails, we force load the built-in asset cache
return (IAssetCache) ((assetCache != null) ? assetCache : new AssetCache(assetServer));
} }
public void ProcessLogin(bool LoginEnabled) public void ProcessLogin(bool LoginEnabled)

View File

@ -3,7 +3,13 @@
<Import assembly="OpenSim.exe"/> <Import assembly="OpenSim.exe"/>
<Import assembly="OpenSim.Framework.dll"/> <Import assembly="OpenSim.Framework.dll"/>
</Runtime> </Runtime>
<ExtensionPoint path = "/OpenSim/Startup"> <ExtensionPoint path="/OpenSim/Startup">
<ExtensionNode name="Plugin" type="OpenSim.Framework.PluginExtensionNode" objectType="OpenSim.IApplicationPlugin"/> <ExtensionNode name="Plugin" type="OpenSim.Framework.PluginExtensionNode" objectType="OpenSim.IApplicationPlugin"/>
</ExtensionPoint> </ExtensionPoint>
<ExtensionPoint path="/OpenSim/AssetCache" name="Region Asset Cache Plugin-point" >
<ExtensionNode name="Cache" type="OpenSim.Framework.PluginExtensionNode" objectType="OpenSim.Framework.IAssetCache"/>
</ExtensionPoint>
<ExtensionPoint path="/OpenSim/AssetServerClient" name="Region Asset Cache Server Interface Plugin-point">
<ExtensionNode name="ServerClient" type="OpenSim.Framework.PluginExtensionNode" objectType="OpenSim.Framework.IAssetServer"/>
</ExtensionPoint>
</Addin> </Addin>

View File

@ -110,6 +110,8 @@
; ;
; If set to local then the local database based asset service will be used in standalone and grid modes ; If set to local then the local database based asset service will be used in standalone and grid modes
; If set to grid then the grid based asset service will be used in standalone and grid modes ; If set to grid then the grid based asset service will be used in standalone and grid modes
; All other values will cause a search for a matching assembly that contains an asset server client.
; See also: AssetCache
asset_database = "default" asset_database = "default"
; Persistence of changed objects happens during regular sweeps. The following control that behaviour to ; Persistence of changed objects happens during regular sweeps. The following control that behaviour to
@ -197,6 +199,17 @@
;WorldMapModule = "WorldMap" ;WorldMapModule = "WorldMap"
;MapImageModule = "MapImageModule" ;MapImageModule = "MapImageModule"
; ##
; ## Customized Cache Implementation
; ##
;
; The AssetCache value allows the name of an alternative caching
; implementation to be specified. This can normally be omitted.
; This value corresponds to the provider value associated with the
; intended cache implementation plugin.
; See also: asset_database
; AssetCache = "OpenSim.Framework.Communications.Cache.AssetCache"
; ## ; ##
; ## EMAIL MODULE ; ## EMAIL MODULE

View File

@ -540,6 +540,7 @@
<Match pattern="*.cs" recurse="true"> <Match pattern="*.cs" recurse="true">
<Exclude name="Tests" pattern="Tests"/> <Exclude name="Tests" pattern="Tests"/>
</Match> </Match>
<Match pattern="*.addin.xml" path="Resources" buildAction="EmbeddedResource" recurse="true"/>
</Files> </Files>
</Project> </Project>