You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "fonsdant (via GitHub)" <gi...@apache.org> on 2024/08/29 01:47:11 UTC

[PR] [WIP] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

fonsdant opened a new pull request, #17038:
URL: https://github.com/apache/kafka/pull/17038

   *More detailed description of your change,
   if necessary. The PR title and PR message become
   the squashed commit message, so use a separate
   comment to ping reviewers.*
   
   *Summary of testing strategy (including rationale)
   for the feature or bug fix. Unit and/or integration
   tests are expected for any behaviour change and
   system tests should be considered for larger changes.*
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "mimaison (via GitHub)" <gi...@apache.org>.
mimaison merged PR #17038:
URL: https://github.com/apache/kafka/pull/17038


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on code in PR #17038:
URL: https://github.com/apache/kafka/pull/17038#discussion_r1746786740


##########
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:
##########
@@ -262,12 +264,13 @@ private void createInternalTopics() {
         );
     }
 
-    Map<TopicPartition, OffsetAndMetadata> listConsumerGroupOffsets(String group)
+    ListConsumerGroupOffsetsResult listConsumerGroupOffsets(List<String> groups)
             throws InterruptedException, ExecutionException {
+        Map<String, ListConsumerGroupOffsetsSpec> groupSpecs = groups.stream()
+                .collect(Collectors.toMap(group -> group, group -> new ListConsumerGroupOffsetsSpec()));
         return adminCall(
-                () -> sourceAdminClient.listConsumerGroupOffsets(group).partitionsToOffsetAndMetadata().get(),
-                () -> String.format("list offsets for consumer group %s on %s cluster", group,
-                        config.sourceClusterAlias())
+                () -> sourceAdminClient.listConsumerGroupOffsets(groupSpecs),
+                () -> String.format("list offsets for consumer groups %s on %s cluster", groups, config.sourceClusterAlias())
         );

Review Comment:
   While looping, we need to get topic partitions and metadata by group. For this reason, I have chosen `ListConsumerGroupOffsetsResult` as the return of listConsumerGroupOffsets as it allows us to do `result.partitionsToOffsetAndMetadata(group).get()` after calling `listConsumerGroups(filteredGroups)`.
   
   In `.all().get()` inside `listConsumerGroups` approach, once we have all topic partitions and metadata for all consumer groups, we will not be able to distinguish each of them by group while looping.
   
   An alternative could be to make a copy of `ListConsumerGroupOffsetsResult.all()` that groups future results by group. This way, we could continue to get them batched and still have how to distinguish what group each one belongs to. But I think it would need KIP, right? So it does not seem to be the case.
   
   Let me know if I have missed something.
   
   Many thanks for your review, @gharris1727! :)



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on PR #17038:
URL: https://github.com/apache/kafka/pull/17038#issuecomment-2427894276

   @mimaison, thanks! I have pushed an update for it.


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on code in PR #17038:
URL: https://github.com/apache/kafka/pull/17038#discussion_r1742821094


##########
connect/mirror/src/test/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnectorTest.java:
##########
@@ -151,7 +155,14 @@ public void testFindConsumerGroups() throws Exception {
         doReturn(groups).when(connector).listConsumerGroups();
         doReturn(true).when(connector).shouldReplicateByTopicFilter(anyString());
         doReturn(true).when(connector).shouldReplicateByGroupFilter(anyString());
-        doReturn(offsets).when(connector).listConsumerGroupOffsets(anyString());

Review Comment:
   I have not used offsets anymore, but offsetsResult need to be mocked



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on PR #17038:
URL: https://github.com/apache/kafka/pull/17038#issuecomment-2430443231

   Thanks, @mimaison! 😄 


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "mimaison (via GitHub)" <gi...@apache.org>.
mimaison commented on PR #17038:
URL: https://github.com/apache/kafka/pull/17038#issuecomment-2418979410

   Thanks for the update. Spotless is failing, see the error in https://github.com/apache/kafka/actions/runs/11364366312/job/31628998328?pr=17038


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "mimaison (via GitHub)" <gi...@apache.org>.
mimaison commented on PR #17038:
URL: https://github.com/apache/kafka/pull/17038#issuecomment-2414855764

   @fonsdant Can you rebase the PR so it triggers the new CI? Thanks


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on PR #17038:
URL: https://github.com/apache/kafka/pull/17038#issuecomment-2327622037

   @gharris1727, thank you for the appointed issues! As suggested, the public access modifier has been removed, a single groupSpec for map entries has been created, and tests have been mocked!


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on code in PR #17038:
URL: https://github.com/apache/kafka/pull/17038#discussion_r1746786740


##########
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:
##########
@@ -262,12 +264,13 @@ private void createInternalTopics() {
         );
     }
 
