public class AgentStatusAggregatorService extends Object implements StatusMessageListener, ServiceLifecycle, AgentPresenceListener
It will keep at least the last value of each status data it is configured to monitor.
It can also keep a history during a given time, and accumulate statistics over a given time.
This service is installed by default for all Agents but it is registered to the status bus only when configured to listen to specific data. There are two ways to configure this service:
#setAggregatePattern() method
| Modifier and Type | Class and Description |
|---|---|
static class |
AgentStatusAggregatorService.Statistics
Internal class, unmutable data structure with min, max, average and
stddev.
|
static class |
AgentStatusAggregatorService.StatusAggregateConfig |
static class |
AgentStatusAggregatorService.TimedValue
Internal class, unmutable data structure with name, timestamp and value.
|
| Constructor and Description |
|---|
AgentStatusAggregatorService() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearAgentDataOlderThan(String agentName,
Instant inst)
Clear all data older than the provided Instant for the given agent name.
|
void |
connecting(AgentInfo... agents)
Indicates that the list of agents represented by
agents is present on the
buses. |
void |
disconnected(AgentInfo... agents)
Invoked when one or more agents are disconnected from this cluster, either
because the shutdown or because they were lost.
|
Map<String,Object> |
getAllLast()
returns the last values of all parameters monitored
|
Map<String,AgentStatusAggregatorService.TimedValue> |
getAllLastTV()
returns the last values of all parameters monitored, with their
timestamp.
|
Map<String,AgentStatusAggregatorService.Statistics> |
getAllStatistics()
returns the statistics of all parameters monitored.
|
double |
getAverage(String key)
returns the average (over the configured duration) for a given key.
|
protected AgentStatusAggregatorService.StatusAggregateConfig |
getConfig(AgentInfo agent,
String dataKey,
String sourceBasedFullKey) |
List<AgentStatusAggregatorService.TimedValue> |
getHistory(String key)
returns the history (over the configured duration) for a given key.
|
Object |
getLast(String key)
returns the last value seen for a given key (which has to be monitored)
|
AgentStatusAggregatorService.TimedValue |
getLastTV(String key)
returns the last value seen for a given key (which has to be monitored)
|
double |
getMax(String key)
returns the max (over the configured duration) for a given key.
|
double |
getMin(String key)
returns the min (over the configured duration) for a given key.
|
AgentStatusAggregatorService.Statistics |
getStatistics(String key)
returns statistics (over the configured duration) for a given key.
|
List<AgentStatusAggregatorService.StatusAggregateConfig> |
getStatusAggregateConfig() |
double |
getStdDev(String key)
returns the stddev (over the configured duration) for a given key.
|
void |
onStatusMessage(StatusMessage msg)
Called when a status message is received.
|
void |
preInit() |
void |
preStart()
Called from the enclosing
Subsystem when
org.lsst.ccs.Subsystem#start() has been called. |
String |
printAllLatestData()
Print all the latest data.
|
protected void |
setAggregatePattern(AgentPropertyPredicate agentPropertyPredicate,
Pattern pattern,
int historyDuration,
int aggregateWindow,
String alias)
Configures the StatusAgregator to monitor all the data which
name matches a regex pattern.
|
void |
setAggregatePattern(AgentPropertyPredicate agentPropertyPredicate,
String pattern)
Configures the StatusAgregator to monitor all the data which
name matches a regex pattern.
|
void |
setAggregatePattern(AgentPropertyPredicate agentPropertyPredicate,
String pattern,
int historyDuration,
int aggregateWindow,
String alias) |
void |
setAggregatePattern(AgentPropertyPredicate agentPropertyPredicate,
String pattern,
String alias) |
void |
setPatternConfigList(List<AgentStatusAggregatorService.StatusAggregateConfig> list) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitafterBuild, afterInit, afterStart, preBuild, preShutdownconnected, disconnectingpublic void preInit()
preInit in interface ServiceLifecyclepublic void preStart()
ServiceLifecycleSubsystem when
org.lsst.ccs.Subsystem#start() has been called.
The preceding lifecycle step is HasLifecycle.postInit()
The following lifecycle step is HasLifecycle.start()
At the time it is called :
PhaseState is
INITIALIZING
connection with the messaging layer is effective, the enclosing
subsystem has started StatusHeartBeat
publication
preStart in interface ServiceLifecyclepublic void connecting(AgentInfo... agents)
AgentPresenceListeneragents is present on the
buses.
This method is invoked when the listener is added with all the agents that
are already connected.
At this point not all services on the connecting agents
are guaranteed to have completely started. This method should be used only
to receive a notification that an agent is connecting.
For a guarantee that an agent information is fully present, please use the
#connected methods.
The implementation should return immediately : any blocking operations
should be scheduled on a separate thread.connecting in interface AgentPresenceListenerpublic void disconnected(AgentInfo... agents)
AgentPresenceListenerdisconnected in interface AgentPresenceListener@ConfigurationParameterChanger(propertyName="patternConfigList") public void setPatternConfigList(List<AgentStatusAggregatorService.StatusAggregateConfig> list)
public List<AgentStatusAggregatorService.StatusAggregateConfig> getStatusAggregateConfig()
public void setAggregatePattern(AgentPropertyPredicate agentPropertyPredicate, String pattern)
agentPropertyPredicate - A Predicate to select which agent the data
is coming from. This predicate allows to select agents
based on the agent propertiespattern - a regex pattern used to select which data is to be retained.historyDuration - duration (in ms) for which to keep history. -1 not to keep
history. -1 is the defaultaggregateWindow - duration (in ms) for which to compute aggregates and stats. -1
not to compute, it is the defaultalias - An alias to be used when storing the data instead of the subsystem name.
By default the data that passes the regex pattern is stored
with a key of the form "agentName/dataTrendingPath.
If an alias is specified the key will be "alias/dataTrendingPath" instead.
This is useful when it is necessary to hide the agentName.
This methods must be invoked before the start lifecycle's method.
If invoked too late an exception will be thrown.public void setAggregatePattern(AgentPropertyPredicate agentPropertyPredicate, String pattern, String alias)
public void setAggregatePattern(AgentPropertyPredicate agentPropertyPredicate, String pattern, int historyDuration, int aggregateWindow, String alias)
protected void setAggregatePattern(AgentPropertyPredicate agentPropertyPredicate, Pattern pattern, int historyDuration, int aggregateWindow, String alias)
pattern - the pattern that the data ("subsystem/key") to be monitored
must match.historyDuration - duration (in ms) for which to keep history. -1 not to keep
history.aggregateWindow - duration (in ms) for which to compute aggregates and stats. -1
not to compute.protected AgentStatusAggregatorService.StatusAggregateConfig getConfig(AgentInfo agent, String dataKey, String sourceBasedFullKey)
public void onStatusMessage(StatusMessage msg)
StatusMessageListeneronStatusMessage in interface StatusMessageListenermsg - Status bus message to be processed.public Object getLast(String key)
key - public AgentStatusAggregatorService.TimedValue getLastTV(String key)
key - public double getAverage(String key)
key - public double getStdDev(String key)
key - public double getMin(String key)
key - public double getMax(String key)
key - public List<AgentStatusAggregatorService.TimedValue> getHistory(String key)
key - public AgentStatusAggregatorService.Statistics getStatistics(String key)
key - public Map<String,Object> getAllLast()
public Map<String,AgentStatusAggregatorService.TimedValue> getAllLastTV()
public Map<String,AgentStatusAggregatorService.Statistics> getAllStatistics()
public void clearAgentDataOlderThan(String agentName, Instant inst)
agentName - the name of the agent for which the data is clearedinst - The provided UTC InstantCopyright © 2024 LSST. All rights reserved.