getCluster(): Cluster
ZkUtils
ZkUtils is…FIXME
ZkUtils is created when…FIXME
|
Note
|
Quoting Nodes and ephemeral nodes from the Zookeeper documentation:
|
| ZNode | Description |
|---|---|
|
| Name | Description |
|---|---|
getCluster Method
getCluster gets the children znodes of /brokers/ids znode and reads their data (as a JSON blob).
getCluster then adds creates a Broker from the znode id and the JSON blob (with a host, a port and endpoints).
|
Note
|
getCluster is used exclusively when ZKRebalancerListener does syncedRebalance (that happens for the currently-deprecated ZookeeperConsumerConnector).
|
Creating ZkUtils Instance — apply Factory Method
apply(
zkUrl: String,
sessionTimeout: Int,
connectionTimeout: Int,
isZkSecurityEnabled: Boolean): ZkUtils
apply…FIXME
|
Note
|
|
Registering Listener for State Changes — subscribeStateChanges Method
subscribeStateChanges(listener: IZkStateListener): Unit
subscribeStateChanges requests ZkClient to subscribeStateChanges with the listener.
|
Note
|
|
Registering Listener for Child Changes — subscribeChildChanges Method
subscribeChildChanges(path: String, listener: IZkChildListener): Option[Seq[String]]
subscribeChildChanges…FIXME
|
Note
|
subscribeChildChanges is used…FIXME
|
De-Registering Listener for Child Changes — unsubscribeChildChanges Method
unsubscribeChildChanges(path: String, childListener: IZkChildListener): Unit
unsubscribeChildChanges requests ZkClient to unsubscribeChildChanges for the input path and childListener.
|
Note
|
unsubscribeChildChanges is used when…FIXME
|
De-Registering Listener for Data Changes — unsubscribeDataChanges Method
unsubscribeDataChanges(path: String, dataListener: IZkDataListener): Unit
unsubscribeDataChanges requests ZkClient to unsubscribeDataChanges for the input path and dataListener.
|
Note
|
unsubscribeDataChanges is used when…FIXME
|
registerBrokerInZk Method
registerBrokerInZk(
id: Int,
host: String,
port: Int,
advertisedEndpoints: Seq[EndPoint],
jmxPort: Int,
rack: Option[String],
apiVersion: ApiVersion): Unit
registerBrokerInZk…FIXME
|
Note
|
registerBrokerInZk is used exclusively when KafkaHealthcheck is requested to register.
|
getTopicPartitionCount Method
getTopicPartitionCount(topic: String): Option[Int]
getTopicPartitionCount…FIXME
|
Note
|
|
Creating JSON with Broker ID — controllerZkData Method
controllerZkData(brokerId: Int, timestamp: Long): String
controllerZkData creates a JSON with the following fields:
-
"version":1 -
"brokerid":[brokerId] -
"timestamp":[timestamp]
import kafka.utils._
scala> ZkUtils.controllerZkData(1, System.currentTimeMillis())
res0: String = {"version":1,"brokerid":1,"timestamp":"1506161225262"}
|
Note
|
controllerZkData is used exclusively when KafkaController is requested for elect.
|
Creating ZkUtils Instance
ZkUtils takes the following when created:
ZkUtils initializes the internal registries and counters.
Reading Data Associated with ZNode — readDataMaybeNull Method
readDataMaybeNull(path: String): (Option[String], Stat)
readDataMaybeNull requests ZkClient to readData from path znode.
readDataMaybeNull returns None (for Option[String]) when path znode is not available.