-    Map<TopicPartition, OffsetAndMetadata> listConsumerGroupOffsets(String group)
+    ListConsumerGroupOffsetsResult listConsumerGroupOffsets(List<String> groups)
             throws InterruptedException, ExecutionException {
+        Map<String, ListConsumerGroupOffsetsSpec> groupSpecs = groups.stream()
+                .collect(Collectors.toMap(group -> group, group -> new ListConsumerGroupOffsetsSpec()));
         return adminCall(
-                () -> sourceAdminClient.listConsumerGroupOffsets(group).partitionsToOffsetAndMetadata().get(),
-                () -> String.format("list offsets for consumer group %s on %s cluster", group,
-                        config.sourceClusterAlias())
+                () -> sourceAdminClient.listConsumerGroupOffsets(groupSpecs),
+                () -> String.format("list offsets for consumer groups %s on %s cluster", groups, config.sourceClusterAlias())
         );

Review Comment:
   While looping, we need to get topic partitions and metadata by group. For this reason, I have chosen `ListConsumerGroupOffsetsResult` as the return of listConsumerGroupOffsets as it allows us to do `result.partitionsToOffsetAndMetadata(group).get()`.
   
   In `.all().get()` approach, once we have all topic partitions and metadata for all consumer groups, we will not be able to distinguish each of them by group.
   
   Let me know if I have missed something.
   
   Many thanks for your review, @gharris1727! :)



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on code in PR #17038:
URL: https://github.com/apache/kafka/pull/17038#discussion_r1746786740


##########
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:
##########
@@ -262,12 +264,13 @@ private void createInternalTopics() {
         );
     }
 
-    Map<TopicPartition, OffsetAndMetadata> listConsumerGroupOffsets(String group)
+    ListConsumerGroupOffsetsResult listConsumerGroupOffsets(List<String> groups)
             throws InterruptedException, ExecutionException {
+        Map<String, ListConsumerGroupOffsetsSpec> groupSpecs = groups.stream()
+                .collect(Collectors.toMap(group -> group, group -> new ListConsumerGroupOffsetsSpec()));
         return adminCall(
-                () -> sourceAdminClient.listConsumerGroupOffsets(group).partitionsToOffsetAndMetadata().get(),
-                () -> String.format("list offsets for consumer group %s on %s cluster", group,
-                        config.sourceClusterAlias())
+                () -> sourceAdminClient.listConsumerGroupOffsets(groupSpecs),
+                () -> String.format("list offsets for consumer groups %s on %s cluster", groups, config.sourceClusterAlias())
         );

Review Comment:
   While looping, we need to get topic partitions and metadata by group. For this reason, I have chosen `ListConsumerGroupOffsetsResult` as the return of listConsumerGroupOffsets as it allows us to do `result.partitionsToOffsetAndMetadata(group).get()` after callling `listConsumerGroups(filteredGroups)`.
   
   In `.all().get()` approach inside `listConsumerGroups`, once we have all topic partitions and metadata for all consumer groups, we will not be able to distinguish each of them by group while looping.
   
   Let me know if I have missed something.
   
   Many thanks for your review, @gharris1727! :)



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on PR #17038:
URL: https://github.com/apache/kafka/pull/17038#issuecomment-2325933706

   @gharris1727, could you check it?


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "mimaison (via GitHub)" <gi...@apache.org>.
mimaison commented on PR #17038:
URL: https://github.com/apache/kafka/pull/17038#issuecomment-2429346494

   I'll leave the PR open for a couple of days in case @gharris1727 wants to take another look.


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on code in PR #17038:
URL: https://github.com/apache/kafka/pull/17038#discussion_r1746786740


##########
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:
##########
@@ -262,12 +264,13 @@ private void createInternalTopics() {
         );
     }
 
