diff options
Diffstat (limited to 'OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs')
-rw-r--r-- | OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs | 119 |
1 files changed, 101 insertions, 18 deletions
diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs index 2c1d946..795ca2e 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs | |||
@@ -41,7 +41,7 @@ using OpenMetaverse; | |||
41 | 41 | ||
42 | namespace OpenSim.Services.Connectors | 42 | namespace OpenSim.Services.Connectors |
43 | { | 43 | { |
44 | public class AssetServicesConnector : IAssetService | 44 | public class AssetServicesConnector : BaseServiceConnector, IAssetService |
45 | { | 45 | { |
46 | private static readonly ILog m_log = | 46 | private static readonly ILog m_log = |
47 | LogManager.GetLogger( | 47 | LogManager.GetLogger( |
@@ -82,6 +82,7 @@ namespace OpenSim.Services.Connectors | |||
82 | } | 82 | } |
83 | 83 | ||
84 | public AssetServicesConnector(IConfigSource source) | 84 | public AssetServicesConnector(IConfigSource source) |
85 | : base(source, "AssetService") | ||
85 | { | 86 | { |
86 | Initialise(source); | 87 | Initialise(source); |
87 | } | 88 | } |
@@ -221,8 +222,16 @@ namespace OpenSim.Services.Connectors | |||
221 | 222 | ||
222 | if (asset == null || asset.Data == null || asset.Data.Length == 0) | 223 | if (asset == null || asset.Data == null || asset.Data.Length == 0) |
223 | { | 224 | { |
224 | asset = SynchronousRestObjectRequester. | 225 | // XXX: Commented out for now since this has either never been properly operational or not for some time |
225 | MakeRequest<int, AssetBase>("GET", uri, 0, m_maxAssetRequestConcurrency); | 226 | // as m_maxAssetRequestConcurrency was being passed as the timeout, not a concurrency limiting option. |
227 | // Wasn't noticed before because timeout wasn't actually used. | ||
228 | // Not attempting concurrency setting for now as this omission was discovered in release candidate | ||
229 | // phase for OpenSimulator 0.8. Need to revisit afterwards. | ||
230 | // asset | ||
231 | // = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>( | ||
232 | // "GET", uri, 0, m_maxAssetRequestConcurrency); | ||
233 | |||
234 | asset = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, m_Auth); | ||
226 | 235 | ||
227 | if (m_Cache != null) | 236 | if (m_Cache != null) |
228 | m_Cache.Cache(asset); | 237 | m_Cache.Cache(asset); |
@@ -252,8 +261,7 @@ namespace OpenSim.Services.Connectors | |||
252 | 261 | ||
253 | string uri = MapServer(id) + "/assets/" + id + "/metadata"; | 262 | string uri = MapServer(id) + "/assets/" + id + "/metadata"; |
254 | 263 | ||
255 | AssetMetadata asset = SynchronousRestObjectRequester. | 264 | AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest<int, AssetMetadata>("GET", uri, 0, m_Auth); |
256 | MakeRequest<int, AssetMetadata>("GET", uri, 0); | ||
257 | return asset; | 265 | return asset; |
258 | } | 266 | } |
259 | 267 | ||
@@ -267,29 +275,45 @@ namespace OpenSim.Services.Connectors | |||
267 | return fullAsset.Data; | 275 | return fullAsset.Data; |
268 | } | 276 | } |
269 | 277 | ||
278 | <<<<<<< HEAD | ||
279 | using (RestClient rc = new RestClient(m_ServerURI)) | ||
280 | { | ||
281 | rc.AddResourcePath("assets"); | ||
282 | rc.AddResourcePath(id); | ||
283 | rc.AddResourcePath("data"); | ||
284 | ======= | ||
270 | RestClient rc = new RestClient(MapServer(id)); | 285 | RestClient rc = new RestClient(MapServer(id)); |
271 | rc.AddResourcePath("assets"); | 286 | rc.AddResourcePath("assets"); |
272 | rc.AddResourcePath(id); | 287 | rc.AddResourcePath(id); |
273 | rc.AddResourcePath("data"); | 288 | rc.AddResourcePath("data"); |
289 | >>>>>>> avn/ubitvar | ||
274 | 290 | ||
275 | rc.RequestMethod = "GET"; | 291 | rc.RequestMethod = "GET"; |
276 | 292 | ||
277 | Stream s = rc.Request(); | 293 | Stream s = rc.Request(m_Auth); |
278 | 294 | ||
279 | if (s == null) | 295 | if (s == null) |
280 | return null; | 296 | return null; |
281 | 297 | ||
282 | if (s.Length > 0) | 298 | if (s.Length > 0) |
283 | { | 299 | { |
284 | byte[] ret = new byte[s.Length]; | 300 | byte[] ret = new byte[s.Length]; |
285 | s.Read(ret, 0, (int)s.Length); | 301 | s.Read(ret, 0, (int)s.Length); |
286 | 302 | ||
303 | <<<<<<< HEAD | ||
304 | return ret; | ||
305 | } | ||
306 | |||
307 | return null; | ||
308 | } | ||
309 | ======= | ||
287 | s.Close(); | 310 | s.Close(); |
288 | return ret; | 311 | return ret; |
289 | } | 312 | } |
290 | 313 | ||
291 | s.Close(); | 314 | s.Close(); |
292 | return null; | 315 | return null; |
316 | >>>>>>> avn/ubitvar | ||
293 | } | 317 | } |
294 | 318 | ||
295 | private class QueuedAssetRequest | 319 | private class QueuedAssetRequest |
@@ -324,12 +348,24 @@ namespace OpenSim.Services.Connectors | |||
324 | List<AssetRetrievedEx> handlers; | 348 | List<AssetRetrievedEx> handlers; |
325 | lock (m_AssetHandlers) | 349 | lock (m_AssetHandlers) |
326 | { | 350 | { |
351 | <<<<<<< HEAD | ||
352 | if (a != null && m_Cache != null) | ||
353 | m_Cache.Cache(a); | ||
354 | ======= | ||
327 | handlers = m_AssetHandlers[id]; | 355 | handlers = m_AssetHandlers[id]; |
328 | m_AssetHandlers.Remove(id); | 356 | m_AssetHandlers.Remove(id); |
329 | } | 357 | } |
358 | >>>>>>> avn/ubitvar | ||
330 | 359 | ||
331 | Util.FireAndForget(x => | 360 | Util.FireAndForget(x => |
332 | { | 361 | { |
362 | <<<<<<< HEAD | ||
363 | handlers = m_AssetHandlers[id]; | ||
364 | m_AssetHandlers.Remove(id); | ||
365 | } | ||
366 | handlers.Invoke(a); | ||
367 | }, m_maxAssetRequestConcurrency, m_Auth); | ||
368 | ======= | ||
333 | foreach (AssetRetrievedEx h in handlers) | 369 | foreach (AssetRetrievedEx h in handlers) |
334 | { | 370 | { |
335 | // Util.FireAndForget(x => | 371 | // Util.FireAndForget(x => |
@@ -346,6 +382,7 @@ namespace OpenSim.Services.Connectors | |||
346 | 382 | ||
347 | // if (handlers != null) | 383 | // if (handlers != null) |
348 | // handlers.Clear(); | 384 | // handlers.Clear(); |
385 | >>>>>>> avn/ubitvar | ||
349 | 386 | ||
350 | success = true; | 387 | success = true; |
351 | } | 388 | } |
@@ -413,6 +450,27 @@ namespace OpenSim.Services.Connectors | |||
413 | return true; | 450 | return true; |
414 | } | 451 | } |
415 | 452 | ||
453 | public virtual bool[] AssetsExist(string[] ids) | ||
454 | { | ||
455 | string uri = m_ServerURI + "/get_assets_exist"; | ||
456 | |||
457 | bool[] exist = null; | ||
458 | try | ||
459 | { | ||
460 | exist = SynchronousRestObjectRequester.MakeRequest<string[], bool[]>("POST", uri, ids, m_Auth); | ||
461 | } | ||
462 | catch (Exception) | ||
463 | { | ||
464 | // This is most likely to happen because the server doesn't support this function, | ||
465 | // so just silently return "doesn't exist" for all the assets. | ||
466 | } | ||
467 | |||
468 | if (exist == null) | ||
469 | exist = new bool[ids.Length]; | ||
470 | |||
471 | return exist; | ||
472 | } | ||
473 | |||
416 | public string Store(AssetBase asset) | 474 | public string Store(AssetBase asset) |
417 | { | 475 | { |
418 | // Have to assign the asset ID here. This isn't likely to | 476 | // Have to assign the asset ID here. This isn't likely to |
@@ -449,9 +507,35 @@ namespace OpenSim.Services.Connectors | |||
449 | 507 | ||
450 | string uri = MapServer(asset.FullID.ToString()) + "/assets/"; | 508 | string uri = MapServer(asset.FullID.ToString()) + "/assets/"; |
451 | 509 | ||
452 | string newID = string.Empty; | 510 | string newID; |
453 | try | 511 | try |
454 | { | 512 | { |
513 | <<<<<<< HEAD | ||
514 | newID = SynchronousRestObjectRequester.MakeRequest<AssetBase, string>("POST", uri, asset, m_Auth); | ||
515 | } | ||
516 | catch (Exception e) | ||
517 | { | ||
518 | m_log.Warn(string.Format("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1} ", asset.ID, e.Message), e); | ||
519 | return string.Empty; | ||
520 | } | ||
521 | |||
522 | // TEMPORARY: SRAS returns 'null' when it's asked to store existing assets | ||
523 | if (newID == null) | ||
524 | { | ||
525 | m_log.DebugFormat("[ASSET CONNECTOR]: Storing of asset {0} returned null; assuming the asset already exists", asset.ID); | ||
526 | return asset.ID; | ||
527 | } | ||
528 | |||
529 | if (string.IsNullOrEmpty(newID)) | ||
530 | return string.Empty; | ||
531 | |||
532 | asset.ID = newID; | ||
533 | |||
534 | if (m_Cache != null) | ||
535 | m_Cache.Cache(asset); | ||
536 | |||
537 | return newID; | ||
538 | ======= | ||
455 | newID = SynchronousRestObjectRequester. | 539 | newID = SynchronousRestObjectRequester. |
456 | MakeRequest<AssetBase, string>("POST", uri, asset, 25); | 540 | MakeRequest<AssetBase, string>("POST", uri, asset, 25); |
457 | if (newID == null || newID == "") | 541 | if (newID == null || newID == "") |
@@ -504,6 +588,7 @@ namespace OpenSim.Services.Connectors | |||
504 | } | 588 | } |
505 | } | 589 | } |
506 | return asset.ID; | 590 | return asset.ID; |
591 | >>>>>>> avn/ubitvar | ||
507 | } | 592 | } |
508 | 593 | ||
509 | public bool UpdateContent(string id, byte[] data) | 594 | public bool UpdateContent(string id, byte[] data) |
@@ -526,8 +611,7 @@ namespace OpenSim.Services.Connectors | |||
526 | 611 | ||
527 | string uri = MapServer(id) + "/assets/" + id; | 612 | string uri = MapServer(id) + "/assets/" + id; |
528 | 613 | ||
529 | if (SynchronousRestObjectRequester. | 614 | if (SynchronousRestObjectRequester.MakeRequest<AssetBase, bool>("POST", uri, asset, m_Auth)) |
530 | MakeRequest<AssetBase, bool>("POST", uri, asset)) | ||
531 | { | 615 | { |
532 | if (m_Cache != null) | 616 | if (m_Cache != null) |
533 | m_Cache.Cache(asset); | 617 | m_Cache.Cache(asset); |
@@ -541,8 +625,7 @@ namespace OpenSim.Services.Connectors | |||
541 | { | 625 | { |
542 | string uri = MapServer(id) + "/assets/" + id; | 626 | string uri = MapServer(id) + "/assets/" + id; |
543 | 627 | ||
544 | if (SynchronousRestObjectRequester. | 628 | if (SynchronousRestObjectRequester.MakeRequest<int, bool>("DELETE", uri, 0, m_Auth)) |
545 | MakeRequest<int, bool>("DELETE", uri, 0)) | ||
546 | { | 629 | { |
547 | if (m_Cache != null) | 630 | if (m_Cache != null) |
548 | m_Cache.Expire(id); | 631 | m_Cache.Expire(id); |