diff options
author | Melanie Thielker | 2009-05-18 23:18:04 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-05-18 23:18:04 +0000 |
commit | 23d902be42fd6d554a9098936d501609fc6e5315 (patch) | |
tree | 1830b906665ffa34b3f7c085e28d87ee16bf4c9f /OpenSim | |
parent | Bug fix and config rename. (diff) | |
download | opensim-SC_OLD-23d902be42fd6d554a9098936d501609fc6e5315.zip opensim-SC_OLD-23d902be42fd6d554a9098936d501609fc6e5315.tar.gz opensim-SC_OLD-23d902be42fd6d554a9098936d501609fc6e5315.tar.bz2 opensim-SC_OLD-23d902be42fd6d554a9098936d501609fc6e5315.tar.xz |
Remove the old asset cache and local services and the configurations for them
Diffstat (limited to '')
13 files changed, 7 insertions, 1149 deletions
diff --git a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs index 1059338..ca4d985 100644 --- a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs +++ b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs | |||
@@ -169,7 +169,7 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager | |||
169 | m_commsManager | 169 | m_commsManager |
170 | = new CommunicationsLocal( | 170 | = new CommunicationsLocal( |
171 | m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, | 171 | m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, |
172 | libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile); | 172 | libraryRootFolder, false); |
173 | 173 | ||
174 | CreateGridInfoService(); | 174 | CreateGridInfoService(); |
175 | } | 175 | } |
@@ -195,7 +195,7 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager | |||
195 | = new HGCommunicationsStandalone( | 195 | = new HGCommunicationsStandalone( |
196 | m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, | 196 | m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, |
197 | gridService, | 197 | gridService, |
198 | libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile); | 198 | libraryRootFolder, false); |
199 | 199 | ||
200 | HGServices = gridService; | 200 | HGServices = gridService; |
201 | 201 | ||
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs deleted file mode 100644 index 7d25ca9..0000000 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ /dev/null | |||
@@ -1,695 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
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. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text.RegularExpressions; | ||
32 | using System.Threading; | ||
33 | using GlynnTucker.Cache; | ||
34 | using log4net; | ||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.Packets; | ||
37 | using OpenSim.Framework.Statistics; | ||
38 | using System.Text; | ||
39 | |||
40 | namespace OpenSim.Framework.Communications.Cache | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// Manages local cache of assets and their sending to viewers. | ||
44 | /// </summary> | ||
45 | /// | ||
46 | /// This class actually encapsulates two largely separate mechanisms. One mechanism fetches assets either | ||
47 | /// synchronously or async and passes the data back to the requester. The second mechanism fetches assets and | ||
48 | /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and | ||
49 | /// AssetNotFound(), which means they do share the same asset and texture caches. | ||
50 | public class AssetCache : IAssetCache | ||
51 | { | ||
52 | private static readonly ILog m_log | ||
53 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
54 | |||
55 | protected ICache m_memcache = new SimpleMemoryCache(); | ||
56 | |||
57 | /// <value> | ||
58 | /// Assets requests which are waiting for asset server data. This includes texture requests | ||
59 | /// </value> | ||
60 | private Dictionary<UUID, AssetRequest> RequestedAssets; | ||
61 | |||
62 | /// <value> | ||
63 | /// Asset requests with data which are ready to be sent back to requesters. This includes textures. | ||
64 | /// </value> | ||
65 | private List<AssetRequest> AssetRequests; | ||
66 | |||
67 | /// <value> | ||
68 | /// Until the asset request is fulfilled, each asset request is associated with a list of requesters | ||
69 | /// </value> | ||
70 | private Dictionary<UUID, AssetRequestsList> RequestLists; | ||
71 | |||
72 | #region IPlugin | ||
73 | |||
74 | /// <summary> | ||
75 | /// The methods and properties in this section are needed to | ||
76 | /// support the IPlugin interface. They cann all be overridden | ||
77 | /// as needed by a derived class. | ||
78 | /// </summary> | ||
79 | |||
80 | public virtual string Name | ||
81 | { | ||
82 | get { return "OpenSim.Framework.Communications.Cache.AssetCache"; } | ||
83 | } | ||
84 | |||
85 | public virtual string Version | ||
86 | { | ||
87 | get { return "1.0"; } | ||
88 | } | ||
89 | |||
90 | public virtual void Initialise() | ||
91 | { | ||
92 | m_log.Debug("[ASSET CACHE]: Asset cache null initialisation"); | ||
93 | } | ||
94 | |||
95 | public virtual void Initialise(IAssetServer assetServer) | ||
96 | { | ||
97 | m_log.Debug("[ASSET CACHE]: Asset cache server-specified initialisation"); | ||
98 | m_log.InfoFormat("[ASSET CACHE]: Asset cache initialisation [{0}/{1}]", Name, Version); | ||
99 | |||
100 | Reset(); | ||
101 | |||
102 | m_assetServer = assetServer; | ||
103 | m_assetServer.SetReceiver(this); | ||
104 | |||
105 | Thread assetCacheThread = new Thread(RunAssetManager); | ||
106 | assetCacheThread.Name = "AssetCacheThread"; | ||
107 | assetCacheThread.IsBackground = true; | ||
108 | assetCacheThread.Start(); | ||
109 | ThreadTracker.Add(assetCacheThread); | ||
110 | } | ||
111 | |||
112 | public virtual void Initialise(ConfigSettings settings, IAssetServer assetServer) | ||
113 | { | ||
114 | m_log.Debug("[ASSET CACHE]: Asset cache configured initialisation"); | ||
115 | Initialise(assetServer); | ||
116 | } | ||
117 | |||
118 | public void Dispose() | ||
119 | { | ||
120 | } | ||
121 | |||
122 | #endregion | ||
123 | |||
124 | public IAssetServer AssetServer | ||
125 | { | ||
126 | get { return m_assetServer; } | ||
127 | } | ||
128 | private IAssetServer m_assetServer; | ||
129 | |||
130 | public AssetCache() | ||
131 | { | ||
132 | m_log.Debug("[ASSET CACHE]: Asset cache (plugin constructor)"); | ||
133 | } | ||
134 | |||
135 | /// <summary> | ||
136 | /// Constructor. | ||
137 | /// </summary> | ||
138 | /// <param name="assetServer"></param> | ||
139 | public AssetCache(IAssetServer assetServer) | ||
140 | { | ||
141 | Initialise(assetServer); | ||
142 | } | ||
143 | |||
144 | public void ShowState() | ||
145 | { | ||
146 | m_log.InfoFormat("Memcache:{0} RequestLists:{1}", | ||
147 | m_memcache.Count, | ||
148 | // AssetRequests.Count, | ||
149 | // RequestedAssets.Count, | ||
150 | RequestLists.Count); | ||
151 | } | ||
152 | |||
153 | public void Clear() | ||
154 | { | ||
155 | m_log.Info("[ASSET CACHE]: Clearing Asset cache"); | ||
156 | |||
157 | if (StatsManager.SimExtraStats != null) | ||
158 | StatsManager.SimExtraStats.ClearAssetCacheStatistics(); | ||
159 | |||
160 | Reset(); | ||
161 | } | ||
162 | |||
163 | /// <summary> | ||
164 | /// Reset the cache. | ||
165 | /// </summary> | ||
166 | private void Reset() | ||
167 | { | ||
168 | AssetRequests = new List<AssetRequest>(); | ||
169 | RequestedAssets = new Dictionary<UUID, AssetRequest>(); | ||
170 | RequestLists = new Dictionary<UUID, AssetRequestsList>(); | ||
171 | } | ||
172 | |||
173 | /// <summary> | ||
174 | /// Process the asset queue which holds data which is packeted up and sent | ||
175 | /// directly back to the client. | ||
176 | /// </summary> | ||
177 | private void RunAssetManager() | ||
178 | { | ||
179 | while (true) | ||
180 | { | ||
181 | try | ||
182 | { | ||
183 | ProcessAssetQueue(); | ||
184 | Thread.Sleep(500); | ||
185 | } | ||
186 | catch (Exception e) | ||
187 | { | ||
188 | if (e != null) | ||
189 | { | ||
190 | m_log.ErrorFormat("[ASSET CACHE]: {0}", e); | ||
191 | } | ||
192 | else | ||
193 | { | ||
194 | // this looks weird, but we've seen this show up as an issue in unit tests, so leave it here until we know why | ||
195 | m_log.Error("[ASSET CACHE]: an exception was thrown in RunAssetManager, but is now null. Something is very wrong."); | ||
196 | } | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | |||
201 | public bool TryGetCachedAsset(UUID assetId, out AssetBase asset) | ||
202 | { | ||
203 | Object tmp; | ||
204 | if (m_memcache.TryGet(assetId, out tmp)) | ||
205 | { | ||
206 | asset = (AssetBase)tmp; | ||
207 | //m_log.Info("Retrieved from cache " + assetId); | ||
208 | return true; | ||
209 | } | ||
210 | |||
211 | asset = null; | ||
212 | return false; | ||
213 | } | ||
214 | |||
215 | public void GetAsset(UUID assetId, AssetRequestCallback callback, bool isTexture) | ||
216 | { | ||
217 | //m_log.DebugFormat("[ASSET CACHE]: Requesting {0} {1}", isTexture ? "texture" : "asset", assetId); | ||
218 | |||
219 | // Xantor 20080526: | ||
220 | // if a request is made for an asset which is not in the cache yet, but has already been requested by | ||
221 | // something else, queue up the callbacks on that requestor instead of swamping the assetserver | ||
222 | // with multiple requests for the same asset. | ||
223 | |||
224 | AssetBase asset; | ||
225 | |||
226 | if (TryGetCachedAsset(assetId, out asset)) | ||
227 | { | ||
228 | callback(assetId, asset); | ||
229 | } | ||
230 | else | ||
231 | { | ||
232 | // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); | ||
233 | |||
234 | NewAssetRequest req = new NewAssetRequest(callback); | ||
235 | AssetRequestsList requestList; | ||
236 | |||
237 | lock (RequestLists) | ||
238 | { | ||
239 | if (RequestLists.TryGetValue(assetId, out requestList)) // do we already have a request pending? | ||
240 | { | ||
241 | // m_log.DebugFormat("[ASSET CACHE]: Intercepted Duplicate request for {0} {1}", isTexture ? "texture" : "asset", assetId); | ||
242 | // add to callbacks for this assetId | ||
243 | RequestLists[assetId].Requests.Add(req); | ||
244 | } | ||
245 | else | ||
246 | { | ||
247 | // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); | ||
248 | requestList = new AssetRequestsList(); | ||
249 | requestList.TimeRequested = DateTime.Now; | ||
250 | requestList.Requests.Add(req); | ||
251 | |||
252 | RequestLists.Add(assetId, requestList); | ||
253 | |||
254 | m_assetServer.RequestAsset(assetId, isTexture); | ||
255 | } | ||
256 | } | ||
257 | } | ||
258 | } | ||
259 | |||
260 | public AssetBase GetAsset(UUID assetID, bool isTexture) | ||
261 | { | ||
262 | // I'm not going over 3 seconds since this will be blocking processing of all the other inbound | ||
263 | // packets from the client. | ||
264 | const int pollPeriod = 200; | ||
265 | int maxPolls = 15; | ||
266 | |||
267 | AssetBase asset; | ||
268 | |||
269 | if (TryGetCachedAsset(assetID, out asset)) | ||
270 | { | ||
271 | return asset; | ||
272 | } | ||
273 | |||
274 | m_assetServer.RequestAsset(assetID, isTexture); | ||
275 | |||
276 | do | ||
277 | { | ||
278 | Thread.Sleep(pollPeriod); | ||
279 | |||
280 | if (TryGetCachedAsset(assetID, out asset)) | ||
281 | { | ||
282 | return asset; | ||
283 | } | ||
284 | } | ||
285 | while (--maxPolls > 0); | ||
286 | |||
287 | m_log.WarnFormat("[ASSET CACHE]: {0} {1} was not received before the retrieval timeout was reached", | ||
288 | isTexture ? "texture" : "asset", assetID.ToString()); | ||
289 | |||
290 | return null; | ||
291 | } | ||
292 | |||
293 | public void AddAsset(AssetBase asset) | ||
294 | { | ||
295 | if (!m_memcache.Contains(asset.FullID)) | ||
296 | { | ||
297 | m_log.Info("[CACHE] Caching " + asset.FullID + " for 24 hours from last access"); | ||
298 | // Use 24 hour rolling asset cache. | ||
299 | m_memcache.AddOrUpdate(asset.FullID, asset, TimeSpan.FromHours(24)); | ||
300 | |||
301 | // According to http://wiki.secondlife.com/wiki/AssetUploadRequest, Local signifies that the | ||
302 | // information is stored locally. It could disappear, in which case we could send the | ||
303 | // ImageNotInDatabase packet to tell the client this. | ||
304 | // | ||
305 | // However, this doesn't quite appear to work with local textures that are part of an avatar's | ||
306 | // appearance texture set. Whilst sending an ImageNotInDatabase does trigger an automatic rebake | ||
307 | // and reupload by the client, if those assets aren't pushed to the asset server anyway, then | ||
308 | // on crossing onto another region server, other avatars can no longer get the required textures. | ||
309 | // There doesn't appear to be any signal from the sim to the newly region border crossed client | ||
310 | // asking it to reupload its local texture assets to that region server. | ||
311 | // | ||
312 | // One can think of other cunning ways around this. For instance, on a region crossing or teleport, | ||
313 | // the original sim could squirt local assets to the new sim. Or the new sim could have pointers | ||
314 | // to the original sim to fetch the 'local' assets (this is getting more complicated). | ||
315 | // | ||
316 | // But for now, we're going to take the easy way out and store local assets globally. | ||
317 | // | ||
318 | // TODO: Also, Temporary is now deprecated. We should start ignoring it and not passing it out from LLClientView. | ||
319 | if (!asset.Temporary || asset.Local) | ||
320 | { | ||
321 | m_assetServer.StoreAsset(asset); | ||
322 | } | ||
323 | |||
324 | if (StatsManager.SimExtraStats != null) | ||
325 | StatsManager.SimExtraStats.AddAsset(asset); | ||
326 | } | ||
327 | } | ||
328 | |||
329 | public void ExpireAsset(UUID uuid) | ||
330 | { | ||
331 | if (m_memcache.Contains(uuid)) | ||
332 | { | ||
333 | m_memcache.Remove(uuid); | ||
334 | |||
335 | if (StatsManager.SimExtraStats != null) | ||
336 | StatsManager.SimExtraStats.RemoveAsset(uuid); | ||
337 | } | ||
338 | } | ||
339 | |||
340 | // See IAssetReceiver | ||
341 | public virtual void AssetReceived(AssetBase asset, bool IsTexture) | ||
342 | { | ||
343 | AssetInfo assetInf = new AssetInfo(asset); | ||
344 | |||
345 | ProcessReceivedAsset(IsTexture, assetInf, null); | ||
346 | |||
347 | if (!m_memcache.Contains(assetInf.FullID)) | ||
348 | { | ||
349 | m_memcache.AddOrUpdate(assetInf.FullID, assetInf, TimeSpan.FromHours(24)); | ||
350 | |||
351 | if (StatsManager.SimExtraStats != null) | ||
352 | StatsManager.SimExtraStats.AddAsset(assetInf); | ||
353 | |||
354 | if (RequestedAssets.ContainsKey(assetInf.FullID)) | ||
355 | { | ||
356 | AssetRequest req = RequestedAssets[assetInf.FullID]; | ||
357 | req.AssetInf = assetInf; | ||
358 | req.NumPackets = CalculateNumPackets(assetInf.Data); | ||
359 | |||
360 | RequestedAssets.Remove(assetInf.FullID); | ||
361 | |||
362 | if (req.AssetRequestSource == 2 && assetInf.Type == 10) | ||
363 | { | ||
364 | // If it's a direct request for a script, drop it | ||
365 | // because it's a hacked client | ||
366 | } | ||
367 | else | ||
368 | { | ||
369 | lock (AssetRequests) | ||
370 | { | ||
371 | AssetRequests.Add(req); | ||
372 | } | ||
373 | } | ||
374 | } | ||
375 | } | ||
376 | |||
377 | // Notify requesters for this asset | ||
378 | AssetRequestsList reqList; | ||
379 | |||
380 | lock (RequestLists) | ||
381 | { | ||
382 | if (RequestLists.TryGetValue(asset.FullID, out reqList)) | ||
383 | RequestLists.Remove(asset.FullID); | ||
384 | } | ||
385 | |||
386 | if (reqList != null) | ||
387 | { | ||
388 | if (StatsManager.SimExtraStats != null) | ||
389 | StatsManager.SimExtraStats.AddAssetRequestTimeAfterCacheMiss(DateTime.Now - reqList.TimeRequested); | ||
390 | |||
391 | foreach (NewAssetRequest req in reqList.Requests) | ||
392 | { | ||
393 | // Xantor 20080526 are we really calling all the callbacks if multiple queued for 1 request? -- Yes, checked | ||
394 | // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.FullID); | ||
395 | req.Callback(asset.FullID, asset); | ||
396 | } | ||
397 | } | ||
398 | } | ||
399 | |||
400 | protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf, IUserService userService) | ||
401 | { | ||
402 | // if (!IsTexture && assetInf.ContainsReferences && false) | ||
403 | // { | ||
404 | // assetInf.Data = ProcessAssetData(assetInf.Data, userService); | ||
405 | // } | ||
406 | } | ||
407 | |||
408 | // See IAssetReceiver | ||
409 | public virtual void AssetNotFound(UUID assetId, bool isTexture) | ||
410 | { | ||
411 | // m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetId); | ||
412 | |||
413 | // Remember the fact that this asset could not be found to prevent delays from repeated requests | ||
414 | m_memcache.Add(assetId, null, TimeSpan.FromHours(24)); | ||
415 | |||
416 | // Notify requesters for this asset | ||
417 | AssetRequestsList reqList; | ||
418 | lock (RequestLists) | ||
419 | { | ||
420 | if (RequestLists.TryGetValue(assetId, out reqList)) | ||
421 | RequestLists.Remove(assetId); | ||
422 | } | ||
423 | |||
424 | if (reqList != null) | ||
425 | { | ||
426 | if (StatsManager.SimExtraStats != null) | ||
427 | StatsManager.SimExtraStats.AddAssetRequestTimeAfterCacheMiss(DateTime.Now - reqList.TimeRequested); | ||
428 | |||
429 | foreach (NewAssetRequest req in reqList.Requests) | ||
430 | { | ||
431 | req.Callback(assetId, null); | ||
432 | } | ||
433 | } | ||
434 | } | ||
435 | |||
436 | /// <summary> | ||
437 | /// Calculate the number of packets required to send the asset to the client. | ||
438 | /// </summary> | ||
439 | /// <param name="data"></param> | ||
440 | /// <returns></returns> | ||
441 | private static int CalculateNumPackets(byte[] data) | ||
442 | { | ||
443 | const uint m_maxPacketSize = 600; | ||
444 | int numPackets = 1; | ||
445 | |||
446 | if (data.LongLength > m_maxPacketSize) | ||
447 | { | ||
448 | // over max number of bytes so split up file | ||
449 | long restData = data.LongLength - m_maxPacketSize; | ||
450 | int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize); | ||
451 | numPackets += restPackets; | ||
452 | } | ||
453 | |||
454 | return numPackets; | ||
455 | } | ||
456 | |||
457 | public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) | ||
458 | { | ||
459 | UUID requestID = UUID.Zero; | ||
460 | byte source = 2; | ||
461 | if (transferRequest.TransferInfo.SourceType == 2) | ||
462 | { | ||
463 | //direct asset request | ||
464 | requestID = new UUID(transferRequest.TransferInfo.Params, 0); | ||
465 | } | ||
466 | else if (transferRequest.TransferInfo.SourceType == 3) | ||
467 | { | ||
468 | //inventory asset request | ||
469 | requestID = new UUID(transferRequest.TransferInfo.Params, 80); | ||
470 | source = 3; | ||
471 | //m_log.Debug("asset request " + requestID); | ||
472 | } | ||
473 | |||
474 | //check to see if asset is in local cache, if not we need to request it from asset server. | ||
475 | //m_log.Debug("asset request " + requestID); | ||
476 | if (!m_memcache.Contains(requestID)) | ||
477 | { | ||
478 | //not found asset | ||
479 | // so request from asset server | ||
480 | if (!RequestedAssets.ContainsKey(requestID)) | ||
481 | { | ||
482 | AssetRequest request = new AssetRequest(); | ||
483 | request.RequestUser = userInfo; | ||
484 | request.RequestAssetID = requestID; | ||
485 | request.TransferRequestID = transferRequest.TransferInfo.TransferID; | ||
486 | request.AssetRequestSource = source; | ||
487 | request.Params = transferRequest.TransferInfo.Params; | ||
488 | RequestedAssets.Add(requestID, request); | ||
489 | m_assetServer.RequestAsset(requestID, false); | ||
490 | } | ||
491 | |||
492 | return; | ||
493 | } | ||
494 | |||
495 | // It has an entry in our cache | ||
496 | AssetBase asset = (AssetBase)m_memcache[requestID]; | ||
497 | |||
498 | // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right. | ||
499 | if (null == asset) | ||
500 | { | ||
501 | //m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing. Dropping", requestID); | ||
502 | return; | ||
503 | } | ||
504 | |||
505 | // Scripts cannot be retrieved by direct request | ||
506 | if (transferRequest.TransferInfo.SourceType == 2 && asset.Type == 10) | ||
507 | return; | ||
508 | |||
509 | // The asset is knosn to exist and is in our cache, so add it to the AssetRequests list | ||
510 | AssetRequest req = new AssetRequest(); | ||
511 | req.RequestUser = userInfo; | ||
512 | req.RequestAssetID = requestID; | ||
513 | req.TransferRequestID = transferRequest.TransferInfo.TransferID; | ||
514 | req.AssetRequestSource = source; | ||
515 | req.Params = transferRequest.TransferInfo.Params; | ||
516 | req.AssetInf = new AssetInfo(asset); | ||
517 | req.NumPackets = CalculateNumPackets(asset.Data); | ||
518 | lock (AssetRequests) | ||
519 | { | ||
520 | AssetRequests.Add(req); | ||
521 | } | ||
522 | } | ||
523 | |||
524 | /// <summary> | ||
525 | /// Process the asset queue which sends packets directly back to the client. | ||
526 | /// </summary> | ||
527 | private void ProcessAssetQueue() | ||
528 | { | ||
529 | //should move the asset downloading to a module, like has been done with texture downloading | ||
530 | if (AssetRequests.Count == 0) | ||
531 | { | ||
532 | //no requests waiting | ||
533 | return; | ||
534 | } | ||
535 | |||
536 | // if less than 5, do all of them | ||
537 | int num = Math.Min(5, AssetRequests.Count); | ||
538 | |||
539 | AssetRequest req; | ||
540 | AssetRequestToClient req2 = new AssetRequestToClient(); | ||
541 | |||
542 | lock (AssetRequests) | ||
543 | { | ||
544 | for (int i = 0; i < num; i++) | ||
545 | { | ||
546 | req = AssetRequests[0]; | ||
547 | AssetRequests.RemoveAt(0); | ||
548 | req2.AssetInf = req.AssetInf; | ||
549 | req2.AssetRequestSource = req.AssetRequestSource; | ||
550 | req2.DataPointer = req.DataPointer; | ||
551 | req2.DiscardLevel = req.DiscardLevel; | ||
552 | req2.ImageInfo = req.ImageInfo; | ||
553 | req2.IsTextureRequest = req.IsTextureRequest; | ||
554 | req2.NumPackets = req.NumPackets; | ||
555 | req2.PacketCounter = req.PacketCounter; | ||
556 | req2.Params = req.Params; | ||
557 | req2.RequestAssetID = req.RequestAssetID; | ||
558 | req2.TransferRequestID = req.TransferRequestID; | ||
559 | req.RequestUser.SendAsset(req2); | ||
560 | } | ||
561 | } | ||
562 | } | ||
563 | |||
564 | public byte[] ProcessAssetData(byte[] assetData, IUserService userService) | ||
565 | { | ||
566 | string data = Encoding.ASCII.GetString(assetData); | ||
567 | |||
568 | data = ProcessAssetDataString(data, userService); | ||
569 | |||
570 | return Encoding.ASCII.GetBytes(data); | ||
571 | } | ||
572 | |||
573 | public string ProcessAssetDataString(string data, IUserService userService) | ||
574 | { | ||
575 | Regex regex = new Regex("(creator_url|owner_url)\\s+(\\S+)"); | ||
576 | |||
577 | data = regex.Replace(data, delegate(Match m) | ||
578 | { | ||
579 | string result = String.Empty; | ||
580 | |||
581 | string key = m.Groups[1].Captures[0].Value; | ||
582 | |||
583 | string value = m.Groups[2].Captures[0].Value; | ||
584 | |||
585 | Uri userUri; | ||
586 | |||
587 | switch (key) | ||
588 | { | ||
589 | case "creator_url": | ||
590 | userUri = new Uri(value); | ||
591 | result = "creator_id " + ResolveUserUri(userService, userUri); | ||
592 | break; | ||
593 | |||
594 | case "owner_url": | ||
595 | userUri = new Uri(value); | ||
596 | result = "owner_id " + ResolveUserUri(userService, userUri); | ||
597 | break; | ||
598 | } | ||
599 | |||
600 | return result; | ||
601 | }); | ||
602 | |||
603 | return data; | ||
604 | } | ||
605 | |||
606 | private Guid ResolveUserUri(IUserService userService, Uri userUri) | ||
607 | { | ||
608 | Guid id; | ||
609 | UserProfileData userProfile = userService.GetUserProfile(userUri); | ||
610 | if (userProfile == null) | ||
611 | { | ||
612 | id = Guid.Empty; | ||
613 | } | ||
614 | else | ||
615 | { | ||
616 | id = userProfile.ID.Guid; | ||
617 | } | ||
618 | return id; | ||
619 | } | ||
620 | |||
621 | |||
622 | public class AssetRequest | ||
623 | { | ||
624 | public IClientAPI RequestUser; | ||
625 | public UUID RequestAssetID; | ||
626 | public AssetInfo AssetInf; | ||
627 | public TextureImage ImageInfo; | ||
628 | public UUID TransferRequestID; | ||
629 | public long DataPointer = 0; | ||
630 | public int NumPackets = 0; | ||
631 | public int PacketCounter = 0; | ||
632 | public bool IsTextureRequest; | ||
633 | public byte AssetRequestSource = 2; | ||
634 | public byte[] Params = null; | ||
635 | //public bool AssetInCache; | ||
636 | //public int TimeRequested; | ||
637 | public int DiscardLevel = -1; | ||
638 | } | ||
639 | |||
640 | public class AssetInfo : AssetBase | ||
641 | { | ||
642 | public AssetInfo(AssetBase aBase) | ||
643 | { | ||
644 | Data = aBase.Data; | ||
645 | FullID = aBase.FullID; | ||
646 | Type = aBase.Type; | ||
647 | Name = aBase.Name; | ||
648 | Description = aBase.Description; | ||
649 | } | ||
650 | |||
651 | public const string Secret = "secret"; | ||
652 | } | ||
653 | |||
654 | public class TextureImage : AssetBase | ||
655 | { | ||
656 | public TextureImage(AssetBase aBase) | ||
657 | { | ||
658 | Data = aBase.Data; | ||
659 | FullID = aBase.FullID; | ||
660 | Type = aBase.Type; | ||
661 | Name = aBase.Name; | ||
662 | Description = aBase.Description; | ||
663 | } | ||
664 | } | ||
665 | |||
666 | /// <summary> | ||
667 | /// A list of requests for a particular asset. | ||
668 | /// </summary> | ||
669 | public class AssetRequestsList | ||
670 | { | ||
671 | /// <summary> | ||
672 | /// A list of requests for assets | ||
673 | /// </summary> | ||
674 | public List<NewAssetRequest> Requests = new List<NewAssetRequest>(); | ||
675 | |||
676 | /// <summary> | ||
677 | /// Record the time that this request was first made. | ||
678 | /// </summary> | ||
679 | public DateTime TimeRequested; | ||
680 | } | ||
681 | |||
682 | /// <summary> | ||
683 | /// Represent a request for an asset that has yet to be fulfilled. | ||
684 | /// </summary> | ||
685 | public class NewAssetRequest | ||
686 | { | ||
687 | public AssetRequestCallback Callback; | ||
688 | |||
689 | public NewAssetRequest(AssetRequestCallback callback) | ||
690 | { | ||
691 | Callback = callback; | ||
692 | } | ||
693 | } | ||
694 | } | ||
695 | } | ||
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs deleted file mode 100644 index 227744d..0000000 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ /dev/null | |||
@@ -1,113 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
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. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using OpenSim.Data; | ||
32 | |||
33 | namespace OpenSim.Framework.Communications.Cache | ||
34 | { | ||
35 | public class SQLAssetServer : AssetServerBase | ||
36 | { | ||
37 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
38 | |||
39 | #region IPlugin | ||
40 | |||
41 | public override string Name | ||
42 | { | ||
43 | get { return "SQL"; } | ||
44 | } | ||
45 | |||
46 | public override string Version | ||
47 | { | ||
48 | get { return "1.0"; } | ||
49 | } | ||
50 | |||
51 | public override void Initialise(ConfigSettings p_set) | ||
52 | { | ||
53 | m_log.Debug("[SQLAssetServer]: Plugin configured initialisation"); | ||
54 | Initialise(p_set.StandaloneAssetPlugin,p_set.StandaloneAssetSource); | ||
55 | } | ||
56 | |||
57 | #endregion | ||
58 | |||
59 | public SQLAssetServer() {} | ||
60 | |||
61 | public SQLAssetServer(string pluginName, string connect) | ||
62 | { | ||
63 | m_log.Debug("[SQLAssetServer]: Direct constructor"); | ||
64 | Initialise(pluginName, connect); | ||
65 | } | ||
66 | |||
67 | public void Initialise(string pluginName, string connect) | ||
68 | { | ||
69 | AddPlugin(pluginName, connect); | ||
70 | } | ||
71 | |||
72 | public SQLAssetServer(IAssetDataPlugin assetProvider) | ||
73 | { | ||
74 | m_assetProvider = assetProvider; | ||
75 | } | ||
76 | |||
77 | public void AddPlugin(string FileName, string connect) | ||
78 | { | ||
79 | m_log.Info("[SQLAssetServer]: AssetStorage: Attempting to load " + FileName); | ||
80 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | ||
81 | |||
82 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
83 | { | ||
84 | if (!pluginType.IsAbstract) | ||
85 | { | ||
86 | Type typeInterface = pluginType.GetInterface("IAssetDataPlugin", true); | ||
87 | |||
88 | if (typeInterface != null) | ||
89 | { | ||
90 | IAssetDataPlugin plug = | ||
91 | (IAssetDataPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
92 | m_assetProvider = plug; | ||
93 | m_assetProvider.Initialise(connect); | ||
94 | |||
95 | m_log.Info("[AssetStorage]: " + | ||
96 | "Added " + m_assetProvider.Name + " " + | ||
97 | m_assetProvider.Version); | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | } | ||
102 | |||
103 | protected override AssetBase GetAsset(AssetRequest req) | ||
104 | { | ||
105 | return m_assetProvider.FetchAsset(req.AssetID); | ||
106 | } | ||
107 | |||
108 | public override void StoreAsset(AssetBase asset) | ||
109 | { | ||
110 | m_assetProvider.CreateAsset(asset); | ||
111 | } | ||
112 | } | ||
113 | } | ||
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index b49e7bc..81fb8e1 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs | |||
@@ -72,25 +72,12 @@ namespace OpenSim.Framework.Communications | |||
72 | } | 72 | } |
73 | protected UserProfileCacheService m_userProfileCacheService; | 73 | protected UserProfileCacheService m_userProfileCacheService; |
74 | 74 | ||
75 | // protected AgentAssetTransactionsManager m_transactionsManager; | ||
76 | |||
77 | // public AgentAssetTransactionsManager TransactionsManager | ||
78 | // { | ||
79 | // get { return m_transactionsManager; } | ||
80 | // } | ||
81 | |||
82 | public IAvatarService AvatarService | 75 | public IAvatarService AvatarService |
83 | { | 76 | { |
84 | get { return m_avatarService; } | 77 | get { return m_avatarService; } |
85 | } | 78 | } |
86 | protected IAvatarService m_avatarService; | 79 | protected IAvatarService m_avatarService; |
87 | 80 | ||
88 | public IAssetCache AssetCache | ||
89 | { | ||
90 | get { return m_assetCache; } | ||
91 | } | ||
92 | protected IAssetCache m_assetCache; | ||
93 | |||
94 | public IInterServiceInventoryServices InterServiceInventoryService | 81 | public IInterServiceInventoryServices InterServiceInventoryService |
95 | { | 82 | { |
96 | get { return m_interServiceInventoryService; } | 83 | get { return m_interServiceInventoryService; } |
@@ -132,7 +119,6 @@ namespace OpenSim.Framework.Communications | |||
132 | bool dumpAssetsToFile, LibraryRootFolder libraryRootFolder) | 119 | bool dumpAssetsToFile, LibraryRootFolder libraryRootFolder) |
133 | { | 120 | { |
134 | m_networkServersInfo = serversInfo; | 121 | m_networkServersInfo = serversInfo; |
135 | m_assetCache = assetCache; | ||
136 | m_userProfileCacheService = new UserProfileCacheService(this, libraryRootFolder); | 122 | m_userProfileCacheService = new UserProfileCacheService(this, libraryRootFolder); |
137 | m_httpServer = httpServer; | 123 | m_httpServer = httpServer; |
138 | } | 124 | } |
diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index a5ee549..a40adf3 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs | |||
@@ -43,51 +43,6 @@ namespace OpenSim.Framework.Communications.Tests | |||
43 | [TestFixture] | 43 | [TestFixture] |
44 | public class AssetCacheTests | 44 | public class AssetCacheTests |
45 | { | 45 | { |
46 | protected UUID m_assetIdReceived; | ||
47 | protected AssetBase m_assetReceived; | ||
48 | |||
49 | /// <summary> | ||
50 | /// Test the 'asynchronous' get asset mechanism (though this won't be done asynchronously within this test) | ||
51 | /// </summary> | ||
52 | [Test] | ||
53 | public void TestGetAsset() | ||
54 | { | ||
55 | UUID assetId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
56 | byte[] assetData = new byte[] { 3, 2, 1 }; | ||
57 | |||
58 | AssetBase asset = new AssetBase(); | ||
59 | asset.FullID = assetId; | ||
60 | asset.Data = assetData; | ||
61 | |||
62 | TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin(); | ||
63 | assetPlugin.CreateAsset(asset); | ||
64 | |||
65 | SQLAssetServer assetServer = new SQLAssetServer(assetPlugin); | ||
66 | IAssetCache assetCache = new AssetCache(assetServer); | ||
67 | |||
68 | assetCache.GetAsset(assetId, AssetRequestCallback, false); | ||
69 | |||
70 | // Manually pump the asset server | ||
71 | while (assetServer.HasWaitingRequests()) | ||
72 | assetServer.ProcessNextRequest(); | ||
73 | |||
74 | Assert.That( | ||
75 | assetId, Is.EqualTo(m_assetIdReceived), "Asset id stored differs from asset id received"); | ||
76 | Assert.That( | ||
77 | assetData, Is.EqualTo(m_assetReceived.Data), "Asset data stored differs from asset data received"); | ||
78 | } | ||
79 | |||
80 | private void AssetRequestCallback(UUID assetId, AssetBase asset) | ||
81 | { | ||
82 | m_assetIdReceived = assetId; | ||
83 | m_assetReceived = asset; | ||
84 | |||
85 | lock (this) | ||
86 | { | ||
87 | Monitor.PulseAll(this); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | private class FakeUserService : IUserService | 46 | private class FakeUserService : IUserService |
92 | { | 47 | { |
93 | public void AddTemporaryUserProfile(UserProfileData userProfile) | 48 | public void AddTemporaryUserProfile(UserProfileData userProfile) |
@@ -109,7 +64,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
109 | { | 64 | { |
110 | UserProfileData userProfile = new UserProfileData(); | 65 | UserProfileData userProfile = new UserProfileData(); |
111 | 66 | ||
112 | userProfile.ID = new UUID( Util.GetHashGuid( uri.ToString(), AssetCache.AssetInfo.Secret )); | 67 | // userProfile.ID = new UUID( Util.GetHashGuid( uri.ToString(), AssetCache.AssetInfo.Secret )); |
113 | 68 | ||
114 | return userProfile; | 69 | return userProfile; |
115 | } | 70 | } |
@@ -189,19 +144,5 @@ namespace OpenSim.Framework.Communications.Tests | |||
189 | return true; | 144 | return true; |
190 | } | 145 | } |
191 | } | 146 | } |
192 | |||
193 | [Test] | ||
194 | public void TestProcessAssetData() | ||
195 | { | ||
196 | string url = "http://host/dir/"; | ||
197 | string creatorData = " creator_url " + url + " "; | ||
198 | string ownerData = " owner_url " + url + " "; | ||
199 | |||
200 | AssetCache assetCache = new AssetCache(); | ||
201 | FakeUserService fakeUserService = new FakeUserService(); | ||
202 | |||
203 | Assert.AreEqual(" creator_id " + Util.GetHashGuid(url, AssetCache.AssetInfo.Secret) + " ", assetCache.ProcessAssetDataString(creatorData, fakeUserService)); | ||
204 | Assert.AreEqual(" owner_id " + Util.GetHashGuid(url, AssetCache.AssetInfo.Secret) + " ", assetCache.ProcessAssetDataString(ownerData, fakeUserService)); | ||
205 | } | ||
206 | } | 147 | } |
207 | } | 148 | } |
diff --git a/OpenSim/Framework/ConfigSettings.cs b/OpenSim/Framework/ConfigSettings.cs index 77b05c8..93efffa 100644 --- a/OpenSim/Framework/ConfigSettings.cs +++ b/OpenSim/Framework/ConfigSettings.cs | |||
@@ -108,14 +108,6 @@ namespace OpenSim.Framework | |||
108 | set { m_standaloneInventoryPlugin = value; } | 108 | set { m_standaloneInventoryPlugin = value; } |
109 | } | 109 | } |
110 | 110 | ||
111 | private string m_standaloneAssetPlugin; | ||
112 | |||
113 | public string StandaloneAssetPlugin | ||
114 | { | ||
115 | get { return m_standaloneAssetPlugin; } | ||
116 | set { m_standaloneAssetPlugin = value; } | ||
117 | } | ||
118 | |||
119 | private string m_standaloneUserPlugin; | 111 | private string m_standaloneUserPlugin; |
120 | 112 | ||
121 | public string StandaloneUserPlugin | 113 | public string StandaloneUserPlugin |
@@ -132,14 +124,6 @@ namespace OpenSim.Framework | |||
132 | set { m_standaloneInventorySource = value; } | 124 | set { m_standaloneInventorySource = value; } |
133 | } | 125 | } |
134 | 126 | ||
135 | private string m_standaloneAssetSource; | ||
136 | |||
137 | public string StandaloneAssetSource | ||
138 | { | ||
139 | get { return m_standaloneAssetSource; } | ||
140 | set { m_standaloneAssetSource = value; } | ||
141 | } | ||
142 | |||
143 | private string m_standaloneUserSource; | 127 | private string m_standaloneUserSource; |
144 | 128 | ||
145 | public string StandaloneUserSource | 129 | public string StandaloneUserSource |
@@ -148,22 +132,6 @@ namespace OpenSim.Framework | |||
148 | set { m_standaloneUserSource = value; } | 132 | set { m_standaloneUserSource = value; } |
149 | } | 133 | } |
150 | 134 | ||
151 | private string m_assetStorage = "local"; | ||
152 | |||
153 | public string AssetStorage | ||
154 | { | ||
155 | get { return m_assetStorage; } | ||
156 | set { m_assetStorage = value; } | ||
157 | } | ||
158 | |||
159 | private string m_assetCache; | ||
160 | |||
161 | public string AssetCache | ||
162 | { | ||
163 | get { return m_assetCache; } | ||
164 | set { m_assetCache = value; } | ||
165 | } | ||
166 | |||
167 | protected string m_storageConnectionString; | 135 | protected string m_storageConnectionString; |
168 | 136 | ||
169 | public string StorageConnectionString | 137 | public string StorageConnectionString |
@@ -180,14 +148,6 @@ namespace OpenSim.Framework | |||
180 | set { m_estateConnectionString = value; } | 148 | set { m_estateConnectionString = value; } |
181 | } | 149 | } |
182 | 150 | ||
183 | protected bool m_dumpAssetsToFile; | ||
184 | |||
185 | public bool DumpAssetsToFile | ||
186 | { | ||
187 | get { return m_dumpAssetsToFile; } | ||
188 | set { m_dumpAssetsToFile = value; } | ||
189 | } | ||
190 | |||
191 | protected string m_librariesXMLFile; | 151 | protected string m_librariesXMLFile; |
192 | public string LibrariesXMLFile | 152 | public string LibrariesXMLFile |
193 | { | 153 | { |
@@ -200,18 +160,6 @@ namespace OpenSim.Framework | |||
200 | m_librariesXMLFile = value; | 160 | m_librariesXMLFile = value; |
201 | } | 161 | } |
202 | } | 162 | } |
203 | protected string m_assetSetsXMLFile; | ||
204 | public string AssetSetsXMLFile | ||
205 | { | ||
206 | get | ||
207 | { | ||
208 | return m_assetSetsXMLFile; | ||
209 | } | ||
210 | set | ||
211 | { | ||
212 | m_assetSetsXMLFile = value; | ||
213 | } | ||
214 | } | ||
215 | 163 | ||
216 | public const uint DefaultAssetServerHttpPort = 8003; | 164 | public const uint DefaultAssetServerHttpPort = 8003; |
217 | public const uint DefaultRegionHttpPort = 9000; | 165 | public const uint DefaultRegionHttpPort = 9000; |
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs index fea3e94..467b099 100644 --- a/OpenSim/Region/Application/ConfigurationLoader.cs +++ b/OpenSim/Region/Application/ConfigurationLoader.cs | |||
@@ -219,7 +219,6 @@ namespace OpenSim | |||
219 | config.Set("startup_console_commands_file", String.Empty); | 219 | config.Set("startup_console_commands_file", String.Empty); |
220 | config.Set("shutdown_console_commands_file", String.Empty); | 220 | config.Set("shutdown_console_commands_file", String.Empty); |
221 | config.Set("DefaultScriptEngine", "XEngine"); | 221 | config.Set("DefaultScriptEngine", "XEngine"); |
222 | config.Set("asset_database", "default"); | ||
223 | config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll"); | 222 | config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll"); |
224 | // life doesn't really work without this | 223 | // life doesn't really work without this |
225 | config.Set("EventQueue", true); | 224 | config.Set("EventQueue", true); |
@@ -237,11 +236,7 @@ namespace OpenSim | |||
237 | config.Set("inventory_source", ""); | 236 | config.Set("inventory_source", ""); |
238 | config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll"); | 237 | config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll"); |
239 | config.Set("user_source", ""); | 238 | config.Set("user_source", ""); |
240 | config.Set("asset_plugin", "OpenSim.Data.SQLite.dll"); | ||
241 | config.Set("asset_source", "URI=file:Asset.db,version=3"); | ||
242 | config.Set("LibrariesXMLFile", string.Format(".{0}inventory{0}Libraries.xml", Path.DirectorySeparatorChar)); | 239 | config.Set("LibrariesXMLFile", string.Format(".{0}inventory{0}Libraries.xml", Path.DirectorySeparatorChar)); |
243 | config.Set("AssetSetsXMLFile", string.Format(".{0}assets{0}AssetSets.xml", Path.DirectorySeparatorChar)); | ||
244 | config.Set("dump_assets_to_file", false); | ||
245 | } | 240 | } |
246 | 241 | ||
247 | { | 242 | { |
@@ -292,10 +287,6 @@ namespace OpenSim | |||
292 | = startupConfig.GetString("storage_connection_string"); | 287 | = startupConfig.GetString("storage_connection_string"); |
293 | m_configSettings.EstateConnectionString | 288 | m_configSettings.EstateConnectionString |
294 | = startupConfig.GetString("estate_connection_string", m_configSettings.StorageConnectionString); | 289 | = startupConfig.GetString("estate_connection_string", m_configSettings.StorageConnectionString); |
295 | m_configSettings.AssetStorage | ||
296 | = startupConfig.GetString("asset_database"); | ||
297 | m_configSettings.AssetCache | ||
298 | = startupConfig.GetString("AssetCache", "OpenSim.Framework.Communications.Cache.AssetCache"); | ||
299 | m_configSettings.ClientstackDll | 290 | m_configSettings.ClientstackDll |
300 | = startupConfig.GetString("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll"); | 291 | = startupConfig.GetString("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll"); |
301 | } | 292 | } |
@@ -310,16 +301,11 @@ namespace OpenSim | |||
310 | m_configSettings.StandaloneInventorySource = standaloneConfig.GetString("inventory_source"); | 301 | m_configSettings.StandaloneInventorySource = standaloneConfig.GetString("inventory_source"); |
311 | m_configSettings.StandaloneUserPlugin = standaloneConfig.GetString("userDatabase_plugin"); | 302 | m_configSettings.StandaloneUserPlugin = standaloneConfig.GetString("userDatabase_plugin"); |
312 | m_configSettings.StandaloneUserSource = standaloneConfig.GetString("user_source"); | 303 | m_configSettings.StandaloneUserSource = standaloneConfig.GetString("user_source"); |
313 | m_configSettings.StandaloneAssetPlugin = standaloneConfig.GetString("asset_plugin"); | ||
314 | m_configSettings.StandaloneAssetSource = standaloneConfig.GetString("asset_source"); | ||
315 | 304 | ||
316 | m_configSettings.LibrariesXMLFile = standaloneConfig.GetString("LibrariesXMLFile"); | 305 | m_configSettings.LibrariesXMLFile = standaloneConfig.GetString("LibrariesXMLFile"); |
317 | m_configSettings.AssetSetsXMLFile = standaloneConfig.GetString("AssetSetsXMLFile"); | ||
318 | |||
319 | m_configSettings.DumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file", false); | ||
320 | } | 306 | } |
321 | 307 | ||
322 | m_networkServersInfo.loadFromConfiguration(m_config.Source); | 308 | m_networkServersInfo.loadFromConfiguration(m_config.Source); |
323 | } | 309 | } |
324 | } | 310 | } |
325 | } \ No newline at end of file | 311 | } |
diff --git a/OpenSim/Region/Application/HGCommands.cs b/OpenSim/Region/Application/HGCommands.cs index 07d3dcb..1786e54 100644 --- a/OpenSim/Region/Application/HGCommands.cs +++ b/OpenSim/Region/Application/HGCommands.cs | |||
@@ -57,7 +57,7 @@ namespace OpenSim | |||
57 | return | 57 | return |
58 | new HGScene( | 58 | new HGScene( |
59 | regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager, | 59 | regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager, |
60 | m_moduleLoader, m_configSettings.DumpAssetsToFile, m_configSettings.PhysicalPrim, | 60 | m_moduleLoader, false, m_configSettings.PhysicalPrim, |
61 | m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); | 61 | m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); |
62 | } | 62 | } |
63 | 63 | ||
@@ -270,4 +270,4 @@ namespace OpenSim | |||
270 | } | 270 | } |
271 | 271 | ||
272 | } | 272 | } |
273 | } \ No newline at end of file | 273 | } |
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index cc1f59a..14ae5f1 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -281,7 +281,6 @@ namespace OpenSim | |||
281 | // Called from base.StartUp() | 281 | // Called from base.StartUp() |
282 | 282 | ||
283 | m_httpServerPort = m_networkServersInfo.HttpListenerPort; | 283 | m_httpServerPort = m_networkServersInfo.HttpListenerPort; |
284 | InitialiseAssetCache(); | ||
285 | m_sceneManager.OnRestartSim += handleRestartRegion; | 284 | m_sceneManager.OnRestartSim += handleRestartRegion; |
286 | } | 285 | } |
287 | 286 | ||
@@ -296,167 +295,6 @@ namespace OpenSim | |||
296 | /// returns an IAssetCache implementation, if possible. This is a virtual | 295 | /// returns an IAssetCache implementation, if possible. This is a virtual |
297 | /// method. | 296 | /// method. |
298 | /// </summary> | 297 | /// </summary> |
299 | protected virtual void InitialiseAssetCache() | ||
300 | { | ||
301 | LegacyAssetClientPluginInitialiser linit = null; | ||
302 | CryptoAssetClientPluginInitialiser cinit = null; | ||
303 | AssetClientPluginInitialiser init = null; | ||
304 | |||
305 | IAssetServer assetServer = null; | ||
306 | string mode = m_configSettings.AssetStorage; | ||
307 | |||
308 | if (mode == null | mode == String.Empty) | ||
309 | mode = "default"; | ||
310 | |||
311 | // If "default" is specified, then the value is adjusted | ||
312 | // according to whether or not the server is running in | ||
313 | // standalone mode. | ||
314 | if (mode.ToLower() == "default") | ||
315 | { | ||
316 | if (m_configSettings.Standalone == false) | ||
317 | mode = "grid"; | ||
318 | else | ||
319 | mode = "local"; | ||
320 | } | ||
321 | |||
322 | switch (mode.ToLower()) | ||
323 | { | ||
324 | // If grid is specified then the grid server is chose regardless | ||
325 | // of whether the server is standalone. | ||
326 | case "grid": | ||
327 | linit = new LegacyAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL); | ||
328 | assetServer = loadAssetServer("Grid", linit); | ||
329 | break; | ||
330 | |||
331 | // If cryptogrid is specified then the cryptogrid server is chose regardless | ||
332 | // of whether the server is standalone. | ||
333 | case "cryptogrid": | ||
334 | cinit = new CryptoAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL, | ||
335 | Environment.CurrentDirectory, true); | ||
336 | assetServer = loadAssetServer("Crypto", cinit); | ||
337 | break; | ||
338 | |||
339 | // If cryptogrid_eou is specified then the cryptogrid_eou server is chose regardless | ||
340 | // of whether the server is standalone. | ||
341 | case "cryptogrid_eou": | ||
342 | cinit = new CryptoAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL, | ||
343 | Environment.CurrentDirectory, false); | ||
344 | assetServer = loadAssetServer("Crypto", cinit); | ||
345 | break; | ||
346 | |||
347 | // If file is specified then the file server is chose regardless | ||
348 | // of whether the server is standalone. | ||
349 | case "file": | ||
350 | linit = new LegacyAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL); | ||
351 | assetServer = loadAssetServer("File", linit); | ||
352 | break; | ||
353 | |||
354 | // If local is specified then we're going to use the local SQL server | ||
355 | // implementation. We drop through, because that will be the fallback | ||
356 | // for the following default clause too. | ||
357 | case "local": | ||
358 | break; | ||
359 | |||
360 | // If the asset_database value is none of the previously mentioned strings, then we | ||
361 | // try to load a turnkey plugin that matches this value. If not we drop through to | ||
362 | // a local default. | ||
363 | default: | ||
364 | try | ||
365 | { | ||
366 | init = new AssetClientPluginInitialiser(m_configSettings); | ||
367 | assetServer = loadAssetServer(m_configSettings.AssetStorage, init); | ||
368 | break; | ||
369 | } | ||
370 | catch | ||
371 | { | ||
372 | } | ||
373 | m_log.Info("[OPENSIMBASE]: Default assetserver will be used"); | ||
374 | break; | ||
375 | } | ||
376 | |||
377 | // Open the local SQL-based database asset server | ||
378 | if (assetServer == null) | ||
379 | { | ||
380 | init = new AssetClientPluginInitialiser(m_configSettings); | ||
381 | SQLAssetServer sqlAssetServer = (SQLAssetServer) loadAssetServer("SQL", init); | ||
382 | sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile); | ||
383 | assetServer = sqlAssetServer; | ||
384 | } | ||
385 | |||
386 | // Initialize the asset cache, passing a reference to the selected | ||
387 | // asset server interface. | ||
388 | m_assetCache = ResolveAssetCache(assetServer); | ||
389 | |||
390 | assetServer.Start(); | ||
391 | } | ||
392 | |||
393 | // This method loads the identified asset server, passing an approrpiately | ||
394 | // initialized Initialise wrapper. There should to be exactly one match, | ||
395 | // if not, then the first match is used. | ||
396 | private IAssetServer loadAssetServer(string id, PluginInitialiserBase pi) | ||
397 | { | ||
398 | if (id != null && id != String.Empty) | ||
399 | { | ||
400 | m_log.DebugFormat("[OPENSIMBASE] Attempting to load asset server id={0}", id); | ||
401 | |||
402 | try | ||
403 | { | ||
404 | PluginLoader<IAssetServer> loader = new PluginLoader<IAssetServer>(pi); | ||
405 | loader.AddFilter(PLUGIN_ASSET_SERVER_CLIENT, new PluginProviderFilter(id)); | ||
406 | loader.Load(PLUGIN_ASSET_SERVER_CLIENT); | ||
407 | |||
408 | if (loader.Plugins.Count > 0) | ||
409 | { | ||
410 | m_log.DebugFormat("[OPENSIMBASE] Asset server {0} loaded", id); | ||
411 | return (IAssetServer) loader.Plugins[0]; | ||
412 | } | ||
413 | } | ||
414 | catch (Exception e) | ||
415 | { | ||
416 | m_log.DebugFormat("[OPENSIMBASE] Asset server {0} not loaded ({1})", id, e.Message); | ||
417 | } | ||
418 | } | ||
419 | return null; | ||
420 | } | ||
421 | |||
422 | /// <summary> | ||
423 | /// Attempt to instantiate an IAssetCache implementation, using the | ||
424 | /// provided IAssetServer reference. | ||
425 | /// An asset cache implementation must provide a constructor that | ||
426 | /// accepts two parameters; | ||
427 | /// [1] A ConfigSettings reference. | ||
428 | /// [2] An IAssetServer reference. | ||
429 | /// The AssetCache value is obtained from the | ||
430 | /// [StartUp]/AssetCache value in the configuration file. | ||
431 | /// </summary> | ||
432 | protected virtual IAssetCache ResolveAssetCache(IAssetServer assetServer) | ||
433 | { | ||
434 | IAssetCache assetCache = null; | ||
435 | if (m_configSettings.AssetCache != null && m_configSettings.AssetCache != String.Empty) | ||
436 | { | ||
437 | m_log.DebugFormat("[OPENSIMBASE]: Attempting to load asset cache id = {0}", m_configSettings.AssetCache); | ||
438 | |||
439 | try | ||
440 | { | ||
441 | PluginInitialiserBase init = new AssetCachePluginInitialiser(m_configSettings, assetServer); | ||
442 | PluginLoader<IAssetCache> loader = new PluginLoader<IAssetCache>(init); | ||
443 | loader.AddFilter(PLUGIN_ASSET_CACHE, new PluginProviderFilter(m_configSettings.AssetCache)); | ||
444 | |||
445 | loader.Load(PLUGIN_ASSET_CACHE); | ||
446 | if (loader.Plugins.Count > 0) | ||
447 | assetCache = (IAssetCache) loader.Plugins[0]; | ||
448 | } | ||
449 | catch (Exception e) | ||
450 | { | ||
451 | m_log.Error("[OPENSIMBASE]: ResolveAssetCache failed"); | ||
452 | m_log.Error(e); | ||
453 | } | ||
454 | } | ||
455 | |||
456 | // If everything else fails, we force load the built-in asset cache | ||
457 | return (IAssetCache) ((assetCache != null) ? assetCache : new AssetCache(assetServer)); | ||
458 | } | ||
459 | |||
460 | public void ProcessLogin(bool LoginEnabled) | 298 | public void ProcessLogin(bool LoginEnabled) |
461 | { | 299 | { |
462 | if (LoginEnabled) | 300 | if (LoginEnabled) |
@@ -755,7 +593,7 @@ namespace OpenSim | |||
755 | 593 | ||
756 | return new Scene( | 594 | return new Scene( |
757 | regionInfo, circuitManager, m_commsManager, sceneGridService, | 595 | regionInfo, circuitManager, m_commsManager, sceneGridService, |
758 | storageManager, m_moduleLoader, m_configSettings.DumpAssetsToFile, m_configSettings.PhysicalPrim, | 596 | storageManager, m_moduleLoader, false, m_configSettings.PhysicalPrim, |
759 | m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); | 597 | m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); |
760 | } | 598 | } |
761 | 599 | ||
diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs index 5c2fe33..e9e4e56 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs | |||
@@ -73,7 +73,6 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
73 | m_interServiceInventoryService = inventoryService; | 73 | m_interServiceInventoryService = inventoryService; |
74 | inventoryService.UserProfileCache = UserProfileCacheService; | 74 | inventoryService.UserProfileCache = UserProfileCacheService; |
75 | 75 | ||
76 | m_assetCache = assetCache; | ||
77 | // Let's swap to always be secure access to inventory | 76 | // Let's swap to always be secure access to inventory |
78 | AddSecureInventoryService((ISecureInventoryService)inventoryService); | 77 | AddSecureInventoryService((ISecureInventoryService)inventoryService); |
79 | m_inventoryServices = null; | 78 | m_inventoryServices = null; |
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index 0adafd3..96271a3 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs | |||
@@ -70,24 +70,6 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
70 | 70 | ||
71 | scene.EventManager.OnNewClient += NewClient; | 71 | scene.EventManager.OnNewClient += NewClient; |
72 | } | 72 | } |
73 | |||
74 | if (m_scene == null) | ||
75 | { | ||
76 | m_scene = scene; | ||
77 | if (config.Configs["StandAlone"] != null) | ||
78 | { | ||
79 | try | ||
80 | { | ||
81 | m_dumpAssetsToFile = config.Configs["StandAlone"].GetBoolean("dump_assets_to_file", false); | ||
82 | } | ||
83 | catch (Exception) | ||
84 | { | ||
85 | } | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | } | ||
90 | } | ||
91 | } | 73 | } |
92 | 74 | ||
93 | public void PostInitialise() | 75 | public void PostInitialise() |
diff --git a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs index 44efb8c..7589e3e 100644 --- a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs +++ b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs | |||
@@ -57,9 +57,6 @@ namespace OpenSim.Tests.Common.Mock | |||
57 | public TestCommunicationsManager(NetworkServersInfo serversInfo) | 57 | public TestCommunicationsManager(NetworkServersInfo serversInfo) |
58 | : base(serversInfo, new BaseHttpServer(666), null, false, null) | 58 | : base(serversInfo, new BaseHttpServer(666), null, false, null) |
59 | { | 59 | { |
60 | SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin()); | ||
61 | m_assetCache = new AssetCache(assetService); | ||
62 | |||
63 | LocalInventoryService lis = new LocalInventoryService(); | 60 | LocalInventoryService lis = new LocalInventoryService(); |
64 | m_inventoryDataPlugin = new TestInventoryDataPlugin(); | 61 | m_inventoryDataPlugin = new TestInventoryDataPlugin(); |
65 | lis.AddPlugin(m_inventoryDataPlugin); | 62 | lis.AddPlugin(m_inventoryDataPlugin); |
@@ -76,13 +73,5 @@ namespace OpenSim.Tests.Common.Mock | |||
76 | LocalBackEndServices gs = new LocalBackEndServices(); | 73 | LocalBackEndServices gs = new LocalBackEndServices(); |
77 | m_gridService = gs; | 74 | m_gridService = gs; |
78 | } | 75 | } |
79 | |||
80 | /// <summary> | ||
81 | /// Start services that take care of business using their own threads. | ||
82 | /// </summary> | ||
83 | public void StartServices() | ||
84 | { | ||
85 | m_assetCache.AssetServer.Start(); | ||
86 | } | ||
87 | } | 76 | } |
88 | } | 77 | } |
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index b64b840..434b734 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | |||
@@ -147,9 +147,6 @@ namespace OpenSim.Tests.Common.Setup | |||
147 | testScene.PhysicsScene | 147 | testScene.PhysicsScene |
148 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test"); | 148 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test"); |
149 | 149 | ||
150 | if (startServices) | ||
151 | cm.StartServices(); | ||
152 | |||
153 | return testScene; | 150 | return testScene; |
154 | } | 151 | } |
155 | 152 | ||