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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionLazy-create a Breaker representing all the breaker names.getName()protected StringReturn the name for this threadprotected voidnotifyBreakerChange(boolean tripped) Method designed to be overridden to receive a notification any time the tripped state of the breaker returned bygetBreaker()changes.voidCalled after this object has been fully and successfully constructedprotected booleanOverloading this method to return true will start this daemon's thread as a Daemon Threadvoidshutdown()Called to request this service clean up any ongoing work and terminate.protected voidsleep(long millis) Sleep for the specified amount of time (unless the daemon is stopping, in which case do not sleep at all).protected voidSleep for the specified amount of time (unless the daemon is stopping, in which case do not sleep at all).Methods inherited from class com.peterphi.std.threading.Daemon
getTextState, getTextStateUpdated, getThread, isRunning, isThreadRunning, setTextState, startThread, startThread, stopAll, stopThread, waitForTermination, waitForTerminationMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.peterphi.std.guice.common.shutdown.iface.StoppableService
preShutdown
-
Constructor Details
-
GuiceDaemon
public GuiceDaemon() -
GuiceDaemon
public GuiceDaemon(boolean daemonThread)
-
-
Method Details
-
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 bygetBreaker()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:DaemonOverloading this method to return true will start this daemon's thread as a Daemon Thread- Overrides:
shouldStartAsDaemonin classDaemon- Returns:
- boolean True if the thread should be started as a daemon, otherwise false
-
postConstruct
public void postConstruct()Description copied from interface:GuiceLifecycleListenerCalled after this object has been fully and successfully constructed- Specified by:
postConstructin interfaceGuiceLifecycleListener
-
shutdown
public void shutdown()Description copied from interface:StoppableServiceCalled to request this service clean up any ongoing work and terminate. SeeShutdownManager.shutdown()for the shutdown sequence guarantees- Specified by:
shutdownin interfaceStoppableService
-
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
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
-
getBreakerNames
-
getThreadName
Description copied from class:DaemonReturn the name for this thread- Overrides:
getThreadNamein classDaemon- Returns:
-