Make it possible to chain another asset service underneath the de-duplicating XAssetService.
This makes it possible to use the dedupliicating service without needing to migrate all the existing asset data beforehand. Currently controlled by a ChainedServiceModule setting in [AssetService] (e.g. ChainedServiceModule = "OpenSim.Services.AssetService.dll:AssetService") Not yet ready for use.user_profiles
parent
d3e76730bd
commit
924d6e892a
|
@ -39,8 +39,7 @@ using OpenMetaverse;
|
||||||
namespace OpenSim.Services.AssetService
|
namespace OpenSim.Services.AssetService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This will be developed into a de-duplicating asset service.
|
/// A de-duplicating asset service.
|
||||||
/// XXX: Currently it's a just a copy of the existing AssetService. so please don't attempt to use it.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class XAssetService : XAssetServiceBase, IAssetService
|
public class XAssetService : XAssetServiceBase, IAssetService
|
||||||
{
|
{
|
||||||
|
@ -48,7 +47,9 @@ namespace OpenSim.Services.AssetService
|
||||||
|
|
||||||
protected static XAssetService m_RootInstance;
|
protected static XAssetService m_RootInstance;
|
||||||
|
|
||||||
public XAssetService(IConfigSource config) : base(config)
|
public XAssetService(IConfigSource config) : this(config, "AssetService") {}
|
||||||
|
|
||||||
|
public XAssetService(IConfigSource config, string configName) : base(config, configName)
|
||||||
{
|
{
|
||||||
if (m_RootInstance == null)
|
if (m_RootInstance == null)
|
||||||
{
|
{
|
||||||
|
@ -56,22 +57,21 @@ namespace OpenSim.Services.AssetService
|
||||||
|
|
||||||
if (m_AssetLoader != null)
|
if (m_AssetLoader != null)
|
||||||
{
|
{
|
||||||
IConfig assetConfig = config.Configs["AssetService"];
|
IConfig assetConfig = config.Configs[configName];
|
||||||
if (assetConfig == null)
|
if (assetConfig == null)
|
||||||
throw new Exception("No AssetService configuration");
|
throw new Exception("No AssetService configuration");
|
||||||
|
|
||||||
string loaderArgs = assetConfig.GetString("AssetLoaderArgs",
|
string loaderArgs = assetConfig.GetString("AssetLoaderArgs", String.Empty);
|
||||||
String.Empty);
|
|
||||||
|
|
||||||
bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true);
|
bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true);
|
||||||
|
|
||||||
if (assetLoaderEnabled)
|
if (assetLoaderEnabled && !HasChainedAssetService)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[XASSET SERVICE]: Loading default asset set from {0}", loaderArgs);
|
m_log.DebugFormat("[XASSET SERVICE]: Loading default asset set from {0}", loaderArgs);
|
||||||
|
|
||||||
m_AssetLoader.ForEachDefaultXmlAsset(
|
m_AssetLoader.ForEachDefaultXmlAsset(
|
||||||
loaderArgs,
|
loaderArgs,
|
||||||
delegate(AssetBase a)
|
a =>
|
||||||
{
|
{
|
||||||
AssetBase existingAsset = Get(a.ID);
|
AssetBase existingAsset = Get(a.ID);
|
||||||
// AssetMetadata existingMetadata = GetMetadata(a.ID);
|
// AssetMetadata existingMetadata = GetMetadata(a.ID);
|
||||||
|
@ -103,7 +103,14 @@ namespace OpenSim.Services.AssetService
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return m_Database.GetAsset(assetID);
|
AssetBase asset = m_Database.GetAsset(assetID);
|
||||||
|
|
||||||
|
if (asset != null)
|
||||||
|
return asset;
|
||||||
|
else if (HasChainedAssetService)
|
||||||
|
return m_ChainedAssetService.Get(id);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -128,9 +135,17 @@ namespace OpenSim.Services.AssetService
|
||||||
|
|
||||||
AssetBase asset = m_Database.GetAsset(assetID);
|
AssetBase asset = m_Database.GetAsset(assetID);
|
||||||
if (asset != null)
|
if (asset != null)
|
||||||
|
{
|
||||||
return asset.Metadata;
|
return asset.Metadata;
|
||||||
|
}
|
||||||
return null;
|
else if (HasChainedAssetService)
|
||||||
|
{
|
||||||
|
return m_ChainedAssetService.GetMetadata(id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual byte[] GetData(string id)
|
public virtual byte[] GetData(string id)
|
||||||
|
@ -143,7 +158,13 @@ namespace OpenSim.Services.AssetService
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
AssetBase asset = m_Database.GetAsset(assetID);
|
AssetBase asset = m_Database.GetAsset(assetID);
|
||||||
return asset.Data;
|
|
||||||
|
if (asset != null)
|
||||||
|
return asset.Data;
|
||||||
|
else if (HasChainedAssetService)
|
||||||
|
return m_ChainedAssetService.GetData(id);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool Get(string id, Object sender, AssetRetrieved handler)
|
public virtual bool Get(string id, Object sender, AssetRetrieved handler)
|
||||||
|
@ -157,6 +178,9 @@ namespace OpenSim.Services.AssetService
|
||||||
|
|
||||||
AssetBase asset = m_Database.GetAsset(assetID);
|
AssetBase asset = m_Database.GetAsset(assetID);
|
||||||
|
|
||||||
|
if (asset == null && HasChainedAssetService)
|
||||||
|
asset = m_ChainedAssetService.Get(id);
|
||||||
|
|
||||||
//m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset);
|
//m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset);
|
||||||
|
|
||||||
handler(id, sender, asset);
|
handler(id, sender, asset);
|
||||||
|
@ -194,6 +218,9 @@ namespace OpenSim.Services.AssetService
|
||||||
if (!UUID.TryParse(id, out assetID))
|
if (!UUID.TryParse(id, out assetID))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Don't bother deleting from a chained asset service. This isn't a big deal since deleting happens
|
||||||
|
// very rarely.
|
||||||
|
|
||||||
return m_Database.Delete(id);
|
return m_Database.Delete(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,11 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Data;
|
using OpenSim.Data;
|
||||||
|
using OpenSim.Server.Base;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using OpenSim.Services.Base;
|
using OpenSim.Services.Base;
|
||||||
|
|
||||||
|
@ -37,10 +39,15 @@ namespace OpenSim.Services.AssetService
|
||||||
{
|
{
|
||||||
public class XAssetServiceBase : ServiceBase
|
public class XAssetServiceBase : ServiceBase
|
||||||
{
|
{
|
||||||
protected IXAssetDataPlugin m_Database = null;
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
protected IAssetLoader m_AssetLoader = null;
|
|
||||||
|
|
||||||
public XAssetServiceBase(IConfigSource config) : base(config)
|
protected IXAssetDataPlugin m_Database;
|
||||||
|
protected IAssetLoader m_AssetLoader;
|
||||||
|
protected IAssetService m_ChainedAssetService;
|
||||||
|
|
||||||
|
protected bool HasChainedAssetService { get { return m_ChainedAssetService != null; } }
|
||||||
|
|
||||||
|
public XAssetServiceBase(IConfigSource config, string configName) : base(config)
|
||||||
{
|
{
|
||||||
string dllName = String.Empty;
|
string dllName = String.Empty;
|
||||||
string connString = String.Empty;
|
string connString = String.Empty;
|
||||||
|
@ -48,7 +55,7 @@ namespace OpenSim.Services.AssetService
|
||||||
//
|
//
|
||||||
// Try reading the [AssetService] section first, if it exists
|
// Try reading the [AssetService] section first, if it exists
|
||||||
//
|
//
|
||||||
IConfig assetConfig = config.Configs["AssetService"];
|
IConfig assetConfig = config.Configs[configName];
|
||||||
if (assetConfig != null)
|
if (assetConfig != null)
|
||||||
{
|
{
|
||||||
dllName = assetConfig.GetString("StorageProvider", dllName);
|
dllName = assetConfig.GetString("StorageProvider", dllName);
|
||||||
|
@ -77,17 +84,35 @@ namespace OpenSim.Services.AssetService
|
||||||
if (m_Database == null)
|
if (m_Database == null)
|
||||||
throw new Exception("Could not find a storage interface in the given module");
|
throw new Exception("Could not find a storage interface in the given module");
|
||||||
|
|
||||||
|
string chainedAssetServiceDesignator = assetConfig.GetString("ChainedServiceModule", null);
|
||||||
|
|
||||||
|
if (chainedAssetServiceDesignator != null)
|
||||||
|
{
|
||||||
|
m_log.InfoFormat(
|
||||||
|
"[XASSET SERVICE BASE]: Loading chained asset service from {0}", chainedAssetServiceDesignator);
|
||||||
|
|
||||||
|
Object[] args = new Object[] { config, configName };
|
||||||
|
m_ChainedAssetService = ServerUtils.LoadPlugin<IAssetService>(chainedAssetServiceDesignator, args);
|
||||||
|
|
||||||
|
if (!HasChainedAssetService)
|
||||||
|
throw new Exception(
|
||||||
|
String.Format("Failed to load ChainedAssetService from {0}", chainedAssetServiceDesignator));
|
||||||
|
}
|
||||||
|
|
||||||
m_Database.Initialise(connString);
|
m_Database.Initialise(connString);
|
||||||
|
|
||||||
string loaderName = assetConfig.GetString("DefaultAssetLoader",
|
if (HasChainedAssetService)
|
||||||
String.Empty);
|
|
||||||
|
|
||||||
if (loaderName != String.Empty)
|
|
||||||
{
|
{
|
||||||
m_AssetLoader = LoadPlugin<IAssetLoader>(loaderName);
|
string loaderName = assetConfig.GetString("DefaultAssetLoader",
|
||||||
|
String.Empty);
|
||||||
|
|
||||||
if (m_AssetLoader == null)
|
if (loaderName != String.Empty)
|
||||||
throw new Exception("Asset loader could not be loaded");
|
{
|
||||||
|
m_AssetLoader = LoadPlugin<IAssetLoader>(loaderName);
|
||||||
|
|
||||||
|
if (m_AssetLoader == null)
|
||||||
|
throw new Exception("Asset loader could not be loaded");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -899,6 +899,7 @@
|
||||||
<Reference name="OpenSim.Framework"/>
|
<Reference name="OpenSim.Framework"/>
|
||||||
<Reference name="OpenSim.Framework.Console"/>
|
<Reference name="OpenSim.Framework.Console"/>
|
||||||
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
|
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
|
||||||
|
<Reference name="OpenSim.Server.Base"/>
|
||||||
<Reference name="OpenSim.Services.Interfaces"/>
|
<Reference name="OpenSim.Services.Interfaces"/>
|
||||||
<Reference name="OpenSim.Services.Base"/>
|
<Reference name="OpenSim.Services.Base"/>
|
||||||
<Reference name="OpenSim.Services.Connectors"/>
|
<Reference name="OpenSim.Services.Connectors"/>
|
||||||
|
|
Loading…
Reference in New Issue