다음을 통해 공유


FabricClient.HealthClient.GetApplicationHealthAsync Method

Definition

Overloads

GetApplicationHealthAsync(ApplicationHealthQueryDescription)

Asynchronously gets the health of the specified Service Fabric application by using the specified query description.

GetApplicationHealthAsync(Uri)

Asynchronously gets the health of the specified Service Fabric application.

GetApplicationHealthAsync(Uri, ApplicationHealthPolicy)

Asynchronously gets the health of the specified Service Fabric application using the application URI and the health policy.

GetApplicationHealthAsync(ApplicationHealthQueryDescription, TimeSpan, CancellationToken)

Asynchronously gets the health of the specified Service Fabric application using the specified query input, timeout and cancellation token.

GetApplicationHealthAsync(Uri, TimeSpan, CancellationToken)

Asynchronously gets the health of the specified Service Fabric application using the specified application URI, timeout and cancellation token.

GetApplicationHealthAsync(Uri, ApplicationHealthPolicy, TimeSpan, CancellationToken)

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

GetApplicationHealthAsync(ApplicationHealthQueryDescription)

Asynchronously gets the health of the specified Service Fabric application by using the specified query description.

public System.Threading.Tasks.Task<System.Fabric.Health.ApplicationHealth> GetApplicationHealthAsync (System.Fabric.Description.ApplicationHealthQueryDescription queryDescription);
member this.GetApplicationHealthAsync : System.Fabric.Description.ApplicationHealthQueryDescription -> System.Threading.Tasks.Task<System.Fabric.Health.ApplicationHealth>
Public Function GetApplicationHealthAsync (queryDescription As ApplicationHealthQueryDescription) As Task(Of ApplicationHealth)

Parameters

queryDescription
ApplicationHealthQueryDescription

The ApplicationHealthQueryDescription instance to describe the query to get application health.

Returns

The health of the specified Service Fabric application.

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

GetApplicationHealthAsync(Uri)

Asynchronously gets the health of the specified Service Fabric application.

public System.Threading.Tasks.Task<System.Fabric.Health.ApplicationHealth> GetApplicationHealthAsync (Uri applicationName);
member this.GetApplicationHealthAsync : Uri -> System.Threading.Tasks.Task<System.Fabric.Health.ApplicationHealth>
Public Function GetApplicationHealthAsync (applicationName As Uri) As Task(Of ApplicationHealth)

Parameters

applicationName
Uri

The URI of the Service Fabric application.

Returns

The health of the specified Service Fabric application.

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:

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 applicationName 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 an application.

public static bool GetApplicationHealth(string clusterConnection)
            {
                ApplicationHealth applicationHealth;
                Uri applicationName = new Uri("fabric:/myapp/todo");

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

                // Get the application health.
                try
                {
                    applicationHealth = fabricClient.HealthManager.GetApplicationHealthAsync(applicationName).Result;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e.Message);

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

                    return false;
                }

                // Display the application health information.
                Console.WriteLine("Get Application Health:");
                Console.WriteLine("  Application {0}: {1}", applicationHealth.ApplicationName, applicationHealth.AggregatedHealthState);

                // List the deployed application health states.
                Console.WriteLine("    Deployed applications:");
                IList<DeployedApplicationHealthState> deployedAppHealthStateList = applicationHealth.DeployedApplicationHealthStates;
                foreach (DeployedApplicationHealthState deployedAppHealthState in deployedAppHealthStateList)
                {
                    Console.WriteLine("      Application: " + deployedAppHealthState.ApplicationName);
                    Console.WriteLine("        Aggregated Health State: " + deployedAppHealthState.AggregatedHealthState);
                    Console.WriteLine("        Node Name: " + deployedAppHealthState.NodeName);
                }

                // List the deployed services health states.
                Console.WriteLine("    Service Health States:");
                IList<ServiceHealthState> deployedSvcsHealthStateList = applicationHealth.ServiceHealthStates;
                foreach (ServiceHealthState serviceHealthState in deployedSvcsHealthStateList)
                {
                    Console.WriteLine("      Service {0}: {1}", serviceHealthState.ServiceName, serviceHealthState.AggregatedHealthState);
                }

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

                Console.WriteLine();
                return true;
            }

Applies to

GetApplicationHealthAsync(Uri, ApplicationHealthPolicy)

Asynchronously gets the health of the specified Service Fabric application using the application URI and the health policy.

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

Parameters

applicationName
Uri

The URI of the Service Fabric application.

healthPolicy
ApplicationHealthPolicy

The ApplicationHealthPolicy instance used to evaluate the application.

Returns

The health reports of the specified Service Fabric application.

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 applicationName 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

GetApplicationHealthAsync(ApplicationHealthQueryDescription, TimeSpan, CancellationToken)

Asynchronously gets the health of the specified Service Fabric application using the specified query input, timeout and cancellation token.

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

Parameters

queryDescription
ApplicationHealthQueryDescription

The ApplicationHealthQueryDescription instance to describe the query to get application health.

timeout
TimeSpan

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

cancellationToken
CancellationToken

The 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 reports of the specified Service Fabric application.

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

GetApplicationHealthAsync(Uri, TimeSpan, CancellationToken)

Asynchronously gets the health of the specified Service Fabric application using the specified application URI, timeout and cancellation token.

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

Parameters

applicationName
Uri

The URI of the Service Fabric application.

timeout
TimeSpan

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

cancellationToken
CancellationToken

The 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 reports of the specified Service Fabric application.

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 applicationName 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

GetApplicationHealthAsync(Uri, ApplicationHealthPolicy, TimeSpan, CancellationToken)

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

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

Parameters

applicationName
Uri

The URI of the Service Fabric application.

healthPolicy
ApplicationHealthPolicy

The application health policy used to evaluate the application health.

timeout
TimeSpan

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

cancellationToken
CancellationToken

The 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 reports of the specified Service Fabric application.

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 applicationName 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