You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "RocMarshal (via GitHub)" <gi...@apache.org> on 2023/11/03 16:48:50 UTC

[PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

RocMarshal opened a new pull request, #23658:
URL: https://github.com/apache/flink/pull/23658

   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   Introduce a new configuration item 'taskmanager.load-balance.mode'   
   The PR resulted from https://github.com/apache/flink/pull/23635#discussion_r1381212518
   
   
   ## Brief change log
   
   Introduce a new configuration item 'taskmanager.load-balance.mode' and make it  compatible with "cluster.evenly-spread-out-slots"
   
   The ticket is mainly to do three items:
   
   - Introduce a new configuration item 'taskmanager.load-balance.mode'
   - Make it  compatible with "cluster.evenly-spread-out-slots"
     - Only update `taskmanager.load-balance.mode` to Slots when the taskmanager.load-balance.mode isn't set and cluster.evenly-spread-out-slots is true.
   
   - Mark "cluster.evenly-spread-out-slots" as Deprecated
   
   
   ## Verifying this change
   
   This change is already covered by existing tests.
   
   This change added tests and can be verified as follows:
   
   - org.apache.flink.configuration.TaskManagerLoadBalanceModeTest
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
     - The serializers: (yes / **no** / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / **no**)
     - If yes, how is the feature documented? (**not applicable** / docs / JavaDocs / not documented)
   


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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #23658:
URL: https://github.com/apache/flink/pull/23658#discussion_r1382746995


##########
flink-core/src/main/java/org/apache/flink/configuration/TaskManagerOptions.java:
##########
@@ -708,6 +711,49 @@ public class TaskManagerOptions {
                             "Time we wait for the timers in milliseconds to finish all pending timer threads"
                                     + " when the stream task is cancelled.");
 
+    @Documentation.Section(Documentation.Sections.ALL_TASK_MANAGER)

Review Comment:
   big +1~



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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #23658:
URL: https://github.com/apache/flink/pull/23658#discussion_r1382342085


##########
flink-core/src/main/java/org/apache/flink/configuration/TaskManagerLoadBalanceMode.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.configuration;
+
+import org.apache.flink.annotation.Internal;
+
+import javax.annotation.Nonnull;
+
+/** Type of {@link TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE}. */
+@Internal
+public enum TaskManagerLoadBalanceMode {

Review Comment:
   make sense~
   updated.



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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk commented on PR #23658:
URL: https://github.com/apache/flink/pull/23658#issuecomment-1809516092

   Sorry that I was on a trip last week and did not have a chance to take a look. The change looks good to me. Just one minor comment that it's better to annotate `TaskManagerLoadBalanceMode#loadFromConfiguration()` with `@Internal` to avoid indicating it as a public interface to users.


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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui merged PR #23658:
URL: https://github.com/apache/flink/pull/23658


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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on PR #23658:
URL: https://github.com/apache/flink/pull/23658#issuecomment-1793358848

   Hi, @1996fanrui Thanks a lot for the comments. I addressed the comments based on your suggestion.
   Would you @zhuzhurk @KarmaGYZ @1996fanrui please mind helping take a look on it  if you have free time? 
   Thank you!


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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui commented on code in PR #23658:
URL: https://github.com/apache/flink/pull/23658#discussion_r1382343888


##########
flink-core/src/main/java/org/apache/flink/configuration/TaskManagerOptions.java:
##########
@@ -708,6 +711,49 @@ public class TaskManagerOptions {
                             "Time we wait for the timers in milliseconds to finish all pending timer threads"
                                     + " when the stream task is cancelled.");
 
+    @Documentation.Section(Documentation.Sections.ALL_TASK_MANAGER)
+    public static final ConfigOption<TaskManagerLoadBalanceMode> TASK_MANAGER_LOAD_BALANCE_MODE =
+            ConfigOptions.key("taskmanager.load-balance.mode")
+                    .enumType(TaskManagerLoadBalanceMode.class)
+                    .defaultValue(TaskManagerLoadBalanceMode.NONE)
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Mode for the load-balance allocation strategy across all available %s. "
+                                                    + "The %s mode tries to spread out the slots evenly across all available %s. "
+                                                    + "The %s mode is the default mode without any specified strategy. ",
+                                            code("TaskManagers"),
+                                            code(TaskManagerLoadBalanceMode.SLOTS.name()),
+                                            code("TaskManagers"),
+                                            code(TaskManagerLoadBalanceMode.NONE.name()))
+                                    .build());
+
+    /** Type of {@link TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE}. */
+    public enum TaskManagerLoadBalanceMode {
+        NONE,
+        SLOTS;
+
+        /**
+         * The method is mainly to load the {@link
+         * TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE} from {@link Configuration}, which is
+         * compatible with {@link ClusterOptions#EVENLY_SPREAD_OUT_SLOTS_STRATEGY}.
+         */
+        public static TaskManagerLoadBalanceMode loadFromConfiguration(
+                @Nonnull Configuration configuration) {
+            Optional<TaskManagerLoadBalanceMode> taskManagerLoadBalanceModeOptional =
+                    configuration.getOptional(TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE);
+            if (taskManagerLoadBalanceModeOptional.isPresent()) {
+                return taskManagerLoadBalanceModeOptional.get();
+            }
+            boolean evenlySpreadOutSlots =
+                    configuration.getBoolean(ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY);
+
+            return evenlySpreadOutSlots
+                    ? TaskManagerLoadBalanceMode.SLOTS
+                    : TaskManagerLoadBalanceMode.NONE;

Review Comment:
   ```suggestion
                       : TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE.defaultValue();
   ```



##########
flink-core/src/test/java/org/apache/flink/configuration/TaskManagerLoadBalanceModeTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.flink.configuration.ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY;
+import static org.apache.flink.configuration.TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE;
+import static org.apache.flink.configuration.TaskManagerOptions.TaskManagerLoadBalanceMode;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for {@link TaskManagerLoadBalanceMode}. */
+class TaskManagerLoadBalanceModeTest {
+
+    @Test
+    void testReadTaskManagerLoadBalanceMode() {
+        // Check for non-set 'taskmanager.load-balance.mode: NONE' and

Review Comment:
   ```suggestion
           // Check for non-set 'taskmanager.load-balance.mode' and
   ```



##########
flink-core/src/test/java/org/apache/flink/configuration/TaskManagerLoadBalanceModeTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.flink.configuration.ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY;
+import static org.apache.flink.configuration.TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE;
+import static org.apache.flink.configuration.TaskManagerOptions.TaskManagerLoadBalanceMode;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for {@link TaskManagerLoadBalanceMode}. */
+class TaskManagerLoadBalanceModeTest {
+
+    @Test
+    void testReadTaskManagerLoadBalanceMode() {
+        // Check for non-set 'taskmanager.load-balance.mode: NONE' and
+        // 'cluster.evenly-spread-out-slots: false'
+        Configuration conf1 = new Configuration();
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf1))
+                .isEqualTo(TaskManagerLoadBalanceMode.NONE);

Review Comment:
   ```suggestion
                   .isEqualTo(TASK_MANAGER_LOAD_BALANCE_MODE.defaultValue());
   ```



##########
flink-core/src/test/java/org/apache/flink/configuration/TaskManagerLoadBalanceModeTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.flink.configuration.ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY;
+import static org.apache.flink.configuration.TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE;
+import static org.apache.flink.configuration.TaskManagerOptions.TaskManagerLoadBalanceMode;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for {@link TaskManagerLoadBalanceMode}. */
+class TaskManagerLoadBalanceModeTest {
+
+    @Test
+    void testReadTaskManagerLoadBalanceMode() {
+        // Check for non-set 'taskmanager.load-balance.mode: NONE' and
+        // 'cluster.evenly-spread-out-slots: false'
+        Configuration conf1 = new Configuration();
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf1))
+                .isEqualTo(TaskManagerLoadBalanceMode.NONE);
+
+        // Check for non-set 'taskmanager.load-balance.mode: NONE' and

Review Comment:
   ```suggestion
           // Check for non-set 'taskmanager.load-balance.mode' and
   ```



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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "KarmaGYZ (via GitHub)" <gi...@apache.org>.
KarmaGYZ commented on code in PR #23658:
URL: https://github.com/apache/flink/pull/23658#discussion_r1382732177


##########
flink-core/src/test/java/org/apache/flink/configuration/TaskManagerLoadBalanceModeTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.flink.configuration.ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY;
+import static org.apache.flink.configuration.TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE;
+import static org.apache.flink.configuration.TaskManagerOptions.TaskManagerLoadBalanceMode;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for {@link TaskManagerLoadBalanceMode}. */
+class TaskManagerLoadBalanceModeTest {
+
+    @Test
+    void testReadTaskManagerLoadBalanceMode() {
+        // Check for non-set 'taskmanager.load-balance.mode' and
+        // 'cluster.evenly-spread-out-slots: false'
+        Configuration conf1 = new Configuration();
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf1))
+                .isEqualTo(TASK_MANAGER_LOAD_BALANCE_MODE.defaultValue());
+
+        // Check for non-set 'taskmanager.load-balance.mode' and
+        // 'cluster.evenly-spread-out-slots: true'
+        Configuration conf2 = new Configuration();
+        conf2.set(EVENLY_SPREAD_OUT_SLOTS_STRATEGY, true);
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf2))
+                .isEqualTo(TaskManagerLoadBalanceMode.SLOTS);
+
+        // Check for setting manually 'taskmanager.load-balance.mode: NONE' and
+        // 'cluster.evenly-spread-out-slots: false'
+        Configuration conf3 = new Configuration();
+        conf3.set(TASK_MANAGER_LOAD_BALANCE_MODE, TaskManagerLoadBalanceMode.NONE);
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf3))
+                .isEqualTo(TaskManagerLoadBalanceMode.NONE);
+
+        // Check for setting manually 'taskmanager.load-balance.mode: NONE' and
+        // 'cluster.evenly-spread-out-slots: true'
+        Configuration conf4 = new Configuration();
+        conf4.set(TASK_MANAGER_LOAD_BALANCE_MODE, TaskManagerLoadBalanceMode.NONE);
+        conf4.set(EVENLY_SPREAD_OUT_SLOTS_STRATEGY, true);
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf4))
+                .isEqualTo(TaskManagerLoadBalanceMode.NONE);

Review Comment:
   Following the FLIP-321, I think we need to guard the backward compatibility here. If a user configures the `EVENLY_SPREAD_OUT_SLOTS_STRATEGY`, the behavior should be equal to configuring `TaskManagerLoadBalanceMode.SLOTS`.



##########
flink-core/src/main/java/org/apache/flink/configuration/TaskManagerOptions.java:
##########
@@ -708,6 +711,49 @@ public class TaskManagerOptions {
                             "Time we wait for the timers in milliseconds to finish all pending timer threads"
                                     + " when the stream task is cancelled.");
 
+    @Documentation.Section(Documentation.Sections.ALL_TASK_MANAGER)
+    public static final ConfigOption<TaskManagerLoadBalanceMode> TASK_MANAGER_LOAD_BALANCE_MODE =
+            ConfigOptions.key("taskmanager.load-balance.mode")
+                    .enumType(TaskManagerLoadBalanceMode.class)
+                    .defaultValue(TaskManagerLoadBalanceMode.NONE)
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Mode for the load-balance allocation strategy across all available %s. "
+                                                    + "The %s mode tries to spread out the slots evenly across all available %s. "
+                                                    + "The %s mode is the default mode without any specified strategy. ",

Review Comment:
   You can use the `list()` to list all the valid options.



