Class HealthCheckHelper


  • public final class HealthCheckHelper
    extends Object
    Helper for invoking HealthCheck's. The helper will look up the HealthCheckRegistry from CamelContext and gather all the registered HealthChecks and invoke them and gather their results. The helper allows filtering out unwanted health checks using Predicate or to invoke only readiness or liveness checks.
    • Method Detail

      • getHealthCheckRegistry

        public static HealthCheckRegistry getHealthCheckRegistry​(CamelContext context)
        Parameters:
        context - the camel context
        Returns:
        the health check registry, or null if health-check is not enabled.
      • getHealthCheck

        public static HealthCheck getHealthCheck​(CamelContext context,
                                                 String id)
        Gets the HealthCheck by the given id (will resolve from classpath if necessary)
        Parameters:
        context - the camel context
        id - the id of the health check
        Returns:
        the health check, or null if no health check exists with this id
      • getHealthCheck

        public static <T extends HealthCheck> T getHealthCheck​(CamelContext context,
                                                               String id,
                                                               Class<T> type)
        Gets the HealthCheck by the given id (will resolve from classpath if necessary)
        Parameters:
        context - the camel context
        id - the id of the health check
        type - the expected type of the health check repository
        Returns:
        the health check, or null if no health check exists with this id
      • getHealthCheckRepository

        public static HealthCheckRepository getHealthCheckRepository​(CamelContext context,
                                                                     String id)
        Gets the HealthCheckRepository by the given id (will resolve from classpath if necessary)
        Parameters:
        context - the camel context
        id - the id of the health check repository
        Returns:
        the health check repository, or null if no health check repository exists with this id
      • getHealthCheckRepository

        public static <T extends HealthCheckRepository> T getHealthCheckRepository​(CamelContext context,
                                                                                   String id,
                                                                                   Class<T> type)
        Gets the HealthCheckRepository by the given id (will resolve from classpath if necessary)
        Parameters:
        context - the camel context
        id - the id of the health check repository
        type - the expected type of the health check repository
        Returns:
        the health check repository, or null if no health check repository exists with this id
      • isResultsUp

        public static boolean isResultsUp​(Collection<HealthCheck.Result> results,
                                          boolean readiness)
        Checks the overall status of the results.
        Parameters:
        results - the results from the invoked health checks
        readiness - readiness or liveness mode
        Returns:
        true if up, or false if down