public class CommandSender extends Object
All methods that send commands return immediately, without waiting for the command to be
processed by the messaging service or the target subsystem. Synchronous command execution can be
achieved by calling get() or getResult()
on the CommandTask returned by this method.
This class is thread-safe, all methods can be called on any thread.
| 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.
|
CommandTask |
send(CommandHandle handle,
Duration timeout,
String command)
Sends a command to a remote subsystem.
|
CommandTask |
send(CommandHandle handle,
Duration timeout,
String destination,
String command)
Sends a command to a remote subsystem.
|
CommandTask |
send(CommandHandle handle,
Duration timeout,
String destination,
String commandName,
String arguments)
Sends a command to a remote subsystem.
|
CommandTask |
send(CommandHandle handle,
String command)
Sends a command to a remote subsystem with the default timeout.
|
CommandTask |
send(CommandHandle handle,
String destination,
String command)
Sends a command to a remote subsystem with the default timeout.
|
CommandTask |
send(CommandHandle handle,
String destination,
String commandName,
String arguments)
Sends a command to a remote subsystem with the default timeout.
|
CommandTask |
send(Duration timeout,
String command)
Sends a command to a remote subsystem, using the default
CommandHandle of this sender to process responses. |
CommandTask |
send(Duration timeout,
String destination,
String command)
Sends a command to a remote subsystem, using the default
CommandHandle of this sender to process responses. |
CommandTask |
send(Duration timeout,
String destination,
String commandName,
String arguments)
Sends a command to a remote subsystem, using the default
CommandHandle of this sender to process responses. |
CommandTask |
send(String command)
Sends a command to a remote subsystem with the default timeout and the default callback handle.
|
CommandTask |
send(String destination,
String command)
Sends a command to a remote subsystem with the default timeout and the default callback handle.
|
CommandTask |
send(String destination,
String commandName,
String arguments)
Sends a command to a remote subsystem with the default timeout and the default callback handle.
|
CommandTask |
sendEncoded(CommandHandle handle,
Duration timeout,
String destination,
String command,
String... args)
Sends a command to a remote subsystem.
|
CommandTask |
sendEncoded(CommandHandle handle,
String destination,
String command,
String... args)
Sends a command to a remote subsystem with the default timeout.
|
CommandTask |
sendEncoded(Duration timeout,
String destination,
String command,
String... args)
Sends a command to a remote subsystem, using the default
CommandHandle of this sender to process responses. |
CommandTask |
sendEncoded(String destination,
String command,
String... args)
Sends a command to a remote subsystem with the default timeout and the default callback handle.
|
CommandTask |
sendRaw(CommandHandle handle,
Duration timeout,
String destination,
String command,
Object... args)
Sends a command to a remote subsystem.
|
CommandTask |
sendRaw(CommandHandle handle,
String destination,
String command,
Object... args)
Sends a command to a remote subsystem with the default timeout.
|
CommandTask |
sendRaw(Duration timeout,
String destination,
String command,
Object... args)
Sends a command to a remote subsystem, using the default
CommandHandle of this sender to process responses. |
CommandTask |
sendRaw(String destination,
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)
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/component0/.../componentN/commandName" 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.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/component0/.../componentN/commandName"} format.args - Command arguments.public CommandTask execute(CommandHandle handle, String command, Object... args)
handle - Handle for processing the command responses.
Cannot be null. If no processing is required, use CommandHandle.NONE.command - Command in "subsystem/component0/.../componentN/commandName" format.args - Command arguments.public CommandTask execute(String command, Object... args)
command - Command in "subsystem/component0/.../componentN/commandName" format.args - Command arguments.public CommandTask sendRaw(CommandHandle handle, Duration timeout, String destination, String command, Object... args)
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.destination - Command destination, in "subsystem/component0/.../componentN" format.command - Command name.args - Command arguments as objects that should be passed directly to the command implementation.public CommandTask sendRaw(Duration timeout, String destination, String command, Object... args)
CommandHandle of this sender to process responses.
If no default handle has been set, responses are ignored.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.destination - Command destination, in "subsystem/component0/.../componentN" format.command - Command name.args - Command arguments as objects that should be passed directly to the command implementation.public CommandTask sendRaw(CommandHandle handle, String destination, String command, Object... args)
handle - Handle for processing the command responses. May be null if no processing is required.destination - Command destination, in "subsystem/component0/.../componentN" format.command - Command name.args - Command arguments as objects that should be passed directly to the command implementation.public CommandTask sendRaw(String destination, String command, Object... args)
destination - Command destination, in "subsystem/component0/.../componentN" format.command - Command name.args - Command arguments as objects that should be passed directly to the command implementation.public CommandTask sendEncoded(CommandHandle handle, Duration timeout, String destination, String command, String... args)
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.destination - Command destination, in "subsystem/component0/.../componentN" format.command - Command name.args - Command arguments encoded as strings.public CommandTask sendEncoded(Duration timeout, String destination, String command, String... args)
CommandHandle of this sender to process responses.
If no default handle has been set, responses are ignored.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.destination - Command destination, in "subsystem/component0/.../componentN" format.command - Command name.args - Command arguments encoded as strings.public CommandTask sendEncoded(CommandHandle handle, String destination, String command, String... args)
handle - Handle for processing the command responses. May be null if no processing is required.destination - Command destination, in "subsystem/component0/.../componentN" format.command - Command name.args - Command arguments encoded as strings.public CommandTask sendEncoded(String destination, String command, String... args)
destination - Command destination, in "subsystem/component0/.../componentN" format.command - Command name.args - Command arguments encoded as strings.public CommandTask send(CommandHandle handle, Duration timeout, String destination, String commandName, String arguments)
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.destination - Command destination, in "subsystem/component0/.../componentN" format.commandName - Command name.arguments - Command arguments encoded as a single string.public CommandTask send(Duration timeout, String destination, String commandName, String arguments)
CommandHandle of this sender to process responses.
If no default handle has been set, responses are ignored.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.destination - Command destination, in "subsystem/component0/.../componentN" format.commandName - Command name.arguments - Command arguments encoded as strings.public CommandTask send(CommandHandle handle, String destination, String commandName, String arguments)
handle - Handle for processing the command responses. May be null if no processing is required.destination - Command destination, in "subsystem/component0/.../componentN" format.commandName - Command name.arguments - Command arguments encoded as a single string.public CommandTask send(String destination, String commandName, String arguments)
destination - Command destination, in "subsystem/component0/.../componentN" format.commandName - Command name.arguments - Command arguments encoded as a single string.public CommandTask send(CommandHandle handle, Duration timeout, String destination, String command)
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.destination - Command destination, in "subsystem/component0/.../componentN" format.command - Command with arguments, encoded as a single string.public CommandTask send(Duration timeout, String destination, String command)
CommandHandle of this sender to process responses.
If no default handle has been set, responses are ignored.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.destination - Command destination, in "subsystem/component0/.../componentN" format.command - Command with arguments, encoded as a single string.public CommandTask send(CommandHandle handle, String destination, String command)
handle - Handle for processing the command responses. May be null if no processing is required.destination - Command destination, in "subsystem/component0/.../componentN" format.command - Command with arguments, encoded as a single string.public CommandTask send(String destination, String command)
destination - Command destination, in "subsystem/component0/.../componentN" format.command - Command with arguments, encoded as a single string.public CommandTask send(CommandHandle handle, Duration timeout, String command)
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 with destination and arguments, as it would be given to a command shell.public CommandTask send(Duration timeout, String command)
CommandHandle of this sender to process responses.
If no default handle has been set, responses are ignored.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 with destination and arguments, as it would be given to a command shell.public CommandTask send(CommandHandle handle, String command)
handle - Handle for processing the command responses. May be null if no processing is required.command - Command with destination and arguments, as it would be given to a command shell.public CommandTask send(String command)
command - Command with destination and arguments, as it would be given to a command shell.Copyright © 2023 LSST. All rights reserved.