public class DaemonStateCoordinator extends Object implements Stoppable
| Constructor and Description |
|---|
DaemonStateCoordinator(Runnable onStart,
Runnable onStartCommand,
Runnable onFinishCommand,
Runnable onStop,
Runnable onStopRequested) |
| Modifier and Type | Method and Description |
|---|---|
void |
awaitIdleTimeout(int timeout) |
void |
awaitStop()
Waits until stopped.
|
boolean |
awaitStopOrIdleTimeout(int timeout)
Waits until stopped, or timeout.
|
DaemonCommandExecution |
getCurrentCommandExecution()
The current command execution, or
null if the daemon is idle. |
double |
getIdleMinutes() |
boolean |
hasBeenIdleFor(int milliseconds) |
boolean |
isBusy() |
boolean |
isIdle() |
boolean |
isRunning() |
boolean |
isStarted()
Has the daemon started accepting connections.
|
boolean |
isStopped() |
boolean |
isStoppingOrStopped() |
DaemonCommandExecution |
onFinishCommand()
Called when the execution of a command is complete (or at least the daemon is available for new commands).
|
DaemonCommandExecution |
onStartCommand(DaemonCommandExecution execution)
Called when the execution of a command begins.
|
boolean |
requestStop() |
void |
start()
Called once when the daemon is up and ready for connections.
|
void |
stop()
Forcibly stops the daemon, even if it is busy.
|
void |
stopAsSoonAsIdle()
Perform a stop, but wait until the daemon is idle to cut any open connections.
|
public void awaitStop()
public void start()
public boolean awaitStopOrIdleTimeout(int timeout)
public void awaitIdleTimeout(int timeout)
throws DaemonStoppedException
DaemonStoppedExceptionpublic void stopAsSoonAsIdle()
onFinishCommand() is called.public void stop()
stop in interface StoppablestopAsSoonAsIdle()public boolean requestStop()
public DaemonCommandExecution onStartCommand(DaemonCommandExecution execution)
If the daemon is busy (i.e. already executing a command), this method will return the existing
execution which the caller should be prepared for without considering the given execution to be in progress.
If the daemon is idle the return value will be null and the given execution will be considered in progress.
public DaemonCommandExecution onFinishCommand()
If the daemon is currently idle, this method will return null. If it is busy, it will return what was the
current execution which will considered to be complete (putting the daemon back in idle state).
If stopAsSoonAsIdle() was previously called, this method will block while the daemon stops
public DaemonCommandExecution getCurrentCommandExecution()
null if the daemon is idle.public boolean isStarted()
public double getIdleMinutes()
public boolean hasBeenIdleFor(int milliseconds)
public boolean isStopped()
public boolean isStoppingOrStopped()
public boolean isIdle()
public boolean isBusy()
public boolean isRunning()
Copyright © 2013. All rights reserved