diff options
author | Justin Clarke Casey | 2009-04-14 17:15:09 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-04-14 17:15:09 +0000 |
commit | 1894157dd3608a15c3336efc2d58eee0de092610 (patch) | |
tree | cfecb8e2104d9a88e82670e27ecedbda0466fa88 /OpenSim | |
parent | * refactor: rename AssetCache.Initialize() to AssetCache.Reset() to avoid hav... (diff) | |
download | opensim-SC-1894157dd3608a15c3336efc2d58eee0de092610.zip opensim-SC-1894157dd3608a15c3336efc2d58eee0de092610.tar.gz opensim-SC-1894157dd3608a15c3336efc2d58eee0de092610.tar.bz2 opensim-SC-1894157dd3608a15c3336efc2d58eee0de092610.tar.xz |
* 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)
Diffstat (limited to '')
8 files changed, 36 insertions, 37 deletions
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 | |||
42 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
44 | protected IAssetReceiver m_receiver; | 44 | protected IAssetReceiver m_receiver; |
45 | protected BlockingQueue<AssetRequest> m_assetRequests; | 45 | protected BlockingQueue<AssetRequest> m_assetRequests = new BlockingQueue<AssetRequest>(); |
46 | protected Thread m_localAssetServerThread; | 46 | protected Thread m_localAssetServerThread; |
47 | protected IAssetDataPlugin m_assetProvider; | 47 | protected IAssetDataPlugin m_assetProvider; |
48 | 48 | ||
@@ -109,6 +109,22 @@ namespace OpenSim.Framework.Communications.Cache | |||
109 | // Temporarily hardcoded - should be a plugin | 109 | // Temporarily hardcoded - should be a plugin |
110 | protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); | 110 | protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); |
111 | 111 | ||
112 | public virtual void Start() | ||
113 | { | ||
114 | m_log.Debug("[ASSET SERVER]: Starting asset server"); | ||
115 | |||
116 | m_localAssetServerThread = new Thread(RunRequests); | ||
117 | m_localAssetServerThread.Name = "LocalAssetServerThread"; | ||
118 | m_localAssetServerThread.IsBackground = true; | ||
119 | m_localAssetServerThread.Start(); | ||
120 | ThreadTracker.Add(m_localAssetServerThread); | ||
121 | } | ||
122 | |||
123 | public virtual void Stop() | ||
124 | { | ||
125 | m_localAssetServerThread.Abort(); | ||
126 | } | ||
127 | |||
112 | public abstract void StoreAsset(AssetBase asset); | 128 | public abstract void StoreAsset(AssetBase asset); |
113 | 129 | ||
114 | /// <summary> | 130 | /// <summary> |
@@ -121,8 +137,8 @@ namespace OpenSim.Framework.Communications.Cache | |||
121 | /// Thrown if the request failed for some other reason than that the | 137 | /// Thrown if the request failed for some other reason than that the |
122 | /// asset cannot be found. | 138 | /// asset cannot be found. |
123 | /// </exception> | 139 | /// </exception> |
124 | protected abstract AssetBase GetAsset(AssetRequest req); | 140 | protected abstract AssetBase GetAsset(AssetRequest req); |
125 | 141 | ||
126 | /// <summary> | 142 | /// <summary> |
127 | /// Process an asset request. This method will call GetAsset(AssetRequest req) | 143 | /// Process an asset request. This method will call GetAsset(AssetRequest req) |
128 | /// on the subclass. | 144 | /// on the subclass. |
@@ -169,18 +185,6 @@ namespace OpenSim.Framework.Communications.Cache | |||
169 | assetLoader.ForEachDefaultXmlAsset(pAssetSetsXml, StoreAsset); | 185 | assetLoader.ForEachDefaultXmlAsset(pAssetSetsXml, StoreAsset); |
170 | } | 186 | } |
171 | 187 | ||
172 | public AssetServerBase() | ||
173 | { | ||
174 | m_log.Info("[ASSET SERVER]: Starting asset storage system"); | ||
175 | m_assetRequests = new BlockingQueue<AssetRequest>(); | ||
176 | |||
177 | m_localAssetServerThread = new Thread(RunRequests); | ||
178 | m_localAssetServerThread.Name = "LocalAssetServerThread"; | ||
179 | m_localAssetServerThread.IsBackground = true; | ||
180 | m_localAssetServerThread.Start(); | ||
181 | ThreadTracker.Add(m_localAssetServerThread); | ||
182 | } | ||
183 | |||
184 | private void RunRequests() | 188 | private void RunRequests() |
185 | { | 189 | { |
186 | while (true) // Since it's a 'blocking queue' | 190 | while (true) // Since it's a 'blocking queue' |
@@ -222,11 +226,6 @@ namespace OpenSim.Framework.Communications.Cache | |||
222 | m_assetProvider.UpdateAsset(asset); | 226 | m_assetProvider.UpdateAsset(asset); |
223 | } | 227 | } |
224 | 228 | ||
225 | public virtual void Close() | ||
226 | { | ||
227 | m_localAssetServerThread.Abort(); | ||
228 | } | ||
229 | |||
230 | public void SetServerInfo(string ServerUrl, string ServerKey) | 229 | public void SetServerInfo(string ServerUrl, string ServerKey) |
231 | { | 230 | { |
232 | } | 231 | } |
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 | |||
554 | } | 554 | } |
555 | } | 555 | } |
556 | 556 | ||
557 | public override void Close() | ||
558 | { | ||
559 | throw new Exception("The method or operation is not implemented."); | ||
560 | } | ||
561 | |||
562 | #endregion | 557 | #endregion |
563 | } | 558 | } |
564 | } | 559 | } |
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 | |||
135 | } | 135 | } |
136 | } | 136 | } |
137 | 137 | ||
138 | public override void Close() | ||
139 | { | ||
140 | throw new Exception("The method or operation is not implemented."); | ||
141 | } | ||
142 | |||
143 | #endregion | 138 | #endregion |
144 | } | 139 | } |
145 | } | 140 | } |
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 | |||
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | public override void Close() | ||
104 | { | ||
105 | base.Close(); | ||
106 | } | ||
107 | |||
108 | protected override AssetBase GetAsset(AssetRequest req) | 103 | protected override AssetBase GetAsset(AssetRequest req) |
109 | { | 104 | { |
110 | return m_assetProvider.FetchAsset(req.AssetID); | 105 | 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 | |||
62 | TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin(); | 62 | TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin(); |
63 | assetPlugin.CreateAsset(asset); | 63 | assetPlugin.CreateAsset(asset); |
64 | 64 | ||
65 | IAssetCache assetCache = new AssetCache(new SQLAssetServer(assetPlugin)); | 65 | IAssetServer assetServer = new SQLAssetServer(assetPlugin); |
66 | IAssetCache assetCache = new AssetCache(assetServer); | ||
67 | assetServer.Start(); | ||
66 | 68 | ||
67 | lock (this) | 69 | lock (this) |
68 | { | 70 | { |
diff --git a/OpenSim/Framework/IAssetServer.cs b/OpenSim/Framework/IAssetServer.cs index f76d125..0a08ff6 100644 --- a/OpenSim/Framework/IAssetServer.cs +++ b/OpenSim/Framework/IAssetServer.cs | |||
@@ -37,11 +37,21 @@ namespace OpenSim.Framework | |||
37 | void Initialise(ConfigSettings settings); | 37 | void Initialise(ConfigSettings settings); |
38 | void Initialise(ConfigSettings settings, string url, string dir, bool test); | 38 | void Initialise(ConfigSettings settings, string url, string dir, bool test); |
39 | void Initialise(ConfigSettings settings, string url); | 39 | void Initialise(ConfigSettings settings, string url); |
40 | |||
41 | /// <summary> | ||
42 | /// Start the asset server | ||
43 | /// </summary> | ||
44 | void Start(); | ||
45 | |||
46 | /// <summary> | ||
47 | /// Stop the asset server | ||
48 | /// </summary> | ||
49 | void Stop(); | ||
50 | |||
40 | void SetReceiver(IAssetReceiver receiver); | 51 | void SetReceiver(IAssetReceiver receiver); |
41 | void RequestAsset(UUID assetID, bool isTexture); | 52 | void RequestAsset(UUID assetID, bool isTexture); |
42 | void StoreAsset(AssetBase asset); | 53 | void StoreAsset(AssetBase asset); |
43 | void UpdateAsset(AssetBase asset); | 54 | void UpdateAsset(AssetBase asset); |
44 | void Close(); | ||
45 | } | 55 | } |
46 | 56 | ||
47 | /// <summary> | 57 | /// <summary> |
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 3840240..7aa9f99 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -381,6 +381,8 @@ namespace OpenSim | |||
381 | // Initialize the asset cache, passing a reference to the selected | 381 | // Initialize the asset cache, passing a reference to the selected |
382 | // asset server interface. | 382 | // asset server interface. |
383 | m_assetCache = ResolveAssetCache(assetServer); | 383 | m_assetCache = ResolveAssetCache(assetServer); |
384 | |||
385 | assetServer.Start(); | ||
384 | } | 386 | } |
385 | 387 | ||
386 | // This method loads the identified asset server, passing an approrpiately | 388 | // This method loads the identified asset server, passing an approrpiately |
diff --git a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs index 8416fb6..3b39d36 100644 --- a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs +++ b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs | |||
@@ -61,6 +61,7 @@ namespace OpenSim.Tests.Common.Mock | |||
61 | 61 | ||
62 | SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin()); | 62 | SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin()); |
63 | m_assetCache = new AssetCache(assetService); | 63 | m_assetCache = new AssetCache(assetService); |
64 | m_assetCache.AssetServer.Start(); | ||
64 | 65 | ||
65 | LocalInventoryService lis = new LocalInventoryService(); | 66 | LocalInventoryService lis = new LocalInventoryService(); |
66 | lis.AddPlugin(m_inventoryDataPlugin); | 67 | lis.AddPlugin(m_inventoryDataPlugin); |