Package org.lsst.ccs.messaging
Class AgentPresenceManager
java.lang.Object
org.lsst.ccs.messaging.AgentPresenceManager
- All Implemented Interfaces:
ClusterMembershipListener,MessageListener,StatusMessageListener
public class AgentPresenceManager
extends Object
implements StatusMessageListener, ClusterMembershipListener
Tracks agent connection and disconnection on the buses.
- Author:
- emarin
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionAgentPresenceManager(AgentInfo agentInfo, AgentMessagingLayer agentMessagingLayer) -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanagentExists(String agentName) This method returns true as soon as the AgentPresenceManager is aware of the existence of the given agent by name.booleanisAgentConnected(String agentName) This method returns true when the given agent is fully connected, OPERATIONAL and ready to receive commands.booleanisAgentConnected(AgentPropertyPredicate agentPredicate) This method returns true when the given agent is fully connected, OPERATIONAL and ready to receive commands.voidmembersJoined(List<String> joined, boolean isMerge) voidmembersLeft(List<String> left) voidCalled when a status message is received.voidprocessConnectionDisconnectionEvent(AgentPresenceManager.AgentPresenceState state, AgentInfo... agentInfos) voidfinal booleanwaitForAgent(String name, long timeout, TimeUnit unit) Deprecated.use method waitForConnectedAgentfinal booleanwaitForAgent(AgentPropertyPredicate predicate, long timeout, TimeUnit unit) Deprecated.use method waitForAgentPredicatefinal booleanwaitForAgentDisconnection(String name, long timeout, TimeUnit unit) Deprecated.Use method waitForDisconnectedAgentfinal voidwaitForAgentPredicate(AgentPropertyPredicate predicate, long timeout, TimeUnit unit) final voidwaitForConnectedAgent(String name, long timeout, TimeUnit unit) final voidwaitForDisconnectedAgent(String name, long timeout, TimeUnit unit) final voidwaitForFirstContact(long timeout, TimeUnit unit)
-
Constructor Details
-
AgentPresenceManager
-
-
Method Details
-
onStatusMessage
Description copied from interface:StatusMessageListenerCalled when a status message is received. The implementation should be thread-safe: the framework makes no guarantees on what thread this method will be called on, and it can be called concurrently for several messages. The implementation should also return immediately : any blocking operations should be scheduled on a separate thread.- Specified by:
onStatusMessagein interfaceStatusMessageListener- Parameters:
s- Status bus message to be processed.
-
listConnectedAgents
- Returns:
- The list with the currently connected Agents
-
waitForFirstContact
-
membersLeft
- Specified by:
membersLeftin interfaceClusterMembershipListener
-
membersJoined
- Specified by:
membersJoinedin interfaceClusterMembershipListener
-
processConnectionDisconnectionEvent
public void processConnectionDisconnectionEvent(AgentPresenceManager.AgentPresenceState state, AgentInfo... agentInfos) -
addAgentPresenceListener
-
removeAgentPresenceListener
-
agentExists
This method returns true as soon as the AgentPresenceManager is aware of the existence of the given agent by name. At this point we don't guarantee that the corresponding agent is ready to receive command requests as it might still be INITIALIZING. To be sure that an agent is fully connected, OPERATIONAL and ready to receive message use method#isAgentConnected(String)instead.- Parameters:
agentName- The name of the agent- Returns:
- true if the AgentPresenceManager is aware of the existence of this agent.
-
isAgentConnected
This method returns true when the given agent is fully connected, OPERATIONAL and ready to receive commands.- Parameters:
agentName- The name of the Agent.- Returns:
- true when the given agent is fully connected.
-
isAgentConnected
This method returns true when the given agent is fully connected, OPERATIONAL and ready to receive commands.- Parameters:
agentPredicate- The predicate to select the Agent.- Returns:
- true when the given agent is fully connected.
-
waitForAgent
@Deprecated public final boolean waitForAgent(String name, long timeout, TimeUnit unit) throws InterruptedException Deprecated.use method waitForConnectedAgentWait for an Agent to be fully connected: all the listeners have been notified on the connected method.- Parameters:
name- The name of the Agenttimeout- The time to wait for the agent to become available.unit- The TimeUnit for the timeout.- Returns:
- True if the Agent is fully connected within the provided timeout, false otherwise.
- Throws:
InterruptedException
-
waitForConnectedAgent
public final void waitForConnectedAgent(String name, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException - Throws:
InterruptedExceptionTimeoutException
-
waitForAgent
@Deprecated public final boolean waitForAgent(AgentPropertyPredicate predicate, long timeout, TimeUnit unit) throws InterruptedException Deprecated.use method waitForAgentPredicateWait for an AgentPredicate to be met.- Parameters:
predicate- The predicate to be mettimeout- The time to wait for the agent to become available.unit- The TimeUnit for the timeout.- Returns:
- True if the Agent is fully connected within the provided timeout, false otherwise.
- Throws:
InterruptedException
-
waitForAgentPredicate
public final void waitForAgentPredicate(AgentPropertyPredicate predicate, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException - Throws:
InterruptedExceptionTimeoutException
-
waitForAgentDisconnection
@Deprecated public final boolean waitForAgentDisconnection(String name, long timeout, TimeUnit unit) throws InterruptedException Deprecated.Use method waitForDisconnectedAgentWait for an Agent to be fully disconnected: all the listeners have been notified on the disconnected method.- Parameters:
name- The name of the Agenttimeout- The time to wait for the agent to become available.unit- The TimeUnit for the timeout.- Returns:
- True if the Agent is disconnected from the buses within the provided timeout, false otherwise.
- Throws:
InterruptedException
-
waitForDisconnectedAgent
public final void waitForDisconnectedAgent(String name, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException - Throws:
InterruptedExceptionTimeoutException
-