ZK should be treated as the source of truth of the topic metadata, whereas brokers just keep a cache of this data that can be a bit out-of-date (and that is one possible reason of UnknownTopicOrPartition). So I would still suggest getting data from ZK, and if some leader is not online then its field would be "-1" but you can still get the full list of all replicas in /brokers/topics/theTopic/ partition.
On Mon, Mar 2, 2015 at 11:08 PM, ChenHongHai <waldenchenka...@outlook.com> wrote: > If there is 1000 brokers, and one topic only has 3 partitions, and 2 > replica.How to easily get all broker of it? If directly get them from > zookeeper /brokers/topics/theTopic/partition, maybe at that time some > partition leader not on line and can't get full list of all leader and > replica. > If try each broker, there are so many. And if one broker return error > code 3, may I 100% sure that broker has no any replica of this topic? > UnknownTopicOrPartition > 3 > This request is for a topic or partition that does not exist on this broker > -- -- Guozhang