public class CommandSender extends Object
| Constructor and Description |
|---|
CommandSender(org.lsst.ccs.messaging.AgentMessagingLayer messenger,
Executor callbackExecutor,
Executor workerExecutor,
org.lsst.ccs.utilities.scheduler.Scheduler timer)
Creates an instance of
CommandSender. |
| Modifier and Type | Method and Description |
|---|---|
CommandTask |
execute(CommandHandle handle,
Duration timeout,
String command,
Object... args)
Sends a command to a remote subsystem.
|
CommandTask |
execute(CommandHandle handle,
String command,
Object... args)
Sends a command to a remote subsystem with the default timeout.
|
CommandTask |
execute(Duration timeout,
String command,
Object... args)
Sends a command to a remote subsystem, using the default
CommandHandle of this sender to process responses. |
CommandTask |
execute(String command,
Object... args)
Sends a command to a remote subsystem with the default timeout and the default callback handle.
|
void |
setCommandHandle(CommandHandle defaultCommandHandle)
Sets the default command handle for this sender.
|
void |
setTimeout(Duration defaultTimeout)
Sets the default command timeout for this sender.
|
public CommandSender(org.lsst.ccs.messaging.AgentMessagingLayer messenger,
Executor callbackExecutor,
Executor workerExecutor,
org.lsst.ccs.utilities.scheduler.Scheduler timer)
CommandSender.messenger - Messaging access point. If null, the environment messaging access will be used.callbackExecutor - Executor for running CommandHandle methods. If null, a dedicated single-threaded executor will be created.workerExecutor - Executor for running potentially time-consuming tasks. If null, a dedicated executor will be created.timer - Scheduling executor for timing commands.public void setTimeout(Duration defaultTimeout)
defaultTimeout - Default timeout.
Zero duration means the command will never time out.
Negative duration means its absolute value will be used and the custom timeout
suggested by the target subsystem through an ACK will be ignored.IllegalArgumentException - If the supplied value is null.public void setCommandHandle(CommandHandle defaultCommandHandle)
defaultCommandHandle - Default command handle.public CommandTask execute(CommandHandle handle, Duration timeout, String command, Object... args)
This method returns immediately, without waiting for the command to be processed
by the messaging service or the target subsystem. Synchronous command execution can
be done by calling get() or getResult()
on the CommandTask returned by this method.
handle - Handle for processing the command responses. May be null if no processing is required.timeout - Timeout. Cannot be null.
Zero duration means the command will never time out.
Negative duration 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 format.args - Command arguments.public CommandTask execute(Duration timeout, String command, Object... args)
CommandHandle of this sender to process responses.
If no default handle has been set, responses will be ignored.
This method returns immediately, without waiting for the command to be processed
by the messaging service or the target subsystem. Synchronous command execution can
be done by calling get() or getResult()
on the CommandTask returned by this method.
timeout - Timeout. Cannot be null.
Zero duration means the command will never time out.
Negative duration 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 format.args - Command arguments.public CommandTask execute(CommandHandle handle, String command, Object... args)
This method returns immediately, without waiting for the command to be processed
by the messaging service or the target subsystem. Synchronous command execution can
be done by calling get() or getResult()
on the CommandTask returned by this method.
handle - Handle for processing the command responses.
Cannot be null. If no processing is required, use CommandHandle.NONE.command - Command in subsystem/path format.args - Command arguments.public CommandTask execute(String command, Object... args)
This method returns immediately, without waiting for the command to be processed
by the messaging service or the target subsystem. Synchronous command execution can
be done by calling get() or getResult()
on the CommandTask returned by this method.
command - Command in subsystem/path format.args - Command arguments.Copyright © 2020 LSST. All rights reserved.