/// <summary>
        /// Begins an asynchronous operation to delete a table.
        /// </summary>
        /// <param name="tableName">The table name.</param>
        /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
        /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
        /// <returns>
        /// An <see cref="IAsyncResult"/> that references the asynchronous request.
        /// </returns>
        public IAsyncResult BeginDeleteTable(string tableName, AsyncCallback callback, object state)
        {
            CommonUtils.CheckStringParameter(tableName, false, "tableName", Protocol.Constants.TableServiceMaxStringPropertySizeInChars);
            TableServiceUtilities.CheckTableName(tableName, "tableName");

            return(TaskImplHelper.BeginImplWithRetry(() => this.DeleteTableImpl(tableName), RetryPolicy, callback, state));
        }
 /// <summary>
 /// Begins an asynchronous operation to create a table with the specified name if it does not already exist.
 /// </summary>
 /// <param name="tableName">The table name.</param>
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginCreateTableIfNotExist(string tableName, AsyncCallback callback, object state)
 {
     return(TaskImplHelper.BeginImpl <bool>(
                (setResult) => this.CreateTableIfNotExistImpl(tableName, setResult),
                callback,
                state));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Begins an asynchronous operation to return 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>
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginListQueuesSegmented(string prefix, QueueListingDetails detailsIncluded, int maxResults, ResultContinuation continuationToken, AsyncCallback callback, object state)
 {
     return(TaskImplHelper.BeginImplWithRetry <ResultSegment <CloudQueue> >(
                (setResult) => this.ListQueuesImpl(prefix, detailsIncluded, continuationToken, maxResults, setResult),
                this.RetryPolicy,
                callback,
                state));
 }
 /// <summary>
 /// Begins the asynchronous request with retry.
 /// </summary>
 /// <typeparam name="T">The result type of the task.</typeparam>
 /// <param name="oracle">The oracle to use.</param>
 /// <param name="impl">The task implementation.</param>
 /// <param name="callback">The asynchronous callback.</param>
 /// <param name="state">The asynchronous state.</param>
 /// <returns>An <see cref="IAsyncResult"/> that represents the asynchronous operation.</returns>
 internal static IAsyncResult BeginAsynchronousRequestWithRetry <T>(
     ShouldRetry oracle,
     Func <Action <T>, TaskSequence> impl,
     AsyncCallback callback,
     object state)
 {
     return(TaskImplHelper.BeginImpl <T>((setResult) => RequestWithRetryImpl <T>(oracle, impl, setResult), callback, state));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Begins an asynchronous operation to execute a query and return the results as a result segment.
 /// </summary>
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginExecuteSegmented(ResultContinuation continuationToken, AsyncCallback callback, object state)
 {
     return(TaskImplHelper.BeginImplWithRetry <ResultSegment <TElement> >(
                (setResult) => this.ExecuteSegmentedImpl(continuationToken, setResult),
                this.RetryPolicy,
                callback,
                state));
 }
        /// <summary>
        /// Begins an asynchronous operation to delete the tables if it exists.
        /// </summary>
        /// <param name="tableName">The table name.</param>
        /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
        /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
        /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
        public IAsyncResult BeginDeleteTableIfExist(string tableName, AsyncCallback callback, object state)
        {
            CommonUtils.CheckStringParameter(tableName, false, "tableName", Protocol.Constants.TableServiceMaxStringPropertySizeInChars);

            TableServiceUtilities.CheckTableName(tableName, "tableName");

            return(TaskImplHelper.BeginImpl <bool>((setResult) => this.DeleteTableIfExistImpl(tableName, setResult), callback, state));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Begins an asynchronous operation to upload 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>
        /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
        /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
        /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
        public IAsyncResult BeginPutBlockList(IEnumerable <string> blockList, BlobRequestOptions options, AsyncCallback callback, object state)
        {
            var fullModifier = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

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

            return(TaskImplHelper.BeginImplWithRetry(() => { return this.UploadBlockList(items, fullModifier); }, fullModifier.RetryPolicy, callback, state));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Completes the asyncresult.
        /// </summary>
        /// <param name="asyncResults">The async results.</param>
        /// <param name="index">The index.</param>
        private static void CompleteAsyncresult(List <IAsyncResult> asyncResults, int index)
        {
            IAsyncResult signalledResult = asyncResults[index];

            // NO locking necessary as they happen on the singleton producer thread
            asyncResults.RemoveAt(index);
            TaskImplHelper.EndImpl(signalledResult);
        }
Ejemplo n.º 9
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));
        }
Ejemplo n.º 10
0
        /// <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);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Begins an asynchronous operation to save changes, using the retry policy specified for the service context.
 /// </summary>
 /// <param name="options">Additional options for saving changes.</param>
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginSaveChangesWithRetries(SaveChangesOptions options, AsyncCallback callback, object state)
 {
     return(TaskImplHelper.BeginImplWithRetry <DataServiceResponse>(
                (setResult) => this.SaveChangesWithRetriesImpl(options, setResult),
                RetryPolicy,
                callback,
                state));
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Begins an asynchronous operation to return 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>
        /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
        /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
        /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
        public IAsyncResult BeginGetPageRanges(BlobRequestOptions options, AsyncCallback callback, object state)
        {
            var fullModifiers = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            return(TaskImplHelper.BeginImplWithRetry <IEnumerable <PageRange> >(
                       (setResult) => this.GetPageRangesImpl(fullModifiers, setResult),
                       fullModifiers.RetryPolicy,
                       callback,
                       state));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Begins an asynchronous operation to clear 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>
        /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
        /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
        /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
        public IAsyncResult BeginClearPages(long startOffset, long length, BlobRequestOptions options, AsyncCallback callback, object state)
        {
            var fullModifiers = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            return(TaskImplHelper.BeginImplWithRetry(
                       () => this.ClearPageImpl(startOffset, length, fullModifiers),
                       fullModifiers.RetryPolicy,
                       callback,
                       state));
        }
Ejemplo n.º 14
0
        /// <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));
        }
 /// <summary>
 /// Begins an asynchronous operation to return a result segment containing a collection
 /// of table names beginning with the specified prefix.
 /// </summary>
 /// <param name="prefix">The table name prefix.</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>
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginListTablesSegmented(string prefix, int maxResults, ResultContinuation continuationToken, AsyncCallback callback, object state)
 {
     return(TaskImplHelper.BeginImplWithRetry <ResultSegment <string> >(
                (setResult) => this.ListTablesSegmentedImpl(
                    prefix,
                    maxResults,
                    continuationToken,
                    setResult),
                this.RetryPolicy,
                callback,
                state));
 }
        /// <summary>
        /// Verifies whether the table exist implementation.
        /// </summary>
        /// <param name="tableName">The table name.</param>
        /// <param name="setResult">The set result.</param>
        /// <returns>A sequence of tasks to do the operation.</returns>
        private TaskSequence DoesTableExistImpl(string tableName, Action <bool> setResult)
        {
            CommonUtils.CheckStringParameter(tableName, false, "tableName", Protocol.Constants.TableServiceMaxStringPropertySizeInChars);
            TableServiceUtilities.CheckTableName(tableName, "tableName");

            var svc = this.GetDataServiceContext();

            var tableExistsQuery = (from table in svc.CreateQuery <TableServiceTable>(Protocol.Constants.TableServiceTablesName)
                                    where table.TableName == tableName
                                    select table).AsTableServiceQuery();

            ResultSegment <TableServiceTable> segment = null;

            while (true)
            {
                Task <ResultSegment <TableServiceTable> > tableExistsSegmentTask;

                if (segment == null)
                {
                    tableExistsSegmentTask = TaskImplHelper.GetRetryableAsyncTask <ResultSegment <TableServiceTable> >(
                        (setResultInner) => tableExistsQuery.ExecuteSegmentedImpl(null, setResultInner), RetryPolicy);
                }
                else
                {
                    tableExistsSegmentTask = TaskImplHelper.GetRetryableAsyncTask <ResultSegment <TableServiceTable> >(segment.GetNextImpl, RetryPolicy);
                }

                yield return(tableExistsSegmentTask);

                if (GetResultOrDefault(tableExistsSegmentTask, out segment))
                {
                    if (segment.Results.Any())
                    {
                        setResult(true);

                        break;
                    }
                    else
                    {
                        setResult(false);

                        break;
                    }
                }
                else
                {
                    setResult(false);

                    break;
                }
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Begins an asynchronous operation to return 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>
        /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
        /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
        /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
        public IAsyncResult BeginDownloadBlockList(BlockListingFilter blockListingFilter, BlobRequestOptions options, AsyncCallback callback, object state)
        {
            var fullModifier = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            return(TaskImplHelper.BeginImplWithRetry <IEnumerable <ListBlockItem> >(
                       (result) =>
            {
                return this.GetDownloadBlockList(blockListingFilter, fullModifier, result);
            },
                       fullModifier.RetryPolicy,
                       callback,
                       state));
        }
        /// <summary>
        /// Creates the table if not exist implementation.
        /// </summary>
        /// <param name="tableName">The table name.</param>
        /// <param name="setResult">The set result.</param>
        /// <returns>A sequence of tasks to do the operation.</returns>
        private TaskSequence CreateTableIfNotExistImpl(string tableName, Action <bool> setResult)
        {
            CommonUtils.CheckStringParameter(tableName, false, "tableName", Protocol.Constants.TableServiceMaxStringPropertySizeInChars);
            TableServiceUtilities.CheckTableName(tableName, "tableName");

            var doesTableExistTask = new InvokeTaskSequenceTask <bool>((set) => this.DoesTableExistImpl(tableName, set));

            yield return(doesTableExistTask);

            if (doesTableExistTask.Result)
            {
                setResult(false);
            }
            else
            {
                var createTableTask = TaskImplHelper.GetRetryableAsyncTask <InvalidOperationException>((resultSetter) => this.CreateTableImpl(tableName, resultSetter), RetryPolicy);

                yield return(createTableTask);

                // wrap any exceptions
                try
                {
                    if (createTableTask.Result == null)
                    {
                        setResult(true);
                    }
                    else
                    {
                        StorageClientException exception = Utilities.TranslateDataServiceClientException(createTableTask.Result) as StorageClientException;
                        if (exception != null &&
                            exception.ErrorCode == StorageErrorCode.ResourceAlreadyExists &&
                            exception.ExtendedErrorInformation != null &&
                            exception.ExtendedErrorInformation.ErrorCode == TableErrorCodeStrings.TableAlreadyExists)
                        {
                            setResult(false);
                        }
                        else
                        {
                            throw createTableTask.Result;
                        }
                    }
                }
                catch (InvalidOperationException ex)
                {
                    throw Utilities.TranslateDataServiceClientException(ex);
                }
            }
        }
Ejemplo n.º 19
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);
        }
Ejemplo n.º 20
0
        /// <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);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Commits the blob by uploading any remaining data and the blocklist asynchronously.
        /// </summary>
        /// <returns>A sequence of events required for commit.</returns>
        private TaskSequence CommitImpl()
        {
            this.CheckWriteState();

            if (this.blockBuffer != null && this.blockBuffer.Length != 0)
            {
                var task = new InvokeTaskSequenceTask(this.FlushInternal);
                yield return(task);

                var result = task.Result; // Materialize the errors
                Console.WriteLine(result);
            }

            // If all blocks are uploaded, commit
            if (this.UseBlocks)
            {
                this.SetBlobMD5();

                var task = TaskImplHelper.GetRetryableAsyncTask(
                    () =>
                {
                    // At the convenience layer we always upload uncommitted blocks
                    List <PutBlockListItem> putBlockList = new List <PutBlockListItem>();
                    foreach (var id in this.blockList)
                    {
                        putBlockList.Add(new PutBlockListItem(id, BlockSearchMode.Uncommitted));
                    }

                    return(this.Blob.ToBlockBlob.UploadBlockList(putBlockList, this.currentModifier));
                },
                    this.currentModifier.RetryPolicy);
                yield return(task);

                var result = task.Result;
                Console.WriteLine(result);
            }

            // Now we can set the full size.
            this.Blob.Properties.Length = this.Length;

            // Clear the internal state
            this.Abort();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Begins an asynchronous operation to upload 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>
        /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
        /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
        /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
        public IAsyncResult BeginPutBlock(string blockId, Stream blockData, string contentMD5, BlobRequestOptions options, AsyncCallback callback, object state)
        {
            var fullModifier = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);
            var position     = blockData.Position;
            var retryPolicy  = blockData.CanSeek ? fullModifier.RetryPolicy : RetryPolicies.NoRetry();

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

                return this.UploadBlock(blockData, blockId, contentMD5, fullModifier);
            },
                       retryPolicy,
                       callback,
                       state));
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Begins an asynchronous operation to write 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>
        /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
        /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
        /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
        public IAsyncResult BeginWritePages(Stream pageData, long startOffset, BlobRequestOptions options, AsyncCallback callback, object state)
        {
            var fullModifiers = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

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

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

                return this.WritePageImpl(pageData, startOffset, sourcePosition, fullModifiers);
            },
                       fullModifiers.RetryPolicy,
                       callback,
                       state));
        }
        /// <summary>
        /// Deletes table if exists implementation.
        /// </summary>
        /// <param name="tableName">The table name.</param>
        /// <param name="setResult">The set result.</param>
        /// <returns>A sequence of tasks to do the operation.</returns>
        private TaskSequence DeleteTableIfExistImpl(string tableName, Action <bool> setResult)
        {
            var doesTableExistTask = TaskImplHelper.GetRetryableAsyncTask <bool>(
                (set) => this.DoesTableExistImpl(tableName, set),
                RetryPolicy);

            yield return(doesTableExistTask);

            if (!doesTableExistTask.Result)
            {
                setResult(false);
            }
            else
            {
                var deleteTableTask = TaskImplHelper.GetRetryableAsyncTask(() => this.DeleteTableImpl(tableName), RetryPolicy);

                yield return(deleteTableTask);

                var result = deleteTableTask.Result;

                setResult(true);
            }
        }
