rajinisivaram commented on code in PR #10964:
URL: https://github.com/apache/kafka/pull/10964#discussion_r918820604


##########
clients/src/main/java/org/apache/kafka/clients/admin/ListConsumerGroupOffsetsResult.java:
##########
@@ -17,33 +17,72 @@
 
 package org.apache.kafka.clients.admin;
 
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
+
+import org.apache.kafka.clients.admin.internals.CoordinatorKey;
 import org.apache.kafka.clients.consumer.OffsetAndMetadata;
 import org.apache.kafka.common.KafkaFuture;
 import org.apache.kafka.common.TopicPartition;
 import org.apache.kafka.common.annotation.InterfaceStability;
 
-import java.util.Map;
-
 /**
- * The result of the {@link Admin#listConsumerGroupOffsets(String)} call.
+ * The result of the {@link Admin#listConsumerGroupOffsets(Map)} and
+ * {@link Admin#listConsumerGroupOffsets(String)} call.
  * <p>
  * The API of this class is evolving, see {@link Admin} for details.
  */
 @InterfaceStability.Evolving
 public class ListConsumerGroupOffsetsResult {
 
-    final KafkaFuture<Map<TopicPartition, OffsetAndMetadata>> future;
+    final Map<CoordinatorKey, KafkaFuture<Map<TopicPartition, 
OffsetAndMetadata>>> futures;
 
-    ListConsumerGroupOffsetsResult(KafkaFuture<Map<TopicPartition, 
OffsetAndMetadata>> future) {
-        this.future = future;
+    ListConsumerGroupOffsetsResult(final Map<CoordinatorKey, 
KafkaFuture<Map<TopicPartition, OffsetAndMetadata>>> futures) {
+        this.futures = futures;
     }
 
     /**
      * Return a future which yields a map of topic partitions to 
OffsetAndMetadata objects.
      * If the group does not have a committed offset for this partition, the 
corresponding value in the returned map will be null.
      */
     public KafkaFuture<Map<TopicPartition, OffsetAndMetadata>> 
partitionsToOffsetAndMetadata() {
-        return future;
+        if (futures.size() != 1) {
+            throw new IllegalStateException("Offsets from multiple consumer 
groups were requested. " +
+                    "Use groupIdsToPartitionsAndOffsetAndMetadata() instead to 
get all futures.");
+        }
+        return futures.values().iterator().next();
     }
 
+    /**
+     * Return a map of group ids to their corresponding futures that yield a 
map of topic partitions to
+     * OffsetAndMetadata objects. If the group doesn't have a committed offset 
for a specific
+     * partition, the corresponding value in the returned map for that group 
id will be null.
+     */
+    public Map<String, KafkaFuture<Map<TopicPartition, OffsetAndMetadata>>> 
groupIdsToPartitionsAndOffsetAndMetadata() {

Review Comment:
   Yes, I was tempted to change this when going through the code, but didn't 
want to change the KIP at this point. And looking at the KIP now, looks like it 
was called `values()` before, so we seem to have changed the name somehow. 
Since we are changing the KIP for the previous comment anyway, let's just do 
`offsets(String group)`. We have `all()` to get the full map anyway. Will 
update the KIP and PR.



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