huyuanfeng2018 commented on code in PR #904:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/904#discussion_r1811667427


##########
flink-autoscaler/src/main/java/org/apache/flink/autoscaler/NumKeyGroupsOrPartitionsParallelismAdjuster.java:
##########
@@ -0,0 +1,134 @@
+/*
+ * 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;
+
+import org.apache.flink.autoscaler.config.AutoScalerOptions;
+import org.apache.flink.autoscaler.event.AutoScalerEventHandler;
+import org.apache.flink.configuration.DescribedEnum;
+import org.apache.flink.configuration.description.InlineElement;
+import org.apache.flink.runtime.jobgraph.JobVertexID;
+
+import static 
org.apache.flink.autoscaler.JobVertexScaler.SCALE_LIMITED_MESSAGE_FORMAT;
+import static org.apache.flink.autoscaler.JobVertexScaler.SCALING_LIMITED;
+import static 
org.apache.flink.autoscaler.config.AutoScalerOptions.SCALING_EVENT_INTERVAL;
+import static org.apache.flink.configuration.description.TextElement.text;
+
+/**
+ * Component responsible adjusts the parallelism of a vertex that knows the 
number of partitions or
+ * a vertex whose upstream shuffle is key by.
+ */
+public class NumKeyGroupsOrPartitionsParallelismAdjuster {

Review Comment:
   Many thanks to @SamBarker for the review.
   
   Why `NumKeyGroupsOrPartitionsParallelismAdjuster` is used here, because 
there has been a judgment before 
   
https://github.com/apache/flink-kubernetes-operator/blob/d2a68eb1eaa2624fce47107b2c371b5cda428830/flink-autoscaler/src/main/java/org/apache/flink/autoscaler/JobVertexScaler.java#L406
   So the responsibility of `NumKeyGroupsOrPartitionsParallelismAdjuster` is 
single(**for key groups or partitions**).
   
   But what you said makes sense. Maybe we should change it to this to cope 
with new extensions that may exist in the future:
   ```suggestion
   public class FinalParallelismAdjuster {
   
      public static <KEY, Context extends JobAutoScalerContext<KEY>> int adjust(
               JobVertexID vertex,
               Context context,
               AutoScalerEventHandler<KEY, Context> eventHandler,
               int maxParallelism,
               int numSourcePartitions,
               int newParallelism,
               int upperBound,
               int parallelismLowerLimit) {
           var adjustByMaxParallelismOrPartitions =
               numSourcePartitions > 0 || inputShipStrategies.contains(HASH);
           if (!adjustByMaxParallelismOrPartitions) {
               return newParallelism;
           }
           ...
               }
   
   }
   ```
   
   The corresponding enum is changed to
   
   ```
   public class KeyGroupOrPartitionsAdjustMode {
   ...
   }
   ```
   
   WDYT?



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