Search in sources :

Example 6 with CoordinatorKey

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

the class DescribeTransactionsResult method description.

/**
 * Get the description of a specific transactional ID.
 *
 * @param transactionalId the transactional ID to describe
 * @return a future which completes when the transaction description of a particular
 *         transactional ID is available.
 * @throws IllegalArgumentException if the `transactionalId` was not included in the
 *         respective call to {@link Admin#describeTransactions(Collection, DescribeTransactionsOptions)}.
 */
public KafkaFuture<TransactionDescription> description(String transactionalId) {
    CoordinatorKey key = CoordinatorKey.byTransactionalId(transactionalId);
    KafkaFuture<TransactionDescription> future = futures.get(key);
    if (future == null) {
        throw new IllegalArgumentException("TransactionalId " + "`" + transactionalId + "` was not included in the request");
    }
    return future;
}
Also used : CoordinatorKey(org.apache.kafka.clients.admin.internals.CoordinatorKey)

Example 7 with CoordinatorKey

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

the class KafkaAdminClient method deleteConsumerGroups.

@Override
public DeleteConsumerGroupsResult deleteConsumerGroups(Collection<String> groupIds, DeleteConsumerGroupsOptions options) {
    SimpleAdminApiFuture<CoordinatorKey, Void> future = DeleteConsumerGroupsHandler.newFuture(groupIds);
    DeleteConsumerGroupsHandler handler = new DeleteConsumerGroupsHandler(logContext);
    invokeDriver(handler, future, options.timeoutMs);
    return new DeleteConsumerGroupsResult(future.all().entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey().idValue, Map.Entry::getValue)));
}
Also used : CoordinatorKey(org.apache.kafka.clients.admin.internals.CoordinatorKey) DeleteConsumerGroupsHandler(org.apache.kafka.clients.admin.internals.DeleteConsumerGroupsHandler)

Example 8 with CoordinatorKey

use of org.apache.kafka.clients.admin.internals.CoordinatorKey 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

CoordinatorKey (org.apache.kafka.clients.admin.internals.CoordinatorKey)8 HashMap (java.util.HashMap)4 Map (java.util.Map)4 TreeMap (java.util.TreeMap)4 AdminApiFuture (org.apache.kafka.clients.admin.internals.AdminApiFuture)1 SimpleAdminApiFuture (org.apache.kafka.clients.admin.internals.AdminApiFuture.SimpleAdminApiFuture)1 AlterConsumerGroupOffsetsHandler (org.apache.kafka.clients.admin.internals.AlterConsumerGroupOffsetsHandler)1 DeleteConsumerGroupOffsetsHandler (org.apache.kafka.clients.admin.internals.DeleteConsumerGroupOffsetsHandler)1 DeleteConsumerGroupsHandler (org.apache.kafka.clients.admin.internals.DeleteConsumerGroupsHandler)1 DescribeConsumerGroupsHandler (org.apache.kafka.clients.admin.internals.DescribeConsumerGroupsHandler)1 DescribeTransactionsHandler (org.apache.kafka.clients.admin.internals.DescribeTransactionsHandler)1 ListConsumerGroupOffsetsHandler (org.apache.kafka.clients.admin.internals.ListConsumerGroupOffsetsHandler)1 RemoveMembersFromConsumerGroupHandler (org.apache.kafka.clients.admin.internals.RemoveMembersFromConsumerGroupHandler)1 MemberIdentity (org.apache.kafka.common.message.LeaveGroupRequestData.MemberIdentity)1