Class GuiceDaemon

java.lang.Object
com.peterphi.std.threading.Daemon
com.peterphi.std.guice.common.daemon.GuiceDaemon
All Implemented Interfaces:
GuiceLifecycleListener, StoppableService, Runnable
Direct Known Subclasses:
GuiceRecurringDaemon

public abstract class GuiceDaemon extends Daemon implements StoppableService, GuiceLifecycleListener
  • Constructor Details

    • GuiceDaemon

      public GuiceDaemon()
    • GuiceDaemon

      public GuiceDaemon(boolean daemonThread)
  • Method Details

    • getBreaker

      public Breaker getBreaker()
      Lazy-create a Breaker representing all the breaker names.
      Returns:
      See Also:
    • notifyBreakerChange

      protected void notifyBreakerChange(boolean tripped)
      Method designed to be overridden to receive a notification any time the tripped state of the breaker returned by getBreaker() changes. This method is executed synchronously with breaker evaluation potentially impacting multiple threads, so it should not block, nor should it perform any heavy computation
      Parameters:
      tripped - true if the breaker is tripped, otherwise false if the breaker is normal
    • shouldStartAsDaemon

      protected boolean shouldStartAsDaemon()
      Description copied from class: Daemon
      Overloading this method to return true will start this daemon's thread as a Daemon Thread
      Overrides:
      shouldStartAsDaemon in class Daemon
      Returns:
      boolean True if the thread should be started as a daemon, otherwise false
    • postConstruct

      public void postConstruct()
      Description copied from interface: GuiceLifecycleListener
      Called after this object has been fully and successfully constructed
      Specified by:
      postConstruct in interface GuiceLifecycleListener
    • shutdown

      public void shutdown()
      Description copied from interface: StoppableService
      Called to request this service clean up any ongoing work and terminate. See ShutdownManager.shutdown() for the shutdown sequence guarantees
      Specified by:
      shutdown in interface StoppableService
    • sleep

      protected void sleep(long millis)
      Sleep for the specified amount of time (unless the daemon is stopping, in which case do not sleep at all). Returns immediately if the thread is interrupted.
      Parameters:
      millis - the amount of time to sleep for
    • sleep

      protected void sleep(Timeout timeout)
      Sleep for the specified amount of time (unless the daemon is stopping, in which case do not sleep at all). Returns immediately if the thread is interrupted.
      Parameters:
      timeout - the amount of time to sleep for
    • getName

      public String getName()
    • getBreakerNames

      public List<String> getBreakerNames()
    • getThreadName

      protected String getThreadName()
      Description copied from class: Daemon
      Return the name for this thread
      Overrides:
      getThreadName in class Daemon
      Returns: