use of org.apache.kafka.clients.admin.DescribeTopicsResult in project core-ng-project by neowu.
the class KafkaController method topics.
public Response topics(Request request) throws ExecutionException, InterruptedException {
ControllerHelper.assertFromLocalNetwork(request.clientIP());
List<KafkaTopic> views = Lists.newArrayList();
try (AdminClient admin = kafka.admin()) {
Set<String> topics = admin.listTopics().names().get();
DescribeTopicsResult descriptions = admin.describeTopics(topics);
for (Map.Entry<String, KafkaFuture<TopicDescription>> entry : descriptions.values().entrySet()) {
String name = entry.getKey();
TopicDescription description = entry.getValue().get();
KafkaTopic view = view(name, description);
views.add(view);
}
}
return Response.bean(views);
}
use of org.apache.kafka.clients.admin.DescribeTopicsResult in project eventapis by kloiasoft.
the class ListTopicSchedule method runInternal.
@Override
boolean runInternal(StopWatch stopWatch) throws InterruptedException, ExecutionException {
stopWatch.start("adminClient.listTopics()");
Collection<String> topicNames = adminClient.listTopics().listings().get().stream().map(TopicListing::name).filter(this::shouldCollectEvent).collect(Collectors.toList());
topicsMap.removeAll(new RemoveTopicPredicate(topicNames));
DescribeTopicsResult describeTopicsResult = adminClient.describeTopics(topicNames);
describeTopicsResult.all().get().forEach((topic, topicDescription) -> topicsMap.executeOnKey(topic, new SetTopicPartitionsProcessor(topicDescription.partitions().stream().map(TopicPartitionInfo::partition).collect(Collectors.toList()))));
metaMap.set(this.getName() + TopicServiceScheduler.LAST_SUCCESS_PREFIX, System.currentTimeMillis());
log.debug("Topics:" + topicsMap.entrySet());
log.debug(stopWatch.prettyPrint());
return true;
}
Aggregations