public class StatusAggregator extends Object implements StatusMessageListener
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.
The StatusAggregator should be registered on the bus, with something like
MessagingAccess.getInstance().forSubsystem("archon-sl").addStatusListener(sa);
note the specific name so that the listener receives status messages also
from its host subsystem, if it is useful.
It should also be configured to monitor and store status data using the setAggregate or setAggregatePattern methods for each relevant data name.
| Modifier and Type | Class and Description |
|---|---|
static class |
StatusAggregator.Statistics
Internal class, unmutable data structure with min, max, average and
stddev.
|
static class |
StatusAggregator.TimedValue
Internal class, unmutable data structure with name, timestamp and value.
|
| Constructor and Description |
|---|
StatusAggregator() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearAggregate(String key)
stop monitoring a given data.
|
Map<String,Object> |
getAllLast()
returns the last values of all parameters monitored
|
Map<String,StatusAggregator.TimedValue> |
getAllLastTV()
returns the last values of all parameters monitored, with their
timestamp.
|
Map<String,StatusAggregator.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 org.lsst.ccs.messaging.StatusAggregator.StatusAggregateConfig |
getConfig(String key) |
List<StatusAggregator.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)
|
StatusAggregator.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.
|
StatusAggregator.Statistics |
getStatistics(String key)
returns statistics (over the configured duration) for a given key.
|
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 |
setAggregate(String key,
int historyDuration,
int aggregateWindow)
Configures the StatusAgregator to monitor a given data.
|
void |
setAggregatePattern(Pattern pattern,
int historyDuration,
int aggregateWindow)
Configures the StatusAgregator to monitor all the data which
name matches a regex pattern.
|
void |
setAggregatePattern(String pattern,
int historyDuration,
int aggregateWindow)
Configures the StatusAgregator to monitor all the data which
name matches a regex pattern.
|
void |
setVariable(String variable,
String value)
set a variable value.
|
void |
setVariables(Map<String,String> values)
set variable values.
|
void |
updVars() |
public void setAggregate(String key, int historyDuration, int aggregateWindow)
key - the name ("subsystem/key") of the data to be monitoredhistoryDuration - 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.public void setAggregatePattern(String pattern, int historyDuration, int aggregateWindow)
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.public void setAggregatePattern(Pattern pattern, int historyDuration, int aggregateWindow)
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.public void clearAggregate(String key)
key - the name ("subsystem/key") of the data to be clearedpublic void setVariable(String variable, String value)
variable - the variable namevalue - the variable valuepublic void setVariables(Map<String,String> values)
values - a name-value mappublic void updVars()
protected org.lsst.ccs.messaging.StatusAggregator.StatusAggregateConfig getConfig(String key)
public void onStatusMessage(StatusMessage msg)
StatusMessageListeneronStatusMessage in interface StatusMessageListenermsg - Status bus message to be processed.public Object getLast(String key)
key - public StatusAggregator.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<StatusAggregator.TimedValue> getHistory(String key)
key - public StatusAggregator.Statistics getStatistics(String key)
key - public Map<String,Object> getAllLast()
public Map<String,StatusAggregator.TimedValue> getAllLastTV()
public Map<String,StatusAggregator.Statistics> getAllStatistics()
Copyright © 2018 LSST. All rights reserved.