-    Map<TopicPartition, OffsetAndMetadata> listConsumerGroupOffsets(String group)
+    ListConsumerGroupOffsetsResult listConsumerGroupOffsets(List<String> groups)
             throws InterruptedException, ExecutionException {
+        Map<String, ListConsumerGroupOffsetsSpec> groupSpecs = groups.stream()
+                .collect(Collectors.toMap(group -> group, group -> new ListConsumerGroupOffsetsSpec()));
         return adminCall(
-                () -> sourceAdminClient.listConsumerGroupOffsets(group).partitionsToOffsetAndMetadata().get(),
-                () -> String.format("list offsets for consumer group %s on %s cluster", group,
-                        config.sourceClusterAlias())
+                () -> sourceAdminClient.listConsumerGroupOffsets(groupSpecs),
+                () -> String.format("list offsets for consumer groups %s on %s cluster", groups, config.sourceClusterAlias())
         );

Review Comment:
   While looping, we need to get topic partitions and metadata by group. For this reason, I have chosen `ListConsumerGroupOffsetsResult` as the return of listConsumerGroupOffsets as it allows us to do `result.partitionsToOffsetAndMetadata(group).get()` after calling `listConsumerGroups(filteredGroups)`.
   
   In `.all().get()` inside `listConsumerGroups` approach, once we have all topic partitions and metadata for all consumer groups, we will not be able to distinguish each of them by group while looping.
   
   Let me know if I have missed something.
   
   Many thanks for your review, @gharris1727! :)



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on PR #17038:
URL: https://github.com/apache/kafka/pull/17038#issuecomment-2416483776

   @mimaison, done! Thanks :)


-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "gharris1727 (via GitHub)" <gi...@apache.org>.
gharris1727 commented on code in PR #17038:
URL: https://github.com/apache/kafka/pull/17038#discussion_r1742462093


