dongnuo123 commented on code in PR #14408:
URL: https://github.com/apache/kafka/pull/14408#discussion_r1331958841
##########
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]));
Review Comment:
Yeah, it makes sense. I'm not sure what to return if there's an exception in
the write operation, since we can't set an error code for a
`DeletableGroupResultCollection`.
--
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]