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
-
Method Summary
Modifier and TypeMethodDescriptionLazy-create a Breaker representing all the breaker names.getName()
protected String
Return the name for this threadprotected void
notifyBreakerChange
(boolean tripped) Method designed to be overridden to receive a notification any time the tripped state of the breaker returned bygetBreaker()
changes.void
Called after this object has been fully and successfully constructedprotected boolean
Overloading this method to return true will start this daemon's thread as a Daemon Threadvoid
shutdown()
Called to request this service clean up any ongoing work and terminate.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).protected void
Sleep 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, waitForTermination
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:Daemon
Overloading this method to return true will start this daemon's thread as a Daemon Thread- Overrides:
shouldStartAsDaemon
in classDaemon
- 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 interfaceGuiceLifecycleListener
-
shutdown
public void shutdown()Description copied from interface:StoppableService
Called to request this service clean up any ongoing work and terminate. SeeShutdownManager.shutdown()
for the shutdown sequence guarantees- Specified by:
shutdown
in 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:Daemon
Return the name for this thread- Overrides:
getThreadName
in classDaemon
- Returns:
-