dajac commented on code in PR #15411:
URL: https://github.com/apache/kafka/pull/15411#discussion_r1557562821


##########
core/src/main/scala/kafka/server/KafkaConfig.scala:
##########
@@ -1046,6 +1054,7 @@ object KafkaConfig {
       .define(ConsumerGroupMaxHeartbeatIntervalMsProp, INT, 
Defaults.CONSUMER_GROUP_MAX_HEARTBEAT_INTERVAL_MS, atLeast(1), MEDIUM, 
ConsumerGroupMaxHeartbeatIntervalMsDoc)
       .define(ConsumerGroupMaxSizeProp, INT, Defaults.CONSUMER_GROUP_MAX_SIZE, 
atLeast(1), MEDIUM, ConsumerGroupMaxSizeDoc)
       .define(ConsumerGroupAssignorsProp, LIST, 
Defaults.CONSUMER_GROUP_ASSIGNORS, null, MEDIUM, ConsumerGroupAssignorsDoc)
+      .defineInternal(ConsumerGroupMigrationPolicyProp, STRING, 
Defaults.CONSUMER_GROUP_MIGRATION_POLICY, 
in(Utils.enumOptions(classOf[ConsumerGroupMigrationPolicy]): _*), MEDIUM, 
ConsumerGroupMigrationPolicyDoc)

Review Comment:
   Could we use `ConfigDef.CaseInsensitiveValidString.in` and extend the test 
to ensure that it is case insensitive?



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/ConsumerGroupMigrationPolicy.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.kafka.coordinator.group;
+
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+public enum ConsumerGroupMigrationPolicy {
+    /** Both upgrade and downgrade are enabled.*/
+    BIDIRECTIONAL("bidirectional"),
+
+    /** Only upgrade is enabled.*/
+    UPGRADE("upgrade"),
+
+    /** Only downgrade is enabled.*/
+    DOWNGRADE("downgrade"),
+
+    /** Neither upgrade nor downgrade is enabled.*/
+    DISABLED("disabled");
+
+    private final String name;
+
+    ConsumerGroupMigrationPolicy(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String toString() {
+        return name;
+    }
+
+    private final static Map<String, ConsumerGroupMigrationPolicy> 
NAME_TO_ENUM = Arrays.stream(values())
+        .collect(Collectors.toMap(policy -> 
policy.name.toLowerCase(Locale.ROOT), Function.identity()));
+
+    /**
+     * Parse a string into the corresponding {@code 
GroupProtocolMigrationPolicy} enum value, in a case-insensitive manner.
+     *
+     * @return The {{@link ConsumerGroupMigrationPolicy}} according to the 
string passed. None is returned if
+     * the string doesn't correspond to a valid policy.
+     */
+    public static ConsumerGroupMigrationPolicy parse(String name) {
+        if (name == null) {
+            return DISABLED;
+        }
+        ConsumerGroupMigrationPolicy policy = 
NAME_TO_ENUM.get(name.toLowerCase(Locale.ROOT));
+
+        return policy == null ? DISABLED : policy;
+    }
+

Review Comment:
   nit: This empty line could be removed.



##########
core/src/main/scala/kafka/server/KafkaConfig.scala:
##########
@@ -677,6 +679,12 @@ object KafkaConfig {
   val ConsumerGroupMaxHeartbeatIntervalMsDoc = "The maximum heartbeat interval 
for registered consumers."
   val ConsumerGroupMaxSizeDoc = "The maximum number of consumers that a single 
consumer group can accommodate."
   val ConsumerGroupAssignorsDoc = "The server side assignors as a list of full 
class names. The first one in the list is considered as the default assignor to 
be used in the case where the consumer does not specify an assignor."
+  val ConsumerGroupMigrationPolicyDoc = "The config that enables converting 
the non-empty classic group using the consumer embedded protocol to the 
non-empty consumer group using the consumer group protocol and vice versa; " +
+    "conversions of empty groups in both directions are always enabled 
regardless of this policy. " +
+    ConsumerGroupMigrationPolicy.BIDIRECTIONAL + ": both upgrade from classic 
group to consumer group and downgrade from consumer group to classic group are 
enabled, " +
+    ConsumerGroupMigrationPolicy.UPGRADE + ": only upgrade is enabled, " +

Review Comment:
   nit: `upgrade` -> `upgrade from classic group to consumer group`.



##########
core/src/main/scala/kafka/server/KafkaConfig.scala:
##########
@@ -677,6 +679,12 @@ object KafkaConfig {
   val ConsumerGroupMaxHeartbeatIntervalMsDoc = "The maximum heartbeat interval 
for registered consumers."
   val ConsumerGroupMaxSizeDoc = "The maximum number of consumers that a single 
consumer group can accommodate."
   val ConsumerGroupAssignorsDoc = "The server side assignors as a list of full 
class names. The first one in the list is considered as the default assignor to 
be used in the case where the consumer does not specify an assignor."
+  val ConsumerGroupMigrationPolicyDoc = "The config that enables converting 
the non-empty classic group using the consumer embedded protocol to the 
non-empty consumer group using the consumer group protocol and vice versa; " +
+    "conversions of empty groups in both directions are always enabled 
regardless of this policy. " +
+    ConsumerGroupMigrationPolicy.BIDIRECTIONAL + ": both upgrade from classic 
group to consumer group and downgrade from consumer group to classic group are 
enabled, " +
+    ConsumerGroupMigrationPolicy.UPGRADE + ": only upgrade is enabled, " +
+    ConsumerGroupMigrationPolicy.DOWNGRADE + ": only downgrade is enabled, " +

Review Comment:
   nit: `downgrade` -> `downgrade from consumer group to classic group`



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to