I’m using this version of kafka:
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.9.2</artifactId>
<version>0.8.1.1</version>
</dependency>
I’m using kafka.server.KafkaServer in memory for some integration tests. I
start KafkaServer and use AdminUtils.createTopic(ZkClient, String, Integer,
Integer, Properties) to create a Topic.
I then use the following code to find the leader (adapted from the sample code
on the SimpleConsumerExample on the Kafka wiki
https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+SimpleConsumer+Example).
consumer = new SimpleConsumer(seed.getHostName(), seed.getPort(), getTimeout(),
getBufferSize(), "leaderLookup");
List<String> topics = Collections.singletonList(getTopic());
TopicMetadataRequest req = new TopicMetadataRequest(topics);
kafka.javaapi.TopicMetadataResponse resp = consumer.send(req);
List<TopicMetadata> metaData = resp.topicsMetadata();
for (TopicMetadata item : metaData) {
for (PartitionMetadata part : item.partitionsMetadata()) {
if (part.partitionId() == getPartition()) {
returnMetaData = part;
break loop;
}
}
}
The problem I have is that item.partitionsMetadata() is always null. So my code
interprets the situation as that the one broker doesn’t know anything about the
topic.
Is this a bug in KafkaServer?
I’ve seen a couple bugs that seem potentially related:
https://issues.apache.org/jira/browse/KAFKA-1367
I also ran this search in the Kafka JIRA which returned a lot of results.
https://issues.apache.org/jira/browse/KAFKA-1998?jql=project%20%3D%20KAFKA%20AND%20text%20~%20%22partition%20metadata%22<https://issues.apache.org/jira/browse/KAFKA-1998?jql=project%20=%20KAFKA%20AND%20text%20~%20"partition%20metadata">
Can anyone shed some light on this for me?
After starting KafkaServer how can I tell whether or not the broker is handling
a given partition for a given topic?
Thanks.