/// <summary> /// Requests that an asset be removed from storage and does not return until the operation completes /// </summary> /// <param name="assetID"></param> /// <returns></returns> public void PurgeAssetSync(OpenMetaverse.UUID assetID) { ManualResetEventSlim syncEvent = new ManualResetEventSlim(); Exception thrown = null; _threadPool.QueueWorkItem(() => { CloudFilesAssetWorker worker = null; try { worker = _asyncAssetWorkers.LeaseObject(); worker.PurgeAsset(assetID); } catch (Exception e) { thrown = e; } finally { if (worker != null) { _asyncAssetWorkers.ReturnObject(worker); } } syncEvent.Set(); }); if (syncEvent.Wait(ASSET_WAIT_TIMEOUT)) { syncEvent.Dispose(); } else { m_log.WarnFormat("[InWorldz.Stratus]: Timout waiting for synchronous asset purge for {0}", assetID); } if (thrown != null) { throw new AssetServerException(thrown.Message, thrown); } }
private Dictionary <string, string> RequestAssetMetadataInternal(OpenMetaverse.UUID assetID) { Dictionary <string, string> meta = null; Util.Retry(2, new List <Type> { typeof(UnrecoverableAssetServerException) }, () => { CloudFilesAssetWorker worker = null; try { try { //nothing in the cache. request from CF worker = _asyncAssetWorkers.LeaseObject(); } catch (Exception e) { //bail out now if we couldn't lease a connection throw new UnrecoverableAssetServerException(e.Message, e); } meta = worker.GetAssetMetadata(assetID); } catch (net.openstack.Core.Exceptions.Response.ItemNotFoundException) { //not an exceptional case. this will happen meta = null; } finally { if (worker != null) { _asyncAssetWorkers.ReturnObject(worker); } } }); return(meta); }
private Dictionary<string, string> GetAssetMetadata(OpenMetaverse.UUID assetId, CloudFilesAssetWorker worker) { try { return worker.GetAssetMetadata(assetId); } catch (net.openstack.Core.Exceptions.Response.ItemNotFoundException) { return null; } }
private Dictionary <string, string> GetAssetMetadata(OpenMetaverse.UUID assetId, CloudFilesAssetWorker worker) { try { return(worker.GetAssetMetadata(assetId)); } catch (net.openstack.Core.Exceptions.Response.ItemNotFoundException) { return(null); } }
private AssetBase GetAssetInternal(OpenMetaverse.UUID assetID) { // Quick exit for null ID case. statTotal++; statGet++; if (assetID == OpenMetaverse.UUID.Zero) { statGetHit++; return(null); } //cache? Cache.CacheEntry cacheObject = null; lock (_assetCache) { _assetCache.TryGetAsset(assetID, out cacheObject); } StratusAsset rawAsset = null; if (cacheObject != null) { statGetHit++; //stream cache or asset cache? if (cacheObject.FullAsset != null) { rawAsset = cacheObject.FullAsset; } else { using (System.IO.MemoryStream stream = new System.IO.MemoryStream(cacheObject.Data, 0, cacheObject.Size)) { rawAsset = DeserializeAssetFromStream(assetID, stream); } } } else { StratusAsset diskAsset = null; if (!Config.Settings.Instance.DisableWritebackCache) { diskAsset = _diskWriteBack.GetAsset(assetID.Guid); } if (diskAsset != null) { rawAsset = diskAsset; } else { Util.Retry(2, new List <Type> { typeof(UnrecoverableAssetServerException) }, () => { ulong start = Util.GetLongTickCount(); CloudFilesAssetWorker worker = null; try { try { //nothing on the local disk, request from CF worker = _asyncAssetWorkers.LeaseObject(); } catch (Exception e) { //exception here is unrecoverable since this is construction statGetInit++; throw new UnrecoverableAssetServerException(e.Message, e); } using (System.IO.MemoryStream stream = worker.GetAsset(assetID)) { statGetFetches++; stream.Position = 0; rawAsset = DeserializeAssetFromStream(assetID, stream); //if we're using the cache, we need to put the raw data in there now stream.Position = 0; this.CacheAssetIfAppropriate(assetID, stream, rawAsset); } } catch (net.openstack.Core.Exceptions.Response.ItemNotFoundException) { statGetNotFound++; //not an exceptional case. this will happen rawAsset = null; } finally { ulong elapsed = Util.GetLongTickCount() - start; statGets.Add(elapsed); if (worker != null) { _asyncAssetWorkers.ReturnObject(worker); } } }); } } //nothing? if (rawAsset == null) { return(null); } //convert return(rawAsset.ToAssetBase()); }