* ARequest changed name to AssetRequest and moved to own file.
* The AssetServerBase is now responsible for dequeueing, the server implementations merely recieves ProcessRequest( AssetRequest req ) * Catchall added around queue processing thread so thread won't abort on exceptions.afrisby
parent
79935881aa
commit
0a4a5bbcef
|
@ -0,0 +1,10 @@
|
||||||
|
using libsecondlife;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework
|
||||||
|
{
|
||||||
|
public struct AssetRequest
|
||||||
|
{
|
||||||
|
public LLUUID AssetID;
|
||||||
|
public bool IsTexture;
|
||||||
|
}
|
||||||
|
}
|
|
@ -72,14 +72,11 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void RunRequests()
|
protected override void ProcessRequest(AssetRequest req)
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
byte[] idata = null;
|
byte[] idata = null;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
AssetStorage foundAsset = null;
|
AssetStorage foundAsset = null;
|
||||||
ARequest req = _assetRequests.Dequeue();
|
|
||||||
IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID));
|
IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID));
|
||||||
if (result.Count > 0)
|
if (result.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -104,7 +101,6 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
_receiver.AssetNotFound(req.AssetID);
|
_receiver.AssetNotFound(req.AssetID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void StoreAsset(AssetBase asset)
|
protected override void StoreAsset(AssetBase asset)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
public abstract class AssetServerBase : IAssetServer
|
public abstract class AssetServerBase : IAssetServer
|
||||||
{
|
{
|
||||||
protected IAssetReceiver _receiver;
|
protected IAssetReceiver _receiver;
|
||||||
protected BlockingQueue<ARequest> _assetRequests;
|
protected BlockingQueue<AssetRequest> _assetRequests;
|
||||||
protected Thread _localAssetServerThread;
|
protected Thread _localAssetServerThread;
|
||||||
protected IAssetProvider m_assetProviderPlugin;
|
protected IAssetProvider m_assetProviderPlugin;
|
||||||
protected object syncLock = new object();
|
protected object syncLock = new object();
|
||||||
|
@ -48,7 +48,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
protected abstract void StoreAsset(AssetBase asset);
|
protected abstract void StoreAsset(AssetBase asset);
|
||||||
protected abstract void CommitAssets();
|
protected abstract void CommitAssets();
|
||||||
|
|
||||||
protected abstract void RunRequests();
|
protected abstract void ProcessRequest(AssetRequest req);
|
||||||
|
|
||||||
public void LoadDefaultAssets()
|
public void LoadDefaultAssets()
|
||||||
{
|
{
|
||||||
|
@ -64,13 +64,30 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
public AssetServerBase()
|
public AssetServerBase()
|
||||||
{
|
{
|
||||||
MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system");
|
MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system");
|
||||||
_assetRequests = new BlockingQueue<ARequest>();
|
_assetRequests = new BlockingQueue<AssetRequest>();
|
||||||
|
|
||||||
_localAssetServerThread = new Thread(RunRequests);
|
_localAssetServerThread = new Thread(RunRequests);
|
||||||
_localAssetServerThread.IsBackground = true;
|
_localAssetServerThread.IsBackground = true;
|
||||||
_localAssetServerThread.Start();
|
_localAssetServerThread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RunRequests()
|
||||||
|
{
|
||||||
|
while (true) // Since it's a 'blocking queue'
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AssetRequest req = _assetRequests.Dequeue();
|
||||||
|
|
||||||
|
ProcessRequest(req);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
MainLog.Instance.Error("ASSETSERVER", e.Message );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void LoadAsset(AssetBase info, bool image, string filename)
|
public void LoadAsset(AssetBase info, bool image, string filename)
|
||||||
{
|
{
|
||||||
//should request Asset from storage manager
|
//should request Asset from storage manager
|
||||||
|
@ -97,7 +114,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
|
|
||||||
public void RequestAsset(LLUUID assetID, bool isTexture)
|
public void RequestAsset(LLUUID assetID, bool isTexture)
|
||||||
{
|
{
|
||||||
ARequest req = new ARequest();
|
AssetRequest req = new AssetRequest();
|
||||||
req.AssetID = assetID;
|
req.AssetID = assetID;
|
||||||
req.IsTexture = isTexture;
|
req.IsTexture = isTexture;
|
||||||
MainLog.Instance.Verbose("ASSET","Adding {0} to request queue", assetID);
|
MainLog.Instance.Verbose("ASSET","Adding {0} to request queue", assetID);
|
||||||
|
|
|
@ -47,15 +47,8 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
|
|
||||||
#region IAssetServer Members
|
#region IAssetServer Members
|
||||||
|
|
||||||
protected override void RunRequests()
|
protected override void ProcessRequest(AssetRequest req)
|
||||||
{
|
{
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
ARequest req = _assetRequests.Dequeue();
|
|
||||||
|
|
||||||
//MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID);
|
|
||||||
|
|
||||||
|
|
||||||
Stream s = null;
|
Stream s = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -89,8 +82,6 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString());
|
MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString());
|
||||||
MainLog.Instance.Error("ASSETCACHE", e.StackTrace);
|
MainLog.Instance.Error("ASSETCACHE", e.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -65,12 +65,8 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
"Added " + m_assetProviderPlugin.Name + " " +
|
"Added " + m_assetProviderPlugin.Name + " " +
|
||||||
m_assetProviderPlugin.Version);
|
m_assetProviderPlugin.Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
typeInterface = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginAssembly = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,15 +77,9 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
m_assetProviderPlugin.CommitAssets();
|
m_assetProviderPlugin.CommitAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void RunRequests()
|
protected override void ProcessRequest(AssetRequest req)
|
||||||
{
|
{
|
||||||
while (true)
|
AssetBase asset;
|
||||||
{
|
|
||||||
ARequest req = _assetRequests.Dequeue();
|
|
||||||
|
|
||||||
//MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID);
|
|
||||||
|
|
||||||
AssetBase asset = null;
|
|
||||||
lock (syncLock)
|
lock (syncLock)
|
||||||
{
|
{
|
||||||
asset = m_assetProviderPlugin.FetchAsset(req.AssetID);
|
asset = m_assetProviderPlugin.FetchAsset(req.AssetID);
|
||||||
|
@ -103,7 +93,6 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
_receiver.AssetNotFound(req.AssetID);
|
_receiver.AssetNotFound(req.AssetID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void StoreAsset(AssetBase asset)
|
protected override void StoreAsset(AssetBase asset)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,10 +60,4 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
IAssetServer GetAssetServer();
|
IAssetServer GetAssetServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct ARequest
|
|
||||||
{
|
|
||||||
public LLUUID AssetID;
|
|
||||||
public bool IsTexture;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue