Package org.yamcs.commanding
Class CommandQueueManager
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractService
-
- org.yamcs.commanding.CommandQueueManager
-
- All Implemented Interfaces:
com.google.common.util.concurrent.Service
,ParameterConsumer
,SystemParametersProducer
public class CommandQueueManager extends com.google.common.util.concurrent.AbstractService implements ParameterConsumer, SystemParametersProducer
Implements the management of the control queues for one processor:- for each command that is sent, based on the sender it finds the queue where the command should go
- depending on the queue state the command can be immediately sent, stored in the queue or rejected
- when the command is immediately sent or rejected, the command queue monitor is not notified
- if the command has transmissionConstraints with timeout > 0, the command can sit in the queue even if the queue is not blocked
-
-
Constructor Summary
Constructors Constructor Description CommandQueueManager(CommandingManager commandingManager)
Constructs a Command Queue Manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CommandQueue
addCommand(User user, PreparedCommand pc)
Called from the CommandingImpl to add a command to the queue.void
addToCommandHistory(org.yamcs.protobuf.Commanding.CommandId commandId, org.yamcs.protobuf.Commanding.CommandHistoryAttribute attribute)
void
doStart()
called at processor startup, subscribe all parameters required for checking command constraintsvoid
doStop()
String
getChannelName()
String
getInstance()
CommandQueue
getQueue(String name)
CommandQueue
getQueue(User user, PreparedCommand pc)
List<CommandQueue>
getQueues()
Collection<ParameterValue>
getSystemParameters()
return the next bunch of parameter values.void
registerListener(CommandQueueListener cqm)
Called from a queue monitor to register itself in order to be notified when new commands are added/removed from the queue.PreparedCommand
rejectCommand(UUID uuid, String username)
PreparedCommand
rejectCommand(org.yamcs.protobuf.Commanding.CommandId commandId, String username)
Called by external clients to remove a command from the queueboolean
removeListener(CommandQueueListener cqm)
PreparedCommand
sendCommand(UUID uuid, boolean rebuild)
PreparedCommand
sendCommand(org.yamcs.protobuf.Commanding.CommandId commandId, boolean rebuild)
Called from external client to release a command from the queueCommandQueue
setQueueState(String queueName, org.yamcs.protobuf.Commanding.QueueState newState)
Called from external clients to change the state of the queuevoid
updateItems(int subscriptionId, List<ParameterValue> items)
-
-
-
Constructor Detail
-
CommandQueueManager
public CommandQueueManager(CommandingManager commandingManager) throws ConfigurationException, ValidationException
Constructs a Command Queue Manager.- Parameters:
commandingManager
-- Throws:
ConfigurationException
- When there is an error in the configuration file. Note: if the configuration file doesn't exist, this exception is not thrown.ValidationException
- When configuration file is incorrect.
-
-
Method Detail
-
doStart
public void doStart()
called at processor startup, subscribe all parameters required for checking command constraints- Specified by:
doStart
in classcom.google.common.util.concurrent.AbstractService
-
doStop
public void doStop()
- Specified by:
doStop
in classcom.google.common.util.concurrent.AbstractService
-
getQueues
public List<CommandQueue> getQueues()
-
getQueue
public CommandQueue getQueue(String name)
-
addCommand
public CommandQueue addCommand(User user, PreparedCommand pc)
Called from the CommandingImpl to add a command to the queue.First the command is added to the command history. Depending on the status of the queue, the command is rejected by setting the CommandFailed in the command history added to the queue or directly sent using the command releaser.
- Parameters:
user
-pc
-- Returns:
- the queue the command was added to
-
addToCommandHistory
public void addToCommandHistory(org.yamcs.protobuf.Commanding.CommandId commandId, org.yamcs.protobuf.Commanding.CommandHistoryAttribute attribute)
-
getQueue
public CommandQueue getQueue(User user, PreparedCommand pc)
- Parameters:
user
-pc
-- Returns:
- the queue where the command should be placed.
-
rejectCommand
public PreparedCommand rejectCommand(org.yamcs.protobuf.Commanding.CommandId commandId, String username)
Called by external clients to remove a command from the queue- Parameters:
commandId
-username
- the username rejecting the command- Returns:
- the command removed from the queeu
-
rejectCommand
public PreparedCommand rejectCommand(UUID uuid, String username)
-
sendCommand
public PreparedCommand sendCommand(org.yamcs.protobuf.Commanding.CommandId commandId, boolean rebuild)
Called from external client to release a command from the queue- Parameters:
commandId
-rebuild
- - if to rebuild the command binary from the source- Returns:
- the prepared command sent
-
sendCommand
public PreparedCommand sendCommand(UUID uuid, boolean rebuild)
-
setQueueState
public CommandQueue setQueueState(String queueName, org.yamcs.protobuf.Commanding.QueueState newState)
Called from external clients to change the state of the queue- Parameters:
queueName
- the queue whose state has to be setnewState
- the new state of the queue- Returns:
- the queue whose state has been changed or null if no queue by the name exists
-
registerListener
public void registerListener(CommandQueueListener cqm)
Called from a queue monitor to register itself in order to be notified when new commands are added/removed from the queue.- Parameters:
cqm
- the callback which will be called with updates
-
removeListener
public boolean removeListener(CommandQueueListener cqm)
-
getInstance
public String getInstance()
-
getChannelName
public String getChannelName()
-
updateItems
public void updateItems(int subscriptionId, List<ParameterValue> items)
- Specified by:
updateItems
in interfaceParameterConsumer
-
getSystemParameters
public Collection<ParameterValue> getSystemParameters()
Description copied from interface:SystemParametersProducer
return the next bunch of parameter values. The values must contain a reference to a Parameter (i.e. parameter definition) and that Parameter does not need to be coming from the XtceDB - the provider can just make it up on the fly.- Specified by:
getSystemParameters
in interfaceSystemParametersProducer
-
-