public class AgentStatusAggregator extends Object
For each Agent present on the buses, this aggregator obtains data dictionary and compiles the
complete list of AgentChannel. Published data not present in the dictionary is ignored.
If there are any listeners interested in a specific Agent, all channels for that Agent are kept
up to date. If there are no such listeners, only "infrequently updated channels" are updated.
Listeners registered with this aggregator are notified of any changes in the channels they
requested. See
addListener(AgentStatusListener listener, AgentChannelsFilter filter) and
addListener(AgentStatusListener listener, Collection agents, Collection channels)
method descriptions for explanation of how filters, as well as explicit lists of agents and
channels, are used to determine what events are delivered to each listener.
The aggregator modifies its state (in response to status messages received on the buses) and notifies listeners on a single dedicated thread. No new messages will be processed, and the aggregator state will not change, until all listeners process the current event. Listeners that need to perform any time consuming or potentially blocking operations should do that on other threads to avoid clogging the aggregator.
Methods that retrieve current status of agents and channels can be called on any thread - they are guaranteed to report consistent information that reflects the aggregator state that existed at some point between processing two consecutive status messages. There is no guarantee, however, that the aggregator will remain in that state by the time these methods return. There is also no guarantee that the state of the aggregator reflects the actual current state of an Agent, due to the asynchronous nature of message delivery and delays in processing.
| Constructor and Description |
|---|
AgentStatusAggregator() |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(AgentStatusListener listener,
AgentChannelsFilter filter)
Adds a listener to be notified of changes in agents and channels specified by the filter.
|
void |
addListener(AgentStatusListener listener,
Collection<String> agents,
Collection<String> channels)
Adds a listener to be notified of changes in specified agents and data
channels.
|
org.lsst.ccs.bus.data.AgentInfo |
getAgent(String agentName)
Return
AgentInfo instance for the specified Agent. |
List<org.lsst.ccs.bus.data.AgentInfo> |
getAgents()
Lists currently connected agents.
|
org.lsst.ccs.bus.states.StateBundle |
getAgentState(String agentName)
Returns the current state of the specified
Agent. |
AgentChannel |
getChannel(String path)
Returns the channel specified by the given path.
|
List<AgentChannel> |
getDictionaryChannels(List<String> agents,
List<String> channelSelectors)
Returns a list of channels identified by the specified selectors.
|
boolean |
hasAgent(String agentName)
Returns
true if the specified localAgent is present on the buses. |
void |
initialize()
Initializes this status aggregator.
|
void |
removeListener(AgentStatusListener listener)
Removes the specified listener.
|
void |
shutdown()
Shuts down this status aggregator.
|
public void initialize()
public void shutdown()
public List<org.lsst.ccs.bus.data.AgentInfo> getAgents()
public org.lsst.ccs.bus.data.AgentInfo getAgent(String agentName)
AgentInfo instance for the specified Agent.agentName - Name of the localAgent.AgentInfo instance, or null is no localAgent with the specified name is connected to the buses.public boolean hasAgent(String agentName)
true if the specified localAgent is present on the buses.agentName - Agent name.true if the localAgent is connected.public List<AgentChannel> getDictionaryChannels(List<String> agents, List<String> channelSelectors)
This method returns all matching channels found in data dictionaries of remote agents, regardless of whether there are any listeners watching those channels. Unwatched channels can only be used to retrieve their paths and static attributes. Current values and metadata may be not set or outdated.
agents - Subsystem names.channelSelectors - Channel selectors.public AgentChannel getChannel(String path)
path - Data channel path.null if the channel is not being watched by this aggregator.public org.lsst.ccs.bus.states.StateBundle getAgentState(String agentName)
Agent.agentName - Name of the localAgent.public void addListener(AgentStatusListener listener, AgentChannelsFilter filter)
The listener is added with the lists of agents and channels returned by the filter's
getAgents() and getOriginChannels() methods, respectively. No reference
to the filter is kept, no filter methods are called when processing messages.
listener - Listener to be added.filter - Channels filter.NullPointerException - if either argument is null.public void addListener(AgentStatusListener listener, Collection<String> agents, Collection<String> channels)
agents and
channels arguments equal to null forces this aggregator
to watch all channels from all agents.
The list of channels passed to this method may contain:
[Agent]/[partial path][/]"
format. Templates that omit the Agent name are expanded against all
agents whose names are in the agents list (or all agents present
on the buses if that list is null). Templates that end with "/"
match all channels that start with "Agent/partial path/".
[agent.name=value&][agent.type=value&][agent.key[=value]&…&agent.key[=value]&][key[=value]&…&key[=value]]"
format, where key and value are names and values of
Agent properties or static channel attributes. If value is
omitted, the existence of the attribute is checked. Note that
templates and selectors are only applied to channels and their attributes as
listed in the agent channels dictionary. Any channels not appearing
in the dictionary are ignored, as are attribute changes.
The listener is notified of agent connection, configuration, and
disconnection events if the agent name is in the supplied list of
channels, or the list is null, or the Agent name is
explicitly contained in any of the templates and selectors.
The listener is notified of value changes in data channels if:
Unless the agent list is null, templates and selectors that do not explicitly
specify agent names are only applied to agents whose names are on the Agent list.
listener - Listener to be added.agents - Names of agents the listener is interested in.
If null, the listener will be notified of changes in all agents.channels - Paths, templates, and selectors specifying channels the listener is interested in.
If null, the listener is notified of changes in all channels from the
specified agents. Supplying an empty list ensures that the listener is only
notified of agent connections and disconnections.NullPointerException - if the listener argument is null.public void removeListener(AgentStatusListener listener)
listener - Listener to be removed.Copyright © 2023 LSST. All rights reserved.