From 1894157dd3608a15c3336efc2d58eee0de092610 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 14 Apr 2009 17:15:09 +0000 Subject: * Explicitly start the asset server thread so that unit tests can run single rather than multi-threaded (which may be behind the occasional test freezes) --- .../Communications/Cache/AssetServerBase.cs | 39 +++++++++++----------- .../Communications/Cache/CryptoGridAssetClient.cs | 5 --- .../Communications/Cache/GridAssetClient.cs | 5 --- .../Communications/Cache/SQLAssetServer.cs | 5 --- .../Communications/Tests/Cache/AssetCacheTests.cs | 4 ++- 5 files changed, 22 insertions(+), 36 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 1d0c030..343667a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -42,7 +42,7 @@ namespace OpenSim.Framework.Communications.Cache = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected IAssetReceiver m_receiver; - protected BlockingQueue m_assetRequests; + protected BlockingQueue m_assetRequests = new BlockingQueue(); protected Thread m_localAssetServerThread; protected IAssetDataPlugin m_assetProvider; @@ -109,6 +109,22 @@ namespace OpenSim.Framework.Communications.Cache // Temporarily hardcoded - should be a plugin protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); + public virtual void Start() + { + m_log.Debug("[ASSET SERVER]: Starting asset server"); + + m_localAssetServerThread = new Thread(RunRequests); + m_localAssetServerThread.Name = "LocalAssetServerThread"; + m_localAssetServerThread.IsBackground = true; + m_localAssetServerThread.Start(); + ThreadTracker.Add(m_localAssetServerThread); + } + + public virtual void Stop() + { + m_localAssetServerThread.Abort(); + } + public abstract void StoreAsset(AssetBase asset); /// @@ -121,8 +137,8 @@ namespace OpenSim.Framework.Communications.Cache /// Thrown if the request failed for some other reason than that the /// asset cannot be found. /// - protected abstract AssetBase GetAsset(AssetRequest req); - + protected abstract AssetBase GetAsset(AssetRequest req); + /// /// Process an asset request. This method will call GetAsset(AssetRequest req) /// on the subclass. @@ -169,18 +185,6 @@ namespace OpenSim.Framework.Communications.Cache assetLoader.ForEachDefaultXmlAsset(pAssetSetsXml, StoreAsset); } - public AssetServerBase() - { - m_log.Info("[ASSET SERVER]: Starting asset storage system"); - m_assetRequests = new BlockingQueue(); - - m_localAssetServerThread = new Thread(RunRequests); - m_localAssetServerThread.Name = "LocalAssetServerThread"; - m_localAssetServerThread.IsBackground = true; - m_localAssetServerThread.Start(); - ThreadTracker.Add(m_localAssetServerThread); - } - private void RunRequests() { while (true) // Since it's a 'blocking queue' @@ -222,11 +226,6 @@ namespace OpenSim.Framework.Communications.Cache m_assetProvider.UpdateAsset(asset); } - public virtual void Close() - { - m_localAssetServerThread.Abort(); - } - public void SetServerInfo(string ServerUrl, string ServerKey) { } diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs index f1c19fa..6e4dd1c 100644 --- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs @@ -554,11 +554,6 @@ namespace OpenSim.Framework.Communications.Cache } } - public override void Close() - { - throw new Exception("The method or operation is not implemented."); - } - #endregion } } diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 7131cb5..c7d4c99 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -135,11 +135,6 @@ namespace OpenSim.Framework.Communications.Cache } } - public override void Close() - { - throw new Exception("The method or operation is not implemented."); - } - #endregion } } diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 41a9561..227744d 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -100,11 +100,6 @@ namespace OpenSim.Framework.Communications.Cache } } - public override void Close() - { - base.Close(); - } - protected override AssetBase GetAsset(AssetRequest req) { return m_assetProvider.FetchAsset(req.AssetID); diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index 9d9810b..264bfe1 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -62,7 +62,9 @@ namespace OpenSim.Framework.Communications.Tests TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin(); assetPlugin.CreateAsset(asset); - IAssetCache assetCache = new AssetCache(new SQLAssetServer(assetPlugin)); + IAssetServer assetServer = new SQLAssetServer(assetPlugin); + IAssetCache assetCache = new AssetCache(assetServer); + assetServer.Start(); lock (this) { -- cgit v1.1