in src/main/java/com/epam/eco/commons/kafka/KafkaUtils.java [85:106]
public static List<TopicPartition> getTopicPartitionsAsList(
KafkaConsumer<?, ?> consumer,
Collection<String> topicNames) {
Validate.notNull(consumer, "Consumer is null");
Validate.notNull(topicNames, "Collection of topic names is null");
if (CollectionUtils.isEmpty(topicNames)) {
return Collections.emptyList();
}
List<TopicPartition> topicPartitions = new ArrayList<>();
for (String topicName : topicNames) {
List<PartitionInfo> partitionInfos = consumer.partitionsFor(topicName);
if (CollectionUtils.isEmpty(partitionInfos)) {
throw new RuntimeException("Partitions metadata not found for topic " + topicName);
}
topicPartitions.addAll(toTopicPartitions(partitionInfos));
}
return topicPartitions;
}