Reputation: 1361
I have set up a 3 node kafka cluster. I want to know which are the brokers available for a producer client. Is there any command to list down the brokers connected to a zookeeper?
Upvotes: 1
Views: 661
Reputation: 3093
You can get the broker list via ZooKeeper by iterating over the broker ids in /brokers/ids and then fetching the broker info from these ids:
ZooKeeper zk = new ZooKeeper("localhost:2181", 10000, null);
List<String> ids = zk.getChildren("/brokers/ids", false);
for (String id : ids) {
String brokerInfo = new String(zk.getData("/brokers/ids/" + id, false, null));
System.out.println(id + ": " + brokerInfo);
}
Upvotes: 4