* 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,18 +72,15 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
}
|
||||
}
|
||||
|
||||
protected override void RunRequests()
|
||||
{
|
||||
while (true)
|
||||
protected override void ProcessRequest(AssetRequest req)
|
||||
{
|
||||
byte[] idata = null;
|
||||
bool found = false;
|
||||
AssetStorage foundAsset = null;
|
||||
ARequest req = _assetRequests.Dequeue();
|
||||
IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID));
|
||||
if (result.Count > 0)
|
||||
{
|
||||
foundAsset = (AssetStorage) result.Next();
|
||||
foundAsset = (AssetStorage)result.Next();
|
||||
found = true;
|
||||
}
|
||||
|
||||
|
@ -104,7 +101,6 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
_receiver.AssetNotFound(req.AssetID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void StoreAsset(AssetBase asset)
|
||||
{
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
public abstract class AssetServerBase : IAssetServer
|
||||
{
|
||||
protected IAssetReceiver _receiver;
|
||||
protected BlockingQueue<ARequest> _assetRequests;
|
||||
protected BlockingQueue<AssetRequest> _assetRequests;
|
||||
protected Thread _localAssetServerThread;
|
||||
protected IAssetProvider m_assetProviderPlugin;
|
||||
protected object syncLock = new object();
|
||||
|
@ -48,7 +48,7 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
protected abstract void StoreAsset(AssetBase asset);
|
||||
protected abstract void CommitAssets();
|
||||
|
||||
protected abstract void RunRequests();
|
||||
protected abstract void ProcessRequest(AssetRequest req);
|
||||
|
||||
public void LoadDefaultAssets()
|
||||
{
|
||||
|
@ -64,13 +64,30 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
public AssetServerBase()
|
||||
{
|
||||
MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system");
|
||||
_assetRequests = new BlockingQueue<ARequest>();
|
||||
_assetRequests = new BlockingQueue<AssetRequest>();
|
||||
|
||||
_localAssetServerThread = new Thread(RunRequests);
|
||||
_localAssetServerThread.IsBackground = true;
|
||||
_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)
|
||||
{
|
||||
//should request Asset from storage manager
|
||||
|
@ -97,7 +114,7 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
|
||||
public void RequestAsset(LLUUID assetID, bool isTexture)
|
||||
{
|
||||
ARequest req = new ARequest();
|
||||
AssetRequest req = new AssetRequest();
|
||||
req.AssetID = assetID;
|
||||
req.IsTexture = isTexture;
|
||||
MainLog.Instance.Verbose("ASSET","Adding {0} to request queue", assetID);
|
||||
|
|
|
@ -47,15 +47,8 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
|
||||
#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;
|
||||
try
|
||||
{
|
||||
|
@ -89,8 +82,6 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString());
|
||||
MainLog.Instance.Error("ASSETCACHE", e.StackTrace);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
if (typeInterface != null)
|
||||
{
|
||||
IAssetProvider plug =
|
||||
(IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||
(IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||
m_assetProviderPlugin = plug;
|
||||
m_assetProviderPlugin.Initialise();
|
||||
|
||||
|
@ -65,12 +65,8 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
"Added " + m_assetProviderPlugin.Name + " " +
|
||||
m_assetProviderPlugin.Version);
|
||||
}
|
||||
|
||||
typeInterface = null;
|
||||
}
|
||||
}
|
||||
|
||||
pluginAssembly = null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -81,15 +77,9 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
m_assetProviderPlugin.CommitAssets();
|
||||
}
|
||||
|
||||
protected override void RunRequests()
|
||||
protected override void ProcessRequest(AssetRequest req)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
ARequest req = _assetRequests.Dequeue();
|
||||
|
||||
//MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID);
|
||||
|
||||
AssetBase asset = null;
|
||||
AssetBase asset;
|
||||
lock (syncLock)
|
||||
{
|
||||
asset = m_assetProviderPlugin.FetchAsset(req.AssetID);
|
||||
|
@ -103,7 +93,6 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
_receiver.AssetNotFound(req.AssetID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void StoreAsset(AssetBase asset)
|
||||
{
|
||||
|
|
|
@ -60,10 +60,4 @@ namespace OpenSim.Framework
|
|||
{
|
||||
IAssetServer GetAssetServer();
|
||||
}
|
||||
|
||||
public struct ARequest
|
||||
{
|
||||
public LLUUID AssetID;
|
||||
public bool IsTexture;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue