KafkaZkClient
is a higher-level Zookeeper client.
-
KafkaServer
is requested to start up (and initZkClient) -
AclAuthorizer
is requested to configure (and createAclPaths) -
ZkSecurityMigrator
, TopicCommand (with the deprecated--zookeeper
option), ReassignPartitionsCommand,PreferredReplicaLeaderElectionCommand
(with the deprecated--zookeeper
option), ConfigCommand tools are executed
Tip
|
Enable Add the following line to
Refer to Logging. |
KafkaZkClient
is a KafkaMetricsGroup with the following performance metrics.
Name | Description |
---|---|
|
Histogram that is updated when |
The performance metrics are registered in kafka.server:type=ZooKeeperClientMetrics group.
getTopicPartitionCount(topic: String): Option[Int]
getTopicPartitionCount
…FIXME
Note
|
getTopicPartitionCount is used when…FIXME
|
registerStateChangeHandler(stateChangeHandler: StateChangeHandler): Unit
registerStateChangeHandler
…FIXME
Note
|
registerStateChangeHandler is used when…FIXME
|
KafkaZkClient
takes the following when created:
KafkaZkClient
initializes the internal registries and counters.
apply(
connectString: String,
isSecure: Boolean,
sessionTimeoutMs: Int,
connectionTimeoutMs: Int,
maxInFlightRequests: Int,
time: Time,
metricGroup: String = "kafka.server",
metricType: String = "SessionExpireListener"): KafkaZkClient
apply
creates a ZooKeeperClient that is then used to create a KafkaZkClient.
Note
|
|
createTopLevelPaths(): Unit
createTopLevelPaths
…FIXME
Note
|
createTopLevelPaths is used when…FIXME
|
updateBrokerInfoInZk(brokerInfo: BrokerInfo): Unit
updateBrokerInfoInZk
…FIXME
Note
|
updateBrokerInfoInZk is used when…FIXME
|
registerZNodeChildChangeHandler(zNodeChildChangeHandler: ZNodeChildChangeHandler): Unit
registerZNodeChildChangeHandler
…FIXME
Note
|
registerZNodeChildChangeHandler is used when…FIXME
|
registerZNodeChangeHandlerAndCheckExistence(zNodeChangeHandler: ZNodeChangeHandler): Boolean
registerZNodeChangeHandlerAndCheckExistence
…FIXME
Note
|
registerZNodeChangeHandlerAndCheckExistence is used when…FIXME
|
deleteLogDirEventNotifications(): Unit
deleteLogDirEventNotifications
…FIXME
Note
|
deleteLogDirEventNotifications is used when…FIXME
|
deleteIsrChangeNotifications(): Unit
deleteIsrChangeNotifications
…FIXME
Note
|
deleteIsrChangeNotifications is used when…FIXME
|
unregisterZNodeChildChangeHandler(path: String): Unit
unregisterZNodeChildChangeHandler
…FIXME
Note
|
unregisterZNodeChildChangeHandler is used when…FIXME
|
unregisterZNodeChangeHandler(path: String): Unit
unregisterZNodeChangeHandler
…FIXME
Note
|
unregisterZNodeChangeHandler is used when…FIXME
|
setControllerEpochRaw(epoch: Int, epochZkVersion: Int): SetDataResponse
setControllerEpochRaw
…FIXME
Note
|
setControllerEpochRaw is used when…FIXME
|
createControllerEpochRaw(epoch: Int): CreateResponse
createControllerEpochRaw
…FIXME
Note
|
createControllerEpochRaw is used when…FIXME
|
getAllBrokersInCluster: Seq[Broker]
getAllBrokersInCluster
fetches broker IDs followed by fetching the metadata of every broker (which is the data associated with a /brokers/ids/[brokerId]
znode).
Note
|
|
getAllTopicsInCluster: Seq[String]
getAllTopicsInCluster
…FIXME
Note
|
getAllTopicsInCluster is used when…FIXME
|
getReplicaAssignmentForTopics(topics: Set[String]): Map[TopicPartition, Seq[Int]]
getReplicaAssignmentForTopics
…FIXME
Note
|
getReplicaAssignmentForTopics is used when…FIXME
|
getPartitionReassignment: collection.Map[TopicPartition, Seq[Int]]
getPartitionReassignment
…FIXME
Note
|
getPartitionReassignment is used when…FIXME
|
getTopicDeletions: Seq[String]
getTopicDeletions
…FIXME
Note
|
getTopicDeletions is used when…FIXME
|
getTopicPartitionStates(
partitions: Seq[TopicPartition]): Map[TopicPartition, LeaderIsrAndControllerEpoch]
getTopicPartitionStates
getTopicPartitionStatesRaw for the given TopicPartitions
.
For every response, getTopicPartitionStates
decodes the JSON-encoded partition state data (for the partitions that were found in ZooKeeper).
Note
|
getTopicPartitionStates is used when KafkaController is requested to updateLeaderAndIsrCache, areReplicasInIsr, updateLeaderEpoch and process a PartitionReassignmentIsrChange controller event.
|
registerZNodeChangeHandler(zNodeChangeHandler: ZNodeChangeHandler): Unit
registerZNodeChangeHandler
…FIXME
Note
|
registerZNodeChangeHandler is used when…FIXME
|
getControllerEpoch: Option[(Int, Stat)]
getControllerEpoch
…FIXME
Note
|
getControllerEpoch is used when…FIXME
|
deletePartitionReassignment(): Unit
deletePartitionReassignment
…FIXME
Note
|
deletePartitionReassignment is used when…FIXME
|
setOrCreatePartitionReassignment(reassignment: collection.Map[TopicPartition, Seq[Int]]): Unit
setOrCreatePartitionReassignment
…FIXME
Note
|
setOrCreatePartitionReassignment is used when…FIXME
|
getControllerId: Option[Int]
getControllerId
sends a request to Zookeeper for the data of the /controller
znode and returns the following:
-
The
brokerid
field of the JSON data when the response isOK
-
None
for aNONODE
response -
Throws a
KeeperException
with the response code and the/controller
path
Note
|
|
checkedEphemeralCreate(path: String, data: Array[Byte]): Unit
checkedEphemeralCreate
…FIXME
Note
|
checkedEphemeralCreate is used when…FIXME
|
registerControllerAndIncrementControllerEpoch(controllerId: Int): (Int, Int)
registerControllerAndIncrementControllerEpoch
…FIXME
Note
|
registerControllerAndIncrementControllerEpoch is used exclusively when KafkaController is requested to elect.
|
retryRequestsUntilConnected[Req <: AsyncRequest](
requests: Seq[Req]): Seq[Req#Response]
retryRequestsUntilConnected
…FIXME
createSequentialPersistentPath(path: String, data: Array[Byte]): String
createSequentialPersistentPath
…FIXME
Note
|
createSequentialPersistentPath is used when KafkaZkClient is requested to propagateLogDirEvent and propagateIsrChanges.
|
propagateLogDirEvent(brokerId: Int): Unit
propagateLogDirEvent
…FIXME
Note
|
propagateLogDirEvent is used exclusively when ReplicaManager is requested to handleLogDirFailure.
|
propagateIsrChanges(isrChangeSet: collection.Set[TopicPartition]): Unit
propagateIsrChanges
…FIXME
Note
|
propagateIsrChanges is used exclusively when ReplicaManager is requested to maybePropagateIsrChanges.
|
getTopicPartitionStatesRaw(
partitions: Seq[TopicPartition]): Seq[GetDataResponse]
getTopicPartitionStatesRaw
gets the topic partition states (from the path /brokers/topics/[topic]/partitions/[partition]/state
in Zookeeper) for the given partitions.
Internally, getTopicPartitionStatesRaw
creates a ZooKeeper GetDataRequest
for the path /brokers/topics/[topic]/partitions/[partition]/state
for every partition (in the given partitions
).
In the end, getTopicPartitionStatesRaw
retryRequestsUntilConnected the GetDataRequests
.
Note
|
|
getTopicPartitionState(partition: TopicPartition): Option[LeaderIsrAndControllerEpoch]
getTopicPartitionState
…FIXME
Note
|
getTopicPartitionState is used when…FIXME
|
getSortedBrokerList(): Seq[Int]
getSortedBrokerList
gets the child znodes at /brokers/ids
path and sorts it by broker ID (according to the natural ordering).
Note
|
|
getChildren(path : String): Seq[String]
getChildren
…FIXME
Note
|
getChildren is used when…FIXME
|
getClusterId: Option[String]
getClusterId
…FIXME
Note
|
getClusterId is used when…FIXME
|
createOrGetClusterId(proposedClusterId: String): String
createOrGetClusterId
…FIXME
Note
|
createOrGetClusterId is used when…FIXME
|
getAllBrokerAndEpochsInCluster: Map[Broker, Long]
getAllBrokerAndEpochsInCluster
…FIXME
Note
|
getAllBrokerAndEpochsInCluster is used when…FIXME
|
getBroker(
brokerId: Int): Option[Broker]
getBroker
…FIXME
Note
|
getBroker is used when…FIXME
|
getAllLogDirEventNotifications: Seq[String]
getAllLogDirEventNotifications
…FIXME
Note
|
getAllLogDirEventNotifications is used when…FIXME
|
getBrokerIdsFromLogDirEvents(
sequenceNumbers: Seq[String]): Seq[Int]
getBrokerIdsFromLogDirEvents
…FIXME
Note
|
getBrokerIdsFromLogDirEvents is used when…FIXME
|
createTopicPartitionStatesRaw(
leaderIsrAndControllerEpochs: Map[TopicPartition, LeaderIsrAndControllerEpoch],
expectedControllerEpochZkVersion: Int
): Seq[CreateResponse]
createTopicPartitionStatesRaw
createTopicPartitions with the topics (of the given partitions).
createTopicPartitionStatesRaw
createTopicPartition with the partitions.
For every partition (in the given leaderIsrAndControllerEpochs
), createTopicPartitionStatesRaw
creates a new CreateRequest
to create /brokers/topics/[topic]/partitions/[partition]/state
persistent znode with the associated LeaderIsrAndControllerEpoch
encoded to JSON format.
// zkCli :2181
$ ./bin/zookeeper-shell.sh :2181 ls /brokers/topics
[t1]
$ ./bin/zookeeper-shell.sh :2181 get /brokers/topics/t1/partitions/0/state
{"controller_epoch":1,"leader":0,"version":1,"leader_epoch":0,"isr":[0]}
In the end, createTopicPartitionStatesRaw
retryRequestsUntilConnected all the CreateRequests
.
Note
|
createTopicPartitionStatesRaw is used exclusively when ZkPartitionStateMachine is requested to initializeLeaderAndIsrForPartitions.
|
createTopicPartitions(
topics: Seq[String],
expectedControllerEpochZkVersion: Int):Seq[CreateResponse]
createTopicPartitions
…FIXME
Note
|
createTopicPartitions is used when…FIXME
|
createTopicPartition(
partitions: Seq[TopicPartition],
expectedControllerEpochZkVersion: Int): Seq[CreateResponse]
createTopicPartition
…FIXME
Note
|
createTopicPartition is used when…FIXME
|
updateLeaderAndIsr(
leaderAndIsrs: Map[TopicPartition, LeaderAndIsr],
controllerEpoch: Int,
expectedControllerEpochZkVersion: Int): UpdateLeaderAndIsrResult
updateLeaderAndIsr
…FIXME
Note
|
updateLeaderAndIsr is used when…FIXME
|
getPartitionsForTopics(
topics: Set[String]): Map[String, Seq[Int]]
getPartitionsForTopics
…FIXME
Note
|
getPartitionsForTopics is used when…FIXME
|
getEntityConfigs(
rootEntityType: String,
sanitizedEntityName: String): Properties
getEntityConfigs
reads the /config/[rootEntityType]/[sanitizedEntityName]
.
getEntityConfigs
…FIXME
Note
|
getEntityConfigs is used exclusively when AdminZkClient is requested to fetchEntityConfig.
|
createAclPaths(): Unit
createAclPaths
…FIXME
Note
|
createAclPaths is used when AclAuthorizer is requested to configure.
|
registerBroker(
brokerInfo: BrokerInfo): Long
registerBroker
…FIXME
Note
|
registerBroker is used when…FIXME
|
updateBrokerInfo(
brokerInfo: BrokerInfo): Unit
updateBrokerInfo
…FIXME
Note
|
updateBrokerInfo is used when…FIXME
|
close(): Unit
Note
|
close is part of the Java’s AutoCloseable contract to close a resource (and relinquishing any underlying resources).
|
close
…FIXME