We have one topic with 4 partitions, but sometimes only get metadata of 2 partitions, did anyone meet this kind of situation before?If some partition has no leader at that moment, will it cause this problem? How to make some partition has no leader?If 6 brokers has some partitions of the topic, will they return same result? Do I need try all of them and merge the result?
SimpleConsumer consumer = consumerPool.getConsumer(seed.host, seed.port, connectionTimeOut, consumerBufferSize, "refreshPartitionMeta"); List<String> topics = new ArrayList<String>() {{ add(topic); }}; TopicMetadataResponse resp = consumer.send(new TopicMetadataRequest(topics)); List<TopicMetadata> metaData = resp.topicsMetadata(); for (TopicMetadata item : metaData) { if(item.errorCode() != kafka.common.ErrorMapping.NoError()) LOG.error(String.format("Something wrong with topic metadata for topic: %s error code: %d ", item.topic(), item.errorCode() )); for (PartitionMetadata part : item.partitionsMetadata()) { partitionMeta.put(part.partitionId(), part); } }