use of org.apache.kafka.clients.admin.DescribeConsumerGroupsOptions in project kafka by apache.
the class StreamsResetter method maybeDeleteActiveConsumers.
private void maybeDeleteActiveConsumers(final String groupId, final Admin adminClient) throws ExecutionException, InterruptedException {
final DescribeConsumerGroupsResult describeResult = adminClient.describeConsumerGroups(Collections.singleton(groupId), new DescribeConsumerGroupsOptions().timeoutMs(10 * 1000));
final List<MemberDescription> members = new ArrayList<>(describeResult.describedGroups().get(groupId).get().members());
if (!members.isEmpty()) {
if (options.has(forceOption)) {
System.out.println("Force deleting all active members in the group: " + groupId);
adminClient.removeMembersFromConsumerGroup(groupId, new RemoveMembersFromConsumerGroupOptions()).all().get();
} else {
throw new IllegalStateException("Consumer group '" + groupId + "' is still active " + "and has following members: " + members + ". " + "Make sure to stop all running application instances before running the reset tool." + " You can use option '--force' to remove active members from the group.");
}
}
}
Aggregations