Class HealthCheckRegistry


  • public class HealthCheckRegistry
    extends Object
    A registry for health checks.
    • Constructor Detail

      • HealthCheckRegistry

        public HealthCheckRegistry​(int asyncExecutorPoolSize)
        Creates a new HealthCheckRegistry.
        Parameters:
        asyncExecutorPoolSize - core pool size for async health check executions
      • HealthCheckRegistry

        public HealthCheckRegistry​(ScheduledExecutorService asyncExecutorService)
        Creates a new HealthCheckRegistry.
        Parameters:
        asyncExecutorService - executor service for async health check executions
    • Method Detail

      • addListener

        public void addListener​(HealthCheckRegistryListener listener)
        Adds a HealthCheckRegistryListener to a collection of listeners that will be notified on health check registration. Listeners will be notified in the order in which they are added. The listener will be notified of all existing health checks when it first registers.
        Parameters:
        listener - listener to add
      • register

        public void register​(String name,
                             HealthCheck healthCheck)
        Registers an application HealthCheck.
        Parameters:
        name - the name of the health check
        healthCheck - the HealthCheck instance
      • unregister

        public void unregister​(String name)
        Unregisters the application HealthCheck with the given name.
        Parameters:
        name - the name of the HealthCheck instance
      • getNames

        public SortedSet<String> getNames()
        Returns a set of the names of all registered health checks.
        Returns:
        the names of all registered health checks
      • runHealthChecks

        public SortedMap<String,​HealthCheck.Result> runHealthChecks()
        Runs the registered health checks and returns a map of the results.
        Returns:
        a map of the health check results
      • runHealthChecks

        public SortedMap<String,​HealthCheck.Result> runHealthChecks​(HealthCheckFilter filter)
        Runs the registered health checks matching the filter and returns a map of the results.
        Parameters:
        filter - health check filter
        Returns:
        a map of the health check results
      • runHealthChecks

        public SortedMap<String,​HealthCheck.Result> runHealthChecks​(ExecutorService executor)
        Runs the registered health checks in parallel and returns a map of the results.
        Parameters:
        executor - object to launch and track health checks progress
        Returns:
        a map of the health check results
      • runHealthChecks

        public SortedMap<String,​HealthCheck.Result> runHealthChecks​(ExecutorService executor,
                                                                          HealthCheckFilter filter)
        Runs the registered health checks matching the filter in parallel and returns a map of the results.
        Parameters:
        executor - object to launch and track health checks progress
        filter - health check filter
        Returns:
        a map of the health check results
      • shutdown

        public void shutdown()
        Shuts down the scheduled executor for async health checks