dongnuo123 commented on code in PR #14408:
URL: https://github.com/apache/kafka/pull/14408#discussion_r1331961609


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:
##########
@@ -523,9 +526,38 @@ public 
CompletableFuture<DeleteGroupsResponseData.DeletableGroupResultCollection
             return 
FutureUtils.failedFuture(Errors.COORDINATOR_NOT_AVAILABLE.exception());
         }
 
-        return FutureUtils.failedFuture(Errors.UNSUPPORTED_VERSION.exception(
-            "This API is not implemented yet."
-        ));
+        final Map<Integer, List<String>> groupsByPartition = new HashMap<>();
+        for (String groupId : groupIds) {
+            final int partition = partitionFor(groupId);
+            final List<String> groupList = 
groupsByPartition.getOrDefault(partition, new ArrayList<>());
+            groupList.add(groupId);
+            groupsByPartition.put(partition, groupList);
+        }
+
+        final 
List<CompletableFuture<DeleteGroupsResponseData.DeletableGroupResultCollection>>
 futures = new ArrayList<>();
+        for (Map.Entry<Integer, List<String>> entry : 
groupsByPartition.entrySet()) {
+            int partition = entry.getKey();
+            List<String> groupList = entry.getValue();
+            
CompletableFuture<DeleteGroupsResponseData.DeletableGroupResultCollection> 
future =
+                    runtime.scheduleWriteOperation("delete-group",
+                            new 
TopicPartition(Topic.GROUP_METADATA_TOPIC_NAME, partition),
+                            coordinator -> coordinator.deleteGroups(context, 
groupList));
+            futures.add(future);
+        }
+
+        final CompletableFuture<Void> allFutures = 
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
+        return allFutures.thenApply(v -> {
+            final DeleteGroupsResponseData.DeletableGroupResultCollection res 
= new DeleteGroupsResponseData.DeletableGroupResultCollection();
+            for 
(CompletableFuture<DeleteGroupsResponseData.DeletableGroupResultCollection> 
future : futures) {
+                try {
+                    DeleteGroupsResponseData.DeletableGroupResultCollection 
result = future.get();

Review Comment:
   done



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