public class Daemon extends Object implements Runnable, Stoppable
Daemon instances are single use and have a start/stop debug. They are also threadsafe.
See DaemonClient for a description of the daemon communication protocol.
| Constructor and Description |
|---|
Daemon(DaemonServerConnector connector,
DaemonRegistry daemonRegistry,
DaemonContext daemonContext,
String password,
DaemonCommandExecuter commandExecuter,
ExecutorFactory executorFactory)
Creates a new daemon instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
awaitIdleTimeout(int idleTimeout)
Waits for the daemon to be idle for the specified number of milliseconds.
|
void |
awaitStop()
Blocks until this daemon is stopped by something else (i.e.
|
boolean |
awaitStopOrIdleTimeout(int idleTimeout)
Waits until the daemon is either stopped, or has been idle for the given number of milliseconds.
|
Address |
getAddress() |
String |
getUid() |
void |
run()
Starts the daemon, blocking until it is stopped (either by Stop command or by another thread calling stop())
|
void |
start()
Starts the daemon, receiving connections asynchronously (i.e.
|
void |
stop()
Stops the daemon, blocking until any current requests/connections have been satisfied.
|
public Daemon(DaemonServerConnector connector, DaemonRegistry daemonRegistry, DaemonContext daemonContext, String password, DaemonCommandExecuter commandExecuter, ExecutorFactory executorFactory)
connector - The provider of server connections for this daemondaemonRegistry - The registry that this daemon should advertise itself inpublic String getUid()
public Address getAddress()
public void start()
IllegalStateException - if this daemon is already running, or has already been stopped.public void stop()
This is the semantically the same as sending the daemon the Stop command.
This method does not quite conform to the semantics of the Stoppable contract in that it will NOT wait for any executing builds to stop before returning. This is by design as we currently have no way of gracefully stopping a build process and blocking until it's done would not allow us to tear down the jvm like we need to. This may change in the future if we create a way to interrupt a build.
What will happen though is that the daemon will immediately disconnect from any clients and remove itself from the registry.
public void awaitStop()
public boolean awaitStopOrIdleTimeout(int idleTimeout)
public void awaitIdleTimeout(int idleTimeout)
throws DaemonStoppedException
DaemonStoppedException - if the daemon is explicitly stopped instead of idling out.Copyright © 2013. All rights reserved