aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorlbsa712007-12-14 08:47:15 +0000
committerlbsa712007-12-14 08:47:15 +0000
commit0a4a5bbcef8df5447b39c11ba52b2434a2f60be0 (patch)
treee07b7388e83304b75bacca816a2e06242aa44f9e /OpenSim
parent* Patch from Justincc that swaps out LLUUIDs for Guid on the inventory REST c... (diff)
downloadopensim-SC_OLD-0a4a5bbcef8df5447b39c11ba52b2434a2f60be0.zip
opensim-SC_OLD-0a4a5bbcef8df5447b39c11ba52b2434a2f60be0.tar.gz
opensim-SC_OLD-0a4a5bbcef8df5447b39c11ba52b2434a2f60be0.tar.bz2
opensim-SC_OLD-0a4a5bbcef8df5447b39c11ba52b2434a2f60be0.tar.xz
* 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.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/AssetRequest.cs10
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServer.cs54
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs25
-rw-r--r--OpenSim/Framework/Communications/Cache/GridAssetClient.cs85
-rw-r--r--OpenSim/Framework/Communications/Cache/SQLAssetServer.cs37
-rw-r--r--OpenSim/Framework/IAssetServer.cs6
6 files changed, 107 insertions, 110 deletions
diff --git a/OpenSim/Framework/AssetRequest.cs b/OpenSim/Framework/AssetRequest.cs
new file mode 100644
index 0000000..163ab70
--- /dev/null
+++ b/OpenSim/Framework/AssetRequest.cs
@@ -0,0 +1,10 @@
1using libsecondlife;
2
3namespace OpenSim.Framework
4{
5 public struct AssetRequest
6 {
7 public LLUUID AssetID;
8 public bool IsTexture;
9 }
10} \ No newline at end of file
diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs
index e5cceaa..00c2b2a 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServer.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs
@@ -72,37 +72,33 @@ namespace OpenSim.Framework.Communications.Cache
72 } 72 }
73 } 73 }
74 74
75 protected override void RunRequests() 75 protected override void ProcessRequest(AssetRequest req)
76 { 76 {
77 while (true) 77 byte[] idata = null;
78 bool found = false;
79 AssetStorage foundAsset = null;
80 IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID));
81 if (result.Count > 0)
78 { 82 {
79 byte[] idata = null; 83 foundAsset = (AssetStorage)result.Next();
80 bool found = false; 84 found = true;
81 AssetStorage foundAsset = null; 85 }
82 ARequest req = _assetRequests.Dequeue(); 86
83 IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); 87 AssetBase asset = new AssetBase();
84 if (result.Count > 0) 88 if (found)
85 { 89 {
86 foundAsset = (AssetStorage) result.Next(); 90 asset.FullID = foundAsset.UUID;
87 found = true; 91 asset.Type = foundAsset.Type;
88 } 92 asset.InvType = foundAsset.Type;
89 93 asset.Name = foundAsset.Name;
90 AssetBase asset = new AssetBase(); 94 idata = foundAsset.Data;
91 if (found) 95 asset.Data = idata;
92 { 96 _receiver.AssetReceived(asset, req.IsTexture);
93 asset.FullID = foundAsset.UUID; 97 }
94 asset.Type = foundAsset.Type; 98 else
95 asset.InvType = foundAsset.Type; 99 {
96 asset.Name = foundAsset.Name; 100 //asset.FullID = ;
97 idata = foundAsset.Data; 101 _receiver.AssetNotFound(req.AssetID);
98 asset.Data = idata;
99 _receiver.AssetReceived(asset, req.IsTexture);
100 }
101 else
102 {
103 //asset.FullID = ;
104 _receiver.AssetNotFound(req.AssetID);
105 }
106 } 102 }
107 } 103 }
108 104
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index e117c93..659b9c9 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications.Cache
40 public abstract class AssetServerBase : IAssetServer 40 public abstract class AssetServerBase : IAssetServer
41 { 41 {
42 protected IAssetReceiver _receiver; 42 protected IAssetReceiver _receiver;
43 protected BlockingQueue<ARequest> _assetRequests; 43 protected BlockingQueue<AssetRequest> _assetRequests;
44 protected Thread _localAssetServerThread; 44 protected Thread _localAssetServerThread;
45 protected IAssetProvider m_assetProviderPlugin; 45 protected IAssetProvider m_assetProviderPlugin;
46 protected object syncLock = new object(); 46 protected object syncLock = new object();
@@ -48,7 +48,7 @@ namespace OpenSim.Framework.Communications.Cache
48 protected abstract void StoreAsset(AssetBase asset); 48 protected abstract void StoreAsset(AssetBase asset);
49 protected abstract void CommitAssets(); 49 protected abstract void CommitAssets();
50 50
51 protected abstract void RunRequests(); 51 protected abstract void ProcessRequest(AssetRequest req);
52 52
53 public void LoadDefaultAssets() 53 public void LoadDefaultAssets()
54 { 54 {
@@ -64,13 +64,30 @@ namespace OpenSim.Framework.Communications.Cache
64 public AssetServerBase() 64 public AssetServerBase()
65 { 65 {
66 MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system"); 66 MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system");
67 _assetRequests = new BlockingQueue<ARequest>(); 67 _assetRequests = new BlockingQueue<AssetRequest>();
68 68
69 _localAssetServerThread = new Thread(RunRequests); 69 _localAssetServerThread = new Thread(RunRequests);
70 _localAssetServerThread.IsBackground = true; 70 _localAssetServerThread.IsBackground = true;
71 _localAssetServerThread.Start(); 71 _localAssetServerThread.Start();
72 } 72 }
73 73
74 private void RunRequests()
75 {
76 while (true) // Since it's a 'blocking queue'
77 {
78 try
79 {
80 AssetRequest req = _assetRequests.Dequeue();
81
82 ProcessRequest(req);
83 }
84 catch(Exception e)
85 {
86 MainLog.Instance.Error("ASSETSERVER", e.Message );
87 }
88 }
89 }
90
74 public void LoadAsset(AssetBase info, bool image, string filename) 91 public void LoadAsset(AssetBase info, bool image, string filename)
75 { 92 {
76 //should request Asset from storage manager 93 //should request Asset from storage manager
@@ -97,7 +114,7 @@ namespace OpenSim.Framework.Communications.Cache
97 114
98 public void RequestAsset(LLUUID assetID, bool isTexture) 115 public void RequestAsset(LLUUID assetID, bool isTexture)
99 { 116 {
100 ARequest req = new ARequest(); 117 AssetRequest req = new AssetRequest();
101 req.AssetID = assetID; 118 req.AssetID = assetID;
102 req.IsTexture = isTexture; 119 req.IsTexture = isTexture;
103 MainLog.Instance.Verbose("ASSET","Adding {0} to request queue", assetID); 120 MainLog.Instance.Verbose("ASSET","Adding {0} to request queue", assetID);
diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
index e2924a4..47104d7 100644
--- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
@@ -36,7 +36,7 @@ using OpenSim.Framework.Servers;
36 36
37namespace OpenSim.Framework.Communications.Cache 37namespace OpenSim.Framework.Communications.Cache
38{ 38{
39 public class GridAssetClient : AssetServerBase 39 public class GridAssetClient : AssetServerBase
40 { 40 {
41 private string _assetServerUrl; 41 private string _assetServerUrl;
42 42
@@ -47,53 +47,44 @@ namespace OpenSim.Framework.Communications.Cache
47 47
48 #region IAssetServer Members 48 #region IAssetServer Members
49 49
50 protected override void RunRequests() 50 protected override void ProcessRequest(AssetRequest req)
51 { 51 {
52 while (true) 52 Stream s = null;
53 try
53 { 54 {
54 ARequest req = _assetRequests.Dequeue(); 55 MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", req.AssetID.ToString());
55 56
56 //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); 57 RestClient rc = new RestClient(_assetServerUrl);
58 rc.AddResourcePath("assets");
59 rc.AddResourcePath(req.AssetID.ToString());
60 if (req.IsTexture)
61 rc.AddQueryParameter("texture");
57 62
63 rc.RequestMethod = "GET";
64 s = rc.Request();
58 65
59 Stream s = null; 66 if (s.Length > 0)
60 try
61 { 67 {
62 MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", req.AssetID.ToString()); 68 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
63 69 AssetBase newAsset = (AssetBase)xs.Deserialize(s);
64 RestClient rc = new RestClient(_assetServerUrl); 70
65 rc.AddResourcePath("assets"); 71 _receiver.AssetReceived(newAsset, req.IsTexture);
66 rc.AddResourcePath(req.AssetID.ToString());
67 if (req.IsTexture)
68 rc.AddQueryParameter("texture");
69
70 rc.RequestMethod = "GET";
71 s = rc.Request();
72
73 if (s.Length > 0)
74 {
75 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
76 AssetBase newAsset = (AssetBase)xs.Deserialize(s);
77
78 _receiver.AssetReceived(newAsset, req.IsTexture);
79 }
80 else
81 {
82 MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", req.AssetID.ToString());
83 _receiver.AssetNotFound(req.AssetID);
84 }
85 } 72 }
86 catch (Exception e) 73 else
87 { 74 {
88 MainLog.Instance.Error("ASSETCACHE", e.Message); 75 MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", req.AssetID.ToString());
89 MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString()); 76 _receiver.AssetNotFound(req.AssetID);
90 MainLog.Instance.Error("ASSETCACHE", e.StackTrace);
91 } 77 }
92 78 }
79 catch (Exception e)
80 {
81 MainLog.Instance.Error("ASSETCACHE", e.Message);
82 MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString());
83 MainLog.Instance.Error("ASSETCACHE", e.StackTrace);
93 } 84 }
94 } 85 }
95 86
96 87
97 88
98 public override void UpdateAsset(AssetBase asset) 89 public override void UpdateAsset(AssetBase asset)
99 { 90 {
@@ -104,18 +95,18 @@ namespace OpenSim.Framework.Communications.Cache
104 { 95 {
105 try 96 try
106 { 97 {
107 // MemoryStream s = new MemoryStream(); 98 // MemoryStream s = new MemoryStream();
108 99
109 // XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); 100 // XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
110 // xs.Serialize(s, asset); 101 // xs.Serialize(s, asset);
111 // RestClient rc = new RestClient(_assetServerUrl); 102 // RestClient rc = new RestClient(_assetServerUrl);
112 MainLog.Instance.Verbose("ASSET", "Storing asset"); 103 MainLog.Instance.Verbose("ASSET", "Storing asset");
113 //rc.AddResourcePath("assets"); 104 //rc.AddResourcePath("assets");
114 // rc.RequestMethod = "POST"; 105 // rc.RequestMethod = "POST";
115 // rc.Request(s); 106 // rc.Request(s);
116 //MainLog.Instance.Verbose("ASSET", "Stored {0}", rc); 107 //MainLog.Instance.Verbose("ASSET", "Stored {0}", rc);
117 MainLog.Instance.Verbose("ASSET", "Sending to " + _assetServerUrl + "/assets/"); 108 MainLog.Instance.Verbose("ASSET", "Sending to " + _assetServerUrl + "/assets/");
118 RestObjectPoster.BeginPostObject<AssetBase>(_assetServerUrl + "/assets/", asset); 109 RestObjectPoster.BeginPostObject<AssetBase>(_assetServerUrl + "/assets/", asset);
119 } 110 }
120 catch (Exception e) 111 catch (Exception e)
121 { 112 {
@@ -132,7 +123,7 @@ namespace OpenSim.Framework.Communications.Cache
132 throw new Exception("The method or operation is not implemented."); 123 throw new Exception("The method or operation is not implemented.");
133 } 124 }
134 125
135 126
136 127
137 #endregion 128 #endregion
138 } 129 }
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
index 9d08785..010581f 100644
--- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
+++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Framework.Communications.Cache
57 if (typeInterface != null) 57 if (typeInterface != null)
58 { 58 {
59 IAssetProvider plug = 59 IAssetProvider plug =
60 (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 60 (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
61 m_assetProviderPlugin = plug; 61 m_assetProviderPlugin = plug;
62 m_assetProviderPlugin.Initialise(); 62 m_assetProviderPlugin.Initialise();
63 63
@@ -65,12 +65,8 @@ namespace OpenSim.Framework.Communications.Cache
65 "Added " + m_assetProviderPlugin.Name + " " + 65 "Added " + m_assetProviderPlugin.Name + " " +
66 m_assetProviderPlugin.Version); 66 m_assetProviderPlugin.Version);
67 } 67 }
68
69 typeInterface = null;
70 } 68 }
71 } 69 }
72
73 pluginAssembly = null;
74 } 70 }
75 71
76 72
@@ -81,27 +77,20 @@ namespace OpenSim.Framework.Communications.Cache
81 m_assetProviderPlugin.CommitAssets(); 77 m_assetProviderPlugin.CommitAssets();
82 } 78 }
83 79
84 protected override void RunRequests() 80 protected override void ProcessRequest(AssetRequest req)
85 { 81 {
86 while (true) 82 AssetBase asset;
83 lock (syncLock)
87 { 84 {
88 ARequest req = _assetRequests.Dequeue(); 85 asset = m_assetProviderPlugin.FetchAsset(req.AssetID);
89 86 }
90 //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); 87 if (asset != null)
91 88 {
92 AssetBase asset = null; 89 _receiver.AssetReceived(asset, req.IsTexture);
93 lock (syncLock) 90 }
94 { 91 else
95 asset = m_assetProviderPlugin.FetchAsset(req.AssetID); 92 {
96 } 93 _receiver.AssetNotFound(req.AssetID);
97 if (asset != null)
98 {
99 _receiver.AssetReceived(asset, req.IsTexture);
100 }
101 else
102 {
103 _receiver.AssetNotFound(req.AssetID);
104 }
105 } 94 }
106 } 95 }
107 96
diff --git a/OpenSim/Framework/IAssetServer.cs b/OpenSim/Framework/IAssetServer.cs
index 2200d90..2fa77a0 100644
--- a/OpenSim/Framework/IAssetServer.cs
+++ b/OpenSim/Framework/IAssetServer.cs
@@ -60,10 +60,4 @@ namespace OpenSim.Framework
60 { 60 {
61 IAssetServer GetAssetServer(); 61 IAssetServer GetAssetServer();
62 } 62 }
63
64 public struct ARequest
65 {
66 public LLUUID AssetID;
67 public bool IsTexture;
68 }
69} 63}