The broker ID is registered in zookeeper ( /brokers/ids/[brokerId]) as an ephemeral node, which allows other brokers and consumers to detect failures. (Currently, the definition of health is rather naive. If registered with zk /brokers/ids/[brokerId], the broker is healthy, otherwise he is dead).
zookeeper ephemeral node exists if the broker session is active.
You can check if the broker works through ZkUtils.getSortedBrokerList (zkClient), which returns the entire active broker identifier under /brokers/ids
import org.I0Itec.zkclient.ZkClient;
ZkClient zkClient = new ZkClient(properties.getProperty("zkQuorum"), zkSessionTimeout, zkConnectionTimeout,ZKStringSerializer$.MODULE$);
ZkUtils.getSortedBrokerList(zkClient);
Kafka Data Structures Link
in Zookeeper
source
share