* 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)
parent
ad2bd74057
commit
1894157dd3
|
@ -42,7 +42,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
protected IAssetReceiver m_receiver;
|
protected IAssetReceiver m_receiver;
|
||||||
protected BlockingQueue<AssetRequest> m_assetRequests;
|
protected BlockingQueue<AssetRequest> m_assetRequests = new BlockingQueue<AssetRequest>();
|
||||||
protected Thread m_localAssetServerThread;
|
protected Thread m_localAssetServerThread;
|
||||||
protected IAssetDataPlugin m_assetProvider;
|
protected IAssetDataPlugin m_assetProvider;
|
||||||
|
|
||||||
|
@ -109,6 +109,22 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
// Temporarily hardcoded - should be a plugin
|
// Temporarily hardcoded - should be a plugin
|
||||||
protected IAssetLoader assetLoader = new AssetLoaderFileSystem();
|
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);
|
public abstract void StoreAsset(AssetBase asset);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -121,8 +137,8 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
/// Thrown if the request failed for some other reason than that the
|
/// Thrown if the request failed for some other reason than that the
|
||||||
/// asset cannot be found.
|
/// asset cannot be found.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
protected abstract AssetBase GetAsset(AssetRequest req);
|
protected abstract AssetBase GetAsset(AssetRequest req);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Process an asset request. This method will call GetAsset(AssetRequest req)
|
/// Process an asset request. This method will call GetAsset(AssetRequest req)
|
||||||
/// on the subclass.
|
/// on the subclass.
|
||||||
|
@ -169,18 +185,6 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
assetLoader.ForEachDefaultXmlAsset(pAssetSetsXml, StoreAsset);
|
assetLoader.ForEachDefaultXmlAsset(pAssetSetsXml, StoreAsset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssetServerBase()
|
|
||||||
{
|
|
||||||
m_log.Info("[ASSET SERVER]: Starting asset storage system");
|
|
||||||
m_assetRequests = new BlockingQueue<AssetRequest>();
|
|
||||||
|
|
||||||
m_localAssetServerThread = new Thread(RunRequests);
|
|
||||||
m_localAssetServerThread.Name = "LocalAssetServerThread";
|
|
||||||
m_localAssetServerThread.IsBackground = true;
|
|
||||||
m_localAssetServerThread.Start();
|
|
||||||
ThreadTracker.Add(m_localAssetServerThread);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RunRequests()
|
private void RunRequests()
|
||||||
{
|
{
|
||||||
while (true) // Since it's a 'blocking queue'
|
while (true) // Since it's a 'blocking queue'
|
||||||
|
@ -222,11 +226,6 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
m_assetProvider.UpdateAsset(asset);
|
m_assetProvider.UpdateAsset(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Close()
|
|
||||||
{
|
|
||||||
m_localAssetServerThread.Abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetServerInfo(string ServerUrl, string ServerKey)
|
public void SetServerInfo(string ServerUrl, string ServerKey)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -554,11 +554,6 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Close()
|
|
||||||
{
|
|
||||||
throw new Exception("The method or operation is not implemented.");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,11 +135,6 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Close()
|
|
||||||
{
|
|
||||||
throw new Exception("The method or operation is not implemented.");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,11 +100,6 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Close()
|
|
||||||
{
|
|
||||||
base.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override AssetBase GetAsset(AssetRequest req)
|
protected override AssetBase GetAsset(AssetRequest req)
|
||||||
{
|
{
|
||||||
return m_assetProvider.FetchAsset(req.AssetID);
|
return m_assetProvider.FetchAsset(req.AssetID);
|
||||||
|
|
|
@ -62,7 +62,9 @@ namespace OpenSim.Framework.Communications.Tests
|
||||||
TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin();
|
TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin();
|
||||||
assetPlugin.CreateAsset(asset);
|
assetPlugin.CreateAsset(asset);
|
||||||
|
|
||||||
IAssetCache assetCache = new AssetCache(new SQLAssetServer(assetPlugin));
|
IAssetServer assetServer = new SQLAssetServer(assetPlugin);
|
||||||
|
IAssetCache assetCache = new AssetCache(assetServer);
|
||||||
|
assetServer.Start();
|
||||||
|
|
||||||
lock (this)
|
lock (this)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,11 +37,21 @@ namespace OpenSim.Framework
|
||||||
void Initialise(ConfigSettings settings);
|
void Initialise(ConfigSettings settings);
|
||||||
void Initialise(ConfigSettings settings, string url, string dir, bool test);
|
void Initialise(ConfigSettings settings, string url, string dir, bool test);
|
||||||
void Initialise(ConfigSettings settings, string url);
|
void Initialise(ConfigSettings settings, string url);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Start the asset server
|
||||||
|
/// </summary>
|
||||||
|
void Start();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stop the asset server
|
||||||
|
/// </summary>
|
||||||
|
void Stop();
|
||||||
|
|
||||||
void SetReceiver(IAssetReceiver receiver);
|
void SetReceiver(IAssetReceiver receiver);
|
||||||
void RequestAsset(UUID assetID, bool isTexture);
|
void RequestAsset(UUID assetID, bool isTexture);
|
||||||
void StoreAsset(AssetBase asset);
|
void StoreAsset(AssetBase asset);
|
||||||
void UpdateAsset(AssetBase asset);
|
void UpdateAsset(AssetBase asset);
|
||||||
void Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -381,6 +381,8 @@ namespace OpenSim
|
||||||
// Initialize the asset cache, passing a reference to the selected
|
// Initialize the asset cache, passing a reference to the selected
|
||||||
// asset server interface.
|
// asset server interface.
|
||||||
m_assetCache = ResolveAssetCache(assetServer);
|
m_assetCache = ResolveAssetCache(assetServer);
|
||||||
|
|
||||||
|
assetServer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method loads the identified asset server, passing an approrpiately
|
// This method loads the identified asset server, passing an approrpiately
|
||||||
|
|
|
@ -61,6 +61,7 @@ namespace OpenSim.Tests.Common.Mock
|
||||||
|
|
||||||
SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin());
|
SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin());
|
||||||
m_assetCache = new AssetCache(assetService);
|
m_assetCache = new AssetCache(assetService);
|
||||||
|
m_assetCache.AssetServer.Start();
|
||||||
|
|
||||||
LocalInventoryService lis = new LocalInventoryService();
|
LocalInventoryService lis = new LocalInventoryService();
|
||||||
lis.AddPlugin(m_inventoryDataPlugin);
|
lis.AddPlugin(m_inventoryDataPlugin);
|
||||||
|
|
Loading…
Reference in New Issue