public class RollingTimeWindowMeanEnricher<T extends java.lang.Number> extends AbstractTypeTransformingEnricher<T,java.lang.Double>
Sensor
data into a rolling average based on a time window.
All values within the window are weighted or discarded based on the timestamps associated with
them (discards occur when a new value is added or an average is requested)
This will not extrapolate figures - it is assumed a value is valid and correct for the entire time period between it and the previous value. Normally, the average attribute is only updated when a new value arrives so it can give a fully informed average, but there is a danger of this going stale.
When an average is requested, it is likely there will be a segment of the window for which there isn't a value. Instead of extrapolating a value and providing different extrapolation techniques, the average is reported with a confidence value which reflects the fraction of the time window for which the values were valid.
Consumers of the average may ignore the confidence value and just use the last known average. They could multiply the returned value by the confidence value to get a decay-type behavior as the window empties. A third alternative is to, at a certain confidence threshold, report that the average is no longer meaningful.
The default average when no data has been received is 0, with a confidence of 0
TODO this may end up being deprecated in favour of near-duplicate code in YAML-friendly YamlRollingTimeWindowMeanEnricher
,
marking as @Beta in 0.7.0 timeframe
Modifier and Type | Class and Description |
---|---|
static class |
RollingTimeWindowMeanEnricher.ConfidenceQualifiedNumber |
AbstractEntityAdjunct.AdjunctTagSupport, AbstractEntityAdjunct.BasicSubscriptionSupport
BrooklynObject.RelationSupport<T extends BrooklynObject>, BrooklynObject.SubscriptionSupport, BrooklynObject.TagSupport
Configurable.ConfigurationSupport
BrooklynObjectInternal.ConfigurationSupportInternal, BrooklynObjectInternal.RelationSupportInternal<T extends BrooklynObject>, BrooklynObjectInternal.SubscriptionSupportInternal
Modifier and Type | Field and Description |
---|---|
static ConfigKey<java.lang.Double> |
CONFIDENCE_REQUIRED_TO_PUBLISH |
SUPPRESS_DUPLICATES
HIGHLIGHT_NAME_LAST_ACTION, HIGHLIGHT_NAME_LAST_CONFIRMATION, HIGHLIGHT_NAME_LAST_VIOLATION, HIGHLIGHT_NAME_TRIGGERS
NOOP
Constructor and Description |
---|
RollingTimeWindowMeanEnricher() |
RollingTimeWindowMeanEnricher(Entity producer,
AttributeSensor<T> source,
AttributeSensor<java.lang.Double> target,
Duration timePeriod)
Deprecated.
since 0.12.0; use
EnricherSpec |
Modifier and Type | Method and Description |
---|---|
RollingTimeWindowMeanEnricher.ConfidenceQualifiedNumber |
getAverage(long fromTime,
long graceAllowed) |
void |
init()
Called by framework (in new-style instances where spec was used) after configuring etc,
but before a reference to this instance is shared.
|
void |
onEvent(SensorEvent<T> event)
The
SensorEvent handler method. |
void |
onEvent(SensorEvent<T> event,
long eventTime) |
setEntity
getEnricherType, getRebindSupport, relations
config, configure, destroy, getAdjunctType, getConfig, getDisplayName, getEntity, getExecutionContext, getHighlights, getManagementContext, getUniqueTag, isDestroyed, isRunning, setDisplayName, setHighlights, subscriptions, tags, toString
addSearchPath, getCatalogItemId, getCatalogItemIdSearchPath, getId, rebind, setCatalogItemId, setCatalogItemIdAndSearchPath, setManagementContext, stackCatalogItemId
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getHighlights, getUniqueTag, isDestroyed, isRunning
getCatalogItemId, getCatalogItemIdSearchPath, getDisplayName, subscriptions, tags
config, getConfig
addSearchPath, setCatalogItemId, setCatalogItemIdAndSearchPath, stackCatalogItemId
public static ConfigKey<java.lang.Double> CONFIDENCE_REQUIRED_TO_PUBLISH
public RollingTimeWindowMeanEnricher()
@Deprecated public RollingTimeWindowMeanEnricher(Entity producer, AttributeSensor<T> source, AttributeSensor<java.lang.Double> target, Duration timePeriod)
EnricherSpec
public void init()
AbstractBrooklynObject
To preserve backwards compatibility for if the instance is constructed directly, one can call the code below, but that means it will be called after references to this policy have been shared with other entities.
if (isLegacyConstruction()) {
init();
}
init
in class AbstractBrooklynObject
public void onEvent(SensorEvent<T> event)
SensorEventListener
SensorEvent
handler method.public void onEvent(SensorEvent<T> event, long eventTime)
public RollingTimeWindowMeanEnricher.ConfidenceQualifiedNumber getAverage(long fromTime, long graceAllowed)