chia7712 commented on code in PR #15462:
URL: https://github.com/apache/kafka/pull/15462#discussion_r1513587296
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java:
##########
@@ -498,29 +497,17 @@ public CompletableFuture<ListGroupsResponseData>
listGroups(
);
}
- final Set<TopicPartition> existingPartitionSet = runtime.partitions();
-
- if (existingPartitionSet.isEmpty()) {
- return CompletableFuture.completedFuture(new
ListGroupsResponseData());
- }
-
- final
List<CompletableFuture<List<ListGroupsResponseData.ListedGroup>>> futures =
- new ArrayList<>();
-
- for (TopicPartition tp : existingPartitionSet) {
- futures.add(runtime.scheduleReadOperation(
- "list-groups",
- tp,
- (coordinator, lastCommittedOffset) ->
coordinator.listGroups(request.statesFilter(), request.typesFilter(),
lastCommittedOffset)
- ).exceptionally(exception -> {
- exception = Errors.maybeUnwrapException(exception);
- if (exception instanceof NotCoordinatorException) {
- return Collections.emptyList();
- } else {
- throw new CompletionException(exception);
- }
- }));
- }
+ final
List<CompletableFuture<List<ListGroupsResponseData.ListedGroup>>> futures =
runtime.scheduleReadAllOperation(
+ "list-groups",
+ (coordinator, lastCommittedOffset) ->
coordinator.listGroups(request.statesFilter(), request.typesFilter(),
lastCommittedOffset)
+ ).stream().map(future -> future.exceptionally(exception -> {
Review Comment:
how about adding the exception function to `scheduleReadAllOperation`? It
brings two benefits:
1. simplify the code from callers
2. avoid creating list repeatedly
--
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]