Class BaseLifeCycle

    • Field Detail

      • logger

        protected Logger logger
      • userExecutor

        protected final com.google.common.util.concurrent.ListeningExecutorService userExecutor
      • statusLock

        protected final Object statusLock
    • Constructor Detail

      • BaseLifeCycle

        public BaseLifeCycle​(com.google.common.util.concurrent.ListeningExecutorService userExecutor,
                             LifeCycle... dependencies)
    • Method Detail

      • addDependency

        public void addDependency​(LifeCycle lifeCycle)
      • run

        public void run()
        Specified by:
        run in interface Runnable
      • doShutdown

        protected abstract void doShutdown()
      • shouldDoWork

        protected boolean shouldDoWork()
        Returns:
        false if any dependencies are inactive, or we are inactive, or we have a global exception.
      • exceptionIfDependenciesNotActive

        protected void exceptionIfDependenciesNotActive()
      • getExceptionFromDependenciesOrNull

        protected Exception getExceptionFromDependenciesOrNull()
      • getException

        public Exception getException()
        Specified by:
        getException in interface LifeCycle
        Returns:
        Exception or null, if there are no fatal Exceptions encountered in the lifecycle of this component.
      • shutdown

        public void shutdown​(long waitMs)
        Description copied from interface: LifeCycle
        Requests shutdown, but will only wait @link waitms milliseconds
        Specified by:
        shutdown in interface LifeCycle
        Parameters:
        waitMs - maximum time to wait in milliseconds
      • exceptionIfNotActive

        protected void exceptionIfNotActive()