Beispiel #1
0
 public ListBlobsResult(string separator, IBlobObjectCollection blobs, IBlobContainer container, BlobServiceVersion version)
 {
     if (blobs == null)
     {
         throw new ArgumentNullException("blobs");
     }
     this.blobs     = blobs;
     this.separator = separator;
     this.container = container;
     this.version   = version;
 }
Beispiel #2
0
 IListBlobObject Microsoft.Cis.Services.Nephos.Common.Storage.IBlobContainer.CreateAppendBlobInstance(string blobName, DateTime snapshot, BlobServiceVersion blobServiceVersion)
 {
     throw new FeatureNotSupportedByEmulatorException("Append Blob");
 }
Beispiel #3
0
        IAsyncResult Microsoft.Cis.Services.Nephos.Common.Storage.IBlobContainer.BeginListBlobs(string blobNamePrefix, BlobPropertyNames propertyNames, string separator, string blobNameStart, DateTime?snapshotStart, IBlobObjectCondition condition, int maxBlobNames, BlobServiceVersion version, AsyncCallback callback, object state)
        {
            AsyncIteratorContext <IBlobObjectCollection> asyncIteratorContext = new AsyncIteratorContext <IBlobObjectCollection>("DbBlobContainer.ListBlobs", callback, state);

            asyncIteratorContext.Begin(this.ListBlobsImpl(blobNamePrefix, propertyNames, separator, blobNameStart, snapshotStart, condition, maxBlobNames, version, asyncIteratorContext));
            return(asyncIteratorContext);
        }
