Esempio n. 1
0
 public GetApplicationTypePagedListRequest(
     IFabricClient fabricClient,
     PagedApplicationTypeQueryDescription queryDescription,
     TimeSpan timeout,
     bool getPagedResults = false)
     : base(fabricClient, timeout)
 {
     this.QueryDescription = queryDescription;
     this.GetPagedResults  = getPagedResults;
     this.IsForPowerShell  = true;
 }
        protected List <string> GetAppVersions(IClusterConnection clusterConnection, string applicationTypeName)
        {
            var queryDesc = new PagedApplicationTypeQueryDescription();

            queryDesc.ApplicationTypeNameFilter = applicationTypeName;

            var versions    = new List <string>();
            var appTypeList = this.GetAllPages(clusterConnection, queryDesc);

            foreach (var item in appTypeList)
            {
                versions.Add(item.ApplicationTypeVersion);
            }

            return(versions);
        }
Esempio n. 3
0
        private void GetResultsWithPagedQuery(IClusterConnection clusterConnection)
        {
            var queryDescription = new PagedApplicationTypeQueryDescription();

            queryDescription.ExcludeApplicationParameters = this.ExcludeApplicationParameters;

            if (!string.IsNullOrEmpty(this.ApplicationTypeName))
            {
                queryDescription.ApplicationTypeNameFilter = this.ApplicationTypeName; // defaults null
            }

            if (!string.IsNullOrEmpty(this.ApplicationTypeVersion))
            {
                queryDescription.ApplicationTypeVersionFilter = this.ApplicationTypeVersion; // defaults null
            }

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

            // If the results do not fit a message, the continuation token is set.
            // Keep getting data until all entries are received.
            bool   morePages = true;
            string currentContinuationToken;

            while (morePages)
            {
                var queryResult = clusterConnection.GetApplicationTypePagedListAsync(
                    queryDescription,
                    this.GetTimeout(),
                    this.GetCancellationToken()).Result;

                // Write results to PowerShell
                foreach (var item in queryResult)
                {
                    this.WriteObject(this.FormatOutput(item));
                }

                // Continuation token is not added as a PsObject because it breaks the pipeline scenarios
                // like Get-ServiceFabricApplicationType | Query_Which_Takes_AppType
                morePages = Helpers.ResultHasMorePages(this, queryResult.ContinuationToken, out currentContinuationToken);

                // Update continuation token
                queryDescription.ContinuationToken = currentContinuationToken;
            }
        }
        protected bool VerifyAppVersion(IClusterConnection clusterConnection, string applicationTypeName, string applicationTypeVersion)
        {
            var queryDesc = new PagedApplicationTypeQueryDescription();

            queryDesc.ApplicationTypeNameFilter = applicationTypeName;

            bool exists      = false;
            var  queryResult = this.GetAllPages(clusterConnection, queryDesc);

            foreach (var item in queryResult)
            {
                if (string.Equals(item.ApplicationTypeVersion, applicationTypeVersion, StringComparison.OrdinalIgnoreCase))
                {
                    exists = true;
                    break;
                }
            }

            return(exists);
        }
        private ApplicationTypePagedList GetAllPages(IClusterConnection clusterConnection, PagedApplicationTypeQueryDescription queryDescription)
        {
            var allResults = new ApplicationTypePagedList();

            bool   morePages = true;
            string currentContinuationToken = queryDescription.ContinuationToken;

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

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

                foreach (var item in queryResult)
                {
                    allResults.Add(item);
                }

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

            return(allResults);
        }
Esempio n. 6
0
 public GetApplicationTypePagedListRequest(IFabricClient fabricClient, PagedApplicationTypeQueryDescription queryDescription, TimeSpan timeout)
     : base(fabricClient, timeout)
 {
     this.QueryDescription = queryDescription;
 }