You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/06/10 06:33:21 UTC

[GitHub] [flink-kubernetes-operator] gyfora commented on a diff in pull request #227: [FLINK-27685] Scale subresource prototype

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


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/FlinkUtils.java:
##########
@@ -278,4 +280,10 @@ public static boolean isKubernetesHAActivated(Configuration configuration) {
     public static boolean clusterShutdownDisabled(FlinkDeploymentSpec spec) {
         return spec.getFlinkVersion().isNewerVersionThan(FlinkVersion.v1_14);
     }
+
+    public static int getNumTaskManagers(Configuration conf) {
+        int parallelism = conf.get(CoreOptions.DEFAULT_PARALLELISM);
+        int taskSlots = conf.get(TaskManagerOptions.NUM_TASK_SLOTS);
+        return (parallelism + taskSlots - 1) / taskSlots;

Review Comment:
   In java integer division always rounds down. 5/2 would result in 2 instead of rounding up to 3 what we need to compute here. `(parallelism + taskSlots - 1) / taskSlots` is a nice trick to divide parallelism/taskslots while rounding up.



-- 
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-unsubscribe@flink.apache.org

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