chia7712 commented on code in PR #17080:
URL: https://github.com/apache/kafka/pull/17080#discussion_r1763983367
##########
clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:
##########
@@ -4143,22 +4144,33 @@ public RemoveMembersFromConsumerGroupResult
removeMembersFromConsumerGroup(Strin
String reason = options.reason() == null || options.reason().isEmpty()
?
DEFAULT_LEAVE_GROUP_REASON :
JoinGroupRequest.maybeTruncateReason(options.reason());
- List<MemberIdentity> members;
- if (options.removeAll()) {
- members = getMembersFromGroup(groupId, reason);
- } else {
- members = options.members().stream()
- .map(m -> m.toMemberIdentity().setReason(reason))
- .collect(Collectors.toList());
+ final SimpleAdminApiFuture<CoordinatorKey, Map<MemberIdentity,
Errors>> future =
+ RemoveMembersFromConsumerGroupHandler.newFuture(groupId);
+ if (!options.removeAll()) {
+ List<MemberIdentity> members = options.members().stream()
+ .map(m -> m.toMemberIdentity().setReason(reason))
+ .collect(Collectors.toList());
+ handleRemoveMembersFromConsumerGroupAndInvokeDriver(groupId,
members, options.timeoutMs, future);
+ return new
RemoveMembersFromConsumerGroupResult(future.get(CoordinatorKey.byGroupId(groupId)),
options.members());
}
- SimpleAdminApiFuture<CoordinatorKey, Map<MemberIdentity, Errors>>
future =
- RemoveMembersFromConsumerGroupHandler.newFuture(groupId);
- RemoveMembersFromConsumerGroupHandler handler = new
RemoveMembersFromConsumerGroupHandler(groupId, members, logContext);
- invokeDriver(handler, future, options.timeoutMs);
+ getMembersFromGroup(groupId, reason).whenComplete((members, ex) -> {
Review Comment:
how about:
```java
KafkaFutureImpl<List<MemberIdentity>> f;
if (options.removeAll()) f = getMembersFromGroup(groupId, reason);
else {
f = new KafkaFutureImpl<>();
f.complete(options.members().stream()
.map(m -> m.toMemberIdentity().setReason(reason))
.collect(Collectors.toList()));
}
f.whenComplete((members, ex) -> {
if (ex != null) {
future.completeExceptionally(Collections.singletonMap(CoordinatorKey.byGroupId(groupId),
ex));
} else {
RemoveMembersFromConsumerGroupHandler handler = new
RemoveMembersFromConsumerGroupHandler(groupId, members, logContext);
invokeDriver(handler, future, options.timeoutMs());
}
});
```
--
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]