Share via


FabricClient.HealthClient.GetNodeHealthAsync Method

Definition

Overloads

GetNodeHealthAsync(NodeHealthQueryDescription)

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

GetNodeHealthAsync(String)

Asynchronously gets the health of a Service Fabric node.

GetNodeHealthAsync(String, ClusterHealthPolicy)

Asynchronously gets the health of a Service Fabric node.

GetNodeHealthAsync(NodeHealthQueryDescription, TimeSpan, CancellationToken)

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

GetNodeHealthAsync(String, TimeSpan, CancellationToken)

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

GetNodeHealthAsync(String, ClusterHealthPolicy, TimeSpan, CancellationToken)

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

GetNodeHealthAsync(NodeHealthQueryDescription)

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

public System.Threading.Tasks.Task<System.Fabric.Health.NodeHealth> GetNodeHealthAsync (System.Fabric.Description.NodeHealthQueryDescription queryDescription);
member this.GetNodeHealthAsync : System.Fabric.Description.NodeHealthQueryDescription -> System.Threading.Tasks.Task<System.Fabric.Health.NodeHealth>
Public Function GetNodeHealthAsync (queryDescription As NodeHealthQueryDescription) As Task(Of NodeHealth)

Parameters

queryDescription
NodeHealthQueryDescription

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

Returns

The health of a Service Fabric node.

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

GetNodeHealthAsync(String)

Asynchronously gets the health of a Service Fabric node.

public System.Threading.Tasks.Task<System.Fabric.Health.NodeHealth> GetNodeHealthAsync (string nodeName);
member this.GetNodeHealthAsync : string -> System.Threading.Tasks.Task<System.Fabric.Health.NodeHealth>
Public Function GetNodeHealthAsync (nodeName As String) As Task(Of NodeHealth)

Parameters

nodeName
String

The Service Fabric node name.

Returns

The health of a Service Fabric node.

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 a node.

public static bool GetNodeHealth(string clusterConnection)
            {
                NodeHealth nodeHealth;

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

                // Get the node health.
                try
                {
                    nodeHealth = fabricClient.HealthManager.GetNodeHealthAsync("Node1").Result;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e.Message);

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

                    return false;
                }

                // Display the node health information.
                Console.WriteLine("Node Health:");
                Console.WriteLine("  Node {0}: {1}", nodeHealth.NodeName, nodeHealth.AggregatedHealthState);

                // List the health events.
                Console.WriteLine("    Health Events:");
                IList<HealthEvent> healthEvents = nodeHealth.HealthEvents;
                foreach (HealthEvent healthEvent in healthEvents)
                {
                    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);
                }

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

                Console.WriteLine(); 
                return true;
            }

Applies to

GetNodeHealthAsync(String, ClusterHealthPolicy)

Asynchronously gets the health of a Service Fabric node.

public System.Threading.Tasks.Task<System.Fabric.Health.NodeHealth> GetNodeHealthAsync (string nodeName, System.Fabric.Health.ClusterHealthPolicy healthPolicy);
member this.GetNodeHealthAsync : string * System.Fabric.Health.ClusterHealthPolicy -> System.Threading.Tasks.Task<System.Fabric.Health.NodeHealth>
Public Function GetNodeHealthAsync (nodeName As String, healthPolicy As ClusterHealthPolicy) As Task(Of NodeHealth)

Parameters

nodeName
String

The Service Fabric node name.

healthPolicy
ClusterHealthPolicy

The cluster health policy used to evaluate the node health.

Returns

The health of a Service Fabric node.

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

GetNodeHealthAsync(NodeHealthQueryDescription, TimeSpan, CancellationToken)

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

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

Parameters

queryDescription
NodeHealthQueryDescription

The query description that defines parameters like health policy, 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 node.

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

GetNodeHealthAsync(String, TimeSpan, CancellationToken)

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

public System.Threading.Tasks.Task<System.Fabric.Health.NodeHealth> GetNodeHealthAsync (string nodeName, TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
member this.GetNodeHealthAsync : string * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Fabric.Health.NodeHealth>
Public Function GetNodeHealthAsync (nodeName As String, timeout As TimeSpan, cancellationToken As CancellationToken) As Task(Of NodeHealth)

Parameters

nodeName
String

The Service Fabric node.

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 node.

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

GetNodeHealthAsync(String, ClusterHealthPolicy, TimeSpan, CancellationToken)

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

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

Parameters

nodeName
String

The Service Fabric node.

healthPolicy
ClusterHealthPolicy

The cluster health policy used to evaluate the node 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 node.

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