/** * List the consumer groups available in the cluster with the default options. * * This is a convenience method for #{@link AdminClient#listConsumerGroups(ListConsumerGroupsOptions)} with default options. * See the overload for more details. * * @return The ListGroupsResult. */ public ListConsumerGroupsResult listConsumerGroups() { return listConsumerGroups(new ListConsumerGroupsOptions()); }
/** * Lists consumer groups. * * @param timeoutMillis The timeout to wait for. * @return A set of group IDs. * @throws ExecutionException If an unexpected error occurred. * @throws InterruptedException If the thread was interrupted. * @throws TimeoutException If a timeout occurred. */ public Set<String> listConsumerGroups(int timeoutMillis) throws ExecutionException, TimeoutException, InterruptedException { return runWithRetry(() -> { final ListConsumerGroupsResult result = admin.listConsumerGroups(new ListConsumerGroupsOptions().timeoutMs(timeoutMillis)); awaitFutures(timeoutMillis, result.all()); final Collection<ConsumerGroupListing> listings = result.all().get(); return listings.stream().map(ConsumerGroupListing::groupId).collect(Collectors.toSet()); }); }
final KafkaFutureImpl<Collection<Object>> all = new KafkaFutureImpl<>(); final long nowMetadata = time.milliseconds(); final long deadline = calcDeadlineMs(nowMetadata, options.timeoutMs()); runnable.call(new Call("findAllBrokers", deadline, new LeastLoadedNodeProvider()) { @Override