##########
flink-core/src/main/java/org/apache/flink/configuration/TaskManagerOptions.java:
##########
@@ -708,6 +711,49 @@ public class TaskManagerOptions {
                             "Time we wait for the timers in milliseconds to finish all pending timer threads"
                                     + " when the stream task is cancelled.");
 
+    @Documentation.Section(Documentation.Sections.ALL_TASK_MANAGER)

Review Comment:
   Should it belong to `EXPERT_SCHEDULING`?



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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #23658:
URL: https://github.com/apache/flink/pull/23658#discussion_r1382342194


##########
flink-core/src/main/java/org/apache/flink/configuration/TaskManagerLoadBalanceMode.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.configuration;
+
+import org.apache.flink.annotation.Internal;
+
+import javax.annotation.Nonnull;
+
+/** Type of {@link TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE}. */
+@Internal
+public enum TaskManagerLoadBalanceMode {
+    NONE,
+    SLOTS;
+
+    /**
+     * The method is mainly to load the {@link TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE}
+     * from {@link Configuration}, which is compatible with {@link
+     * ClusterOptions#EVENLY_SPREAD_OUT_SLOTS_STRATEGY}.
+     */
+    public static TaskManagerLoadBalanceMode loadFromConfiguration(
+            @Nonnull Configuration configuration) {
+        TaskManagerLoadBalanceMode taskManagerLoadBalanceMode =
+                configuration.get(TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE);
+        boolean evenlySpreadOutSlots =
+                configuration.getBoolean(ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY);
+
+        if (taskManagerLoadBalanceMode != TaskManagerLoadBalanceMode.NONE
+                && taskManagerLoadBalanceMode != null) {

Review Comment:
   Thanks for the reminding~ 
   I checked the value-passing logic. It's precise on your comments.



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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #23658:
URL: https://github.com/apache/flink/pull/23658#discussion_r1382783206


##########
flink-core/src/test/java/org/apache/flink/configuration/TaskManagerLoadBalanceModeTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.flink.configuration.ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY;
+import static org.apache.flink.configuration.TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE;
+import static org.apache.flink.configuration.TaskManagerOptions.TaskManagerLoadBalanceMode;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for {@link TaskManagerLoadBalanceMode}. */
+class TaskManagerLoadBalanceModeTest {
+
+    @Test
+    void testReadTaskManagerLoadBalanceMode() {
+        // Check for non-set 'taskmanager.load-balance.mode' and
+        // 'cluster.evenly-spread-out-slots: false'
+        Configuration conf1 = new Configuration();
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf1))
+                .isEqualTo(TASK_MANAGER_LOAD_BALANCE_MODE.defaultValue());
+
+        // Check for non-set 'taskmanager.load-balance.mode' and
+        // 'cluster.evenly-spread-out-slots: true'
+        Configuration conf2 = new Configuration();
+        conf2.set(EVENLY_SPREAD_OUT_SLOTS_STRATEGY, true);
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf2))
+                .isEqualTo(TaskManagerLoadBalanceMode.SLOTS);
+
+        // Check for setting manually 'taskmanager.load-balance.mode: NONE' and
+        // 'cluster.evenly-spread-out-slots: false'
+        Configuration conf3 = new Configuration();
+        conf3.set(TASK_MANAGER_LOAD_BALANCE_MODE, TaskManagerLoadBalanceMode.NONE);
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf3))
+                .isEqualTo(TaskManagerLoadBalanceMode.NONE);
+
+        // Check for setting manually 'taskmanager.load-balance.mode: NONE' and
+        // 'cluster.evenly-spread-out-slots: true'
+        Configuration conf4 = new Configuration();
+        conf4.set(TASK_MANAGER_LOAD_BALANCE_MODE, TaskManagerLoadBalanceMode.NONE);
+        conf4.set(EVENLY_SPREAD_OUT_SLOTS_STRATEGY, true);
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf4))
+                .isEqualTo(TaskManagerLoadBalanceMode.NONE);

