gyfora commented on code in PR #726:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/726#discussion_r1423061343


##########
flink-autoscaler/src/main/java/org/apache/flink/autoscaler/ScalingMetricEvaluator.java:
##########
@@ -297,6 +301,28 @@ private void computeTargetDataRate(
         }
     }
 
+    @VisibleForTesting
+    protected static Map<ScalingMetric, EvaluatedScalingMetric> 
evaluateGlobalMetrics(
+            SortedMap<Instant, CollectedMetrics> metricHistory) {
+        var latest = 
metricHistory.get(metricHistory.lastKey()).getGlobalMetrics();
+        var out = new HashMap<ScalingMetric, EvaluatedScalingMetric>();
+
+        var gcPressure = latest.getOrDefault(GC_PRESSURE, Double.NaN);
+        var lastHeapUsage = latest.getOrDefault(HEAP_USAGE, Double.NaN);
+
+        out.put(GC_PRESSURE, EvaluatedScalingMetric.of(gcPressure));
+        out.put(
+                HEAP_USAGE,
+                new EvaluatedScalingMetric(
+                        lastHeapUsage, getAverageGlobalMetric(HEAP_USAGE, 
metricHistory)));
+        return out;
+    }
+
+    private static double getAverageGlobalMetric(
+            ScalingMetric metric, SortedMap<Instant, CollectedMetrics> 
metricsHistory) {
+        return getAverage(metric, null, metricsHistory);
+    }
+
     public static double getAverage(
             ScalingMetric metric,
             JobVertexID jobVertexId,

Review Comment:
   will do



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to