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

These changes replace all direct references to the AssetCache with
IAssetCache. There is no change to functionality. Everything works as
before.

This is laying the groundwork for making it possible to register
alternative asset caching mechanisms without disrupting other parts of
OpenSim or their dependencies upon AssetCache functionality.
0.6.3-post-fixes
Sean Dague 2009-02-09 21:47:55 +00:00
parent 70051278c4
commit 8088802c21
27 changed files with 85 additions and 68 deletions

View File

@ -74,7 +74,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
internal static IInventoryServices InventoryServices = null;
internal static IUserService UserServices = null;
internal static IAvatarService AvatarServices = null;
internal static AssetCache AssetServices = null;
internal static IAssetCache AssetServices = null;
internal static string Prefix = null;
internal static IConfig Config = null;
internal static string GodKey = null;

View File

@ -37,7 +37,7 @@ using GlynnTucker.Cache;
namespace OpenSim.Framework.Communications.Cache
{
public delegate void AssetRequestCallback(UUID assetID, AssetBase asset);
// public delegate void AssetRequestCallback(UUID assetID, AssetBase asset);
/// <summary>
/// Manages local cache of assets and their sending to viewers.
@ -47,7 +47,8 @@ namespace OpenSim.Framework.Communications.Cache
/// synchronously or async and passes the data back to the requester. The second mechanism fetches assets 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
public class AssetCache : IAssetReceiver
public class AssetCache : IAssetCache, IAssetReceiver
{
protected ICache m_memcache = new SimpleMemoryCache();
@ -148,7 +149,7 @@ namespace OpenSim.Framework.Communications.Cache
/// Process the asset queue which holds data which is packeted up and sent
/// directly back to the client.
/// </summary>
public void RunAssetManager()
private void RunAssetManager()
{
while (true)
{

View File

@ -98,7 +98,7 @@ namespace OpenSim.Framework.Communications.Capabilities
//private string eventQueue = "0100/";
private BaseHttpServer m_httpListener;
private UUID m_agentID;
private AssetCache m_assetCache;
private IAssetCache m_assetCache;
private int m_eventQueueCount = 1;
private Queue<string> m_capsEventQueue = new Queue<string>();
private bool m_dumpAssetsToFile;
@ -121,7 +121,7 @@ namespace OpenSim.Framework.Communications.Capabilities
public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null;
public GetClientDelegate GetClient = null;
public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath,
public Caps(IAssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath,
UUID agent, bool dumpAssetsToFile, string regionName)
{
m_assetCache = assetCache;

View File

@ -87,11 +87,11 @@ namespace OpenSim.Framework.Communications
}
protected IAvatarService m_avatarService;
public AssetCache AssetCache
public IAssetCache AssetCache
{
get { return m_assetCache; }
}
protected AssetCache m_assetCache;
protected IAssetCache m_assetCache;
public IInterServiceInventoryServices InterServiceInventoryService
{
@ -127,7 +127,7 @@ namespace OpenSim.Framework.Communications
/// <param name="httpServer"></param>
/// <param name="assetCache"></param>
/// <param name="dumpAssetsToFile"></param>
public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache,
public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, IAssetCache assetCache,
bool dumpAssetsToFile, LibraryRootFolder libraryRootFolder)
{
m_networkServersInfo = serversInfo;

View File

@ -309,37 +309,53 @@ namespace OpenSim
/// </summary>
protected virtual void InitialiseAssetCache()
{
// If the assetcache is set to default, then use the grid asset service in grid mode and the local database
// based asset service in standalone mode
IAssetServer assetServer;
if (m_configSettings.AssetStorage == "grid"
|| (m_configSettings.AssetStorage == "default" && false == m_configSettings.Standalone))
IAssetServer assetServer = null;
string mode = m_configSettings.AssetStorage;
if (m_configSettings.Standalone == false &&
m_configSettings.AssetStorage == "default")
mode = "grid";
switch (mode)
{
case "grid" :
assetServer = new GridAssetClient(m_networkServersInfo.AssetURL);
}
else if (m_configSettings.AssetStorage == "cryptogrid") // Decrypt-Only
{
break;
case "cryptogrid" :
assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL,
Environment.CurrentDirectory, true);
}
else if (m_configSettings.AssetStorage == "cryptogrid_eou") // Encrypts All Assets
{
break;
case "cryptogrid_eou" :
assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL,
Environment.CurrentDirectory, false);
}
else if (m_configSettings.AssetStorage == "file")
{
break;
case "file" :
assetServer = new FileAssetClient(m_networkServersInfo.AssetURL);
}
else
break;
default :
if (!ResolveAssetServer(out assetServer))
{
SQLAssetServer sqlAssetServer = new SQLAssetServer(m_configSettings.StandaloneAssetPlugin, m_configSettings.StandaloneAssetSource);
sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile);
assetServer = sqlAssetServer;
}
break;
}
m_assetCache = new AssetCache(assetServer);
m_assetCache = ResolveAssetCache(assetServer);
}
private bool ResolveAssetServer(out IAssetServer assetServer)
{
assetServer = null;
return false;
}
private IAssetCache ResolveAssetCache(IAssetServer assetServer)
{
return new AssetCache(assetServer);
}
public void ProcessLogin(bool LoginEnabled)

View File

@ -89,7 +89,7 @@ namespace OpenSim.Region.Environment
/// <returns></returns>
public IClientNetworkServer CreateServer(
IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port,
AssetCache assetCache, AgentCircuitManager authenticateClass)
IAssetCache assetCache, AgentCircuitManager authenticateClass)
{
return CreateServer(
_listenIP, ref port, proxyPortOffset, allow_alternate_port, null, assetCache, authenticateClass);
@ -110,7 +110,7 @@ namespace OpenSim.Region.Environment
/// <returns></returns>
public IClientNetworkServer CreateServer(
IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, IConfigSource configSource,
AssetCache assetCache, AgentCircuitManager authenticateClass)
IAssetCache assetCache, AgentCircuitManager authenticateClass)
{
if (plugin != null)
{

View File

@ -38,7 +38,7 @@ namespace OpenSim.Region.ClientStack
{
void Initialise(
IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource,
AssetCache assetCache, AgentCircuitManager authenticateClass);
IAssetCache assetCache, AgentCircuitManager authenticateClass);
Socket Server { get; }
bool HandlesRegion(Location x);

View File

@ -65,7 +65,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private int m_debugPacketLevel;
private readonly AssetCache m_assetCache;
private readonly IAssetCache m_assetCache;
private int m_cachedTextureSerial;
private Timer m_clientPingTimer;
@ -429,7 +429,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// Constructor
/// </summary>
public LLClientView(
EndPoint remoteEP, IScene scene, AssetCache assetCache, LLPacketServer packServer,
EndPoint remoteEP, IScene scene, IAssetCache assetCache, LLPacketServer packServer,
AuthenticateResponse sessionInfo, UUID agentId, UUID sessionId, uint circuitCode, EndPoint proxyEP,
ClientStackUserSettings userSettings)
{

View File

@ -55,7 +55,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
new Dictionary<UUID, IPriorityQueueHandle<Prio<J2KImage>>>();
private LLClientView m_client;
private readonly AssetCache m_assetCache;
private readonly IAssetCache m_assetCache;
private bool m_shuttingdown = false;
private readonly IJ2KDecoder m_j2kDecodeModule;
@ -67,7 +67,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="client">LLClientView of client</param>
/// <param name="pAssetCache">The Asset retrieval system</param>
/// <param name="pJ2kDecodeModule">The Jpeg2000 Decoder</param>
public LLImageManager(LLClientView client, AssetCache pAssetCache, IJ2KDecoder pJ2kDecodeModule)
public LLImageManager(LLClientView client, IAssetCache pAssetCache, IJ2KDecoder pJ2kDecodeModule)
{
m_client = client;
m_assetCache = pAssetCache;

View File

@ -90,7 +90,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="proxyEP"></param>
/// <returns></returns>
protected virtual IClientAPI CreateNewCircuit(
EndPoint remoteEP, IScene scene, AssetCache assetCache,
EndPoint remoteEP, IScene scene, IAssetCache assetCache,
LLPacketServer packServer, AuthenticateResponse sessionInfo,
UUID agentId, UUID sessionId, uint circuitCode, EndPoint proxyEP)
{
@ -134,7 +134,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// true if a new circuit was created, false if a circuit with the given circuit code already existed
/// </returns>
public virtual bool AddNewClient(
EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache,
EndPoint epSender, UseCircuitCodePacket useCircuit, IAssetCache assetCache,
AuthenticateResponse sessionInfo, EndPoint proxyEP)
{
IClientAPI newuser;

View File

@ -76,7 +76,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected bool Allow_Alternate_Port;
protected IPAddress listenIP = IPAddress.Parse("0.0.0.0");
protected IScene m_localScene;
protected AssetCache m_assetCache;
protected IAssetCache m_assetCache;
/// <value>
/// Manages authentication for agent circuits
@ -131,7 +131,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public LLUDPServer(
IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, IConfigSource configSource,
AssetCache assetCache, AgentCircuitManager authenticateClass)
IAssetCache assetCache, AgentCircuitManager authenticateClass)
{
Initialise(_listenIP, ref port, proxyPortOffset, allow_alternate_port, configSource, assetCache, authenticateClass);
}
@ -148,7 +148,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="circuitManager"></param>
public void Initialise(
IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource,
AssetCache assetCache, AgentCircuitManager circuitManager)
IAssetCache assetCache, AgentCircuitManager circuitManager)
{
ClientStackUserSettings userSettings = new ClientStackUserSettings();

View File

@ -48,7 +48,7 @@ namespace OpenSim.Region.ClientStack
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected AssetCache m_assetCache;
protected IAssetCache m_assetCache;
protected Dictionary<EndPoint, uint> m_clientCircuits = new Dictionary<EndPoint, uint>();
protected NetworkServersInfo m_networkServersInfo;

View File

@ -51,7 +51,7 @@ namespace OpenSim.Region.Communications.Hypergrid
public HGCommunicationsGridMode(
NetworkServersInfo serversInfo, BaseHttpServer httpServer,
AssetCache assetCache, SceneManager sman, LibraryRootFolder libraryRootFolder)
IAssetCache assetCache, SceneManager sman, LibraryRootFolder libraryRootFolder)
: base(serversInfo, httpServer, assetCache, false, libraryRootFolder)
{

View File

@ -40,7 +40,7 @@ namespace OpenSim.Region.Communications.Hypergrid
public HGCommunicationsStandalone(
NetworkServersInfo serversInfo,
BaseHttpServer httpServer,
AssetCache assetCache,
IAssetCache assetCache,
IUserService userService,
IUserAdminService userServiceAdmin,
LocalInventoryService inventoryService,

View File

@ -83,7 +83,7 @@ namespace OpenSim.Region.Communications.Hypergrid
// This is key-ed on agent ID
protected Dictionary<UUID, RegionInfo> m_knownRegions = new Dictionary<UUID, RegionInfo>();
protected AssetCache m_assetcache;
protected IAssetCache m_assetcache;
protected UserProfileCacheService m_userProfileCache;
protected SceneManager m_sceneman;
@ -120,7 +120,7 @@ namespace OpenSim.Region.Communications.Hypergrid
/// </summary>
/// <param name="servers_info"></param>
/// <param name="httpServe"></param>
public HGGridServices(NetworkServersInfo servers_info, BaseHttpServer httpServe, AssetCache asscache, SceneManager sman)
public HGGridServices(NetworkServersInfo servers_info, BaseHttpServer httpServe, IAssetCache asscache, SceneManager sman)
{
serversInfo = servers_info;
httpServer = httpServe;

View File

@ -71,7 +71,7 @@ namespace OpenSim.Region.Communications.Hypergrid
}
public HGGridServicesGridMode(NetworkServersInfo servers_info, BaseHttpServer httpServe,
AssetCache asscache, SceneManager sman, UserProfileCacheService userv)
IAssetCache asscache, SceneManager sman, UserProfileCacheService userv)
: base(servers_info, httpServe, asscache, sman)
{
m_remoteBackend = new OGS1GridServices(servers_info, httpServe);

View File

@ -79,7 +79,7 @@ namespace OpenSim.Region.Communications.Hypergrid
}
public HGGridServicesStandalone(NetworkServersInfo servers_info, BaseHttpServer httpServe, AssetCache asscache, SceneManager sman)
public HGGridServicesStandalone(NetworkServersInfo servers_info, BaseHttpServer httpServe, IAssetCache asscache, SceneManager sman)
: base(servers_info, httpServe, asscache, sman)
{
//Respond to Grid Services requests

View File

@ -37,7 +37,7 @@ namespace OpenSim.Region.Communications.Local
public CommunicationsLocal(
NetworkServersInfo serversInfo,
BaseHttpServer httpServer,
AssetCache assetCache,
IAssetCache assetCache,
IUserService userService,
IUserAdminService userServiceAdmin,
LocalInventoryService inventoryService,

View File

@ -36,7 +36,7 @@ namespace OpenSim.Region.Communications.OGS1
{
public CommunicationsOGS1(
NetworkServersInfo serversInfo, BaseHttpServer httpServer,
AssetCache assetCache, LibraryRootFolder libraryRootFolder)
IAssetCache assetCache, LibraryRootFolder libraryRootFolder)
: base(serversInfo, httpServer, assetCache, false, libraryRootFolder)
{
OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo, httpServer);

View File

@ -59,9 +59,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
/// <summary>
/// Cache to which dearchived assets will be added
/// </summary>
protected AssetCache m_cache;
protected IAssetCache m_cache;
public AssetsDearchiver(AssetCache cache)
public AssetsDearchiver(IAssetCache cache)
{
m_cache = cache;
}

View File

@ -73,9 +73,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
/// <summary>
/// Asset cache used to request the assets
/// </summary>
protected AssetCache m_assetCache;
protected IAssetCache m_assetCache;
protected internal AssetsRequest(ICollection<UUID> uuids, AssetCache assetCache, AssetsRequestCallback assetsRequestCallback)
protected internal AssetsRequest(ICollection<UUID> uuids, IAssetCache assetCache, AssetsRequestCallback assetsRequestCallback)
{
m_uuids = uuids;
m_assetsRequestCallback = assetsRequestCallback;

View File

@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
public HGScene(RegionInfo regInfo, AgentCircuitManager authen,
CommunicationsManager commsMan, SceneCommunicationService sceneGridService,
AssetCache assetCach, StorageManager storeManager,
IAssetCache assetCach, StorageManager storeManager,
ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
: base(regInfo, authen, commsMan, sceneGridService, assetCach, storeManager, moduleLoader,

View File

@ -272,7 +272,7 @@ namespace OpenSim.Region.Framework.Scenes
public Scene(RegionInfo regInfo, AgentCircuitManager authen,
CommunicationsManager commsMan, SceneCommunicationService sceneGridService,
AssetCache assetCach, StorageManager storeManager,
IAssetCache assetCach, StorageManager storeManager,
ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
{

View File

@ -126,9 +126,9 @@ namespace OpenSim.Region.Framework.Scenes
protected string m_datastore;
private AssetCache m_assetCache;
private IAssetCache m_assetCache;
public AssetCache AssetCache
public IAssetCache AssetCache
{
get { return m_assetCache; }
set { m_assetCache = value; }

View File

@ -251,7 +251,7 @@ namespace OpenSim.Region.Framework.Scenes
m_part.ScheduleFullUpdate();
return;
}
AssetCache cache = m_part.ParentGroup.Scene.AssetCache;
IAssetCache cache = m_part.ParentGroup.Scene.AssetCache;
cache.GetAsset(item.AssetID, delegate(UUID assetID, AssetBase asset)
{

View File

@ -40,7 +40,7 @@ namespace OpenSim.Tests.Common.Mock
public TestScene(
RegionInfo regInfo, AgentCircuitManager authen,
CommunicationsManager commsMan, SceneCommunicationService sceneGridService,
AssetCache assetCach, StorageManager storeManager,
IAssetCache assetCach, StorageManager storeManager,
ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
: base(regInfo, authen, commsMan, sceneGridService, assetCach, storeManager, moduleLoader,

View File

@ -74,7 +74,7 @@ namespace OpenSim.Tests.Common.Setup
SceneCommunicationService scs = new SceneCommunicationService(cm);
SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin());
AssetCache ac = new AssetCache(assetService);
IAssetCache ac = (IAssetCache) new AssetCache(assetService);
StorageManager sm = new StorageManager("OpenSim.Data.Null.dll", "", "");
IConfigSource configSource = new IniConfigSource();