From 8088802c218d7eb4a47018b5b3bb70e7463a03b1 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 9 Feb 2009 21:47:55 +0000 Subject: From Alan Webb 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. --- OpenSim/Region/Application/OpenSimBase.cs | 68 +++++++++++++--------- OpenSim/Region/ClientStack/ClientStackManager.cs | 4 +- OpenSim/Region/ClientStack/IClientNetworkServer.cs | 2 +- .../Region/ClientStack/LindenUDP/LLClientView.cs | 6 +- .../Region/ClientStack/LindenUDP/LLImageManager.cs | 4 +- .../Region/ClientStack/LindenUDP/LLPacketServer.cs | 4 +- .../Region/ClientStack/LindenUDP/LLUDPServer.cs | 6 +- .../Region/ClientStack/RegionApplicationBase.cs | 2 +- .../Hypergrid/HGCommunicationsGridMode.cs | 2 +- .../Hypergrid/HGCommunicationsStandalone.cs | 2 +- .../Communications/Hypergrid/HGGridServices.cs | 4 +- .../Hypergrid/HGGridServicesGridMode.cs | 2 +- .../Hypergrid/HGGridServicesStandalone.cs | 2 +- .../Communications/Local/CommunicationsLocal.cs | 2 +- .../Communications/OGS1/CommunicationsOGS1.cs | 2 +- .../Modules/World/Archiver/AssetsDearchiver.cs | 4 +- .../Modules/World/Archiver/AssetsRequest.cs | 4 +- .../Scenes/Hypergrid/HGScene.Inventory.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneBase.cs | 4 +- .../Framework/Scenes/SceneObjectPartInventory.cs | 2 +- 21 files changed, 73 insertions(+), 57 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index d032864..f2ea81d 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -309,37 +309,53 @@ namespace OpenSim /// 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)) - { - assetServer = new GridAssetClient(m_networkServersInfo.AssetURL); - } - else if (m_configSettings.AssetStorage == "cryptogrid") // Decrypt-Only + + IAssetServer assetServer = null; + string mode = m_configSettings.AssetStorage; + + if (m_configSettings.Standalone == false && + m_configSettings.AssetStorage == "default") + mode = "grid"; + + switch (mode) { - assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL, + case "grid" : + assetServer = new GridAssetClient(m_networkServersInfo.AssetURL); + break; + case "cryptogrid" : + assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL, Environment.CurrentDirectory, true); - } - else if (m_configSettings.AssetStorage == "cryptogrid_eou") // Encrypts All Assets - { - assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL, + 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; } - else if (m_configSettings.AssetStorage == "file") - { - assetServer = new FileAssetClient(m_networkServersInfo.AssetURL); - } - else - { - SQLAssetServer sqlAssetServer = new SQLAssetServer(m_configSettings.StandaloneAssetPlugin, m_configSettings.StandaloneAssetSource); - sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile); - assetServer = sqlAssetServer; - } - 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) diff --git a/OpenSim/Region/ClientStack/ClientStackManager.cs b/OpenSim/Region/ClientStack/ClientStackManager.cs index 6bc4c4b..6cad7c9 100644 --- a/OpenSim/Region/ClientStack/ClientStackManager.cs +++ b/OpenSim/Region/ClientStack/ClientStackManager.cs @@ -89,7 +89,7 @@ namespace OpenSim.Region.Environment /// 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 /// 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) { diff --git a/OpenSim/Region/ClientStack/IClientNetworkServer.cs b/OpenSim/Region/ClientStack/IClientNetworkServer.cs index 0073389..8bd5434 100644 --- a/OpenSim/Region/ClientStack/IClientNetworkServer.cs +++ b/OpenSim/Region/ClientStack/IClientNetworkServer.cs @@ -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); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 71fced9..f53174a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -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 /// 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) { @@ -3748,7 +3748,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerGenericMessage(sender, method, msg); return true; } - catch(Exception e) + catch (Exception e) { m_log.Error("[GENERICMESSAGE] " + e); } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs index 9b71770..43a2e23 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP new Dictionary>>(); 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 /// LLClientView of client /// The Asset retrieval system /// The Jpeg2000 Decoder - public LLImageManager(LLClientView client, AssetCache pAssetCache, IJ2KDecoder pJ2kDecodeModule) + public LLImageManager(LLClientView client, IAssetCache pAssetCache, IJ2KDecoder pJ2kDecodeModule) { m_client = client; m_assetCache = pAssetCache; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs index 2b52220..a42ae04 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs @@ -90,7 +90,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// 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 /// public virtual bool AddNewClient( - EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, + EndPoint epSender, UseCircuitCodePacket useCircuit, IAssetCache assetCache, AuthenticateResponse sessionInfo, EndPoint proxyEP) { IClientAPI newuser; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index f53d485..bdc4490 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -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; /// /// 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 /// 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(); diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index dcc17a7..18d8c5c 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs @@ -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 m_clientCircuits = new Dictionary(); protected NetworkServersInfo m_networkServersInfo; diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs index c4d48a9..4de4b2b 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs @@ -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) { diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs index 804640e..39e13d1 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs @@ -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, diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs index 2ca956b..9b11a2c 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs @@ -83,7 +83,7 @@ namespace OpenSim.Region.Communications.Hypergrid // This is key-ed on agent ID protected Dictionary m_knownRegions = new Dictionary(); - 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 /// /// /// - 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; diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs index b1f9f63..d1f416d 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs @@ -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); diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs index 27a7a0e..a2453db 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs @@ -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 diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index 6489408..3a5c33e 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -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, diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs index 7f6fbc8..c506dd0 100644 --- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs +++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs @@ -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); diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs index 0ef1e1d..95ff468 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs @@ -59,9 +59,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver /// /// Cache to which dearchived assets will be added /// - protected AssetCache m_cache; + protected IAssetCache m_cache; - public AssetsDearchiver(AssetCache cache) + public AssetsDearchiver(IAssetCache cache) { m_cache = cache; } diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs index 7a6c810..b7fd170 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs @@ -73,9 +73,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver /// /// Asset cache used to request the assets /// - protected AssetCache m_assetCache; + protected IAssetCache m_assetCache; - protected internal AssetsRequest(ICollection uuids, AssetCache assetCache, AssetsRequestCallback assetsRequestCallback) + protected internal AssetsRequest(ICollection uuids, IAssetCache assetCache, AssetsRequestCallback assetsRequestCallback) { m_uuids = uuids; m_assetsRequestCallback = assetsRequestCallback; diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs index f36075e..ba81270 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs @@ -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, diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 55fc02a..2fae8ac 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -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) { diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index cee9037..b0f328d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -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; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index efd486d..c15ac47 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -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) { -- cgit v1.1