public class CommandTask extends Object
CommandTask sends a command to a target subsystem and handles the responses.
Methods are provided to check if the command processing is complete, to wait for its completion, and to retrieve the result.| Constructor and Description |
|---|
CommandTask(CommandSender sender,
CommandHandle handle,
Duration timeout,
String command,
Object... args)
Creates a
CommandTask. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel()
Cancels this command task.
|
Object |
get()
Waits if necessary for the command execution to complete, and then returns its result.
|
Object[] |
getArguments()
Returns the command arguments.
|
String |
getCommand()
Returns the command as a string in subsystem/path/method format.
|
Object |
getResult()
Waits if necessary for the command execution to complete, and then returns its result or exception.
|
boolean |
isCancelled()
Returns
true if this command task was canceled before it completed normally. |
boolean |
isDone()
Returns true if this command task has completed.
|
void |
send()
Triggers sending the command to the target subsystem.
|
public CommandTask(CommandSender sender, CommandHandle handle, Duration timeout, String command, Object... args)
CommandTask.sender - CommandSender that created this task.handle - Object to be notified of responses to the command.timeout - Timeout. Zero means the command will never time out. Negative
timeout means its absolute value will be used and the custom timeout
suggested by the target subsystem through an ACK will be ignored.command - Command in subsystem/path/method format.args - Command arguments.public void send()
public Object get() throws IllegalStateException, InterruptedException, org.lsst.ccs.messaging.CommandRejectedException, CancellationException, TimeoutException, ExecutionException
IllegalStateException - If the command cannot be sent.InterruptedException - If the current thread was interrupted while waiting.org.lsst.ccs.messaging.CommandRejectedException - If the command was rejected by the target subsystem.CancellationException - If the command was canceled.TimeoutException - If the command timed out.ExecutionException - If an exception was thrown by the target subsystem while executing the command,
or the result of the execution is an instance of Throwable.public Object getResult() throws InterruptedException
get() method, this method does not throw command-related exceptions. Instead,
the outcome of this command task is reported through the return value.get() method.InterruptedException - If the current thread was interrupted while waiting.public boolean cancel()
CommandHandle methods will not be called, and the get() method will throw CancellationException.
The target subsystem will not be notified of cancellation.False if the command task could not be canceled, typically because it has already completed normally; true otherwise.public boolean isCancelled()
true if this command task was canceled before it completed normally.public boolean isDone()
True if this task completed.public String getCommand()
public Object[] getArguments()
Copyright © 2020 LSST. All rights reserved.