
public class AgentStatusAggregatorService extends Object implements StatusMessageListener, ServiceLifecycle, AgentPresenceListener, AgentService
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 |
connecting(AgentInfo agent)
Indicates that the agent represented by
agent is present on the
buses. |
void |
disconnecting(AgentInfo agent)
Indicates that the agent represented by
agent has left the buses. |
String |
getAgentServiceName()
Get the name of this service.
|
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 |
preStart()
Called from the enclosing
Subsystem when
org.lsst.ccs.Subsystem#start() has been called. |
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, waitafterInit, preBuild, preInit, preShutdownconnected, connectingstartForAgentpublic String getAgentServiceName()
AgentServicegetAgentServiceName in interface AgentServicepublic 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 agent)
AgentPresenceListeneragent is present on the
buses.
This method is called when the first messages for a given agent is received.
In the case of an agent starting up the fist messages is sent when the
agent is in PhaseState::INITIALIZING state. At this point not all services
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 disconnecting(AgentInfo agent)
AgentPresenceListeneragent has left the buses.
The implementation should return immediately : any blocking operations
should be scheduled on a separate thread.disconnecting 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()
Copyright © 2019 LSST. All rights reserved.