Dela via


FabricClient.HealthClient.GetServiceHealthAsync Method

Definition

Overloads

GetServiceHealthAsync(ServiceHealthQueryDescription)

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

GetServiceHealthAsync(Uri)

Asynchronously gets the health of a Service Fabric service.

GetServiceHealthAsync(Uri, ApplicationHealthPolicy)

Asynchronously gets the health of a Service Fabric service.

GetServiceHealthAsync(ServiceHealthQueryDescription, TimeSpan, CancellationToken)

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

GetServiceHealthAsync(Uri, TimeSpan, CancellationToken)

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

GetServiceHealthAsync(Uri, ApplicationHealthPolicy, TimeSpan, CancellationToken)

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

GetServiceHealthAsync(ServiceHealthQueryDescription)

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

public System.Threading.Tasks.Task<System.Fabric.Health.ServiceHealth> GetServiceHealthAsync (System.Fabric.Description.ServiceHealthQueryDescription queryDescription);
member this.GetServiceHealthAsync : System.Fabric.Description.ServiceHealthQueryDescription -> System.Threading.Tasks.Task<System.Fabric.Health.ServiceHealth>
Public Function GetServiceHealthAsync (queryDescription As ServiceHealthQueryDescription) As Task(Of ServiceHealth)

Parameters

queryDescription
ServiceHealthQueryDescription

The query description.

Returns

The health of a Service Fabric service.

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

GetServiceHealthAsync(Uri)

Asynchronously gets the health of a Service Fabric service.

public System.Threading.Tasks.Task<System.Fabric.Health.ServiceHealth> GetServiceHealthAsync (Uri serviceName);
member this.GetServiceHealthAsync : Uri -> System.Threading.Tasks.Task<System.Fabric.Health.ServiceHealth>
Public Function GetServiceHealthAsync (serviceName As Uri) As Task(Of ServiceHealth)

Parameters

serviceName
Uri

The name of the Service Fabric service.

Returns

The health of a Service Fabric service.

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:

FabricHealthEntityNotFound.

InvalidNameUri is returned when serviceName is not a valid Service Fabric Name.

CommunicationError is returned when a communication error caused the operation to fail.

InvalidCredentialType.

InvalidX509FindType.

InvalidX509StoreLocation.

InvalidX509StoreName.

InvalidX509Thumbprint.

InvalidProtectionLevel.

InvalidX509Store.

InvalidSubjectName.

InvalidAllowedCommonNameList.

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

public static bool GetServiceHealth(string clusterConnection)
            {
                ServiceHealth serviceHealth;
                Uri serviceName = new Uri("fabric:/myapp/todo/svc1");

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

                // Get the service health.
                try
                {
                    serviceHealth = fabricClient.HealthManager.GetServiceHealthAsync(serviceName).Result;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e.Message);

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

                    return false;
                }

                Console.WriteLine("Service Health:");
                Console.WriteLine("  Service {0}: {1}", serviceHealth.ServiceName, serviceHealth.AggregatedHealthState);

                // List the health states.
                Console.WriteLine("    Partition Health States:");
                IList<PartitionHealthState> partitionHealthStates = serviceHealth.PartitionHealthStates;
                foreach (PartitionHealthState partitionHealthState in partitionHealthStates)
                {
                    Console.WriteLine("      Aggregated Health State: " + partitionHealthState.AggregatedHealthState);
                    Console.WriteLine("      Partition ID: " + partitionHealthState.PartitionId);
                }

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

GetServiceHealthAsync(Uri, ApplicationHealthPolicy)

Asynchronously gets the health of a Service Fabric service.

public System.Threading.Tasks.Task<System.Fabric.Health.ServiceHealth> GetServiceHealthAsync (Uri serviceName, System.Fabric.Health.ApplicationHealthPolicy healthPolicy);
member this.GetServiceHealthAsync : Uri * System.Fabric.Health.ApplicationHealthPolicy -> System.Threading.Tasks.Task<System.Fabric.Health.ServiceHealth>
Public Function GetServiceHealthAsync (serviceName As Uri, healthPolicy As ApplicationHealthPolicy) As Task(Of ServiceHealth)

Parameters

serviceName
Uri

The name of the Service Fabric service.

healthPolicy
ApplicationHealthPolicy

The application health policy used to evaluate service health.

Returns

The health of a Service Fabric service.

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:

FabricHealthEntityNotFound.

InvalidNameUri is returned when serviceName is not a valid Service Fabric Name.

CommunicationError is returned when a communication error caused the operation to fail.

InvalidCredentialType.

InvalidX509FindType.

InvalidX509StoreLocation.

InvalidX509StoreName.

InvalidX509Thumbprint.

InvalidProtectionLevel.

InvalidX509Store.

InvalidSubjectName.

InvalidAllowedCommonNameList.

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

GetServiceHealthAsync(ServiceHealthQueryDescription, TimeSpan, CancellationToken)

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

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

Parameters

queryDescription
ServiceHealthQueryDescription

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

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

GetServiceHealthAsync(Uri, TimeSpan, CancellationToken)

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

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

Parameters

serviceName
Uri

The name of the Service Fabric service.

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

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:

FabricHealthEntityNotFound.

InvalidNameUri is returned when serviceName is not a valid Service Fabric Name.

CommunicationError is returned when a communication error caused the operation to fail.

InvalidCredentialType.

InvalidX509FindType.

InvalidX509StoreLocation.

InvalidX509StoreName.

InvalidX509Thumbprint.

InvalidProtectionLevel.

InvalidX509Store.

InvalidSubjectName.

InvalidAllowedCommonNameList.

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

GetServiceHealthAsync(Uri, ApplicationHealthPolicy, TimeSpan, CancellationToken)

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

public System.Threading.Tasks.Task<System.Fabric.Health.ServiceHealth> GetServiceHealthAsync (Uri serviceName, System.Fabric.Health.ApplicationHealthPolicy healthPolicy, TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
member this.GetServiceHealthAsync : Uri * System.Fabric.Health.ApplicationHealthPolicy * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Fabric.Health.ServiceHealth>
Public Function GetServiceHealthAsync (serviceName As Uri, healthPolicy As ApplicationHealthPolicy, timeout As TimeSpan, cancellationToken As CancellationToken) As Task(Of ServiceHealth)

Parameters

serviceName
Uri

The name of the Service Fabric service.

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

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:

FabricHealthEntityNotFound.

InvalidNameUri is returned when serviceName is not a valid Service Fabric Name.

CommunicationError is returned when a communication error caused the operation to fail.

InvalidCredentialType.

InvalidX509FindType.

InvalidX509StoreLocation.

InvalidX509StoreName.

InvalidX509Thumbprint.

InvalidProtectionLevel.

InvalidX509Store.

InvalidSubjectName.

InvalidAllowedCommonNameList.

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