tidy of sensor timestamp workaround, in response to code review
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/9453502e Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/9453502e Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/9453502e Branch: refs/heads/master Commit: 9453502e0fb3aac129768578653f1292a4925dee Parents: 87604e2 Author: Alex Heneveld <[email protected]> Authored: Mon Feb 9 17:42:47 2015 +0000 Committer: Alex Heneveld <[email protected]> Committed: Mon Feb 9 17:42:47 2015 +0000 ---------------------------------------------------------------------- .../main/java/brooklyn/enricher/basic/Propagator.java | 5 +++-- .../java/brooklyn/enricher/basic/Transformer.java | 1 - .../enricher/RollingTimeWindowMeanEnricher.java | 14 +++----------- 3 files changed, 6 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9453502e/core/src/main/java/brooklyn/enricher/basic/Propagator.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/enricher/basic/Propagator.java b/core/src/main/java/brooklyn/enricher/basic/Propagator.java index 78dcac9..5e3ae23 100644 --- a/core/src/main/java/brooklyn/enricher/basic/Propagator.java +++ b/core/src/main/java/brooklyn/enricher/basic/Propagator.java @@ -25,7 +25,6 @@ import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import brooklyn.catalog.Catalog; import brooklyn.config.ConfigKey; import brooklyn.entity.Entity; import brooklyn.entity.basic.Attributes; @@ -151,7 +150,7 @@ public class Propagator extends AbstractEnricher implements SensorEventListener< emit((Sensor)destinationSensor, event.getValue()); } - /** useful post-addition to emit current values */ + /** useful once sensors are added to emit all values */ public void emitAllAttributes() { emitAllAttributes(false); } @@ -166,6 +165,8 @@ public class Propagator extends AbstractEnricher implements SensorEventListener< if (s instanceof AttributeSensor) { AttributeSensor destinationSensor = (AttributeSensor<?>) getDestinationSensor(s); Object v = producer.getAttribute((AttributeSensor<?>)s); + // TODO we should keep a timestamp for the source sensor and echo it + // (this pretends timestamps are current, which probably isn't the case when we are propagating) if (v != null || includeNullValues) entity.setAttribute(destinationSensor, v); } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9453502e/core/src/main/java/brooklyn/enricher/basic/Transformer.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/enricher/basic/Transformer.java b/core/src/main/java/brooklyn/enricher/basic/Transformer.java index d126307..86911e7 100644 --- a/core/src/main/java/brooklyn/enricher/basic/Transformer.java +++ b/core/src/main/java/brooklyn/enricher/basic/Transformer.java @@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkArgument; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import brooklyn.catalog.Catalog; import brooklyn.config.ConfigKey; import brooklyn.entity.Entity; import brooklyn.entity.basic.ConfigKeys; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9453502e/policy/src/main/java/brooklyn/enricher/RollingTimeWindowMeanEnricher.java ---------------------------------------------------------------------- diff --git a/policy/src/main/java/brooklyn/enricher/RollingTimeWindowMeanEnricher.java b/policy/src/main/java/brooklyn/enricher/RollingTimeWindowMeanEnricher.java index 3c9247b..694977c 100644 --- a/policy/src/main/java/brooklyn/enricher/RollingTimeWindowMeanEnricher.java +++ b/policy/src/main/java/brooklyn/enricher/RollingTimeWindowMeanEnricher.java @@ -64,11 +64,6 @@ public class RollingTimeWindowMeanEnricher<T extends Number> extends AbstractTyp public static ConfigKey<Double> CONFIDENCE_REQUIRED_TO_PUBLISH = ConfigKeys.newDoubleConfigKey("confidenceRequired", "Minimum confidence level (ie period covered) required to publish a rolling average", 0.8d); - // without this, we will refuse to publish if the server time differs from the publisher time (in a distributed setup); - // also we won't publish if a lot of time is spent actually doing the computation - public static ConfigKey<Duration> TIMESTAMP_GRACE_TIME = ConfigKeys.newConfigKey(Duration.class, "timestampGraceTime", - "When computing windowed average, allow this much slippage time between published metrics and local clock", Duration.millis(500)); - public static class ConfidenceQualifiedNumber { final Double value; final double confidence; @@ -133,10 +128,12 @@ public class RollingTimeWindowMeanEnricher<T extends Number> extends AbstractTyp } } + @Deprecated /** @deprecatedsince 0.7.0; not used; use the 2-arg method */ public ConfidenceQualifiedNumber getAverage() { - return getAverage(System.currentTimeMillis(), getConfig(TIMESTAMP_GRACE_TIME).toMilliseconds()); + return getAverage(System.currentTimeMillis(), 0); } + @Deprecated /** @deprecated since 0.7.0; not used; use the 2-arg method */ public ConfidenceQualifiedNumber getAverage(long fromTimeExact) { return getAverage(fromTimeExact, 0); } @@ -146,11 +143,6 @@ public class RollingTimeWindowMeanEnricher<T extends Number> extends AbstractTyp return lastAverage = new ConfidenceQualifiedNumber(lastAverage.value, 0.0d); } - // (previously there was an old comment here, pre-Jul-2014, - // saying "grkvlt - see email to development list"; - // but i can't find that email) - // some of the more recent confidence and bogus-timestamp + exclusion logic might fix this though - long firstTimestamp = -1; Iterator<Long> ti = timestamps.iterator(); while (ti.hasNext()) {
