Sdílet prostřednictvím


FabricClient.HealthClient.GetReplicaHealthAsync Method

Definition

Overloads

GetReplicaHealthAsync(Guid, Int64, TimeSpan, CancellationToken)

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

GetReplicaHealthAsync(Guid, Int64, ApplicationHealthPolicy)

Asynchronously gets the health of a Service Fabric replica.

GetReplicaHealthAsync(Guid, Int64, ApplicationHealthPolicy, TimeSpan, CancellationToken)

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

GetReplicaHealthAsync(Guid, Int64)

Asynchronously gets the health of a Service Fabric replica.

GetReplicaHealthAsync(ReplicaHealthQueryDescription)

Asynchronously gets the health of a Service Fabric replica specified by the query description.

GetReplicaHealthAsync(ReplicaHealthQueryDescription, TimeSpan, CancellationToken)

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

GetReplicaHealthAsync(Guid, Int64, TimeSpan, CancellationToken)

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

public System.Threading.Tasks.Task<System.Fabric.Health.ReplicaHealth> GetReplicaHealthAsync (Guid partitionId, long replicaId, TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
member this.GetReplicaHealthAsync : Guid * int64 * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Fabric.Health.ReplicaHealth>
Public Function GetReplicaHealthAsync (partitionId As Guid, replicaId As Long, timeout As TimeSpan, cancellationToken As CancellationToken) As Task(Of ReplicaHealth)

Parameters

partitionId
Guid

The ID of the Service Fabric partition.

replicaId
Int64

The ID of the Service Fabric replica.

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

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

GetReplicaHealthAsync(Guid, Int64, ApplicationHealthPolicy)

Asynchronously gets the health of a Service Fabric replica.

public System.Threading.Tasks.Task<System.Fabric.Health.ReplicaHealth> GetReplicaHealthAsync (Guid partitionId, long replicaId, System.Fabric.Health.ApplicationHealthPolicy healthPolicy);
member this.GetReplicaHealthAsync : Guid * int64 * System.Fabric.Health.ApplicationHealthPolicy -> System.Threading.Tasks.Task<System.Fabric.Health.ReplicaHealth>
Public Function GetReplicaHealthAsync (partitionId As Guid, replicaId As Long, healthPolicy As ApplicationHealthPolicy) As Task(Of ReplicaHealth)

Parameters

partitionId
Guid

The ID of the Service Fabric partition.

replicaId
Int64

The ID of the Service Fabric replica.

healthPolicy
ApplicationHealthPolicy

The application health policy used to evaluate the entity health.

Returns

The health of a Service Fabric replica.

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

GetReplicaHealthAsync(Guid, Int64, ApplicationHealthPolicy, TimeSpan, CancellationToken)

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

public System.Threading.Tasks.Task<System.Fabric.Health.ReplicaHealth> GetReplicaHealthAsync (Guid partitionId, long replicaId, System.Fabric.Health.ApplicationHealthPolicy healthPolicy, TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
member this.GetReplicaHealthAsync : Guid * int64 * System.Fabric.Health.ApplicationHealthPolicy * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Fabric.Health.ReplicaHealth>
Public Function GetReplicaHealthAsync (partitionId As Guid, replicaId As Long, healthPolicy As ApplicationHealthPolicy, timeout As TimeSpan, cancellationToken As CancellationToken) As Task(Of ReplicaHealth)

Parameters

partitionId
Guid

The ID of the Service Fabric partition.

replicaId
Int64

The ID of the Service Fabric replica.

healthPolicy
ApplicationHealthPolicy

The application health policy used to evaluate the entity 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 replica.

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

GetReplicaHealthAsync(Guid, Int64)

Asynchronously gets the health of a Service Fabric replica.

public System.Threading.Tasks.Task<System.Fabric.Health.ReplicaHealth> GetReplicaHealthAsync (Guid partitionId, long replicaId);
member this.GetReplicaHealthAsync : Guid * int64 -> System.Threading.Tasks.Task<System.Fabric.Health.ReplicaHealth>
Public Function GetReplicaHealthAsync (partitionId As Guid, replicaId As Long) As Task(Of ReplicaHealth)

Parameters

partitionId
Guid

The ID of the Service Fabric partition.

replicaId
Int64

The ID of the Service Fabric replica.

Returns

The health of a Service Fabric replica.

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

public static bool GetReplicaHealth(string clusterConnection)
            {
                ReplicaHealth replicaHealth;

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

                // Get the replica health.
                try
                {
                    replicaHealth = fabricClient.HealthManager.GetReplicaHealthAsync(
            new Guid("a7206315-e53b-4d05-b59c-e210caa28893"), 130538257146083818).Result;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e.Message);

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

                    return false;
                }

                Console.WriteLine("Replica Health:");
                Console.WriteLine("  ID: " + replicaHealth.Id);
                Console.WriteLine("    Aggregated Health State: " + replicaHealth.AggregatedHealthState);
                Console.WriteLine("    Kind: " + replicaHealth.Kind);
                Console.WriteLine("    Partition ID: " + replicaHealth.PartitionId);

                // List the health events.
                Console.WriteLine("    Health Events:");
                IList<HealthEvent> healthEvents = replicaHealth.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 = replicaHealth.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

GetReplicaHealthAsync(ReplicaHealthQueryDescription)

Asynchronously gets the health of a Service Fabric replica specified by the query description.

public System.Threading.Tasks.Task<System.Fabric.Health.ReplicaHealth> GetReplicaHealthAsync (System.Fabric.Description.ReplicaHealthQueryDescription queryDescription);
member this.GetReplicaHealthAsync : System.Fabric.Description.ReplicaHealthQueryDescription -> System.Threading.Tasks.Task<System.Fabric.Health.ReplicaHealth>
Public Function GetReplicaHealthAsync (queryDescription As ReplicaHealthQueryDescription) As Task(Of ReplicaHealth)

Parameters

queryDescription
ReplicaHealthQueryDescription

The query description.

Returns

The health of a Service Fabric replica.

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

GetReplicaHealthAsync(ReplicaHealthQueryDescription, TimeSpan, CancellationToken)

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

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

Parameters

queryDescription
ReplicaHealthQueryDescription

The query description.

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

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