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


##########
clients/src/main/java/org/apache/kafka/clients/admin/internals/DescribeConsumerGroupsHandler.java:
##########
@@ -89,18 +96,42 @@ public AdminApiLookupStrategy<CoordinatorKey> 
lookupStrategy() {
     }
 
     @Override
-    public DescribeGroupsRequest.Builder buildBatchedRequest(int 
coordinatorId, Set<CoordinatorKey> keys) {
-        List<String> groupIds = keys.stream().map(key -> {
+    public Collection<RequestAndKeys<CoordinatorKey>> buildRequest(int 
coordinatorId, Set<CoordinatorKey> keys) {
+        Set<CoordinatorKey> newConsumerGroups = new HashSet<>();
+        Set<CoordinatorKey> oldConsumerGroups = new HashSet<>();
+
+        keys.forEach(key -> {
             if (key.type != FindCoordinatorRequest.CoordinatorType.GROUP) {
-                throw new IllegalArgumentException("Invalid transaction 
coordinator key " + key +
+                throw new IllegalArgumentException("Invalid group coordinator 
key " + key +
                     " when building `DescribeGroups` request");
             }
-            return key.idValue;
-        }).collect(Collectors.toList());
-        DescribeGroupsRequestData data = new DescribeGroupsRequestData()
-            .setGroups(groupIds)
-            .setIncludeAuthorizedOperations(includeAuthorizedOperations);
-        return new DescribeGroupsRequest.Builder(data);
+
+            // Be default, we always try with using the new consumer group
+            // describe API. If it fails, we fail back to using the classic
+            // group API.
+            if (useClassicGroupApi.getOrDefault(key.idValue, false)) {
+                oldConsumerGroups.add(key);
+            } else {
+                newConsumerGroups.add(key);
+            }
+        });
+
+        List<RequestAndKeys<CoordinatorKey>> requests = new ArrayList<>();
+        if (!newConsumerGroups.isEmpty()) {
+            ConsumerGroupDescribeRequestData data = new 
ConsumerGroupDescribeRequestData()
+                .setGroupIds(newConsumerGroups.stream().map(key -> 
key.idValue).collect(Collectors.toList()))
+                .setIncludeAuthorizedOperations(includeAuthorizedOperations);
+            requests.add(new RequestAndKeys<>(new 
ConsumerGroupDescribeRequest.Builder(data, true), newConsumerGroups));

Review Comment:
   `true` must be removed here when https://github.com/apache/kafka/pull/15255 
is merged.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to