Beispiel #1
0
 /// <summary>
 /// <para>Gets the status of compose deployments created that match filters specified in query description (if any).
 /// If the compose deployments do not fit in a page, one page of results is returned as well as a continuation token which can be used to get the next page.</para>
 /// </summary>
 /// <param name="composeDeploymentQueryDescription">
 /// <para>The <see cref="Description.ComposeDeploymentStatusQueryDescription" /> that determines which compose deployments should be queried.</para>
 /// </param>
 /// <param name="client"><see cref="System.Fabric.FabricClient"/> object.</param>
 /// <param name="timeout">
 /// <para>Defines the maximum amount of time the system will allow this operation to continue before returning <see cref="System.TimeoutException" />.</para>
 /// </param>
 /// <returns>
 /// <para>A <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous query operation.
 /// The value of TResult parameter is an <see cref="Microsoft.ServiceFabric.Preview.Client.Query.ComposeDeploymentStatusList" /> that represents the list of compose deployments that respect the filters in the <see cref="Description.ComposeDeploymentStatusQueryDescription" /> and fit the page.
 /// If the provided query description has no matching compose deployments, it will return a list of 0 entries.</para>
 /// </returns>
 /// <exception cref="System.Fabric.FabricObjectClosedException">
 /// <para>
 ///     See <see href="https://azure.microsoft.com/documentation/articles/service-fabric-errors-and-exceptions/"/> for handling common FabricClient failures.</para>
 /// </exception>
 /// <exception cref="System.TimeoutException">
 /// <para>
 ///     See <see href="https://azure.microsoft.com/documentation/articles/service-fabric-errors-and-exceptions/"/> for handling common FabricClient failures.</para>
 /// </exception>
 /// <exception cref="System.Fabric.FabricException">
 /// <para>
 ///     See also <see href="https://azure.microsoft.com/documentation/articles/service-fabric-errors-and-exceptions/"/> for handling common FabricClient failures.</para>
 /// </exception>
 public static Task <ComposeDeploymentStatusList> GetComposeDeploymentStatusPagedListAsync(
     this FabricClient.QueryClient client,
     ComposeDeploymentStatusQueryDescription composeDeploymentQueryDescription,
     TimeSpan timeout)
 {
     return(Task <ComposeDeploymentStatusList> .Run(() => { return ComposeDeploymentStatusListConverter(client.GetComposeDeploymentStatusPagedListAsync(composeDeploymentQueryDescription.ToWrapper(), timeout).Result); }));
 }
        protected override void ProcessRecord()
        {
            var clusterConnection = this.GetClusterConnection();

            var queryDescription = new ComposeDeploymentStatusQueryDescription()
            {
                DeploymentNameFilter = this.DeploymentName
            };

            if (this.MaxResults.HasValue)
            {
                queryDescription.MaxResults = this.MaxResults.Value;
            }

            try
            {
                this.GetAllPagesImpl(queryDescription, clusterConnection);
            }
            catch (AggregateException aggregateException)
            {
                aggregateException.Handle((ae) =>
                {
                    this.ThrowTerminatingError(
                        ae,
                        Constants.GetComposeDeploymentStatusErrorId,
                        clusterConnection);
                    return(true);
                });
            }
        }
        private void GetAllPagesImpl(ComposeDeploymentStatusQueryDescription queryDescription, IClusterConnection clusterConnection)
        {
            bool   morePages = true;
            string currentContinuationToken = queryDescription.ContinuationToken;

            while (morePages)
            {
                // Override continuation token
                queryDescription.ContinuationToken = currentContinuationToken;

                var queryResult = clusterConnection.GetComposeDeploymentStatusPagedListAsync(
                    queryDescription,
                    this.GetTimeout(),
                    this.GetCancellationToken()).Result;

                foreach (var item in queryResult)
                {
                    this.WriteObject(this.FormatOutput(item));
                }

                morePages = Helpers.ResultHasMorePages(this, queryResult.ContinuationToken, out currentContinuationToken);
            }
        }