/// <summary>
        /// Uploads a list of blocks to a new or existing blob.
        /// </summary>
        /// <param name="blockList">An enumerable collection of block IDs, as base64-encoded strings.</param>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        public void PutBlockList(IEnumerable <string> blockList, BlobRequestOptions options)
        {
            var fullModifier = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            List <PutBlockListItem> items = blockList.Select(i => { return(new PutBlockListItem(i, BlockSearchMode.Latest)); }).ToList();

            TaskImplHelper.ExecuteImplWithRetry(() => { return(this.UploadBlockList(items, fullModifier)); }, fullModifier.RetryPolicy);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets a collection of page ranges and their starting and ending bytes.
        /// </summary>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        /// <returns>An enumerable collection of page ranges.</returns>
        public IEnumerable <PageRange> GetPageRanges(BlobRequestOptions options)
        {
            var fullModifiers = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            return(TaskImplHelper.ExecuteImplWithRetry <IEnumerable <PageRange> >(
                       (setResult) => this.GetPageRangesImpl(fullModifiers, setResult),
                       fullModifiers.RetryPolicy));
        }
        /// <summary>
        /// Returns an enumerable collection of the blob's blocks, using the specified block list filter.
        /// </summary>
        /// <param name="blockListingFilter">One of the enumeration values that indicates whether to return
        /// committed blocks, uncommitted blocks, or both.</param>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        /// <returns>An enumerable collection of objects implementing <see cref="ListBlockItem"/>.</returns>
        public IEnumerable <ListBlockItem> DownloadBlockList(BlockListingFilter blockListingFilter, BlobRequestOptions options)
        {
            var fullModifier = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            return(TaskImplHelper.ExecuteImplWithRetry <IEnumerable <ListBlockItem> >(
                       (result) =>
            {
                return this.GetDownloadBlockList(blockListingFilter, fullModifier, result);
            },
                       fullModifier.RetryPolicy));
        }
Esempio n. 4
0
        /// <summary>
        /// Writes pages to a page blob.
        /// </summary>
        /// <param name="pageData">A stream providing the page data.</param>
        /// <param name="startOffset">The offset at which to begin writing, in bytes. The offset must be a multiple of 512.</param>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        public void WritePages(Stream pageData, long startOffset, BlobRequestOptions options)
        {
            var fullModifiers = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            long sourcePosition = pageData.CanSeek ? pageData.Position : 0;

            TaskImplHelper.ExecuteImplWithRetry(
                () =>
            {
                if (pageData.CanSeek == false)
                {
                    sourcePosition--;
                }

                return(this.WritePageImpl(pageData, startOffset, sourcePosition, fullModifiers));
            },
                fullModifiers.RetryPolicy);
        }
        /// <summary>
        /// Uploads a single block.
        /// </summary>
        /// <param name="blockId">A base64-encoded block ID that identifies the block.</param>
        /// <param name="blockData">A stream that provides the data for the block.</param>
        /// <param name="contentMD5">An optional hash value that will be used to set the <see cref="BlobProperties.ContentMD5"/> property
        /// on the blob. May be <c>null</c> or an empty string.</param>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        public void PutBlock(string blockId, Stream blockData, string contentMD5, BlobRequestOptions options)
        {
            var fullModifier = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);
            var position     = blockData.Position;
            var retryPolicy  = blockData.CanSeek ? fullModifier.RetryPolicy : RetryPolicies.NoRetry();

            TaskImplHelper.ExecuteImplWithRetry(
                () =>
            {
                if (blockData.CanSeek)
                {
                    blockData.Position = position;
                }

                return(this.UploadBlock(blockData, blockId, contentMD5, fullModifier));
            },
                retryPolicy);
        }
