ImmutableList.Builder<ConnectorPartition> builder = ImmutableList.builder();
for (TopicMetadata metadata : topicMetadataResponse.topicsMetadata()) {
for (PartitionMetadata part : metadata.partitionsMetadata()) {
log.debug("Adding Partition %s/%s", metadata.topic(), part.partitionId());
Broker leader = part.leader();
if (leader == null) { // Leader election going on...
log.warn("No leader for partition %s/%s found!", metadata.topic(), part.partitionId());
}
else {
builder.add(new KafkaPartition(metadata.topic(),
part.partitionId(),
HostAddress.fromParts(leader.host(), leader.port()),
ImmutableList.copyOf(Lists.transform(part.isr(), brokerToHostAddress()))));
}
}
}