public interface ServiceController
Modifier and Type | Interface and Description |
---|---|
static class |
ServiceController.TerminationStatus
Enum to represent termination status of the application when it completed.
|
Modifier and Type | Method and Description |
---|---|
void |
awaitTerminated()
Waits for termination of the remote service.
|
void |
awaitTerminated(long timeout,
TimeUnit timeoutUnit)
Waits for termination of the remote service for no more than the given timeout limit.
|
RunId |
getRunId()
Returns the
RunId of the running application. |
ServiceController.TerminationStatus |
getTerminationStatus()
Gets the termination status of the application represented by this controller.
|
void |
kill()
Requests to forcefully kill a running service.
|
void |
onRunning(Runnable runnable,
Executor executor)
Attaches a
Runnable that will get executed when the service is running. |
void |
onTerminated(Runnable runnable,
Executor executor)
Attaches a
Runnable that will get executed when the serivce is terminated. |
Future<Command> |
sendCommand(Command command)
Sends a user command to the running application.
|
Future<Command> |
sendCommand(String runnableName,
Command command)
Sends a user command to the given runnable of the running application.
|
Future<? extends ServiceController> |
terminate()
Requests to terminate the running service.
|
Future<Command> sendCommand(Command command)
command
- The command to send.Future
that will be completed when the command is successfully processed
by the target application.Future<Command> sendCommand(String runnableName, Command command)
runnableName
- Name of the TwillRunnable
.command
- The command to send.Future
that will be completed when the command is successfully processed
by the target runnable.Future<? extends ServiceController> terminate()
Future
representing the termination state
will be returned.Future
that represents the termination of the service. The future result will be
this ServiceController
. If the service terminated with a ServiceController.TerminationStatus.FAILED
status,
calling the Future.get()
on the returning future will throw ExecutionException
.void kill()
void onRunning(Runnable runnable, Executor executor)
Runnable
that will get executed when the service is running.runnable
- the Runnable
to be executed when the service is running.executor
- the executor in which the runnable will be executed with.void onTerminated(Runnable runnable, Executor executor)
Runnable
that will get executed when the serivce is terminated.runnable
- the Runnable
to be executed when the service is terminated.executor
- the executor in which the runnable will be executed with.void awaitTerminated() throws ExecutionException
ExecutionException
- if the service terminated due to exception.void awaitTerminated(long timeout, TimeUnit timeoutUnit) throws TimeoutException, ExecutionException
timeout
- the maximum time to waittimeoutUnit
- the time unit of the timeoutTimeoutException
- if the service is not terminated within the given time.ExecutionException
- if the service terminated due to exception.@Nullable ServiceController.TerminationStatus getTerminationStatus()
null
if the application is still runningCopyright © 2013-2016 The Apache Software Foundation. All rights reserved.