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


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/ConsumerGroupMigrationPolicy.java:
##########
@@ -0,0 +1,74 @@
+/*
+ * 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 policy;
+
+    ConsumerGroupMigrationPolicy(String config) {
+        this.policy = config;
+    }

Review Comment:
   nit: We use different names `config` and `policy`. This is confusing. How 
about using `name`?



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/ConsumerGroupMigrationPolicy.java:
##########
@@ -0,0 +1,74 @@
+/*
+ * 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 policy;
+
+    ConsumerGroupMigrationPolicy(String config) {
+        this.policy = config;
+    }
+
+    @Override
+    public String toString() {
+        return policy;
+    }
+
+    public static String validValuesDescription =
+        BIDIRECTIONAL   + ": both upgrade from classic group to consumer group 
and downgrade from consumer group to classic group are enabled" + ", " +
+        UPGRADE         + ": only upgrade is enabled" + ", " +
+        DOWNGRADE       + ": only downgrade is enabled" + ", " +

Review Comment:
   nit: Should we complement with the from...to... like you side for 
BIDIRECTIONAL? 



##########
core/src/test/scala/unit/kafka/server/KafkaConfigTest.scala:
##########
@@ -1831,6 +1832,22 @@ class KafkaConfigTest {
     assertTrue(config.isNewGroupCoordinatorEnabled)
   }
 
+  @Test
+  def testGroupProtocolMigrationPolicy(): Unit = {
+    val props = new Properties()
+    props.putAll(kraftProps())
+
+    // Invalid GroupProtocolMigrationPolicy value.
+    props.put(KafkaConfig.ConsumerGroupMigrationPolicyProp, "foo")
+    assertThrows(classOf[ConfigException], () => KafkaConfig.fromProps(props))
+
+    ConsumerGroupMigrationPolicy.values().foreach { policy =>
+      props.put(KafkaConfig.ConsumerGroupMigrationPolicyProp, policy.toString)

Review Comment:
   Is it case sensitive?



##########
core/src/test/scala/unit/kafka/server/KafkaConfigTest.scala:
##########
@@ -1831,6 +1832,22 @@ class KafkaConfigTest {
     assertTrue(config.isNewGroupCoordinatorEnabled)
   }
 
+  @Test
+  def testGroupProtocolMigrationPolicy(): Unit = {
+    val props = new Properties()
+    props.putAll(kraftProps())
+
+    // Invalid GroupProtocolMigrationPolicy value.
+    props.put(KafkaConfig.ConsumerGroupMigrationPolicyProp, "foo")
+    assertThrows(classOf[ConfigException], () => KafkaConfig.fromProps(props))
+
+    ConsumerGroupMigrationPolicy.values().foreach { policy =>

Review Comment:
   nit: You can omit the `()` after `values`.



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/ConsumerGroupMigrationPolicy.java:
##########
@@ -0,0 +1,74 @@
+/*
+ * 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 policy;
+
+    ConsumerGroupMigrationPolicy(String config) {
+        this.policy = config;
+    }
+
+    @Override
+    public String toString() {
+        return policy;
+    }
+
+    public static String validValuesDescription =
+        BIDIRECTIONAL   + ": both upgrade from classic group to consumer group 
and downgrade from consumer group to classic group are enabled" + ", " +
+        UPGRADE         + ": only upgrade is enabled" + ", " +
+        DOWNGRADE       + ": only downgrade is enabled" + ", " +
+        DISABLED        + ": neither upgrade nor downgrade is enabled.";

Review Comment:
   nit: Should we say that it is still possible to convert an empty group when 
empty?



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