aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs2
-rw-r--r--OpenSim/Framework/Communications/Cache/GridAssetClient.cs103
2 files changed, 43 insertions, 62 deletions
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
74 _assetRequests.Enqueue(req); 74 _assetRequests.Enqueue(req);
75 } 75 }
76 76
77 public void UpdateAsset(AssetBase asset) 77 public virtual void UpdateAsset(AssetBase asset)
78 { 78 {
79 lock (syncLock) 79 lock (syncLock)
80 { 80 {
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;
35 35
36namespace OpenSim.Framework.Communications.Cache 36namespace OpenSim.Framework.Communications.Cache
37{ 37{
38 public class GridAssetClient : IAssetServer 38 public class GridAssetClient : AssetServerBase
39 { 39 {
40 private string _assetServerUrl; 40 private string _assetServerUrl;
41 private IAssetReceiver _receiver;
42 41
43 public GridAssetClient(string serverUrl) 42 public GridAssetClient(string serverUrl)
44 { 43 {
@@ -47,54 +46,60 @@ namespace OpenSim.Framework.Communications.Cache
47 46
48 #region IAssetServer Members 47 #region IAssetServer Members
49 48
50 public void SetReceiver(IAssetReceiver receiver) 49 protected override void RunRequests()
51 { 50 {
52 _receiver = receiver; 51 while (true)
53 }
54
55 public void FetchAsset(LLUUID assetID, bool isTexture)
56 {
57 Stream s = null;
58 try
59 { 52 {
60 MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString()); 53 ARequest req = _assetRequests.Dequeue();
61 54
62 RestClient rc = new RestClient(_assetServerUrl); 55 //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID);
63 rc.AddResourcePath("assets");
64 rc.AddResourcePath(assetID.ToString());
65 if (isTexture)
66 rc.AddQueryParameter("texture");
67 56
68 rc.RequestMethod = "GET";
69 s = rc.Request();
70 57
71 if (s.Length > 0) 58 Stream s = null;
59 try
72 { 60 {
73 XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); 61 MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", req.AssetID.ToString());
74 AssetBase asset = (AssetBase) xs.Deserialize(s); 62
75 63 RestClient rc = new RestClient(_assetServerUrl);
76 _receiver.AssetReceived(asset, isTexture); 64 rc.AddResourcePath("assets");
65 rc.AddResourcePath(req.AssetID.ToString());
66 if (req.IsTexture)
67 rc.AddQueryParameter("texture");
68
69 rc.RequestMethod = "GET";
70 s = rc.Request();
71
72 if (s.Length > 0)
73 {
74 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
75 AssetBase newAsset = (AssetBase)xs.Deserialize(s);
76
77 _receiver.AssetReceived(newAsset, req.IsTexture);
78 }
79 else
80 {
81 MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", req.AssetID.ToString());
82 _receiver.AssetNotFound(req.AssetID);
83 }
77 } 84 }
78 else 85 catch (Exception e)
79 { 86 {
80 MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", assetID.ToString()); 87 MainLog.Instance.Error("ASSETCACHE", e.Message);
81 _receiver.AssetNotFound(assetID); 88 MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString());
89 MainLog.Instance.Error("ASSETCACHE", e.StackTrace);
82 } 90 }
83 } 91
84 catch (Exception e)
85 {
86 MainLog.Instance.Error("ASSETCACHE", e.Message);
87 MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", assetID.ToString());
88 MainLog.Instance.Error("ASSETCACHE", e.StackTrace);
89 } 92 }
90 } 93 }
91 94
92 public void UpdateAsset(AssetBase asset) 95
96
97 public override void UpdateAsset(AssetBase asset)
93 { 98 {
94 throw new Exception("The method or operation is not implemented."); 99 throw new Exception("The method or operation is not implemented.");
95 } 100 }
96 101
97 public void StoreAndCommitAsset(AssetBase asset) 102 protected override void StoreAsset(AssetBase asset)
98 { 103 {
99 try 104 try
100 { 105 {
@@ -113,40 +118,16 @@ namespace OpenSim.Framework.Communications.Cache
113 } 118 }
114 } 119 }
115 120
116 public void Close() 121 protected override void CommitAssets()
117 {
118 throw new Exception("The method or operation is not implemented.");
119 }
120
121 public void LoadAsset(AssetBase info, bool image, string filename)
122 { 122 {
123 throw new Exception("The method or operation is not implemented.");
124 } 123 }
125 124
126 public List<AssetBase> GetDefaultAssets() 125 public override void Close()
127 { 126 {
128 throw new Exception("The method or operation is not implemented."); 127 throw new Exception("The method or operation is not implemented.");
129 } 128 }
130 129
131 public AssetBase CreateImageAsset(string assetIdStr, string name, string filename) 130
132 {
133 throw new Exception("The method or operation is not implemented.");
134 }
135
136 public void ForEachDefaultAsset(Action<AssetBase> action)
137 {
138 throw new Exception("The method or operation is not implemented.");
139 }
140
141 public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage)
142 {
143 throw new Exception("The method or operation is not implemented.");
144 }
145
146 public void ForEachXmlAsset(Action<AssetBase> action)
147 {
148 throw new Exception("The method or operation is not implemented.");
149 }
150 131
151 #endregion 132 #endregion
152 } 133 }