Esempio n. 6
0
        internal static IEnumerable <T> LazyEnumerateSegmented <T>(Func <Action <ResultSegment <T> >, TaskSequence> impl, RetryPolicy retryPolicy)
        {
            var segment = TaskImplHelper.ExecuteImplWithRetry <ResultSegment <T> >(impl, retryPolicy);
            CloudBlobDirectory cloudDirectoryInLastPartition = null;
            T lastElement = default(T);

            while (true)
            {
                foreach (var result in segment.Results)
                {
                    if (cloudDirectoryInLastPartition != null && result is CloudBlobDirectory)
                    {
                        var cloudBlobDirectory = result as CloudBlobDirectory;
                        if (cloudDirectoryInLastPartition.Uri == cloudBlobDirectory.Uri)
                        {
                            continue;
                        }
                    }

                    lastElement = result;
                    yield return(result);
                }

                if (!segment.HasMoreResults)
                {
                    break;
                }

                if (lastElement is CloudBlobDirectory)
                {
                    cloudDirectoryInLastPartition = lastElement as CloudBlobDirectory;
                }

                segment = segment.GetNext();
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Sets the properties of the queue service.
 /// </summary>
 /// <param name="properties">The queue service properties.</param>
 public void SetServiceProperties(ServiceProperties properties)
 {
     TaskImplHelper.ExecuteImplWithRetry(() => this.SetServicePropertiesImpl(properties), this.RetryPolicy);
 }
Esempio n. 8
0
 /// <summary>
 /// Gets the properties of the queue service.
 /// </summary>
 /// <returns>The queue service properties.</returns>
 public ServiceProperties GetServiceProperties()
 {
     return(TaskImplHelper.ExecuteImplWithRetry <ServiceProperties>((setResult) => this.GetServicePropertiesImpl(setResult), this.RetryPolicy));
 }
Esempio n. 9
0
 /// <summary>
 /// Returns a result segment containing a collection of queues
 /// whose names begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The queue name prefix.</param>
 /// <param name="detailsIncluded">One of the enumeration values that indicates which details to include in the listing.</param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the
 /// per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
 /// <returns>A result segment containing a collection of queues.</returns>
 public ResultSegment <CloudQueue> ListQueuesSegmented(string prefix, QueueListingDetails detailsIncluded, int maxResults, ResultContinuation continuationToken)
 {
     return(TaskImplHelper.ExecuteImplWithRetry <ResultSegment <CloudQueue> >(
                (setResult) => this.ListQueuesImpl(prefix, detailsIncluded, continuationToken, maxResults, setResult),
                this.RetryPolicy));
 }
Esempio n. 10
0
 /// <summary>
 /// Saves changes, using the retry policy specified for the service context.
 /// </summary>
 /// <param name="options">Additional options for saving changes.</param>
 /// <returns> A <see cref="DataServiceResponse"/> that represents the result of the operation.</returns>
 public DataServiceResponse SaveChangesWithRetries(SaveChangesOptions options)
 {
     return(TaskImplHelper.ExecuteImplWithRetry <DataServiceResponse>(
                (setResult) => this.SaveChangesWithRetriesImpl(options, setResult),
                RetryPolicy));
 }
Esempio n. 11
0
        /// <summary>
        /// Gets the next result segment.
        /// </summary>
        /// <returns>The next result segment.</returns>
        public ResultSegment <TElement> GetNext()
        {
            CommonUtils.AssertSegmentResultNotComplete <TElement>(this);

            return(TaskImplHelper.ExecuteImplWithRetry <ResultSegment <TElement> >(this.GetNextImpl, this.retryPolicy));
        }
 /// <summary>
 /// Creates a table with specified name.
 /// </summary>
 /// <param name="tableName">The table name.</param>
 public void CreateTable(string tableName)
 {
     TaskImplHelper.ExecuteImplWithRetry(() => this.CreateTableImpl(tableName, null), RetryPolicy);
 }
Esempio n. 13
0
        /// <summary>
        /// Clears pages from a page blob.
        /// </summary>
        /// <param name="startOffset">The offset at which to begin clearing pages, in bytes. The offset must be a multiple of 512.</param>
        /// <param name="length">The length of the data range to be cleared, in bytes. The length must be a multiple of 512.</param>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        public void ClearPages(long startOffset, long length, BlobRequestOptions options)
        {
            var fullModifiers = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            TaskImplHelper.ExecuteImplWithRetry(() => this.ClearPageImpl(startOffset, length, fullModifiers), fullModifiers.RetryPolicy);
        }
Esempio n. 14
0
        /// <summary>
        /// Creates a page blob.
        /// </summary>
        /// <param name="size">The maximum size of the page blob, in bytes.</param>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        public void Create(long size, BlobRequestOptions options)
        {
            var fullModifiers = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            TaskImplHelper.ExecuteImplWithRetry(() => this.CreateImpl(fullModifiers, size), fullModifiers.RetryPolicy);
        }
        /// <summary>
        /// Returns a result segment containing a collection of blob items.
        /// </summary>
        /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the
        /// per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>
        /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        /// <returns>A result segment containing objects that implement <see cref="IListBlobItem"/>.</returns>
        public ResultSegment <IListBlobItem> ListBlobsSegmented(int maxResults, ResultContinuation continuationToken, BlobRequestOptions options)
        {
            var fullModifiers = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            return(TaskImplHelper.ExecuteImplWithRetry <ResultSegment <IListBlobItem> >((setResult) => this.Container.ListBlobsImpl(this.Prefix, fullModifiers, continuationToken, maxResults, setResult), fullModifiers.RetryPolicy));
        }