##########
clients/src/main/java/org/apache/kafka/clients/admin/ListConsumerGroupOffsetsResult.java:
##########
@@ -40,7 +40,7 @@ public class ListConsumerGroupOffsetsResult {
 
     final Map<String, KafkaFuture<Map<TopicPartition, OffsetAndMetadata>>> futures;
 
-    ListConsumerGroupOffsetsResult(final Map<CoordinatorKey, KafkaFuture<Map<TopicPartition, OffsetAndMetadata>>> futures) {
+    public ListConsumerGroupOffsetsResult(final Map<CoordinatorKey, KafkaFuture<Map<TopicPartition, OffsetAndMetadata>>> futures) {

Review Comment:
   This is a change to the public interface, which would require a KIP. Please revert this change and find an alternative. Thanks!



##########
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:
##########
@@ -262,12 +264,13 @@ private void createInternalTopics() {
         );
     }
 
-    Map<TopicPartition, OffsetAndMetadata> listConsumerGroupOffsets(String group)
+    ListConsumerGroupOffsetsResult listConsumerGroupOffsets(List<String> groups)
             throws InterruptedException, ExecutionException {
+        Map<String, ListConsumerGroupOffsetsSpec> groupSpecs = groups.stream()
+                .collect(Collectors.toMap(group -> group, group -> new ListConsumerGroupOffsetsSpec()));

Review Comment:
   nit: create one of these Spec objects and reuse it for every entry in the map.



##########
connect/mirror/src/test/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnectorTest.java:
##########
@@ -151,7 +155,14 @@ public void testFindConsumerGroups() throws Exception {
         doReturn(groups).when(connector).listConsumerGroups();
         doReturn(true).when(connector).shouldReplicateByTopicFilter(anyString());
         doReturn(true).when(connector).shouldReplicateByGroupFilter(anyString());
-        doReturn(offsets).when(connector).listConsumerGroupOffsets(anyString());

Review Comment:
   I think this leaves the `offsets` variable unused.



##########
connect/mirror/src/test/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnectorTest.java:
##########
@@ -151,7 +155,14 @@ public void testFindConsumerGroups() throws Exception {
         doReturn(groups).when(connector).listConsumerGroups();
         doReturn(true).when(connector).shouldReplicateByTopicFilter(anyString());
         doReturn(true).when(connector).shouldReplicateByGroupFilter(anyString());
-        doReturn(offsets).when(connector).listConsumerGroupOffsets(anyString());
+
+        Map<CoordinatorKey, KafkaFuture<Map<TopicPartition, OffsetAndMetadata>>> futures = new HashMap<>();
+        futures.put(CoordinatorKey.byGroupId("g1"), KafkaFuture.completedFuture(offsets));
+        futures.put(CoordinatorKey.byGroupId("g2"), KafkaFuture.completedFuture(offsets));
+        ListConsumerGroupOffsetsResult offsetsResult = new ListConsumerGroupOffsetsResult(futures);
+        offsetsResult = spy(offsetsResult);

Review Comment:
   I think you can avoid needing to change the constructor visibility if you use mock(ListConsumerGroupOffsetsResult.class) instead.



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "gharris1727 (via GitHub)" <gi...@apache.org>.
gharris1727 commented on code in PR #17038:
URL: https://github.com/apache/kafka/pull/17038#discussion_r1745922035


##########
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:
##########
@@ -262,12 +264,13 @@ private void createInternalTopics() {
         );
     }
 
-    Map<TopicPartition, OffsetAndMetadata> listConsumerGroupOffsets(String group)
+    ListConsumerGroupOffsetsResult listConsumerGroupOffsets(List<String> groups)
             throws InterruptedException, ExecutionException {
+        Map<String, ListConsumerGroupOffsetsSpec> groupSpecs = groups.stream()
+                .collect(Collectors.toMap(group -> group, group -> new ListConsumerGroupOffsetsSpec()));
         return adminCall(
-                () -> sourceAdminClient.listConsumerGroupOffsets(group).partitionsToOffsetAndMetadata().get(),
-                () -> String.format("list offsets for consumer group %s on %s cluster", group,
-                        config.sourceClusterAlias())
+                () -> sourceAdminClient.listConsumerGroupOffsets(groupSpecs),
+                () -> String.format("list offsets for consumer groups %s on %s cluster", groups, config.sourceClusterAlias())
         );

Review Comment:
   I think to make this adminCall functional, the first argument needs to be blocking. I think you need to use .all().get() instead of returning the whole Result object.



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "gharris1727 (via GitHub)" <gi...@apache.org>.
gharris1727 commented on code in PR #17038:
URL: https://github.com/apache/kafka/pull/17038#discussion_r1747411117


##########
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:
##########
@@ -262,12 +264,13 @@ private void createInternalTopics() {
         );
     }
 
-    Map<TopicPartition, OffsetAndMetadata> listConsumerGroupOffsets(String group)
+    ListConsumerGroupOffsetsResult listConsumerGroupOffsets(List<String> groups)
             throws InterruptedException, ExecutionException {
+        Map<String, ListConsumerGroupOffsetsSpec> groupSpecs = groups.stream()
+                .collect(Collectors.toMap(group -> group, group -> new ListConsumerGroupOffsetsSpec()));
         return adminCall(
-                () -> sourceAdminClient.listConsumerGroupOffsets(group).partitionsToOffsetAndMetadata().get(),
-                () -> String.format("list offsets for consumer group %s on %s cluster", group,
-                        config.sourceClusterAlias())
+                () -> sourceAdminClient.listConsumerGroupOffsets(groupSpecs),
+                () -> String.format("list offsets for consumer groups %s on %s cluster", groups, config.sourceClusterAlias())
         );

Review Comment:
   `ListConsumerGroupOffsetsResult#all()` has the return type `KafkaFuture<Map<String, Map<TopicPartition, OffsetAndMetadata>>>` which should include group information. I don't think it merges the results of the different groups together.



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on code in PR #17038:
URL: https://github.com/apache/kafka/pull/17038#discussion_r1746786740


##########
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:
##########
@@ -262,12 +264,13 @@ private void createInternalTopics() {
         );
     }
 
-    Map<TopicPartition, OffsetAndMetadata> listConsumerGroupOffsets(String group)
+    ListConsumerGroupOffsetsResult listConsumerGroupOffsets(List<String> groups)
             throws InterruptedException, ExecutionException {
+        Map<String, ListConsumerGroupOffsetsSpec> groupSpecs = groups.stream()
+                .collect(Collectors.toMap(group -> group, group -> new ListConsumerGroupOffsetsSpec()));
         return adminCall(
-                () -> sourceAdminClient.listConsumerGroupOffsets(group).partitionsToOffsetAndMetadata().get(),
-                () -> String.format("list offsets for consumer group %s on %s cluster", group,
-                        config.sourceClusterAlias())
+                () -> sourceAdminClient.listConsumerGroupOffsets(groupSpecs),
+                () -> String.format("list offsets for consumer groups %s on %s cluster", groups, config.sourceClusterAlias())
         );

Review Comment:
   While looping, we need to get topic partitions and metadata by group. For this reason, I have chosen `ListConsumerGroupOffsetsResult` as the return of listConsumerGroupOffsets as it allows us to do `result.partitionsToOffsetAndMetadata(group).get()` after callling `listConsumerGroups(filteredGroups)`.
   
   In `.all().get()` approach, once we have all topic partitions and metadata for all consumer groups, we will not be able to distinguish each of them by group after callling `listConsumerGroups(filteredGroups)`.
   
   Let me know if I have missed something.
   
   Many thanks for your review, @gharris1727! :)



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on code in PR #17038:
URL: https://github.com/apache/kafka/pull/17038#discussion_r1746786740


##########
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:
##########
@@ -262,12 +264,13 @@ private void createInternalTopics() {
         );
     }
 
-    Map<TopicPartition, OffsetAndMetadata> listConsumerGroupOffsets(String group)
+    ListConsumerGroupOffsetsResult listConsumerGroupOffsets(List<String> groups)
             throws InterruptedException, ExecutionException {
+        Map<String, ListConsumerGroupOffsetsSpec> groupSpecs = groups.stream()
+                .collect(Collectors.toMap(group -> group, group -> new ListConsumerGroupOffsetsSpec()));
         return adminCall(
-                () -> sourceAdminClient.listConsumerGroupOffsets(group).partitionsToOffsetAndMetadata().get(),
-                () -> String.format("list offsets for consumer group %s on %s cluster", group,
-                        config.sourceClusterAlias())
+                () -> sourceAdminClient.listConsumerGroupOffsets(groupSpecs),
+                () -> String.format("list offsets for consumer groups %s on %s cluster", groups, config.sourceClusterAlias())
         );

Review Comment:
   While looping, we need to get topic partitions and metadata by group. For this reason, I have chosen `ListConsumerGroupOffsetsResult` as the return of listConsumerGroupOffsets as it allows us to do `result.partitionsToOffsetAndMetadata(group).get()` after callling `listConsumerGroups(filteredGroups)`.
   
   In `.all().get()` inside `listConsumerGroups` approach, once we have all topic partitions and metadata for all consumer groups, we will not be able to distinguish each of them by group while looping.
   
   Let me know if I have missed something.
   
   Many thanks for your review, @gharris1727! :)



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on code in PR #17038:
URL: https://github.com/apache/kafka/pull/17038#discussion_r1747860138


##########
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorCheckpointConnector.java:
##########
@@ -262,12 +264,13 @@ private void createInternalTopics() {
         );
     }
 
-    Map<TopicPartition, OffsetAndMetadata> listConsumerGroupOffsets(String group)
+    ListConsumerGroupOffsetsResult listConsumerGroupOffsets(List<String> groups)
             throws InterruptedException, ExecutionException {
+        Map<String, ListConsumerGroupOffsetsSpec> groupSpecs = groups.stream()
+                .collect(Collectors.toMap(group -> group, group -> new ListConsumerGroupOffsetsSpec()));
         return adminCall(
-                () -> sourceAdminClient.listConsumerGroupOffsets(group).partitionsToOffsetAndMetadata().get(),
-                () -> String.format("list offsets for consumer group %s on %s cluster", group,
-                        config.sourceClusterAlias())
+                () -> sourceAdminClient.listConsumerGroupOffsets(groupSpecs),
+                () -> String.format("list offsets for consumer groups %s on %s cluster", groups, config.sourceClusterAlias())
         );

Review Comment:
   Oh! You are right! Sorry, Greg, I have mixed up the return type. I will push a commit to fix it. Constructive review, thanks!
   



-- 
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-unsubscribe@kafka.apache.org

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


Re: [PR] KAFKA-17233: MirrorCheckpointConnector should use batched listConsumerGroupOffsets [kafka]

Posted by "fonsdant (via GitHub)" <gi...@apache.org>.
fonsdant commented on PR #17038:
URL: https://github.com/apache/kafka/pull/17038#issuecomment-2344125595

   Hi, @gharris1727! Could you review it, please?


-- 
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-unsubscribe@kafka.apache.org

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