Class HealthcheckRunner<T>

  • All Implemented Interfaces:
    Runnable, Callable<T>

    public class HealthcheckRunner<T>
    extends Object
    implements Callable<T>, Runnable
    Run a configurable (health check) action at fixed intervals until this action longer raises an exception. Fatal conditions can be configured to abort the health check early.
    Author:
    raven
    • Field Detail

      • retryCount

        protected long retryCount
      • interval

        protected long interval
      • intervalTimeUnit

        protected TimeUnit intervalTimeUnit
      • action

        protected Callable<? extends T> action
      • fatalConditions

        protected List<java.util.function.Predicate<? super Throwable>> fatalConditions
      • continuationConditions

        protected List<java.util.function.Supplier<Boolean>> continuationConditions
      • isAborted

        protected boolean isAborted
      • thread

        protected volatile Thread thread
        The thread that called run()
    • Constructor Detail

      • HealthcheckRunner

        public HealthcheckRunner​(long retryCount,
                                 long interval,
                                 TimeUnit intervalTimeUnit,
                                 Callable<? extends T> action,
                                 List<java.util.function.Predicate<? super Throwable>> fatalConditions,
                                 List<java.util.function.Supplier<Boolean>> continuationConditions)
    • Method Detail

      • abort

        public void abort()
      • isAborted

        public boolean isAborted()
      • isConditionallyAborted

        public boolean isConditionallyAborted()
      • run

        public void run()
        Prefer this method if the result should be ignored
        Specified by:
        run in interface Runnable
      • call

        public T call()
        Specified by:
        call in interface Callable<T>