Search in sources :

Example 1 with RemoveMembersFromConsumerGroupHandler

use of org.apache.kafka.clients.admin.internals.RemoveMembersFromConsumerGroupHandler in project kafka by apache.

the class KafkaAdminClient method removeMembersFromConsumerGroup.

@Override
public RemoveMembersFromConsumerGroupResult removeMembersFromConsumerGroup(String groupId, RemoveMembersFromConsumerGroupOptions options) {
    List<MemberIdentity> members;
    if (options.removeAll()) {
        members = getMembersFromGroup(groupId);
    } else {
        members = options.members().stream().map(MemberToRemove::toMemberIdentity).collect(Collectors.toList());
    }
    String reason = options.reason() == null ? LEAVE_GROUP_REASON : LEAVE_GROUP_REASON + ": " + options.reason();
    members.forEach(member -> member.setReason(reason));
    SimpleAdminApiFuture<CoordinatorKey, Map<MemberIdentity, Errors>> future = RemoveMembersFromConsumerGroupHandler.newFuture(groupId);
    RemoveMembersFromConsumerGroupHandler handler = new RemoveMembersFromConsumerGroupHandler(groupId, members, logContext);
    invokeDriver(handler, future, options.timeoutMs);
    return new RemoveMembersFromConsumerGroupResult(future.get(CoordinatorKey.byGroupId(groupId)), options.members());
}
Also used : CoordinatorKey(org.apache.kafka.clients.admin.internals.CoordinatorKey) MemberIdentity(org.apache.kafka.common.message.LeaveGroupRequestData.MemberIdentity) RemoveMembersFromConsumerGroupHandler(org.apache.kafka.clients.admin.internals.RemoveMembersFromConsumerGroupHandler) Map(java.util.Map) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 CoordinatorKey (org.apache.kafka.clients.admin.internals.CoordinatorKey)1 RemoveMembersFromConsumerGroupHandler (org.apache.kafka.clients.admin.internals.RemoveMembersFromConsumerGroupHandler)1 MemberIdentity (org.apache.kafka.common.message.LeaveGroupRequestData.MemberIdentity)1