Class 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
    Note: the update of the command monitors is done in the same thread. That means that if the connection to one of the monitors is lost, there may be a delay of a few seconds. As the monitoring clients will be priviledged users most likely connected in the same LAN, I don't consider this to be an issue.
    • Method Detail

      • doStart

        public void doStart()
        called at processor startup, subscribe all parameters required for checking command constraints
        Specified by:
        doStart in class com.google.common.util.concurrent.AbstractService
      • doStop

        public void doStop()
        Specified by:
        doStop in class com.google.common.util.concurrent.AbstractService
      • 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
      • 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
      • 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 set
        newState - 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
      • getInstance

        public String getInstance()
      • getChannelName

        public String getChannelName()