Review Comment:
   Hi, @KarmaGYZ Thanks for the comment.
   I guess your concern should be the backward compatibility handling of cases like Case1 and Case2 between `line-33-line44`?   Because in the current case, if the user proactively sets this value, they should understand the meaning of this option. In other words, in this case, `None` is the final value expected by the user. 
   Please let me know what's your opinion~ :)



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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #23658:
URL: https://github.com/apache/flink/pull/23658#issuecomment-1792805398

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b4d6bef71fe5bee3a299422a9e2037c38cf33bdf",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "b4d6bef71fe5bee3a299422a9e2037c38cf33bdf",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b4d6bef71fe5bee3a299422a9e2037c38cf33bdf UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #23658:
URL: https://github.com/apache/flink/pull/23658#discussion_r1382342010


##########
flink-core/src/main/java/org/apache/flink/configuration/TaskManagerLoadBalanceMode.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.configuration;
+
+import org.apache.flink.annotation.Internal;
+
+import javax.annotation.Nonnull;
+
+/** Type of {@link TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE}. */
+@Internal
+public enum TaskManagerLoadBalanceMode {
+    NONE,
+    SLOTS;
+
+    /**
+     * The method is mainly to load the {@link TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE}
+     * from {@link Configuration}, which is compatible with {@link
+     * ClusterOptions#EVENLY_SPREAD_OUT_SLOTS_STRATEGY}.
+     */
+    public static TaskManagerLoadBalanceMode loadFromConfiguration(
+            @Nonnull Configuration configuration) {
+        TaskManagerLoadBalanceMode taskManagerLoadBalanceMode =
+                configuration.get(TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE);
+        boolean evenlySpreadOutSlots =
+                configuration.getBoolean(ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY);
+
+        if (taskManagerLoadBalanceMode != TaskManagerLoadBalanceMode.NONE
+                && taskManagerLoadBalanceMode != null) {
+            return taskManagerLoadBalanceMode;
+        }
+        if (evenlySpreadOutSlots) {
+            return TaskManagerLoadBalanceMode.SLOTS;
+        }

Review Comment:
   Sorry for not get correctly your viewpoint before. Thank you for your clarification



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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui commented on PR #23658:
URL: https://github.com/apache/flink/pull/23658#issuecomment-1809801025

   > Thanks @zhuzhurk for the comment & @1996fanrui for the ping. I'll drive a simple jira & pr to advance it.
   
   @RocMarshal No, don't need extra PR and JIRA. As @KarmaGYZ 's suggestion, it's better to finish all commits related to DefaultSchduler of in #23635 . And merge them after all commits are perfect. Otherwise, it will introduce a lot of minor fix commits, such as this suggestion[1].
   
   [1] https://github.com/apache/flink/pull/23658#issuecomment-1809516092
   
   
   
   


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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui commented on code in PR #23658:
URL: https://github.com/apache/flink/pull/23658#discussion_r1382337335


##########
flink-core/src/test/java/org/apache/flink/configuration/TaskManagerLoadBalanceModeTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.configuration;
+
+import org.apache.flink.util.TestLoggerExtension;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import static org.apache.flink.configuration.ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY;
+import static org.apache.flink.configuration.TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for {@link TaskManagerLoadBalanceMode}. */
+@ExtendWith(TestLoggerExtension.class)

Review Comment:
   ```suggestion
   ```
   
   `org.apache.flink.util.TestLoggerExtension` has been loaded fort the whole `flink-core` module, so the class level doesn't need it.



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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on PR #23658:
URL: https://github.com/apache/flink/pull/23658#issuecomment-1809790375

   Thanks  @zhuzhurk for the comment & @1996fanrui for the ping.
   I'll drive a simple jira & pr to advance it.


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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on PR #23658:
URL: https://github.com/apache/flink/pull/23658#issuecomment-1793300301

   Hi, @1996fanrui Could you help take a look in your free time? Thank you~ :)


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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #23658:
URL: https://github.com/apache/flink/pull/23658#discussion_r1382341874


##########
flink-core/src/main/java/org/apache/flink/configuration/ClusterOptions.java:
##########
@@ -84,17 +88,47 @@ public class ClusterOptions {
                                     + "By default it will use 4 * the number of CPU cores (hardware contexts) that the cluster process has access to. "
                                     + "Increasing the pool size allows to run more IO operations concurrently.");
 
+    /**
+     * @deprecated Please use {@link TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE} instead.
+     *     Note: The 'taskmanager.load-balance.mode: SLOTS' is equal to
+     *     'cluster.evenly-spread-out-slots: true'. The 'taskmanager.load-balance.mode: NONE' is
+     *     equal to 'cluster.evenly-spread-out-slots: false'.
+     */
+    @Deprecated
     @Documentation.Section(Documentation.Sections.EXPERT_SCHEDULING)
     public static final ConfigOption<Boolean> EVENLY_SPREAD_OUT_SLOTS_STRATEGY =
-            ConfigOptions.key("cluster.evenly-spread-out-slots")
+            ConfigOptions.key(EVENLY_SPREAD_OUT_SLOTS_STRATEGY_KEY)
                     .booleanType()
                     .defaultValue(false)
                     .withDescription(
                             Description.builder()
                                     .text(
-                                            "Enable the slot spread out allocation strategy. This strategy tries to spread out "
-                                                    + "the slots evenly across all available %s.",
-                                            code("TaskExecutors"))
+                                            "Enable the slot spread out allocation strategy. "
+                                                    + "This strategy tries to spread out "
+                                                    + "the slots evenly across all available %s. "
+                                                    + "Note: The configuration item is deprecated. "
+                                                    + "Please use '%s' instead. "
+                                                    + "The '%s: %s' is equal to '%s: %s'. "
+                                                    + "The '%s: %s' is equal to '%s: %s'.",
+                                            code("TaskExecutors"),
+                                            code(
+                                                    TaskManagerOptions
+                                                            .TASK_MANAGER_LOAD_BALANCE_MODE
+                                                            .key()),
+                                            code(
+                                                    TaskManagerOptions
+                                                            .TASK_MANAGER_LOAD_BALANCE_MODE
+                                                            .key()),
+                                            code("SLOTS"),
+                                            code(EVENLY_SPREAD_OUT_SLOTS_STRATEGY_KEY),
+                                            code("true"),
+                                            code(
+                                                    TaskManagerOptions
+                                                            .TASK_MANAGER_LOAD_BALANCE_MODE
+                                                            .key()),
+                                            code("NONE"),
+                                            code(EVENLY_SPREAD_OUT_SLOTS_STRATEGY_KEY),
+                                            code("false"))

Review Comment:
   updated~



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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui commented on code in PR #23658:
URL: https://github.com/apache/flink/pull/23658#discussion_r1382318102


##########
flink-core/src/main/java/org/apache/flink/configuration/TaskManagerLoadBalanceMode.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.configuration;
+
+import org.apache.flink.annotation.Internal;
+
+import javax.annotation.Nonnull;
+
+/** Type of {@link TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE}. */
+@Internal
+public enum TaskManagerLoadBalanceMode {

Review Comment:
   I don't think it should be a separate class, especially it shouldn't be marked as `@Internal` class, because users will use it during `conf.set`, such as : `conf.set(TASK_MANAGER_LOAD_BALANCE_MODE, TaskManagerLoadBalanceMode.SLOTS)`.
   
   It's better to add the class as a internal class of `TaskManagerOptions`. Please check out `JobManagerOptions.SchedulerType`.



##########
flink-core/src/main/java/org/apache/flink/configuration/ClusterOptions.java:
##########
@@ -84,17 +88,47 @@ public class ClusterOptions {
                                     + "By default it will use 4 * the number of CPU cores (hardware contexts) that the cluster process has access to. "
                                     + "Increasing the pool size allows to run more IO operations concurrently.");
 
+    /**
+     * @deprecated Please use {@link TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE} instead.
+     *     Note: The 'taskmanager.load-balance.mode: SLOTS' is equal to
+     *     'cluster.evenly-spread-out-slots: true'. The 'taskmanager.load-balance.mode: NONE' is
+     *     equal to 'cluster.evenly-spread-out-slots: false'.
+     */
+    @Deprecated
     @Documentation.Section(Documentation.Sections.EXPERT_SCHEDULING)
     public static final ConfigOption<Boolean> EVENLY_SPREAD_OUT_SLOTS_STRATEGY =
-            ConfigOptions.key("cluster.evenly-spread-out-slots")
+            ConfigOptions.key(EVENLY_SPREAD_OUT_SLOTS_STRATEGY_KEY)
                     .booleanType()
                     .defaultValue(false)
                     .withDescription(
                             Description.builder()
                                     .text(
-                                            "Enable the slot spread out allocation strategy. This strategy tries to spread out "
-                                                    + "the slots evenly across all available %s.",
-                                            code("TaskExecutors"))
+                                            "Enable the slot spread out allocation strategy. "
+                                                    + "This strategy tries to spread out "
+                                                    + "the slots evenly across all available %s. "
+                                                    + "Note: The configuration item is deprecated. "
+                                                    + "Please use '%s' instead. "
+                                                    + "The '%s: %s' is equal to '%s: %s'. "
+                                                    + "The '%s: %s' is equal to '%s: %s'.",
+                                            code("TaskExecutors"),
+                                            code(
+                                                    TaskManagerOptions
+                                                            .TASK_MANAGER_LOAD_BALANCE_MODE
+                                                            .key()),
+                                            code(
+                                                    TaskManagerOptions
+                                                            .TASK_MANAGER_LOAD_BALANCE_MODE
+                                                            .key()),
+                                            code("SLOTS"),
+                                            code(EVENLY_SPREAD_OUT_SLOTS_STRATEGY_KEY),
+                                            code("true"),
+                                            code(
+                                                    TaskManagerOptions
+                                                            .TASK_MANAGER_LOAD_BALANCE_MODE
+                                                            .key()),
+                                            code("NONE"),
+                                            code(EVENLY_SPREAD_OUT_SLOTS_STRATEGY_KEY),
+                                            code("false"))

Review Comment:
   This change may be not needed.
   
   This desctription is used in doc, however depreated options will be removed in doc. You can check out your html change.
   
   If this suggestion makes sense, please clean up the code, for example: check whether `EVENLY_SPREAD_OUT_SLOTS_STRATEGY_KEY` can be reverted.



##########
flink-core/src/main/java/org/apache/flink/configuration/TaskManagerOptions.java:
##########
@@ -708,6 +708,23 @@ public class TaskManagerOptions {
                             "Time we wait for the timers in milliseconds to finish all pending timer threads"
                                     + " when the stream task is cancelled.");
 
+    @Documentation.Section(Documentation.Sections.ALL_TASK_MANAGER)
+    public static final ConfigOption<TaskManagerLoadBalanceMode> TASK_MANAGER_LOAD_BALANCE_MODE =
+            ConfigOptions.key("taskmanager.load-balance.mode")
+                    .enumType(TaskManagerLoadBalanceMode.class)
+                    .defaultValue(TaskManagerLoadBalanceMode.NONE)
+                    .withDescription(
+                            Description.builder()
+                                    .text(
+                                            "Mode for the load-balance allocation strategy across all available %s. "
+                                                    + "The %s mode tries to spread out the slots evenly across all available %s. "
+                                                    + "The %s mode is the default mode without any specified strategy. ",
+                                            code("TaskExecutors"),

Review Comment:
   Would you mind updating it from `TaskExecutors` to `TaskManagers`?
   
   TaskExecutor is a class. From user side, we always call it `TaskManagers`.



##########
flink-core/src/main/java/org/apache/flink/configuration/TaskManagerLoadBalanceMode.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.configuration;
+
+import org.apache.flink.annotation.Internal;
+
+import javax.annotation.Nonnull;
+
+/** Type of {@link TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE}. */
+@Internal
+public enum TaskManagerLoadBalanceMode {
+    NONE,
+    SLOTS;
+
+    /**
+     * The method is mainly to load the {@link TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE}
+     * from {@link Configuration}, which is compatible with {@link
+     * ClusterOptions#EVENLY_SPREAD_OUT_SLOTS_STRATEGY}.
+     */
+    public static TaskManagerLoadBalanceMode loadFromConfiguration(
+            @Nonnull Configuration configuration) {
+        TaskManagerLoadBalanceMode taskManagerLoadBalanceMode =
+                configuration.get(TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE);
+        boolean evenlySpreadOutSlots =
+                configuration.getBoolean(ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY);
+
+        if (taskManagerLoadBalanceMode != TaskManagerLoadBalanceMode.NONE
+                && taskManagerLoadBalanceMode != null) {
+            return taskManagerLoadBalanceMode;
+        }
+        if (evenlySpreadOutSlots) {
+            return TaskManagerLoadBalanceMode.SLOTS;
+        }

Review Comment:
   > please note we only update `taskmanager.load-balance.mode` to Slots when the `taskmanager.load-balance.mode` isn't set and `cluster.evenly-spread-out-slots` is true.
   
   As I metioned in FLINK-33348, the current code doesn't respect this rule.
   
   - If user sets `taskmanager.load-balance.mode : None` and `cluster.evenly-spread-out-slots : true` manually, we should respect `taskmanager.load-balance.mode : None`.
   - If user doesn't set `taskmanager.load-balance.mode : None` and set `cluster.evenly-spread-out-slots : true`, we should update `taskmanager.load-balance.mode` to `Slots`.
   
   In biref, the default `None` isn't same with user set `taskmanager.load-balance.mode` to `None` manually.
   
   How to check the None is default value or from user set? Please check `conf.getOptional()` instead of `conf.get()` , and please add a test for these 2 cases.
   
   Please correct me if my understanding is wrong.



##########
flink-core/src/test/java/org/apache/flink/configuration/TaskManagerLoadBalanceModeTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.configuration;
+
+import org.apache.flink.util.TestLoggerExtension;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import static org.apache.flink.configuration.ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY;
+import static org.apache.flink.configuration.TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for {@link TaskManagerLoadBalanceMode}. */
+@ExtendWith(TestLoggerExtension.class)
+class TaskManagerLoadBalanceModeTest {
+
+    @Test
+    void testReadTaskManagerLoadBalanceMode() {
+        Configuration conf = new Configuration();
+
+        // Check for 'taskmanager.load-balance.mode: NONE' and 'cluster.evenly-spread-out-slots:
+        // false'
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf))
+                .isEqualTo(TaskManagerLoadBalanceMode.NONE);
+
+        // Check for 'taskmanager.load-balance.mode: NONE' and 'cluster.evenly-spread-out-slots:
+        // true'
+        conf.setString(EVENLY_SPREAD_OUT_SLOTS_STRATEGY.key(), "true");
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf))
+                .isEqualTo(TaskManagerLoadBalanceMode.SLOTS);
+
+        // Check for 'taskmanager.load-balance.mode: SLOTS' and 'cluster.evenly-spread-out-slots:
+        // false'
+        conf.setString(
+                TASK_MANAGER_LOAD_BALANCE_MODE.key(), TaskManagerLoadBalanceMode.SLOTS.name());
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf))
+                .isEqualTo(TaskManagerLoadBalanceMode.SLOTS);
+
+        // Check for 'taskmanager.load-balance.mode: SLOTS' and 'cluster.evenly-spread-out-slots:
+        // true'
+        conf.setString(EVENLY_SPREAD_OUT_SLOTS_STRATEGY.key(), "true");
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf))
+                .isEqualTo(TaskManagerLoadBalanceMode.SLOTS);