Ejemplo n.º 25
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();
            }
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Ends an asynchronous operation to set the properties of the queue service.
 /// </summary>
 /// <param name="asyncResult">The result returned from a prior call to <see cref="BeginSetServiceProperties"/>.</param>
 public void EndSetServiceProperties(IAsyncResult asyncResult)
 {
     TaskImplHelper.EndImplWithRetry(asyncResult);
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Begins an asynchronous operation to set the properties of the queue service.
 /// </summary>
 /// <param name="properties">The queue service properties.</param>
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user defined object to be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginSetServiceProperties(ServiceProperties properties, AsyncCallback callback, object state)
 {
     return(TaskImplHelper.BeginImplWithRetry(() => this.SetServicePropertiesImpl(properties), this.RetryPolicy, callback, state));
 }
Ejemplo n.º 28
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);
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Ends an asynchronous operation to get the properties of the queue service.
 /// </summary>
 /// <param name="asyncResult">The result returned from a prior call to <see cref="BeginGetServiceProperties"/>.</param>
 /// <returns>The queue service properties.</returns>
 public ServiceProperties EndGetServiceProperties(IAsyncResult asyncResult)
 {
     return(TaskImplHelper.EndImplWithRetry <ServiceProperties>(asyncResult));
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Begins an asynchronous operation to get the properties of the queue service.
 /// </summary>
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user defined object to be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginGetServiceProperties(AsyncCallback callback, object state)
 {
     return(TaskImplHelper.BeginImplWithRetry <ServiceProperties>((setResult) => this.GetServicePropertiesImpl(setResult), this.RetryPolicy, callback, state));
 }