Package org.lsst.ccs.messaging
Class AgentMessagingLayer
java.lang.Object
org.lsst.ccs.messaging.AgentMessagingLayer
- All Implemented Interfaces:
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
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddBusMessagePreProcessor(BusMessagePreProcessor preProcessor) Add a BusMessagePreProcessor the the AgentMessagingLayer.voidAdds a listener on the Command bus.voidaddCommandMessageListener(CommandMessageListener listener, Predicate<BusMessage<? extends Serializable, ?>> filter) Adds a listener on the Command bus with a filter.voidaddLogMessageListener(LogMessageListener listener) Adds a listener on the Log bus.voidaddLogMessageListener(LogMessageListener listener, Predicate<BusMessage<? extends Serializable, ?>> filter) Adds a listener on the Log bus with a filter.voidaddOutgoingMessageListenerForBus(OutgoingMessageListener listener, Bus... bus) voidAdds a listener on the Status bus.voidaddStatusMessageListener(StatusMessageListener listener, Predicate<BusMessage<? extends Serializable, ?>> filter) Adds a listener on the Status bus with a filter.voidstatic AgentMessagingLayercreateInstance(AgentInfo agentInfo, LockLevelService lockLevelService) Build an Instance of an AgentMessagingLayer for a given Agent by providing the AgentInfo object.booleanDoes this messaging layer need a Heartbeat for failure detection?voidRemoves a listener on the Command busvoidremoveLogMessageListener(LogMessageListener listener) Removes a listener on the Log busvoidvoidRemoves a listener on the Status busvoidrestart(int seconds) This method is meant to be invoked from JMXvoidsendCommandReply(CommandReply reply) Sends a Command Reply on the Command Bus.voidsendCommandRequest(CommandRequest cmd, CommandOriginator originator) Sends a Command Request on the Command Bus.voidsendCommandRequest(CommandRequest cmd, CommandOriginator originator, boolean checkDestinationExists) voidsendLogMessage(LogMessage msg) Sends a Log Message on the Log BusvoidSends a Status Message on the Status BusvoidsendStatusMessage(StatusMessage msg, MessageFlag... flags) voidvoidsetCommandExecutor(CommandExecutor executor) Defines the component able to execute an incoming commandvoidvoid
-
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:
restartin interfaceAgentMessagingLayerMBean- Parameters:
seconds- The number of seconds to wait before restarting the messaging layer.
-
addBusMessagePreProcessor
Add a BusMessagePreProcessor the the AgentMessagingLayer.- Parameters:
preProcessor- The BusMessagePreProcessor to be added.
-
getApplicationLayer
-
getMessagingLayer
-
getAgentInfo
-
shutdownBusAccess
public void shutdownBusAccess() -
connectToBuses
public void connectToBuses() -
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
- Returns:
- The public API
-
addLogMessageListener
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 busfilter- The BusMessageFilter to be applied to the incoming Bus Messages
-
addStatusMessageListener
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 busfilter- The BusMessageFilter to be applied to the incoming Bus Messages
-
addCommandMessageListener
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 busfilter- The BusMessageFilter to be applied to the incoming Bus Messages
-
removeLogMessageListener
Removes a listener on the Log bus- Parameters:
listener- the listener to be removed on the Log bus
-
removeStatusMessageListener
Removes a listener on the Status bus- Parameters:
listener- the listener to be removed on the Status bus
-
removeCommandMessageListener
Removes a listener on the Command bus- Parameters:
listener- the listener to be removed on the Command bus
-
sendLogMessage
Sends a Log Message on the Log Bus- Parameters:
msg- The message to be sent on the Log bus
-
sendStatusMessage
Sends a Status Message on the Status Bus- Parameters:
msg- The message to be sent on the Status bus
-
sendStatusMessage
-
sendCommandRequest
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 busoriginator- 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
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
Defines the component able to execute an incoming command- Parameters:
executor-
-
setClusterDeserializationErrorHandler
-
addOutgoingMessageListenerForBus
-
removeOutgoingMessageListenerForBus
-