Review Comment:
   It's better to split these tests to separate code block. The conf is used and changed by all cases, it's not clear.
   
   For example, you want to test `taskmanager.load-balance.mode: SLOTS and cluster.evenly-spread-out-slots: false` in the third case, you must check what the `cluster.evenly-spread-out-slots` is in the second case. It's not clear and easy to bug.
   
   
   ```
   // code block1
   {
     Configuration conf = new Configuration();
   }
   
   
   // code block2
   {
     Configuration conf = new Configuration();
   }
   ```



##########
flink-core/src/main/java/org/apache/flink/configuration/TaskManagerLoadBalanceMode.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.configuration;
+
+import org.apache.flink.annotation.Internal;
+
+import javax.annotation.Nonnull;
+
+/** Type of {@link TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE}. */
+@Internal
+public enum TaskManagerLoadBalanceMode {
+    NONE,
+    SLOTS;
+
+    /**
+     * The method is mainly to load the {@link TaskManagerOptions#TASK_MANAGER_LOAD_BALANCE_MODE}
+     * from {@link Configuration}, which is compatible with {@link
+     * ClusterOptions#EVENLY_SPREAD_OUT_SLOTS_STRATEGY}.
+     */
+    public static TaskManagerLoadBalanceMode loadFromConfiguration(
+            @Nonnull Configuration configuration) {
+        TaskManagerLoadBalanceMode taskManagerLoadBalanceMode =
+                configuration.get(TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE);
+        boolean evenlySpreadOutSlots =
+                configuration.getBoolean(ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY);
+
+        if (taskManagerLoadBalanceMode != TaskManagerLoadBalanceMode.NONE
+                && taskManagerLoadBalanceMode != null) {

Review Comment:
   You wrote a couple of `taskManagerLoadBalanceMode != null` or `taskManagerLoadBalanceMode == null`.
   
   IIUC, it never be null due to `TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE` has default value.
   
   Please clean up your code and remove uncessary code, thanks~



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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "KarmaGYZ (via GitHub)" <gi...@apache.org>.
KarmaGYZ commented on code in PR #23658:
URL: https://github.com/apache/flink/pull/23658#discussion_r1382812017


##########
flink-core/src/test/java/org/apache/flink/configuration/TaskManagerLoadBalanceModeTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.flink.configuration.ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY;
+import static org.apache.flink.configuration.TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE;
+import static org.apache.flink.configuration.TaskManagerOptions.TaskManagerLoadBalanceMode;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for {@link TaskManagerLoadBalanceMode}. */
+class TaskManagerLoadBalanceModeTest {
+
+    @Test
+    void testReadTaskManagerLoadBalanceMode() {
+        // Check for non-set 'taskmanager.load-balance.mode' and
+        // 'cluster.evenly-spread-out-slots: false'
+        Configuration conf1 = new Configuration();
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf1))
+                .isEqualTo(TASK_MANAGER_LOAD_BALANCE_MODE.defaultValue());
+
+        // Check for non-set 'taskmanager.load-balance.mode' and
+        // 'cluster.evenly-spread-out-slots: true'
+        Configuration conf2 = new Configuration();
+        conf2.set(EVENLY_SPREAD_OUT_SLOTS_STRATEGY, true);
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf2))
+                .isEqualTo(TaskManagerLoadBalanceMode.SLOTS);
+
+        // Check for setting manually 'taskmanager.load-balance.mode: NONE' and
+        // 'cluster.evenly-spread-out-slots: false'
+        Configuration conf3 = new Configuration();
+        conf3.set(TASK_MANAGER_LOAD_BALANCE_MODE, TaskManagerLoadBalanceMode.NONE);
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf3))
+                .isEqualTo(TaskManagerLoadBalanceMode.NONE);
+
+        // Check for setting manually 'taskmanager.load-balance.mode: NONE' and
+        // 'cluster.evenly-spread-out-slots: true'
+        Configuration conf4 = new Configuration();
+        conf4.set(TASK_MANAGER_LOAD_BALANCE_MODE, TaskManagerLoadBalanceMode.NONE);
+        conf4.set(EVENLY_SPREAD_OUT_SLOTS_STRATEGY, true);
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf4))
+                .isEqualTo(TaskManagerLoadBalanceMode.NONE);

