Class AgentMessagingLayer

java.lang.Object
org.lsst.ccs.messaging.AgentMessagingLayer
All Implemented Interfaces:
AgentMessagingLayerMBean

public class AgentMessagingLayer extends Object implements AgentMessagingLayerMBean
This interface provides messaging methods for a component (eg an agent) to be able to communicate on the buses. Provided methods allow to add/remove message listeners on each of the buses, to send message on each of the buses, to specify a unique CommandExecutor associated to the agent and a list of CommandOriginator.
Author:
LSST CCS Team
  • Method Details

    • createInstance

      public static AgentMessagingLayer createInstance(AgentInfo agentInfo, LockLevelService lockLevelService)
      Build an Instance of an AgentMessagingLayer for a given Agent by providing the AgentInfo object.
      Parameters:
      agentInfo -
      lockLevelService -
      Returns:
      The corresponding AgentMessagingLayer.
    • restart

      public void restart(int seconds)
      This method is meant to be invoked from JMX
      Specified by:
      restart in interface AgentMessagingLayerMBean
      Parameters:
      seconds - The number of seconds to wait before restarting the messaging layer.
    • addBusMessagePreProcessor

      public final void addBusMessagePreProcessor(BusMessagePreProcessor preProcessor)
      Add a BusMessagePreProcessor the the AgentMessagingLayer.
      Parameters:
      preProcessor - The BusMessagePreProcessor to be added.
    • getApplicationLayer

      public BusApplicationLayer getApplicationLayer()
    • getMessagingLayer

      public MessagingLayer getMessagingLayer()
    • getAgentInfo

      public AgentInfo getAgentInfo()
    • shutdownBusAccess

      public void shutdownBusAccess()
    • connectToBuses

      public void connectToBuses()
    • getAgentPresenceManager

      public AgentPresenceManager getAgentPresenceManager()
    • needsHeartbeat

      public boolean needsHeartbeat()
      Does this messaging layer need a Heartbeat for failure detection?
      Returns:
      true if this feature is not provided and the Toolkit needs to provide a heartbeat.
    • getAgentLockService

      public LockLevelService getAgentLockService()
      Returns:
      The public API
    • addLogMessageListener

      public void addLogMessageListener(LogMessageListener listener)
      Adds a listener on the Log bus. By default the listener is negate passed messages published from this AgentMessagingLayer.
      Parameters:
      listener - the listener to be added on the Log bus
    • addLogMessageListener

      public void addLogMessageListener(LogMessageListener listener, Predicate<BusMessage<? extends Serializable,?>> filter)
      Adds a listener on the Log bus with a filter. The listener is passed bus messages that pass the filter. If the filter is null, all messages are passed to the filter.
      Parameters:
      listener - the listener to be added on the Log bus
      filter - The BusMessageFilter to be applied to the incoming Bus Messages
    • addStatusMessageListener

      public void addStatusMessageListener(StatusMessageListener listener)
      Adds a listener on the Status bus. By default the listener is negate passed messages published from this AgentMessagingLayer.
      Parameters:
      listener - the listener to be added on the Status bus
    • addStatusMessageListener

      public void addStatusMessageListener(StatusMessageListener listener, Predicate<BusMessage<? extends Serializable,?>> filter)
      Adds a listener on the Status bus with a filter. The listener is passed bus messages that pass the filter. If the filter is null, all messages are passed to the filter.
      Parameters:
      listener - the listener to be added on the Status bus
      filter - The BusMessageFilter to be applied to the incoming Bus Messages
    • addCommandMessageListener

      public void addCommandMessageListener(CommandMessageListener listener)
      Adds a listener on the Command bus. By default the listener is negate passed messages published from this AgentMessagingLayer.
      Parameters:
      listener - the listener to be added on the Command bus
    • addCommandMessageListener

      public void addCommandMessageListener(CommandMessageListener listener, Predicate<BusMessage<? extends Serializable,?>> filter)
      Adds a listener on the Command bus with a filter. The listener is passed bus messages that pass the filter. If the filter is null, all messages are passed to the filter.
      Parameters:
      listener - the listener to be added on the Command bus
      filter - The BusMessageFilter to be applied to the incoming Bus Messages
    • removeLogMessageListener

      public void removeLogMessageListener(LogMessageListener listener)
      Removes a listener on the Log bus
      Parameters:
      listener - the listener to be removed on the Log bus
    • removeStatusMessageListener

      public void removeStatusMessageListener(StatusMessageListener listener)
      Removes a listener on the Status bus
      Parameters:
      listener - the listener to be removed on the Status bus
    • removeCommandMessageListener

      public void removeCommandMessageListener(CommandMessageListener listener)
      Removes a listener on the Command bus
      Parameters:
      listener - the listener to be removed on the Command bus
    • sendLogMessage

      public void sendLogMessage(LogMessage msg)
      Sends a Log Message on the Log Bus
      Parameters:
      msg - The message to be sent on the Log bus
    • sendStatusMessage

      public void sendStatusMessage(StatusMessage msg)
      Sends a Status Message on the Status Bus
      Parameters:
      msg - The message to be sent on the Status bus
    • sendStatusMessage

      public void sendStatusMessage(StatusMessage msg, MessageFlag... flags)
    • sendCommandRequest

      public void sendCommandRequest(CommandRequest cmd, CommandOriginator originator)
      Sends a Command Request on the Command Bus. This message will be received by the CommandExecutor and the list of CommandMessageListener
      Parameters:
      cmd - The CommandRequest to be sent on the Command bus
      originator - The component that has requested the execution of the command
      Throws:
      DestinationsException - if the command target is not present on the buses.
    • sendCommandRequest

      public void sendCommandRequest(CommandRequest cmd, CommandOriginator originator, boolean checkDestinationExists)
    • sendCommandReply

      public void sendCommandReply(CommandReply reply)
      Sends a Command Reply on the Command Bus. This message will be received by the CommandOriginator and the list of CommandMessageListener The reply can be a Nack, Ack, Error or Result
      Parameters:
      reply - The CommandReply to be sent on the Command bus
    • waitForMessageLayerConnection

      public void waitForMessageLayerConnection()
    • setCommandExecutor

      public void setCommandExecutor(CommandExecutor executor)
      Defines the component able to execute an incoming command
      Parameters:
      executor -
    • setClusterDeserializationErrorHandler

      public void setClusterDeserializationErrorHandler(ClusterDeserializationErrorHandler h)
    • addOutgoingMessageListenerForBus

      public void addOutgoingMessageListenerForBus(OutgoingMessageListener listener, Bus... bus)
    • removeOutgoingMessageListenerForBus

      public void removeOutgoingMessageListenerForBus(OutgoingMessageListener listener)