diff options
author | lbsa71 | 2007-10-19 07:46:03 +0000 |
---|---|---|
committer | lbsa71 | 2007-10-19 07:46:03 +0000 |
commit | 46700d3b7d5bd71d880b3cc0dd0e2d6edd701195 (patch) | |
tree | 7f2d7a8c71e288daaa2b9b6f4d6ed35b0ef54d21 /OpenSim | |
parent | Fix for assetserver crashing (Thank you Chi11ken) (diff) | |
download | opensim-SC-46700d3b7d5bd71d880b3cc0dd0e2d6edd701195.zip opensim-SC-46700d3b7d5bd71d880b3cc0dd0e2d6edd701195.tar.gz opensim-SC-46700d3b7d5bd71d880b3cc0dd0e2d6edd701195.tar.bz2 opensim-SC-46700d3b7d5bd71d880b3cc0dd0e2d6edd701195.tar.xz |
* Total refactoring of Asset Server for massive win
* There is now a AssetServerBase
* lolcat in ur assets
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetCache.cs | 9 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetServer.cs | 501 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 180 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 206 | ||||
-rw-r--r-- | OpenSim/Framework/General/Interfaces/IAssetServer.cs | 3 | ||||
-rw-r--r-- | OpenSim/Framework/General/Types/AssetBase.cs | 6 | ||||
-rw-r--r-- | OpenSim/Grid/AssetServer/Main.cs | 8 | ||||
-rw-r--r-- | OpenSim/Region/Application/OpenSimMain.cs | 8 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/Program.cs | 2 |
9 files changed, 351 insertions, 572 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 4ae8595..17829b2 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs | |||
@@ -91,7 +91,12 @@ namespace OpenSim.Framework.Communications.Cache | |||
91 | { | 91 | { |
92 | System.Console.WriteLine("Creating Asset cache"); | 92 | System.Console.WriteLine("Creating Asset cache"); |
93 | _assetServer = this.LoadAssetDll(assetServerDLLName); | 93 | _assetServer = this.LoadAssetDll(assetServerDLLName); |
94 | |||
95 | |||
96 | // TODO: This actually does nothing to no IAssetServer implementor. Delete? | ||
94 | _assetServer.SetServerInfo(assetServerURL, assetServerKey); | 97 | _assetServer.SetServerInfo(assetServerURL, assetServerKey); |
98 | |||
99 | |||
95 | _assetServer.SetReceiver(this); | 100 | _assetServer.SetReceiver(this); |
96 | Assets = new Dictionary<LLUUID, AssetInfo>(); | 101 | Assets = new Dictionary<LLUUID, AssetInfo>(); |
97 | Textures = new Dictionary<LLUUID, TextureImage>(); | 102 | Textures = new Dictionary<LLUUID, TextureImage>(); |
@@ -159,7 +164,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
159 | { //texture | 164 | { //texture |
160 | TextureImage textur = new TextureImage(asset); | 165 | TextureImage textur = new TextureImage(asset); |
161 | this.Textures.Add(textur.FullID, textur); | 166 | this.Textures.Add(textur.FullID, textur); |
162 | this._assetServer.CreateAsset(asset); | 167 | this._assetServer.StoreAndCommitAsset(asset); |
163 | } | 168 | } |
164 | else | 169 | else |
165 | { | 170 | { |
@@ -173,7 +178,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
173 | { | 178 | { |
174 | AssetInfo assetInf = new AssetInfo(asset); | 179 | AssetInfo assetInf = new AssetInfo(asset); |
175 | this.Assets.Add(assetInf.FullID, assetInf); | 180 | this.Assets.Add(assetInf.FullID, assetInf); |
176 | this._assetServer.CreateAsset(asset); | 181 | this._assetServer.StoreAndCommitAsset(asset); |
177 | } | 182 | } |
178 | } | 183 | } |
179 | } | 184 | } |
diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index e5329ec..a374df2 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs | |||
@@ -24,370 +24,137 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.Collections.Generic; |
30 | using System.Threading; | 30 | using System.IO; |
31 | using Db4objects.Db4o; | 31 | using System.Threading; |
32 | using Db4objects.Db4o.Query; | 32 | using Db4objects.Db4o; |
33 | using libsecondlife; | 33 | using Db4objects.Db4o.Query; |
34 | using Nini.Config; | 34 | using libsecondlife; |
35 | using OpenSim.Framework.Console; | 35 | using Nini.Config; |
36 | using OpenSim.Framework.Interfaces; | 36 | using OpenSim.Framework.Communications.Cache; |
37 | using OpenSim.Framework.Types; | 37 | using OpenSim.Framework.Console; |
38 | using OpenSim.Framework.Utilities; | 38 | using OpenSim.Framework.Interfaces; |
39 | 39 | using OpenSim.Framework.Types; | |
40 | namespace OpenSim.Framework.Communications.Caches | 40 | using OpenSim.Framework.Utilities; |
41 | { | 41 | |
42 | 42 | namespace OpenSim.Framework.Communications.Cache | |
43 | public class LocalAssetServer : IAssetServer | 43 | { |
44 | { | 44 | public class LocalAssetServer : AssetServerBase |
45 | private IAssetReceiver _receiver; | 45 | { |
46 | private BlockingQueue<ARequest> _assetRequests; | 46 | private IObjectContainer db; |
47 | private IObjectContainer db; | 47 | |
48 | private Thread _localAssetServerThread; | 48 | public LocalAssetServer() |
49 | 49 | { | |
50 | public LocalAssetServer() | 50 | bool yapfile; |
51 | { | 51 | yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); |
52 | System.Console.WriteLine("Starting Db4o asset storage system"); | 52 | |
53 | bool yapfile; | 53 | db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); |
54 | this._assetRequests = new BlockingQueue<ARequest>(); | 54 | MainLog.Instance.Verbose("Db4 Asset database creation"); |
55 | yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); | 55 | |
56 | 56 | if (!yapfile) | |
57 | MainLog.Instance.Verbose("Local Asset Server class created"); | 57 | { |
58 | db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); | 58 | SetUpAssetDatabase(); |
59 | MainLog.Instance.Verbose("Db4 Asset database creation"); | 59 | } |
60 | 60 | ||
61 | if (!yapfile) | 61 | this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); |
62 | { | 62 | this._localAssetServerThread.IsBackground = true; |
63 | this.SetUpAssetDatabase(); | 63 | this._localAssetServerThread.Start(); |
64 | } | 64 | |
65 | 65 | } | |
66 | this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); | 66 | |
67 | this._localAssetServerThread.IsBackground = true; | 67 | public void CreateAndCommitAsset(AssetBase asset) |
68 | this._localAssetServerThread.Start(); | 68 | { |
69 | 69 | AssetStorage store = new AssetStorage(); | |
70 | } | 70 | store.Data = asset.Data; |
71 | 71 | store.Name = asset.Name; | |
72 | public void SetReceiver(IAssetReceiver receiver) | 72 | store.UUID = asset.FullID; |
73 | { | 73 | db.Set(store); |
74 | this._receiver = receiver; | 74 | db.Commit(); |
75 | } | 75 | } |
76 | 76 | ||
77 | public void FetchAsset(LLUUID assetID, bool isTexture) | 77 | override public void Close() |
78 | { | 78 | { |
79 | ARequest req = new ARequest(); | 79 | if (db != null) |
80 | req.AssetID = assetID; | 80 | { |
81 | req.IsTexture = isTexture; | 81 | MainLog.Instance.Verbose("Closing local asset server database"); |
82 | this._assetRequests.Enqueue(req); | 82 | db.Close(); |
83 | } | 83 | } |
84 | 84 | } | |
85 | public void UpdateAsset(AssetBase asset) | 85 | |
86 | { | 86 | private void RunRequests() |
87 | 87 | { | |
88 | } | 88 | while (true) |
89 | 89 | { | |
90 | public void CreateAsset(AssetBase asset) | 90 | byte[] idata = null; |
91 | { | 91 | bool found = false; |
92 | AssetStorage store = new AssetStorage(); | 92 | AssetStorage foundAsset = null; |
93 | store.Data = asset.Data; | 93 | ARequest req = this._assetRequests.Dequeue(); |
94 | store.Name = asset.Name; | 94 | IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); |
95 | store.UUID = asset.FullID; | 95 | if (result.Count > 0) |
96 | db.Set(store); | 96 | { |
97 | db.Commit(); | 97 | foundAsset = (AssetStorage)result.Next(); |
98 | } | 98 | found = true; |
99 | 99 | } | |
100 | public void SetServerInfo(string ServerUrl, string ServerKey) | 100 | |
101 | { | 101 | AssetBase asset = new AssetBase(); |
102 | 102 | if (found) | |
103 | } | 103 | { |
104 | public void Close() | 104 | asset.FullID = foundAsset.UUID; |
105 | { | 105 | asset.Type = foundAsset.Type; |
106 | if (db != null) | 106 | asset.InvType = foundAsset.Type; |
107 | { | 107 | asset.Name = foundAsset.Name; |
108 | MainLog.Instance.Verbose("Closing local asset server database"); | 108 | idata = foundAsset.Data; |
109 | db.Close(); | 109 | asset.Data = idata; |
110 | } | 110 | _receiver.AssetReceived(asset, req.IsTexture); |
111 | } | 111 | } |
112 | 112 | else | |
113 | private void RunRequests() | 113 | { |
114 | { | 114 | //asset.FullID = ; |
115 | while (true) | 115 | _receiver.AssetNotFound(req.AssetID); |
116 | { | 116 | } |
117 | byte[] idata = null; | 117 | |
118 | bool found = false; | 118 | } |
119 | AssetStorage foundAsset = null; | 119 | |
120 | ARequest req = this._assetRequests.Dequeue(); | 120 | } |
121 | IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); | 121 | |
122 | if (result.Count > 0) | 122 | override protected void StoreAsset(AssetBase asset) |
123 | { | 123 | { |
124 | foundAsset = (AssetStorage)result.Next(); | 124 | AssetStorage store = new AssetStorage(); |
125 | found = true; | 125 | store.Data = asset.Data; |
126 | } | 126 | store.Name = asset.Name; |
127 | 127 | store.UUID = asset.FullID; | |
128 | AssetBase asset = new AssetBase(); | 128 | db.Set(store); |
129 | if (found) | 129 | |
130 | { | 130 | CommitAssets(); |
131 | asset.FullID = foundAsset.UUID; | 131 | } |
132 | asset.Type = foundAsset.Type; | 132 | |
133 | asset.InvType = foundAsset.Type; | 133 | protected override void CommitAssets() |
134 | asset.Name = foundAsset.Name; | 134 | { |
135 | idata = foundAsset.Data; | 135 | db.Commit(); |
136 | asset.Data = idata; | 136 | } |
137 | _receiver.AssetReceived(asset, req.IsTexture); | 137 | |
138 | } | 138 | private void SetUpAssetDatabase() |
139 | else | 139 | { |
140 | { | 140 | MainLog.Instance.Verbose("LOCAL ASSET SERVER", "Setting up asset database"); |
141 | //asset.FullID = ; | 141 | |
142 | _receiver.AssetNotFound(req.AssetID); | 142 | ForEachDefaultAsset(this, StoreAsset); |
143 | } | 143 | ForEachXmlAsset(this, StoreAsset); |
144 | 144 | } | |
145 | } | 145 | } |
146 | 146 | ||
147 | } | 147 | public class AssetUUIDQuery : Predicate |
148 | 148 | { | |
149 | private void SetUpAssetDatabase() | 149 | private LLUUID _findID; |
150 | { | 150 | |
151 | MainLog.Instance.Verbose("Setting up asset database"); | 151 | public AssetUUIDQuery(LLUUID find) |
152 | 152 | { | |
153 | AssetBase Image = new AssetBase(); | 153 | _findID = find; |
154 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); | 154 | } |
155 | Image.Name = "Bricks"; | 155 | public bool Match(AssetStorage asset) |
156 | this.LoadAsset(Image, true, "bricks.jp2"); | 156 | { |
157 | AssetStorage store = new AssetStorage(); | 157 | return (asset.UUID == _findID); |
158 | store.Data = Image.Data; | 158 | } |
159 | store.Name = Image.Name; | 159 | } |
160 | store.UUID = Image.FullID; | 160 | } \ No newline at end of file |
161 | db.Set(store); | ||
162 | db.Commit(); | ||
163 | |||
164 | Image = new AssetBase(); | ||
165 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); | ||
166 | Image.Name = "Plywood"; | ||
167 | this.LoadAsset(Image, true, "plywood.jp2"); | ||
168 | store = new AssetStorage(); | ||
169 | store.Data = Image.Data; | ||
170 | store.Name = Image.Name; | ||
171 | store.UUID = Image.FullID; | ||
172 | db.Set(store); | ||
173 | db.Commit(); | ||
174 | |||
175 | Image = new AssetBase(); | ||
176 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); | ||
177 | Image.Name = "Rocks"; | ||
178 | this.LoadAsset(Image, true, "rocks.jp2"); | ||
179 | store = new AssetStorage(); | ||
180 | store.Data = Image.Data; | ||
181 | store.Name = Image.Name; | ||
182 | store.UUID = Image.FullID; | ||
183 | db.Set(store); | ||
184 | db.Commit(); | ||
185 | |||
186 | Image = new AssetBase(); | ||
187 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); | ||
188 | Image.Name = "Granite"; | ||
189 | this.LoadAsset(Image, true, "granite.jp2"); | ||
190 | store = new AssetStorage(); | ||
191 | store.Data = Image.Data; | ||
192 | store.Name = Image.Name; | ||
193 | store.UUID = Image.FullID; | ||
194 | db.Set(store); | ||
195 | db.Commit(); | ||
196 | |||
197 | Image = new AssetBase(); | ||
198 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); | ||
199 | Image.Name = "Hardwood"; | ||
200 | this.LoadAsset(Image, true, "hardwood.jp2"); | ||
201 | store = new AssetStorage(); | ||
202 | store.Data = Image.Data; | ||
203 | store.Name = Image.Name; | ||
204 | store.UUID = Image.FullID; | ||
205 | db.Set(store); | ||
206 | db.Commit(); | ||
207 | |||
208 | Image = new AssetBase(); | ||
209 | Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); | ||
210 | Image.Name = "Prim Base Texture"; | ||
211 | this.LoadAsset(Image, true, "plywood.jp2"); | ||
212 | store = new AssetStorage(); | ||
213 | store.Data = Image.Data; | ||
214 | store.Name = Image.Name; | ||
215 | store.UUID = Image.FullID; | ||
216 | db.Set(store); | ||
217 | db.Commit(); | ||
218 | |||
219 | Image = new AssetBase(); | ||
220 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); | ||
221 | Image.Name = "Map Base Texture"; | ||
222 | this.LoadAsset(Image, true, "map_base.jp2"); | ||
223 | store = new AssetStorage(); | ||
224 | store.Data = Image.Data; | ||
225 | store.Name = Image.Name; | ||
226 | store.UUID = Image.FullID; | ||
227 | db.Set(store); | ||
228 | db.Commit(); | ||
229 | |||
230 | Image = new AssetBase(); | ||
231 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); | ||
232 | Image.Name = "Map Texture"; | ||
233 | this.LoadAsset(Image, true, "map1.jp2"); | ||
234 | store = new AssetStorage(); | ||
235 | store.Data = Image.Data; | ||
236 | store.Name = Image.Name; | ||
237 | store.UUID = Image.FullID; | ||
238 | db.Set(store); | ||
239 | db.Commit(); | ||
240 | |||
241 | Image = new AssetBase(); | ||
242 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); | ||
243 | Image.Name = "Female Body Texture"; | ||
244 | this.LoadAsset(Image, true, "femalebody.jp2"); | ||
245 | store = new AssetStorage(); | ||
246 | store.Data = Image.Data; | ||
247 | store.Name = Image.Name; | ||
248 | store.UUID = Image.FullID; | ||
249 | db.Set(store); | ||
250 | db.Commit(); | ||
251 | |||
252 | Image = new AssetBase(); | ||
253 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); | ||
254 | Image.Name = "Female Bottom Texture"; | ||
255 | this.LoadAsset(Image, true, "femalebottom.jp2"); | ||
256 | store = new AssetStorage(); | ||
257 | store.Data = Image.Data; | ||
258 | store.Name = Image.Name; | ||
259 | store.UUID = Image.FullID; | ||
260 | db.Set(store); | ||
261 | db.Commit(); | ||
262 | |||
263 | Image = new AssetBase(); | ||
264 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); | ||
265 | Image.Name = "Female Face Texture"; | ||
266 | this.LoadAsset(Image, true, "femaleface.jp2"); | ||
267 | store = new AssetStorage(); | ||
268 | store.Data = Image.Data; | ||
269 | store.Name = Image.Name; | ||
270 | store.UUID = Image.FullID; | ||
271 | db.Set(store); | ||
272 | db.Commit(); | ||
273 | |||
274 | Image = new AssetBase(); | ||
275 | Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); | ||
276 | Image.Name = "Skin"; | ||
277 | Image.Type = 13; | ||
278 | Image.InvType = 13; | ||
279 | this.LoadAsset(Image, false, "base_skin.dat"); | ||
280 | store = new AssetStorage(); | ||
281 | store.Data = Image.Data; | ||
282 | store.Name = Image.Name; | ||
283 | store.UUID = Image.FullID; | ||
284 | db.Set(store); | ||
285 | db.Commit(); | ||
286 | |||
287 | |||
288 | Image = new AssetBase(); | ||
289 | Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | ||
290 | Image.Name = "Shape"; | ||
291 | Image.Type = 13; | ||
292 | Image.InvType = 13; | ||
293 | this.LoadAsset(Image, false, "base_shape.dat"); | ||
294 | store = new AssetStorage(); | ||
295 | store.Data = Image.Data; | ||
296 | store.Name = Image.Name; | ||
297 | store.UUID = Image.FullID; | ||
298 | db.Set(store); | ||
299 | db.Commit(); | ||
300 | |||
301 | Image = new AssetBase(); | ||
302 | Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); | ||
303 | Image.Name = "Shirt"; | ||
304 | Image.Type = 5; | ||
305 | Image.InvType = 18; | ||
306 | this.LoadAsset(Image, false, "newshirt.dat"); | ||
307 | store = new AssetStorage(); | ||
308 | store.Data = Image.Data; | ||
309 | store.Name = Image.Name; | ||
310 | store.UUID = Image.FullID; | ||
311 | db.Set(store); | ||
312 | db.Commit(); | ||
313 | |||
314 | Image = new AssetBase(); | ||
315 | Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); | ||
316 | Image.Name = "Shirt"; | ||
317 | Image.Type = 5; | ||
318 | Image.InvType = 18; | ||
319 | this.LoadAsset(Image, false, "newpants.dat"); | ||
320 | store = new AssetStorage(); | ||
321 | store.Data = Image.Data; | ||
322 | store.Name = Image.Name; | ||
323 | store.UUID = Image.FullID; | ||
324 | db.Set(store); | ||
325 | db.Commit(); | ||
326 | |||
327 | string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); | ||
328 | if (File.Exists(filePath)) | ||
329 | { | ||
330 | XmlConfigSource source = new XmlConfigSource(filePath); | ||
331 | ReadAssetDetails(source); | ||
332 | } | ||
333 | } | ||
334 | |||
335 | protected void ReadAssetDetails(IConfigSource source) | ||
336 | { | ||
337 | AssetBase newAsset = null; | ||
338 | for (int i = 0; i < source.Configs.Count; i++) | ||
339 | { | ||
340 | newAsset = new AssetBase(); | ||
341 | newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); | ||
342 | newAsset.Name = source.Configs[i].GetString("name", ""); | ||
343 | newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); | ||
344 | newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); | ||
345 | string fileName = source.Configs[i].GetString("fileName", ""); | ||
346 | if (fileName != "") | ||
347 | { | ||
348 | this.LoadAsset(newAsset, false, fileName); | ||
349 | AssetStorage store = new AssetStorage(); | ||
350 | store.Data = newAsset.Data; | ||
351 | store.Name = newAsset.Name; | ||
352 | store.UUID = newAsset.FullID; | ||
353 | db.Set(store); | ||
354 | db.Commit(); | ||
355 | } | ||
356 | } | ||
357 | } | ||
358 | |||
359 | private void LoadAsset(AssetBase info, bool image, string filename) | ||
360 | { | ||
361 | //should request Asset from storage manager | ||
362 | //but for now read from file | ||
363 | |||
364 | string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; | ||
365 | string fileName = Path.Combine(dataPath, filename); | ||
366 | FileInfo fInfo = new FileInfo(fileName); | ||
367 | long numBytes = fInfo.Length; | ||
368 | FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); | ||
369 | byte[] idata = new byte[numBytes]; | ||
370 | BinaryReader br = new BinaryReader(fStream); | ||
371 | idata = br.ReadBytes((int)numBytes); | ||
372 | br.Close(); | ||
373 | fStream.Close(); | ||
374 | info.Data = idata; | ||
375 | //info.loaded=true; | ||
376 | } | ||
377 | } | ||
378 | public class AssetUUIDQuery : Predicate | ||
379 | { | ||
380 | private LLUUID _findID; | ||
381 | |||
382 | public AssetUUIDQuery(LLUUID find) | ||
383 | { | ||
384 | _findID = find; | ||
385 | } | ||
386 | public bool Match(AssetStorage asset) | ||
387 | { | ||
388 | return (asset.UUID == _findID); | ||
389 | } | ||
390 | } | ||
391 | |||
392 | } | ||
393 | |||
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs new file mode 100644 index 0000000..7073000 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs | |||
@@ -0,0 +1,180 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.IO; | ||
4 | using System.Threading; | ||
5 | using libsecondlife; | ||
6 | using Nini.Config; | ||
7 | using OpenSim.Framework.Console; | ||
8 | using OpenSim.Framework.Interfaces; | ||
9 | using OpenSim.Framework.Types; | ||
10 | using OpenSim.Framework.Utilities; | ||
11 | |||
12 | namespace OpenSim.Framework.Communications.Cache | ||
13 | { | ||
14 | public abstract class AssetServerBase : IAssetServer | ||
15 | { | ||
16 | protected IAssetReceiver _receiver; | ||
17 | protected BlockingQueue<ARequest> _assetRequests; | ||
18 | protected Thread _localAssetServerThread; | ||
19 | protected IAssetProvider m_assetProviderPlugin; | ||
20 | protected object syncLock = new object(); | ||
21 | |||
22 | protected abstract void StoreAsset(AssetBase asset); | ||
23 | protected abstract void CommitAssets(); | ||
24 | |||
25 | public void LoadDefaultAssets() | ||
26 | { | ||
27 | MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); | ||
28 | |||
29 | ForEachDefaultAsset( this, StoreAsset ); | ||
30 | ForEachXmlAsset( this, StoreAsset ); | ||
31 | |||
32 | CommitAssets(); | ||
33 | } | ||
34 | |||
35 | |||
36 | public static AssetBase CreateAsset(IAssetServer assetServer, string assetIdStr, string name, string filename, bool isImage) | ||
37 | { | ||
38 | AssetBase asset = new AssetBase( | ||
39 | new LLUUID(assetIdStr), | ||
40 | name | ||
41 | ); | ||
42 | |||
43 | if (!String.IsNullOrEmpty(filename)) | ||
44 | { | ||
45 | MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename ); | ||
46 | |||
47 | assetServer.LoadAsset(asset, isImage, filename); | ||
48 | } | ||
49 | else | ||
50 | { | ||
51 | MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name ); | ||
52 | } | ||
53 | |||
54 | return asset; | ||
55 | } | ||
56 | |||
57 | private static AssetBase CreateImageAsset(IAssetServer assetServer, string assetIdStr, string name, string filename) | ||
58 | { | ||
59 | return CreateAsset(assetServer, assetIdStr, name, filename, true); | ||
60 | } | ||
61 | |||
62 | public static List<AssetBase> GetDefaultAssets(IAssetServer assetServer) | ||
63 | { | ||
64 | List<AssetBase> assets = new List<AssetBase>(); | ||
65 | |||
66 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); | ||
67 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2")); | ||
68 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2")); | ||
69 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2")); | ||
70 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2")); | ||
71 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2")); | ||
72 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2")); | ||
73 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2")); | ||
74 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2")); | ||
75 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); | ||
76 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2")); | ||
77 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); | ||
78 | |||
79 | assets.Add(CreateAsset(assetServer, "77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); | ||
80 | assets.Add(CreateAsset(assetServer, "66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); | ||
81 | assets.Add(CreateAsset(assetServer, "00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); | ||
82 | assets.Add(CreateAsset(assetServer, "00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); | ||
83 | |||
84 | return assets; | ||
85 | } | ||
86 | |||
87 | public static void ForEachDefaultAsset(IAssetServer assetServer, Action<AssetBase> action) | ||
88 | { | ||
89 | List<AssetBase> assets = GetDefaultAssets(assetServer); | ||
90 | assets.ForEach(action); | ||
91 | } | ||
92 | |||
93 | public AssetServerBase() | ||
94 | { | ||
95 | System.Console.WriteLine("Starting Db4o asset storage system"); | ||
96 | this._assetRequests = new BlockingQueue<ARequest>(); | ||
97 | } | ||
98 | |||
99 | public void LoadAsset(AssetBase info, bool image, string filename) | ||
100 | { | ||
101 | //should request Asset from storage manager | ||
102 | //but for now read from file | ||
103 | |||
104 | string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; | ||
105 | string fileName = Path.Combine(dataPath, filename); | ||
106 | FileInfo fInfo = new FileInfo(fileName); | ||
107 | long numBytes = fInfo.Length; | ||
108 | FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); | ||
109 | byte[] idata = new byte[numBytes]; | ||
110 | BinaryReader br = new BinaryReader(fStream); | ||
111 | idata = br.ReadBytes((int)numBytes); | ||
112 | br.Close(); | ||
113 | fStream.Close(); | ||
114 | info.Data = idata; | ||
115 | //info.loaded=true; | ||
116 | } | ||
117 | |||
118 | public static void ForEachXmlAsset(IAssetServer assetServer, Action<AssetBase> action) | ||
119 | { | ||
120 | string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); | ||
121 | if (File.Exists(filePath)) | ||
122 | { | ||
123 | XmlConfigSource source = new XmlConfigSource(filePath); | ||
124 | |||
125 | for (int i = 0; i < source.Configs.Count; i++) | ||
126 | { | ||
127 | string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); | ||
128 | string name = source.Configs[i].GetString("name", ""); | ||
129 | sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); | ||
130 | sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); | ||
131 | string fileName = source.Configs[i].GetString("fileName", ""); | ||
132 | |||
133 | AssetBase newAsset = CreateAsset(assetServer, assetIdStr, name, fileName, false); | ||
134 | |||
135 | newAsset.Type = type; | ||
136 | newAsset.InvType = invType; | ||
137 | |||
138 | } | ||
139 | } | ||
140 | } | ||
141 | |||
142 | public void SetReceiver(IAssetReceiver receiver) | ||
143 | { | ||
144 | this._receiver = receiver; | ||
145 | } | ||
146 | |||
147 | public void FetchAsset(LLUUID assetID, bool isTexture) | ||
148 | { | ||
149 | ARequest req = new ARequest(); | ||
150 | req.AssetID = assetID; | ||
151 | req.IsTexture = isTexture; | ||
152 | this._assetRequests.Enqueue(req); | ||
153 | } | ||
154 | |||
155 | public void UpdateAsset(AssetBase asset) | ||
156 | { | ||
157 | lock (syncLock) | ||
158 | { | ||
159 | m_assetProviderPlugin.UpdateAsset(asset); | ||
160 | m_assetProviderPlugin.CommitAssets(); | ||
161 | } | ||
162 | } | ||
163 | |||
164 | public void StoreAndCommitAsset(AssetBase asset) | ||
165 | { | ||
166 | lock (syncLock) | ||
167 | { | ||
168 | StoreAsset(asset); | ||
169 | CommitAssets(); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | public void SetServerInfo(string ServerUrl, string ServerKey) | ||
174 | { | ||
175 | |||
176 | } | ||
177 | |||
178 | public abstract void Close(); | ||
179 | } | ||
180 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 35ec1cf..cf54b81 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | |||
@@ -36,32 +36,22 @@ using OpenSim.Framework.Interfaces; | |||
36 | using OpenSim.Framework.Types; | 36 | using OpenSim.Framework.Types; |
37 | using OpenSim.Framework.Utilities; | 37 | using OpenSim.Framework.Utilities; |
38 | 38 | ||
39 | namespace OpenSim.Framework.Communications.Caches | 39 | namespace OpenSim.Framework.Communications.Cache |
40 | { | 40 | { |
41 | 41 | public class SQLAssetServer : AssetServerBase | |
42 | public class SQLAssetServer : IAssetServer | ||
43 | { | 42 | { |
44 | private IAssetReceiver _receiver; | ||
45 | private BlockingQueue<ARequest> _assetRequests; | ||
46 | private Thread _localAssetServerThread; | ||
47 | protected IAssetProvider m_assetProviderPlugin; | ||
48 | private object syncLock = new object(); | ||
49 | |||
50 | |||
51 | public SQLAssetServer(string pluginName) | 43 | public SQLAssetServer(string pluginName) |
52 | { | 44 | { |
53 | _assetRequests = new BlockingQueue<ARequest>(); | 45 | _assetRequests = new BlockingQueue<ARequest>(); |
54 | AddPlugin(pluginName); | 46 | AddPlugin(pluginName); |
55 | 47 | ||
56 | SetUpAssetDatabase(); | ||
57 | |||
58 | this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); | 48 | this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); |
59 | this._localAssetServerThread.IsBackground = true; | 49 | this._localAssetServerThread.IsBackground = true; |
60 | this._localAssetServerThread.Start(); | 50 | this._localAssetServerThread.Start(); |
61 | 51 | ||
62 | } | 52 | } |
63 | 53 | ||
64 | public SQLAssetServer( IAssetProvider assetProvider ) | 54 | public SQLAssetServer(IAssetProvider assetProvider) |
65 | { | 55 | { |
66 | m_assetProviderPlugin = assetProvider; | 56 | m_assetProviderPlugin = assetProvider; |
67 | } | 57 | } |
@@ -93,49 +83,15 @@ namespace OpenSim.Framework.Communications.Caches | |||
93 | pluginAssembly = null; | 83 | pluginAssembly = null; |
94 | } | 84 | } |
95 | 85 | ||
96 | public void SetReceiver(IAssetReceiver receiver) | ||
97 | { | ||
98 | this._receiver = receiver; | ||
99 | } | ||
100 | |||
101 | public void FetchAsset(LLUUID assetID, bool isTexture) | ||
102 | { | ||
103 | ARequest req = new ARequest(); | ||
104 | req.AssetID = assetID; | ||
105 | req.IsTexture = isTexture; | ||
106 | this._assetRequests.Enqueue(req); | ||
107 | } | ||
108 | |||
109 | public void UpdateAsset(AssetBase asset) | ||
110 | { | ||
111 | lock (syncLock) | ||
112 | { | ||
113 | m_assetProviderPlugin.UpdateAsset(asset); | ||
114 | m_assetProviderPlugin.CommitAssets(); | ||
115 | } | ||
116 | } | ||
117 | 86 | ||
118 | public void CreateAsset(AssetBase asset) | 87 | public override void Close() |
119 | { | ||
120 | lock (syncLock) | ||
121 | { | ||
122 | m_assetProviderPlugin.CreateAsset(asset); | ||
123 | m_assetProviderPlugin.CommitAssets(); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | public void SetServerInfo(string ServerUrl, string ServerKey) | ||
128 | { | ||
129 | |||
130 | } | ||
131 | public void Close() | ||
132 | { | 88 | { |
133 | m_assetProviderPlugin.CommitAssets(); | 89 | m_assetProviderPlugin.CommitAssets(); |
134 | } | 90 | } |
135 | 91 | ||
136 | private void RunRequests() | 92 | private void RunRequests() |
137 | { | 93 | { |
138 | 94 | ||
139 | while (true) | 95 | while (true) |
140 | { | 96 | { |
141 | ARequest req = this._assetRequests.Dequeue(); | 97 | ARequest req = this._assetRequests.Dequeue(); |
@@ -160,156 +116,14 @@ namespace OpenSim.Framework.Communications.Caches | |||
160 | 116 | ||
161 | } | 117 | } |
162 | 118 | ||
163 | private void SetUpAssetDatabase() | 119 | protected override void StoreAsset(AssetBase asset) |
164 | { | 120 | { |
165 | MainLog.Instance.Verbose("Setting up asset database"); | 121 | m_assetProviderPlugin.CreateAsset(asset); |
166 | |||
167 | AssetBase Image = new AssetBase(); | ||
168 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); | ||
169 | Image.Name = "Bricks"; | ||
170 | this.LoadAsset(Image, true, "bricks.jp2"); | ||
171 | m_assetProviderPlugin.CreateAsset(Image); | ||
172 | |||
173 | Image = new AssetBase(); | ||
174 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); | ||
175 | Image.Name = "Plywood"; | ||
176 | this.LoadAsset(Image, true, "plywood.jp2"); | ||
177 | m_assetProviderPlugin.CreateAsset(Image); | ||
178 | |||
179 | Image = new AssetBase(); | ||
180 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); | ||
181 | Image.Name = "Rocks"; | ||
182 | this.LoadAsset(Image, true, "rocks.jp2"); | ||
183 | m_assetProviderPlugin.CreateAsset(Image); | ||
184 | |||
185 | Image = new AssetBase(); | ||
186 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); | ||
187 | Image.Name = "Granite"; | ||
188 | this.LoadAsset(Image, true, "granite.jp2"); | ||
189 | m_assetProviderPlugin.CreateAsset(Image); | ||
190 | |||
191 | Image = new AssetBase(); | ||
192 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); | ||
193 | Image.Name = "Hardwood"; | ||
194 | this.LoadAsset(Image, true, "hardwood.jp2"); | ||
195 | m_assetProviderPlugin.CreateAsset(Image); | ||
196 | |||
197 | Image = new AssetBase(); | ||
198 | Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); | ||
199 | Image.Name = "Prim Base Texture"; | ||
200 | this.LoadAsset(Image, true, "plywood.jp2"); | ||
201 | m_assetProviderPlugin.CreateAsset(Image); | ||
202 | |||
203 | Image = new AssetBase(); | ||
204 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); | ||
205 | Image.Name = "Map Base Texture"; | ||
206 | this.LoadAsset(Image, true, "map_base.jp2"); | ||
207 | m_assetProviderPlugin.CreateAsset(Image); | ||
208 | |||
209 | Image = new AssetBase(); | ||
210 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); | ||
211 | Image.Name = "Map Texture"; | ||
212 | this.LoadAsset(Image, true, "map1.jp2"); | ||
213 | m_assetProviderPlugin.CreateAsset(Image); | ||
214 | |||
215 | Image = new AssetBase(); | ||
216 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); | ||
217 | Image.Name = "Female Body Texture"; | ||
218 | this.LoadAsset(Image, true, "femalebody.jp2"); | ||
219 | m_assetProviderPlugin.CreateAsset(Image); | ||
220 | |||
221 | Image = new AssetBase(); | ||
222 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); | ||
223 | Image.Name = "Female Bottom Texture"; | ||
224 | this.LoadAsset(Image, true, "femalebottom.jp2"); | ||
225 | m_assetProviderPlugin.CreateAsset(Image); | ||
226 | |||
227 | Image = new AssetBase(); | ||
228 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); | ||
229 | Image.Name = "Female Face Texture"; | ||
230 | this.LoadAsset(Image, true, "femaleface.jp2"); | ||
231 | m_assetProviderPlugin.CreateAsset(Image); | ||
232 | |||
233 | Image = new AssetBase(); | ||
234 | Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); | ||
235 | Image.Name = "Skin"; | ||
236 | Image.Type = 13; | ||
237 | Image.InvType = 13; | ||
238 | this.LoadAsset(Image, false, "base_skin.dat"); | ||
239 | m_assetProviderPlugin.CreateAsset(Image); | ||
240 | |||
241 | Image = new AssetBase(); | ||
242 | Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | ||
243 | Image.Name = "Shape"; | ||
244 | Image.Type = 13; | ||
245 | Image.InvType = 13; | ||
246 | this.LoadAsset(Image, false, "base_shape.dat"); | ||
247 | m_assetProviderPlugin.CreateAsset(Image); | ||
248 | |||
249 | Image = new AssetBase(); | ||
250 | Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); | ||
251 | Image.Name = "Shirt"; | ||
252 | Image.Type = 5; | ||
253 | Image.InvType = 18; | ||
254 | this.LoadAsset(Image, false, "newshirt.dat"); | ||
255 | m_assetProviderPlugin.CreateAsset(Image); | ||
256 | |||
257 | Image = new AssetBase(); | ||
258 | Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); | ||
259 | Image.Name = "Shirt"; | ||
260 | Image.Type = 5; | ||
261 | Image.InvType = 18; | ||
262 | this.LoadAsset(Image, false, "newpants.dat"); | ||
263 | m_assetProviderPlugin.CreateAsset(Image); | ||
264 | |||
265 | string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); | ||
266 | if (File.Exists(filePath)) | ||
267 | { | ||
268 | XmlConfigSource source = new XmlConfigSource(filePath); | ||
269 | ReadAssetDetails(source); | ||
270 | } | ||
271 | |||
272 | m_assetProviderPlugin.CommitAssets(); | ||
273 | } | 122 | } |
274 | 123 | ||
275 | protected void ReadAssetDetails(IConfigSource source) | 124 | protected override void CommitAssets() |
276 | { | 125 | { |
277 | AssetBase newAsset = null; | 126 | m_assetProviderPlugin.CommitAssets(); |
278 | for (int i = 0; i < source.Configs.Count; i++) | ||
279 | { | ||
280 | newAsset = new AssetBase(); | ||
281 | newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); | ||
282 | newAsset.Name = source.Configs[i].GetString("name", ""); | ||
283 | newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); | ||
284 | newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); | ||
285 | string fileName = source.Configs[i].GetString("fileName", ""); | ||
286 | if (fileName != "") | ||
287 | { | ||
288 | MainLog.Instance.Verbose("Creating new asset: " + newAsset.Name); | ||
289 | this.LoadAsset(newAsset, false, fileName); | ||
290 | m_assetProviderPlugin.CreateAsset(newAsset); | ||
291 | } | ||
292 | } | ||
293 | } | ||
294 | |||
295 | private void LoadAsset(AssetBase info, bool image, string filename) | ||
296 | { | ||
297 | //should request Asset from storage manager | ||
298 | //but for now read from file | ||
299 | |||
300 | string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; | ||
301 | string fileName = Path.Combine(dataPath, filename); | ||
302 | FileInfo fInfo = new FileInfo(fileName); | ||
303 | long numBytes = fInfo.Length; | ||
304 | FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); | ||
305 | byte[] idata = new byte[numBytes]; | ||
306 | BinaryReader br = new BinaryReader(fStream); | ||
307 | idata = br.ReadBytes((int)numBytes); | ||
308 | br.Close(); | ||
309 | fStream.Close(); | ||
310 | info.Data = idata; | ||
311 | //info.loaded=true; | ||
312 | } | 127 | } |
313 | } | 128 | } |
314 | 129 | } \ No newline at end of file | |
315 | } | ||
diff --git a/OpenSim/Framework/General/Interfaces/IAssetServer.cs b/OpenSim/Framework/General/Interfaces/IAssetServer.cs index f6849bf..e7401eb 100644 --- a/OpenSim/Framework/General/Interfaces/IAssetServer.cs +++ b/OpenSim/Framework/General/Interfaces/IAssetServer.cs | |||
@@ -39,9 +39,10 @@ namespace OpenSim.Framework.Interfaces | |||
39 | void SetReceiver(IAssetReceiver receiver); | 39 | void SetReceiver(IAssetReceiver receiver); |
40 | void FetchAsset(LLUUID assetID, bool isTexture); | 40 | void FetchAsset(LLUUID assetID, bool isTexture); |
41 | void UpdateAsset(AssetBase asset); | 41 | void UpdateAsset(AssetBase asset); |
42 | void CreateAsset(AssetBase asset); | 42 | void StoreAndCommitAsset(AssetBase asset); |
43 | void SetServerInfo(string ServerUrl, string ServerKey); | 43 | void SetServerInfo(string ServerUrl, string ServerKey); |
44 | void Close(); | 44 | void Close(); |
45 | void LoadAsset(AssetBase info, bool image, string filename); | ||
45 | } | 46 | } |
46 | 47 | ||
47 | // could change to delegate? | 48 | // could change to delegate? |
diff --git a/OpenSim/Framework/General/Types/AssetBase.cs b/OpenSim/Framework/General/Types/AssetBase.cs index ddd033f..628724d 100644 --- a/OpenSim/Framework/General/Types/AssetBase.cs +++ b/OpenSim/Framework/General/Types/AssetBase.cs | |||
@@ -44,5 +44,11 @@ namespace OpenSim.Framework.Types | |||
44 | { | 44 | { |
45 | 45 | ||
46 | } | 46 | } |
47 | |||
48 | public AssetBase(LLUUID assetId, string name) | ||
49 | { | ||
50 | FullID = assetId; | ||
51 | Name = name; | ||
52 | } | ||
47 | } | 53 | } |
48 | } | 54 | } |
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs index 7a7c843..3061e5c 100644 --- a/OpenSim/Grid/AssetServer/Main.cs +++ b/OpenSim/Grid/AssetServer/Main.cs | |||
@@ -30,13 +30,14 @@ using System; | |||
30 | using System.IO; | 30 | using System.IO; |
31 | 31 | ||
32 | using libsecondlife; | 32 | using libsecondlife; |
33 | using OpenSim.Framework.Communications.Cache; | ||
33 | using OpenSim.Framework.Configuration; | 34 | using OpenSim.Framework.Configuration; |
34 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
35 | using OpenSim.Framework.Servers; | 36 | using OpenSim.Framework.Servers; |
36 | using OpenSim.Framework.Configuration; | 37 | using OpenSim.Framework.Configuration; |
37 | using OpenSim.Framework.Interfaces; | 38 | using OpenSim.Framework.Interfaces; |
38 | using OpenSim.Framework.Utilities; | 39 | using OpenSim.Framework.Utilities; |
39 | using OpenSim.Framework.Communications.Caches; | 40 | |
40 | /* | 41 | /* |
41 | using System.Text; | 42 | using System.Text; |
42 | using Db4objects.Db4o; | 43 | using Db4objects.Db4o; |
@@ -114,7 +115,10 @@ namespace OpenSim.Grid.AssetServer | |||
114 | { | 115 | { |
115 | try | 116 | try |
116 | { | 117 | { |
117 | m_assetServer = new SQLAssetServer(config.DatabaseProvider); | 118 | SQLAssetServer assetServer = new SQLAssetServer(config.DatabaseProvider ); |
119 | assetServer.LoadDefaultAssets(); | ||
120 | |||
121 | m_assetServer = assetServer; | ||
118 | } | 122 | } |
119 | catch (Exception e) | 123 | catch (Exception e) |
120 | { | 124 | { |
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index ca72d62..4753145 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs | |||
@@ -32,7 +32,6 @@ using System.IO; | |||
32 | using System.Text; | 32 | using System.Text; |
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using OpenSim.Framework.Communications.Cache; | 34 | using OpenSim.Framework.Communications.Cache; |
35 | using OpenSim.Framework.Communications.Caches; | ||
36 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Interfaces; | 36 | using OpenSim.Framework.Interfaces; |
38 | using OpenSim.Framework.Servers; | 37 | using OpenSim.Framework.Servers; |
@@ -286,9 +285,14 @@ namespace OpenSim | |||
286 | } | 285 | } |
287 | else | 286 | else |
288 | { | 287 | { |
289 | assetServer = new SQLAssetServer(standaloneAssetPlugin); | 288 | SQLAssetServer sqlAssetServer = new SQLAssetServer(standaloneAssetPlugin); |
289 | sqlAssetServer.LoadDefaultAssets(); | ||
290 | assetServer = sqlAssetServer; | ||
290 | } | 291 | } |
292 | |||
293 | // TODO: This actually does nothing to no IAssetServer implementor. Delete? | ||
291 | assetServer.SetServerInfo(m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); | 294 | assetServer.SetServerInfo(m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); |
295 | |||
292 | m_assetCache = new AssetCache(assetServer); | 296 | m_assetCache = new AssetCache(assetServer); |
293 | // m_assetCache = new assetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); | 297 | // m_assetCache = new assetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); |
294 | } | 298 | } |
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 47b9ddd..7967867 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs | |||
@@ -32,7 +32,6 @@ using System.IO; | |||
32 | using System.Net; | 32 | using System.Net; |
33 | using libsecondlife; | 33 | using libsecondlife; |
34 | using OpenSim.Framework.Communications.Cache; | 34 | using OpenSim.Framework.Communications.Cache; |
35 | using OpenSim.Framework.Communications.Caches; | ||
36 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Types; | 36 | using OpenSim.Framework.Types; |
38 | using OpenSim.Region.ClientStack; | 37 | using OpenSim.Region.ClientStack; |
@@ -58,7 +57,6 @@ namespace SimpleApp | |||
58 | m_networkServersInfo = new NetworkServersInfo( 1000, 1000 ); | 57 | m_networkServersInfo = new NetworkServersInfo( 1000, 1000 ); |
59 | 58 | ||
60 | LocalAssetServer assetServer = new LocalAssetServer(); | 59 | LocalAssetServer assetServer = new LocalAssetServer(); |
61 | assetServer.SetServerInfo(m_networkServersInfo.AssetURL, ""); | ||
62 | 60 | ||
63 | m_assetCache = new AssetCache(assetServer); | 61 | m_assetCache = new AssetCache(assetServer); |
64 | } | 62 | } |