Review Comment:
   sounds good to me.



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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #23658:
URL: https://github.com/apache/flink/pull/23658#discussion_r1382342315


##########
flink-core/src/test/java/org/apache/flink/configuration/TaskManagerLoadBalanceModeTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.configuration;
+
+import org.apache.flink.util.TestLoggerExtension;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import static org.apache.flink.configuration.ClusterOptions.EVENLY_SPREAD_OUT_SLOTS_STRATEGY;
+import static org.apache.flink.configuration.TaskManagerOptions.TASK_MANAGER_LOAD_BALANCE_MODE;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for {@link TaskManagerLoadBalanceMode}. */
+@ExtendWith(TestLoggerExtension.class)
+class TaskManagerLoadBalanceModeTest {
+
+    @Test
+    void testReadTaskManagerLoadBalanceMode() {
+        Configuration conf = new Configuration();
+
+        // Check for 'taskmanager.load-balance.mode: NONE' and 'cluster.evenly-spread-out-slots:
+        // false'
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf))
+                .isEqualTo(TaskManagerLoadBalanceMode.NONE);
+
+        // Check for 'taskmanager.load-balance.mode: NONE' and 'cluster.evenly-spread-out-slots:
+        // true'
+        conf.setString(EVENLY_SPREAD_OUT_SLOTS_STRATEGY.key(), "true");
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf))
+                .isEqualTo(TaskManagerLoadBalanceMode.SLOTS);
+
+        // Check for 'taskmanager.load-balance.mode: SLOTS' and 'cluster.evenly-spread-out-slots:
+        // false'
+        conf.setString(
+                TASK_MANAGER_LOAD_BALANCE_MODE.key(), TaskManagerLoadBalanceMode.SLOTS.name());
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf))
+                .isEqualTo(TaskManagerLoadBalanceMode.SLOTS);
+
+        // Check for 'taskmanager.load-balance.mode: SLOTS' and 'cluster.evenly-spread-out-slots:
+        // true'
+        conf.setString(EVENLY_SPREAD_OUT_SLOTS_STRATEGY.key(), "true");
+        assertThat(TaskManagerLoadBalanceMode.loadFromConfiguration(conf))
+                .isEqualTo(TaskManagerLoadBalanceMode.SLOTS);

Review Comment:
   Sounds nice to me.
   updated~



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


Re: [PR] [FLINK-33448][runtime] Introduce a new configuration item 'taskmanager.load-balance.mode' [flink]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui commented on PR #23658:
URL: https://github.com/apache/flink/pull/23658#issuecomment-1809570312

   > Sorry that I was on a trip last week and did not have a chance to take a look. The change looks good to me. Just one minor comment that it's better to annotate `TaskManagerLoadBalanceMode#loadFromConfiguration()` with `@Internal` to avoid indicating it as a public interface to users.
   
   Thanks @zhuzhurk for the review and good suggestion!
   
   cc @RocMarshal 


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