Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MeanReducer no longer divides by zero.

  • Loading branch information...
commit a9fd4ab40c744b810ce00fae808f9f7e668a8332 1 parent fe3fa6c
Jason Jackson authored
View
5 src/clj/backtype/storm/daemon/executor.clj
@@ -269,7 +269,10 @@
interval)
data-points (->> name->imetric
(map (fn [[name imetric]]
- (IMetricsConsumer$DataPoint. name (.getValueAndReset ^IMetric imetric))))
+ (let [value (.getValueAndReset ^IMetric imetric)]
+ (if value
+ (IMetricsConsumer$DataPoint. name value)))))
+ (filter identity)
(into []))]]
(if (seq data-points)
(task/send-unanchored task-data Constants/METRICS_STREAM_ID [task-info data-points])))))
View
6 src/jvm/backtype/storm/metric/api/MeanReducer.java
@@ -29,6 +29,10 @@ public MeanReducerState reduce(MeanReducerState acc, Object input) {
}
public Object extractResult(MeanReducerState acc) {
- return new Double(acc.sum / (double)acc.count);
+ if(acc.count > 0) {
+ return new Double(acc.sum / (double)acc.count);
+ } else {
+ return null;
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.