Beispiel #4
0
        private IEnumerator <IAsyncResult> ListBlobsImpl(string blobNamePrefix, BlobPropertyNames propertyNames, string separator, string blobNameStart, DateTime?snapshotStart, IBlobObjectCondition condition, int maxBlobNames, BlobServiceVersion version, AsyncIteratorContext <IBlobObjectCollection> context)
        {
            IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug;

            object[] objArray = new object[] { blobNamePrefix, propertyNames, separator, blobNameStart, snapshotStart, condition, maxBlobNames, this.Timeout };
            verboseDebug.Log("ListBlobsImpl({0},{1},{2},{3},{4},{5},{6},{7})", objArray);
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute <DbBlobObjectCollection>((TimeSpan param0) => {
                DbBlobObjectCollection dbBlobObjectCollections;
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    this.LoadBlobContainer(dbContext);
                    IQueryable <Blob> blobs = this.MakeListBlobsQuery(blobNamePrefix, blobNameStart, snapshotStart, separator, condition, maxBlobNames, dbContext);
                    dbBlobObjectCollections = this.ReadListBlobsResult(blobNamePrefix, separator, maxBlobNames, blobs);
                }
                return(dbBlobObjectCollections);
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbBlobContainer.ListBlobs"));

            yield return(asyncResult);

            context.ResultData = this.StorageManager.AsyncProcessor.EndExecute <DbBlobObjectCollection>(asyncResult);
        }
Beispiel #5
0
 public static IListBlobObject CreateBlockBlobInstance(this IBlobContainer container, string blobName, BlobServiceVersion blobServiceVersion)
 {
     return(container.CreateBlockBlobInstance(blobName, StorageStampHelpers.RootBlobSnapshotVersion, blobServiceVersion));
 }
Beispiel #6
0
 public static IBlobObject CreateBlobObjectInstance(this IBlobContainer container, BlobType blobType, string blobName, BlobServiceVersion blobServiceVersion)
 {
     if (blobType == BlobType.ListBlob)
     {
         return(container.CreateBlockBlobInstance(blobName, StorageStampHelpers.RootBlobSnapshotVersion, blobServiceVersion));
     }
     if (blobType == BlobType.AppendBlob)
     {
         return(container.CreateAppendBlobInstance(blobName, StorageStampHelpers.RootBlobSnapshotVersion, blobServiceVersion));
     }
     if (blobType != BlobType.IndexBlob)
     {
         throw new ArgumentException("blobType");
     }
     return(container.CreateIndexBlobObjectInstance(blobName, StorageStampHelpers.RootBlobSnapshotVersion, blobServiceVersion));
 }
Beispiel #7
0
 public abstract IAsyncResult BeginListBlobs(IAccountIdentifier identifier, string account, string container, BlobServiceVersion version, string blobPrefix, string delimiter, string containerMarker, string blobMarker, DateTime?snapshotMarker, DateTime?ifModifiedSinceTime, DateTime?ifNotModifiedSinceTime, bool includeDisabledContainers, bool isFetchingMetadata, bool isIncludingSnapshots, bool isIncludingPageBlobs, bool isIncludingAppendBlobs, bool isIncludingUncommittedBlobs, bool isIncludingLeaseStatus, int?maxBlobNames, TimeSpan timeout, RequestContext requestContext, AsyncCallback callback, object state);
Beispiel #8
0
        private IEnumerator <IAsyncResult> GetBlockListImpl(IBlobObjectCondition condition, BlockListTypes blockListTypes, BlobServiceVersion blobServiceVersion, AsyncIteratorContext <IBlockLists> context)
        {
            IAsyncResult asyncResult;

            try
            {
                asyncResult = ((IListBlobObject)this.blob).BeginGetBlockList(Helpers.Convert(condition), blockListTypes, blobServiceVersion, context.GetResumeCallback(), context.GetResumeState("RealBlobObject.GetBlockListImpl"));
            }
            catch (Exception exception)
            {
                StorageStamp.TranslateException(exception);
                throw;
            }
            yield return(asyncResult);

            try
            {
                context.ResultData = ((IListBlobObject)this.blob).EndGetBlockList(asyncResult);
            }
            catch (Exception exception1)
            {
                StorageStamp.TranslateException(exception1);
                throw;
            }
        }
Beispiel #9
0
 internal DbListBlobObject(DbStorageManager storageManager, Blob blob, BlobServiceVersion blobServiceVersion) : base(storageManager, blob, blobServiceVersion)
 {
     base.LeaseInfo = new BlobLeaseInfo(blob, DateTime.UtcNow);
 }
Beispiel #10
0
 internal DbListBlobObject(DbBlobContainer container, string blobName, DateTime snapshot, BlobServiceVersion blobServiceVersion) : base(container, blobName, snapshot, BlobType.ListBlob, blobServiceVersion)
 {
 }
Beispiel #11
0
        IAsyncResult Microsoft.Cis.Services.Nephos.Common.Storage.IListBlobObject.BeginGetBlockList(IBlobObjectCondition condition, BlockListTypes blockListTypes, BlobServiceVersion blobServiceVersion, AsyncCallback callback, object state)
        {
            AsyncIteratorContext <IBlockLists> asyncIteratorContext = new AsyncIteratorContext <IBlockLists>("DbListBlobObject.GetBlockList", callback, state);

            asyncIteratorContext.Begin(this.GetBlockListImpl(condition, blockListTypes, blobServiceVersion, asyncIteratorContext));
            return(asyncIteratorContext);
        }
Beispiel #12
0
        private IEnumerator <IAsyncResult> GetBlockListImpl(IBlobObjectCondition condition, BlockListTypes blockListTypes, BlobServiceVersion blobServiceVersion, AsyncIteratorContext <IBlockLists> context)
        {
            IAsyncResult asyncResult = this._storageManager.AsyncProcessor.BeginExecute <BlockLists>((TimeSpan param0) => {
                BlockLists blockList;
                using (TransactionScope transactionScope = new TransactionScope())
                {
                    using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                    {
                        base.LoadContainer(dbContext);
                        BlockBlob blockBlob         = base.LoadBlockBlob(dbContext, true);
                        BlobLeaseInfo blobLeaseInfo = new BlobLeaseInfo(blockBlob, DateTime.UtcNow);
                        DbBlobObject.CheckConditionsAndReturnResetRequired(blockBlob, blobLeaseInfo, condition, null, false);
                        BlockLists dbBlockCollections = new BlockLists()
                        {
                            BlobLastModificationTime = blockBlob.LastModificationTime.Value,
                            BlobSize = blockBlob.ContentLength
                        };
                        if ((blockListTypes & BlockListTypes.Committed) != BlockListTypes.None)
                        {
                            List <IBlock> blocks = new List <IBlock>();
                            if (blockBlob.HasBlock.Value)
                            {
                                foreach (CommittedBlock committedBlock in
                                         from blck in dbContext.CommittedBlocks
                                         where (blck.AccountName == this._blob.AccountName) && (blck.ContainerName == this._blob.ContainerName) && (blck.BlobName == this._blob.BlobName) && (blck.VersionTimestamp == this._blob.VersionTimestamp)
                                         select blck)
                                {
                                    blocks.Add(new Block(DbListBlobObject.FromHexString(committedBlock.BlockId), committedBlock.Length.Value));
                                }
                            }
                            dbBlockCollections.CommittedBlockList = new DbListBlobObject.DbBlockCollection(blocks);
                        }
                        if ((blockListTypes & BlockListTypes.Uncommitted) != BlockListTypes.None)
                        {
                            List <IBlock> blocks1 = new List <IBlock>();
                            foreach (BlockData blockDatum in
                                     from blck in dbContext.BlocksData
                                     where (blck.AccountName == this._blob.AccountName) && (blck.ContainerName == this._blob.ContainerName) && (blck.BlobName == this._blob.BlobName) && (blck.VersionTimestamp == this._blob.VersionTimestamp) && !blck.IsCommitted
                                     select blck)
                            {
                                blocks1.Add(new Block(DbListBlobObject.FromHexString(blockDatum.BlockId), blockDatum.Length.Value));
                            }
                            dbBlockCollections.UncommittedBlockList = new DbListBlobObject.DbBlockCollection(blocks1);
                        }
                        transactionScope.Complete();
                        this._blob     = blockBlob;
                        this.LeaseInfo = blobLeaseInfo;
                        blockList      = dbBlockCollections;
                    }
                }
                return(blockList);
            }, base.Timeout, context.GetResumeCallback(), context.GetResumeState("DbListBlobObject.GetBlockList"));

            yield return(asyncResult);

            context.ResultData = this._storageManager.AsyncProcessor.EndExecute <BlockLists>(asyncResult);
        }
Beispiel #13
0
        public static void ValidatePutBlockListArguments(IBlobObject blob, long contentLength, byte[] applicationMetadata, byte[][] blockIdList, BlockSource[] blockSourceList, byte[] md5, IBlobObjectCondition condition, BlobServiceVersion blobServiceVersion)
        {
            if (blob.Snapshot != StorageStampHelpers.RootBlobSnapshotVersion)
            {
                throw new XStoreArgumentException("This operation is only supported on the root blob.");
            }
            if (contentLength < (long)-1)
            {
                throw new ArgumentOutOfRangeException("contentLength", "contentLength must be >= -1");
            }
            if (contentLength > 5242880000000L)
            {
                throw new BlobContentTooLargeException(new long?(5242880000000L), null, null);
            }
            StorageStampHelpers.ValidateApplicationMetadata(applicationMetadata);
            if (blockSourceList != null && blobServiceVersion < BlobServiceVersion.July09)
            {
                throw new XStoreArgumentException("blockSourceList is only allowed for verisons STG18 and up.");
            }
            int num  = (blockIdList != null ? (int)blockIdList.Length : 0);
            int num1 = (blockSourceList != null ? (int)blockSourceList.Length : 0);

            if (blockIdList != null && blockSourceList != null && num != num1)
            {
                string str = string.Format("blockIdList (length {0}) and blockSourceList (length {1}) must be of the same length.", num, num1);
                throw new XStoreArgumentException(str);
            }
            if ((long)num > (long)50000)
            {
                throw new BlockListTooLongException();
            }
            StorageStampHelpers.ValidateMD5(md5);
        }
Beispiel #14
0
 public abstract IAsyncResult BeginPutBlobFromBlocks(IAccountIdentifier identifier, string account, string container, string blob, BlobServiceVersion blobServiceVersion, byte[][] blockIdList, BlockSource[] blockSourceList, IPutBlobProperties putBlobProperties, BlobObjectCondition condition, OverwriteOption overwriteOption, IUpdateOptions updateOptions, TimeSpan timeout, RequestContext requestContext, AsyncCallback callback, object state);
Beispiel #15
0
 IIndexBlobObject Microsoft.Cis.Services.Nephos.Common.Storage.IBlobContainer.CreateIndexBlobObjectInstance(string blobName, DateTime snapshot, BlobServiceVersion blobServiceVersion)
 {
     return(new DbPageBlobObject(this, blobName, snapshot, blobServiceVersion));
 }
Beispiel #16
0
        private IEnumerator <IAsyncResult> ListBlobsImpl(string blobNamePrefix, BlobPropertyNames propertyNames, string separator, string blobNameStart, DateTime?snapshotStart, IBlobObjectCondition condition, int maxBlobNames, BlobServiceVersion version, AsyncIteratorContext <IBlobObjectCollection> context)
        {
            IAsyncResult asyncResult;

            try
            {
                asyncResult = this.InternalContainer.BeginListBlobs(blobNamePrefix, propertyNames, separator, blobNameStart, snapshotStart, Helpers.Convert(condition), maxBlobNames, version, context.GetResumeCallback(), context.GetResumeState("BlobContainer.ListBlobsImpl"));
            }
            catch (Exception exception)
            {
                StorageStamp.TranslateException(exception);
                throw;
            }
            yield return(asyncResult);

            try
            {
                IBlobObjectCollection blobObjectCollections = this.InternalContainer.EndListBlobs(asyncResult);
                context.ResultData = new BlobObjectCollection(blobObjectCollections);
            }
            catch (Exception exception1)
            {
                StorageStamp.TranslateException(exception1);
                throw;
            }
        }
Beispiel #17
0
        IBlobObject Microsoft.Cis.Services.Nephos.Common.Storage.IBlobContainer.CreateBaseBlobObjectInstance(string blobName, DateTime snapshot, BlobServiceVersion version)
        {
            IBlobObject baseBlobObject;

            try
            {
                IBlobObject blobObject = this.InternalContainer.CreateBaseBlobObjectInstance(blobName, snapshot, version);
                baseBlobObject = new BaseBlobObject(blobObject);
            }
            catch (Exception exception)
            {
                StorageStamp.TranslateException(exception);
                throw;
            }
            return(baseBlobObject);
        }
Beispiel #18
0
        public IAsyncResult BeginGetBlockList(IBlobObjectCondition condition, BlockListTypes blockListTypes, BlobServiceVersion blobServiceVersion, AsyncCallback callback, object state)
        {
            AsyncIteratorContext <IBlockLists> asyncIteratorContext = new AsyncIteratorContext <IBlockLists>("RealBlobObject.GetBlockList", callback, state);

            asyncIteratorContext.Begin(this.GetBlockListImpl(condition, blockListTypes, blobServiceVersion, asyncIteratorContext));
            return(asyncIteratorContext);
        }
Beispiel #19
0
 public abstract IAsyncResult BeginGetBlockList(IAccountIdentifier identifier, string account, string container, string blob, BlockListTypes blockListTypes, BlobServiceVersion blobServiceVersion, BlobObjectCondition condition, DateTime?snapshot, TimeSpan timeout, RequestContext requestContext, AsyncCallback callback, object state);