From 88f04731ca42444ae6a3a04d600799b882514d6a Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 1 Nov 2007 15:54:59 +0000 Subject: Test on the grid asset problem, don't update to this version unless you just want to test to see if this fixes anything (but it could just as well break grid assets even more). --- .../Communications/Cache/AssetServerBase.cs | 2 +- .../Communications/Cache/GridAssetClient.cs | 103 +++++++++------------ 2 files changed, 43 insertions(+), 62 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 7109910..7c9df88 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -74,7 +74,7 @@ namespace OpenSim.Framework.Communications.Cache _assetRequests.Enqueue(req); } - public void UpdateAsset(AssetBase asset) + public virtual void UpdateAsset(AssetBase asset) { lock (syncLock) { diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 66fa245..ec163fb 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -35,10 +35,9 @@ using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache { - public class GridAssetClient : IAssetServer + public class GridAssetClient : AssetServerBase { private string _assetServerUrl; - private IAssetReceiver _receiver; public GridAssetClient(string serverUrl) { @@ -47,54 +46,60 @@ namespace OpenSim.Framework.Communications.Cache #region IAssetServer Members - public void SetReceiver(IAssetReceiver receiver) + protected override void RunRequests() { - _receiver = receiver; - } - - public void FetchAsset(LLUUID assetID, bool isTexture) - { - Stream s = null; - try + while (true) { - MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString()); + ARequest req = _assetRequests.Dequeue(); - RestClient rc = new RestClient(_assetServerUrl); - rc.AddResourcePath("assets"); - rc.AddResourcePath(assetID.ToString()); - if (isTexture) - rc.AddQueryParameter("texture"); + //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); - rc.RequestMethod = "GET"; - s = rc.Request(); - if (s.Length > 0) + Stream s = null; + try { - XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); - AssetBase asset = (AssetBase) xs.Deserialize(s); - - _receiver.AssetReceived(asset, isTexture); + MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", req.AssetID.ToString()); + + RestClient rc = new RestClient(_assetServerUrl); + rc.AddResourcePath("assets"); + rc.AddResourcePath(req.AssetID.ToString()); + if (req.IsTexture) + rc.AddQueryParameter("texture"); + + rc.RequestMethod = "GET"; + s = rc.Request(); + + if (s.Length > 0) + { + XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + AssetBase newAsset = (AssetBase)xs.Deserialize(s); + + _receiver.AssetReceived(newAsset, req.IsTexture); + } + else + { + MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", req.AssetID.ToString()); + _receiver.AssetNotFound(req.AssetID); + } } - else + catch (Exception e) { - MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", assetID.ToString()); - _receiver.AssetNotFound(assetID); + MainLog.Instance.Error("ASSETCACHE", e.Message); + MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString()); + MainLog.Instance.Error("ASSETCACHE", e.StackTrace); } - } - catch (Exception e) - { - MainLog.Instance.Error("ASSETCACHE", e.Message); - MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", assetID.ToString()); - MainLog.Instance.Error("ASSETCACHE", e.StackTrace); + } } - public void UpdateAsset(AssetBase asset) + + + public override void UpdateAsset(AssetBase asset) { throw new Exception("The method or operation is not implemented."); } - public void StoreAndCommitAsset(AssetBase asset) + protected override void StoreAsset(AssetBase asset) { try { @@ -113,40 +118,16 @@ namespace OpenSim.Framework.Communications.Cache } } - public void Close() - { - throw new Exception("The method or operation is not implemented."); - } - - public void LoadAsset(AssetBase info, bool image, string filename) + protected override void CommitAssets() { - throw new Exception("The method or operation is not implemented."); } - public List GetDefaultAssets() + public override void Close() { throw new Exception("The method or operation is not implemented."); } - public AssetBase CreateImageAsset(string assetIdStr, string name, string filename) - { - throw new Exception("The method or operation is not implemented."); - } - - public void ForEachDefaultAsset(Action action) - { - throw new Exception("The method or operation is not implemented."); - } - - public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage) - { - throw new Exception("The method or operation is not implemented."); - } - - public void ForEachXmlAsset(Action action) - { - throw new Exception("The method or operation is not implemented."); - } + #endregion } -- cgit v1.1