示例#1
0
        protected override void ProcessRecord()
        {
            var clusterConnection = this.GetClusterConnection();

            try
            {
                var queryDescription = new DeployedApplicationHealthQueryDescription(this.ApplicationName, this.NodeName);
                if (this.ConsiderWarningAsError.HasValue)
                {
                    queryDescription.HealthPolicy = new ApplicationHealthPolicy()
                    {
                        ConsiderWarningAsError = this.ConsiderWarningAsError.GetValueOrDefault(),
                    };
                }

                if (this.EventsHealthStateFilter.HasValue)
                {
                    this.WriteWarning(StringResources.PowerShell_EventsHealthStateFilter_Deprecated);
                    if (!this.EventsFilter.HasValue)
                    {
                        this.EventsFilter = (HealthStateFilter)this.EventsHealthStateFilter;
                    }
                }

                if (this.EventsFilter.HasValue)
                {
                    queryDescription.EventsFilter = new HealthEventsFilter()
                    {
                        HealthStateFilterValue = this.EventsFilter.Value,
                    };
                }

                if (this.DeployedServicePackagesHealthStateFilter.HasValue)
                {
                    this.WriteWarning(StringResources.PowerShell_DeployedServicePackagesHealthStateFilter_Deprecated);
                    if (!this.DeployedServicePackagesFilter.HasValue)
                    {
                        this.DeployedServicePackagesFilter = (HealthStateFilter)this.DeployedServicePackagesHealthStateFilter;
                    }
                }

                if (this.DeployedServicePackagesFilter.HasValue)
                {
                    queryDescription.DeployedServicePackagesFilter = new DeployedServicePackageHealthStatesFilter()
                    {
                        HealthStateFilterValue = this.DeployedServicePackagesFilter.Value,
                    };
                }

                if (this.ExcludeHealthStatistics)
                {
                    queryDescription.HealthStatisticsFilter = new DeployedApplicationHealthStatisticsFilter()
                    {
                        ExcludeHealthStatistics = this.ExcludeHealthStatistics
                    };
                }

                var deployedApplicationHealth = clusterConnection.GetDeployedApplicationHealthAsync(
                    queryDescription,
                    this.GetTimeout(),
                    this.GetCancellationToken()).Result;
                this.WriteObject(this.FormatOutput(deployedApplicationHealth));
            }
            catch (AggregateException aggregateException)
            {
                aggregateException.Handle((ae) =>
                {
                    this.ThrowTerminatingError(
                        ae,
                        Constants.GetDeployedApplicationHealthErrorId,
                        clusterConnection);
                    return(true);
                });
            }
        }
示例#2
0
 public GetDeployedApplicationHealthRequest(IFabricClient fabricClient, DeployedApplicationHealthQueryDescription queryDescription, TimeSpan timeout)
     : base(fabricClient, timeout)
 {
     ThrowIf.Null(queryDescription, "queryDescription");
     this.QueryDescription = queryDescription;
 }