mimaison commented on a change in pull request #10743:
URL: https://github.com/apache/kafka/pull/10743#discussion_r648519181



##########
File path: 
clients/src/main/java/org/apache/kafka/clients/admin/internals/CoordinatorStrategy.java
##########
@@ -40,61 +54,116 @@ public CoordinatorStrategy(
 
     @Override
     public ApiRequestScope lookupScope(CoordinatorKey key) {
-        // The `FindCoordinator` API does not support batched lookups, so we 
use a
-        // separate lookup context for each coordinator key we need to lookup
-        return new LookupRequestScope(key);
+        if (batch) {
+            if (key.type == CoordinatorType.GROUP) {
+                return GROUP_REQUEST_SCOPE;
+            } else {
+                return TXN_REQUEST_SCOPE;
+            }
+        } else {
+            // If the `FindCoordinator` API does not support batched lookups, 
we use a
+            // separate lookup context for each coordinator key we need to 
lookup
+            return new LookupRequestScope(key);
+        }
     }
 
     @Override
     public FindCoordinatorRequest.Builder buildRequest(Set<CoordinatorKey> 
keys) {
-        CoordinatorKey key = requireSingleton(keys);
-        return new FindCoordinatorRequest.Builder(
-            new FindCoordinatorRequestData()
-                .setKey(key.idValue)
-                .setKeyType(key.type.id())
-        );
+        unrepresentableKeys = keys.stream().filter(k -> 
!isRepresentableKey(k.idValue)).collect(Collectors.toSet());
+        keys = keys.stream().filter(k -> 
isRepresentableKey(k.idValue)).collect(Collectors.toSet());
+        if (batch) {
+            keys = requireSameType(keys);
+            type = keys.iterator().next().type;

Review comment:
       Yes `requireSameType` ensures there is 1 type




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

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


Reply via email to