mxm commented on code in PR #953:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/953#discussion_r1991797302


##########
flink-autoscaler/src/main/java/org/apache/flink/autoscaler/metrics/CustomEvaluator.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.autoscaler.metrics;
+
+import org.apache.flink.autoscaler.topology.JobTopology;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.plugin.Plugin;
+import org.apache.flink.runtime.jobgraph.JobVertexID;
+
+import lombok.Getter;
+
+import java.time.Duration;
+import java.time.Instant;
+import java.util.Map;
+import java.util.SortedMap;
+
+/**
+ * Interface for custom evaluators that allow custom scaling metric 
evaluations. Implementations of
+ * this interface can provide custom logic to evaluate vertex metrics and 
merge them with internally
+ * evaluated metrics.
+ */
+public interface CustomEvaluator extends Plugin {
+
+    /**
+     * Evaluates scaling metrics for a given job vertex based on the 
internally evaluated metrics
+     * and context.
+     *
+     * @param vertex The {@link JobVertexID} identifying the vertex whose 
metrics are being
+     *     evaluated.
+     * @param evaluatedMetrics An un-modifiable view of current vertex 
internally evaluated metrics.
+     * @param evaluationContext The evaluation context providing job-related 
configurations and
+     *     historical metrics.
+     * @return A map of evaluated scaling metrics for the vertex which would 
get merged with
+     *     internally evaluated metrics.
+     * @throws UnsupportedOperationException if an attempt is made to modify 
the {@code
+     *     evaluatedMetrics}, {@code Context.jobConf}, {@code 
Context.metricsHistory}, {@code
+     *     Context.evaluatedVertexMetrics}.
+     */
+    Map<ScalingMetric, EvaluatedScalingMetric> evaluateVertexMetrics(
+            JobVertexID vertex,
+            Map<ScalingMetric, EvaluatedScalingMetric> evaluatedMetrics,

Review Comment:
   This parameter seems redundant because the context already contains the 
evaluated Metrics map.



##########
flink-autoscaler/src/main/java/org/apache/flink/autoscaler/config/AutoScalerOptions.java:
##########
@@ -382,4 +385,19 @@ private static ConfigOptions.OptionBuilder 
autoScalerConfig(String key) {
                                             
"scaling.key-group.partitions.adjust.mode"))
                             .withDescription(
                                     "How to adjust the parallelism of Source 
vertex or upstream shuffle is keyBy");
+
+    public static final ConfigOption<String> CUSTOM_EVALUATOR_NAME =

Review Comment:
   How about deriving the name from the CustomEvaluator interface? We can load 
all the names when we load the custom evaluator implementations.



-- 
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]

Reply via email to