gyfora commented on code in PR #556:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/556#discussion_r1151818091
##########
flink-kubernetes-operator-autoscaler/src/main/java/org/apache/flink/kubernetes/operator/autoscaler/ScalingMetricEvaluator.java:
##########
@@ -251,12 +251,20 @@ private static double getAverage(
ScalingMetric metric,
JobVertexID jobVertexId,
SortedMap<Instant, Map<JobVertexID, Map<ScalingMetric, Double>>>
metricsHistory) {
- return StatUtils.mean(
+ double[] metricsValues =
metricsHistory.values().stream()
.map(m -> m.get(jobVertexId))
.filter(m -> m.containsKey(metric))
.mapToDouble(m -> m.get(metric))
.filter(d -> !Double.isNaN(d))
- .toArray());
+ .toArray();
+ for (double metricsValue : metricsValues) {
+ if (Double.isInfinite(metricsValue)) {
+ // As long as infinite values are present, we can't properly
average. We need to
+ // wait until they are evicted.
+ return metricsValue;
Review Comment:
This confused me a little, should we simply return Double.positive_infinity
here explicitly?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]