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

System.Threading.Tasks.Task<NodeHealth>

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.

System.ArgumentNullException

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

System.ArgumentException

Caused by one of the following:

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

System.TimeoutException

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.

System.UnauthorizedAccessException

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
System.String

The Service Fabric node name.

Returns

System.Threading.Tasks.Task<NodeHealth>

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.

System.ArgumentNullException

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

System.ArgumentException

Caused by one of the following:

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

System.TimeoutException

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.

System.UnauthorizedAccessException

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
System.String

The Service Fabric node name.

healthPolicy
ClusterHealthPolicy

The cluster health policy used to evaluate the node health.

Returns

System.Threading.Tasks.Task<NodeHealth>

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.

System.ArgumentNullException

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

System.ArgumentException

Caused by one of the following:

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

System.TimeoutException

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.

System.UnauthorizedAccessException

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>

Parameters

queryDescription
NodeHealthQueryDescription

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

timeout
System.TimeSpan

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

cancellationToken
System.Threading.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

System.Threading.Tasks.Task<NodeHealth>

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.

System.ArgumentNullException

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

System.ArgumentException

Caused by one of the following:

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

System.TimeoutException

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.

System.UnauthorizedAccessException

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>

Parameters

nodeName
System.String

The Service Fabric node.

timeout
System.TimeSpan

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

cancellationToken
System.Threading.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

System.Threading.Tasks.Task<NodeHealth>

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.

System.ArgumentNullException

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

System.ArgumentException

Caused by one of the following:

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

System.TimeoutException

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.

System.UnauthorizedAccessException

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>

Parameters

nodeName
System.String

The Service Fabric node.

healthPolicy
ClusterHealthPolicy

The cluster health policy used to evaluate the node health.

timeout
System.TimeSpan

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

cancellationToken
System.Threading.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

System.Threading.Tasks.Task<NodeHealth>

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.

System.ArgumentNullException

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

System.ArgumentException

Caused by one of the following:

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

System.TimeoutException

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.

System.UnauthorizedAccessException

Caused by one of the following:

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

Applies to