Aracılığıyla paylaş


FabricClient.HealthClient.GetClusterHealthAsync Method

Definition

Overloads

GetClusterHealthAsync(ClusterHealthQueryDescription, TimeSpan, CancellationToken)

Asynchronously gets the health of a Service Fabric cluster by using a query description, a timeout and cancellation token.

GetClusterHealthAsync(TimeSpan, CancellationToken)

Asynchronously gets the health of a Service Fabric cluster by using the specified timeout and cancellation token.

GetClusterHealthAsync(ClusterHealthPolicy, TimeSpan, CancellationToken)

Asynchronously gets the health of a Service Fabric cluster by using the specified health policy, timeout and cancellation token.

GetClusterHealthAsync(ClusterHealthQueryDescription)

Asynchronously gets the health of a Service Fabric cluster by using a query description.

GetClusterHealthAsync()

Asynchronously gets the health of a Service Fabric cluster.

GetClusterHealthAsync(ClusterHealthPolicy)

Asynchronously gets the health of a Service Fabric cluster, evaluating it using the specified policy.

GetClusterHealthAsync(ClusterHealthQueryDescription, TimeSpan, CancellationToken)

Asynchronously gets the health of a Service Fabric cluster by using a query description, a timeout and cancellation token.

public System.Threading.Tasks.Task<System.Fabric.Health.ClusterHealth> GetClusterHealthAsync (System.Fabric.Description.ClusterHealthQueryDescription queryDescription, TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
member this.GetClusterHealthAsync : System.Fabric.Description.ClusterHealthQueryDescription * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Fabric.Health.ClusterHealth>
Public Function GetClusterHealthAsync (queryDescription As ClusterHealthQueryDescription, timeout As TimeSpan, cancellationToken As CancellationToken) As Task(Of ClusterHealth)

Parameters

queryDescription
ClusterHealthQueryDescription

The query description that defined query parameters like health policies, filters etc.

timeout
TimeSpan

The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException.

cancellationToken
CancellationToken

The optional cancellation token that the operation is observing. It can be used to send a notification that the operation should be canceled. Note that cancellation is advisory and that the operation may still be completed even if it is canceled.

Returns

The health of a Service Fabric cluster.

Exceptions

The FabricClient object is in a closed state. Dispose of the FabricClient object you are using and instantiate a new FabricClient object.

Returned when a null reference is passed to a method that does not accept it as a valid argument.

Caused by one of the following:

E_INVALIDARG is returned when one or more arguments are not valid.

Caused by one of the following:

OperationTimedOut is returned when the operation takes more than the user provided timeout to complete.

Caused by one of the following:

ServiceTooBusy is returned when the service is too busy to process the operation.

Caused by one of the following:

E_ACCESSDENIED is returned when the access check has failed for this operation.

Applies to

GetClusterHealthAsync(TimeSpan, CancellationToken)

Asynchronously gets the health of a Service Fabric cluster by using the specified timeout and cancellation token.

public System.Threading.Tasks.Task<System.Fabric.Health.ClusterHealth> GetClusterHealthAsync (TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
member this.GetClusterHealthAsync : TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Fabric.Health.ClusterHealth>
Public Function GetClusterHealthAsync (timeout As TimeSpan, cancellationToken As CancellationToken) As Task(Of ClusterHealth)

Parameters

timeout
TimeSpan

The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException.

cancellationToken
CancellationToken

The optional cancellation token that the operation is observing. It can be used to send a notification that the operation should be canceled. Note that cancellation is advisory and that the operation may still be completed even if it is canceled.

Returns

The health of a Service Fabric cluster.

Exceptions

The FabricClient object is in a closed state. Dispose of the FabricClient object you are using and instantiate a new FabricClient object.

Returned when a null reference is passed to a method that does not accept it as a valid argument.

Caused by one of the following:

E_INVALIDARG is returned when one or more arguments are not valid.

Caused by one of the following:

OperationTimedOut is returned when the operation takes more than the user provided timeout to complete.

Caused by one of the following:

ServiceTooBusy is returned when the service is too busy to process the operation.

Caused by one of the following:

E_ACCESSDENIED is returned when the access check has failed for this operation.

Applies to

GetClusterHealthAsync(ClusterHealthPolicy, TimeSpan, CancellationToken)

Asynchronously gets the health of a Service Fabric cluster by using the specified health policy, timeout and cancellation token.

public System.Threading.Tasks.Task<System.Fabric.Health.ClusterHealth> GetClusterHealthAsync (System.Fabric.Health.ClusterHealthPolicy healthPolicy, TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
member this.GetClusterHealthAsync : System.Fabric.Health.ClusterHealthPolicy * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Fabric.Health.ClusterHealth>
Public Function GetClusterHealthAsync (healthPolicy As ClusterHealthPolicy, timeout As TimeSpan, cancellationToken As CancellationToken) As Task(Of ClusterHealth)

Parameters

healthPolicy
ClusterHealthPolicy

The cluster health policy used to evaluate cluster health.

timeout
TimeSpan

The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException.

cancellationToken
CancellationToken

The optional cancellation token that the operation is observing. It can be used to send a notification that the operation should be canceled. Note that cancellation is advisory and that the operation may still be completed even if it is canceled.

Returns

The health of a Service Fabric cluster.

Exceptions

The FabricClient object is in a closed state. Dispose of the FabricClient object you are using and instantiate a new FabricClient object.

Returned when a null reference is passed to a method that does not accept it as a valid argument.

Caused by one of the following:

E_INVALIDARG is returned when one or more arguments are not valid.

Caused by one of the following:

OperationTimedOut is returned when the operation takes more than the user provided timeout to complete.

Caused by one of the following:

ServiceTooBusy is returned when the service is too busy to process the operation.

Caused by one of the following:

E_ACCESSDENIED is returned when the access check has failed for this operation.

Applies to

GetClusterHealthAsync(ClusterHealthQueryDescription)

Asynchronously gets the health of a Service Fabric cluster by using a query description.

public System.Threading.Tasks.Task<System.Fabric.Health.ClusterHealth> GetClusterHealthAsync (System.Fabric.Description.ClusterHealthQueryDescription queryDescription);
member this.GetClusterHealthAsync : System.Fabric.Description.ClusterHealthQueryDescription -> System.Threading.Tasks.Task<System.Fabric.Health.ClusterHealth>
Public Function GetClusterHealthAsync (queryDescription As ClusterHealthQueryDescription) As Task(Of ClusterHealth)

Parameters

queryDescription
ClusterHealthQueryDescription

The query description that defines query parameters like health policies, filters etc.

Returns

The health of a Service Fabric cluster.

Exceptions

The FabricClient object is in a closed state. Dispose of the FabricClient object you are using and instantiate a new FabricClient object.

Returned when a null reference is passed to a method that does not accept it as a valid argument.

Caused by one of the following:

E_INVALIDARG is returned when one or more arguments are not valid.

Caused by one of the following:

OperationTimedOut is returned when the operation takes more than the specified time to complete.

Caused by one of the following:

ServiceTooBusy is returned when the service is too busy to process the operation.

Caused by one of the following:

E_ACCESSDENIED is returned when the access check has failed for this operation.

Applies to

GetClusterHealthAsync()

Asynchronously gets the health of a Service Fabric cluster.

public System.Threading.Tasks.Task<System.Fabric.Health.ClusterHealth> GetClusterHealthAsync ();
member this.GetClusterHealthAsync : unit -> System.Threading.Tasks.Task<System.Fabric.Health.ClusterHealth>
Public Function GetClusterHealthAsync () As Task(Of ClusterHealth)

Returns

The health of a Service Fabric cluster.

Exceptions

The FabricClient object is in a closed state. Dispose of the FabricClient object you are using and instantiate a new FabricClient object.

Returned when a null reference is passed to a method that does not accept it as a valid argument.

Caused by one of the following:

E_INVALIDARG is returned when one or more arguments are not valid.

Caused by one of the following:

OperationTimedOut is returned when the operation takes more than the specified time to complete.

Caused by one of the following:

ServiceTooBusy is returned when the service is too busy to process the operation.

Caused by one of the following:

E_ACCESSDENIED is returned when the access check has failed for this operation.

Remarks

The following example gets the health of the cluster.

public static bool GetClusterHealth(string clusterConnection)
            {
                ClusterHealth clusterHealth;

                // Connect to the cluster.
                FabricClient fabricClient = new FabricClient(clusterConnection);

                // Get the cluster health.
                try
                {
                    clusterHealth = fabricClient.HealthManager.GetClusterHealthAsync().Result;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e.Message);

                    if (e.InnerException != null)
            Console.WriteLine("  Inner Exception: " + e.InnerException.Message);

                    return false;
                }

                // Display the cluster health state.
                Console.WriteLine("Cluster Health:");
                Console.WriteLine("  Aggregated Health State: " + clusterHealth.AggregatedHealthState);
                Console.WriteLine();

                // Display the application health states on the cluster.
                Console.WriteLine("  Application Health States:");
                IList<ApplicationHealthState> applicationHealthStateList = clusterHealth.ApplicationHealthStates;
                foreach(ApplicationHealthState applicationHealthState in applicationHealthStateList)
                {
                    Console.WriteLine("    Application {0}: {1}", applicationHealthState.ApplicationName, applicationHealthState.AggregatedHealthState);
                }

                // Display Node Health States on the cluster.
                Console.WriteLine("  Node Health States:");
                IList<NodeHealthState> nodeHealthStateList = clusterHealth.NodeHealthStates;
                foreach (NodeHealthState nodeHealthState in nodeHealthStateList)
                {
                    Console.WriteLine("    Node Name: " + nodeHealthState.NodeName);
                    Console.WriteLine("      Aggregated Health State: " + nodeHealthState.AggregatedHealthState);
                }

                // Display Health Events.
                Console.WriteLine("  Health Events:");
                IList<HealthEvent> healthEventList = clusterHealth.HealthEvents;
                foreach(HealthEvent healthEvent in healthEventList)
                {
                    Console.WriteLine("      Health Event:");
                    Console.WriteLine("        Last Modified: " + healthEvent.LastModifiedUtcTimestamp);
                    Console.WriteLine("        Source UTC Timestamp: " + healthEvent.SourceUtcTimestamp);
                    Console.WriteLine("        Is Expired: " + healthEvent.IsExpired);
                    Console.WriteLine("        Health Information:");
                    Console.WriteLine("          Description: " + healthEvent.HealthInformation.Description);
                    Console.WriteLine("          Source ID: " + healthEvent.HealthInformation.SourceId);
                    Console.WriteLine("          Health State: " + healthEvent.HealthInformation.HealthState);
                    Console.WriteLine("          Property: " + healthEvent.HealthInformation.Property);
                    Console.WriteLine("          Remove When Expired: " + healthEvent.HealthInformation.RemoveWhenExpired);
                    Console.WriteLine("          Sequence Number: " + healthEvent.HealthInformation.SequenceNumber);
                    Console.WriteLine("          Time to Live: " + healthEvent.HealthInformation.TimeToLive);
                }

                Console.WriteLine("  Unhealthy Evaluations:");
                IList<HealthEvaluation> healthEvaluationList = clusterHealth.UnhealthyEvaluations;
                foreach(HealthEvaluation healthEvaluation in healthEvaluationList)
                {
                    Console.WriteLine("    Kind: " + healthEvaluation.Kind);
                    Console.WriteLine("      Aggregated Health State: " + healthEvaluation.AggregatedHealthState);
                    Console.WriteLine("      Description: " + healthEvaluation.Description);
                }

                return true;
            }

Applies to

GetClusterHealthAsync(ClusterHealthPolicy)

Asynchronously gets the health of a Service Fabric cluster, evaluating it using the specified policy.

public System.Threading.Tasks.Task<System.Fabric.Health.ClusterHealth> GetClusterHealthAsync (System.Fabric.Health.ClusterHealthPolicy healthPolicy);
member this.GetClusterHealthAsync : System.Fabric.Health.ClusterHealthPolicy -> System.Threading.Tasks.Task<System.Fabric.Health.ClusterHealth>
Public Function GetClusterHealthAsync (healthPolicy As ClusterHealthPolicy) As Task(Of ClusterHealth)

Parameters

healthPolicy
ClusterHealthPolicy

The cluster health policy used to evaluate cluster health.

Returns

The health of a Service Fabric cluster.

Exceptions

The FabricClient object is in a closed state. Dispose of the FabricClient object you are using and instantiate a new FabricClient object.

Returned when a null reference is passed to a method that does not accept it as a valid argument.

Caused by one of the following:

E_INVALIDARG is returned when one or more arguments are not valid.

Caused by one of the following:

OperationTimedOut is returned when the operation takes more than the specified time to complete.

Caused by one of the following:

ServiceTooBusy is returned when the service is too busy to process the operation.

Caused by one of the following:

E_ACCESSDENIED is returned when the access check has failed for this operation.

Applies to