chia7712 commented on code in PR #19508:
URL: https://github.com/apache/kafka/pull/19508#discussion_r2061482809


##########
clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:
##########
@@ -3541,27 +3541,29 @@ ListGroupsRequest.Builder createRequest(int timeoutMs) {
                         }
 
                         private void 
maybeAddGroup(ListGroupsResponseData.ListedGroup group) {
-                            final String groupId = group.groupId();
-                            final Optional<GroupType> type;
-                            if (group.groupType() == null || 
group.groupType().isEmpty()) {
-                                type = Optional.empty();
-                            } else {
-                                type = 
Optional.of(GroupType.parse(group.groupType()));
-                            }
-                            final String protocolType = group.protocolType();
-                            final Optional<GroupState> groupState;
-                            if (group.groupState() == null || 
group.groupState().isEmpty()) {
-                                groupState = Optional.empty();
-                            } else {
-                                groupState = 
Optional.of(GroupState.parse(group.groupState()));
+                            String protocolType = group.protocolType();
+                            if (options.protocolTypes().isEmpty() || 
options.protocolTypes().contains(protocolType)) {

Review Comment:
   Have you considered adding the protocol filter to RPC?



##########
clients/src/main/java/org/apache/kafka/common/requests/ListGroupsRequest.java:
##########
@@ -50,8 +53,18 @@ public ListGroupsRequest build(short version) {
                         "v" + version + ", but we need v4 or newer to request 
groups by states.");
             }
             if (!data.typesFilter().isEmpty() && version < 5) {
-                throw new UnsupportedVersionException("The broker only 
supports ListGroups " +
-                    "v" + version + ", but we need v5 or newer to request 
groups by type.");
+                // Types filter is supported by brokers with version 4.0.0 or 
later. Older brokers only support
+                // classic groups, so listing consumer groups on an older 
broker does not need to use a types filter.
+                // If the types filter is only for consumer and classic, or 
just classic groups, it can be safely omitted.
+                // This allows a modern admin client to list consumer groups 
on older brokers in a straightforward way.
+                HashSet<String> typesCopy = new HashSet<>(data.typesFilter());
+                boolean containedClassic = 
typesCopy.remove(GroupType.CLASSIC.toString());
+                boolean containedConsumer = 
typesCopy.remove(GroupType.CONSUMER.toString());
+                if (!typesCopy.isEmpty() && (containedClassic || 
!containedConsumer)) {
+                    throw new UnsupportedVersionException("The broker only 
supports ListGroups " +
+                        "v" + version + ", but we need v5 or newer to request 
groups by type.");

Review Comment:
   Could you please add the unsupported types to the error message?



##########
core/src/main/scala/kafka/admin/ConfigCommand.scala:
##########
@@ -350,7 +350,7 @@ object ConfigCommand extends Logging {
         case ClientMetricsType =>
           
adminClient.listClientMetricsResources().all().get().asScala.map(_.name).toSeq
         case GroupType =>
-          
adminClient.listGroups(ListGroupsOptions.forConsumerGroups()).all.get.asScala.map(_.groupId).toSeq
+          adminClient.listGroups().all.get.asScala.map(_.groupId).toSeq

Review Comment:
   It seems we revert the change of listing consumer-only groups?



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