Commit 9fab7de8 authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

Fixed some NPS in Filter Toolchain for invalid derived metrics

parent 8b3f212a
...@@ -206,7 +206,9 @@ public abstract class AbstractFilter<M extends MetricValue<?>> implements ...@@ -206,7 +206,9 @@ public abstract class AbstractFilter<M extends MetricValue<?>> implements
if (isOverallMetric) { if (isOverallMetric) {
M overall = getDerivedMetricValueFor(DerivedMetric.this, M overall = getDerivedMetricValueFor(DerivedMetric.this,
incoming, null); incoming, null);
setOverallMetric(overall); if (overall != null) {
setOverallMetric(overall);
}
} else { } else {
for (Host host : hosts) { for (Host host : hosts) {
M perHost = getDerivedMetricValueFor(DerivedMetric.this, M perHost = getDerivedMetricValueFor(DerivedMetric.this,
......
...@@ -83,14 +83,17 @@ public abstract class StatisticsFilter extends ...@@ -83,14 +83,17 @@ public abstract class StatisticsFilter extends
Metric<?> derivedMetric, List<Metric<?>> inputs, Host host) { Metric<?> derivedMetric, List<Metric<?>> inputs, Host host) {
assert inputs.size() == 1; assert inputs.size() == 1;
assert host == null; assert host == null;
Metric<?> input = inputs.get(0); Metric<? extends MetricValue<?>> input = inputs.get(0);
if (input.isOverallMetric()) { if (input.isOverallMetric()) {
throw new AssertionError( throw new AssertionError(
"Only available for per-host input metrics."); "Only available for per-host input metrics.");
} }
LinkedList<MetricValue> mvs = new LinkedList<MetricValue>( List<? extends MetricValue<?>> values = input.getAllPerHostMetrics();
input.getAllPerHostMetrics()); if (values == null || values.isEmpty()) {
return new StatisticsMetricValue(mvs); return null;
}
LinkedList<MetricValue> mvs = new LinkedList<MetricValue>(values);
return new StatisticsMetricValue(mvs);
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment