[ 
https://issues.apache.org/jira/browse/KAFKA-6320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16301110#comment-16301110
 ] 

ASF GitHub Bot commented on KAFKA-6320:
---------------------------------------

omkreddy commented on a change in pull request #4351: KAFKA-6320: move ZK 
metrics in KafkaHealthCheck to ZookeeperClient
URL: https://github.com/apache/kafka/pull/4351#discussion_r158439935
 
 

 ##########
 File path: core/src/main/scala/kafka/zk/KafkaZkClient.scala
 ##########
 @@ -1174,6 +1188,67 @@ class KafkaZkClient(zooKeeperClient: ZooKeeperClient, 
isSecure: Boolean, time: T
     }
   }
 
+  /**
+    * Get the cluster id.
+    * @return optional cluster id in String.
+    */
+  def getClusterId: Option[String] = {
+    val getDataRequest = GetDataRequest(ClusterIdZNode.path)
+    val getDataResponse = retryRequestUntilConnected(getDataRequest)
+    getDataResponse.resultCode match {
+      case Code.OK => Some(ClusterIdZNode.fromJson(getDataResponse.data))
+      case Code.NONODE => None
+      case _ => throw getDataResponse.resultException.get
+    }
+  }
+
+  /**
+    * Create the cluster Id. If the cluster id already exists, return the 
current cluster id.
+    * @return  cluster id
+    */
+  def createOrGetClusterId(proposedClusterId: String): String = {
+    try {
+      createRecursive(ClusterIdZNode.path, 
ClusterIdZNode.toJson(proposedClusterId))
+      proposedClusterId
+    } catch {
+      case e: NodeExistsException => getClusterId.getOrElse(
+        throw new KafkaException("Failed to get cluster id from Zookeeper. 
This can happen if /cluster/id is deleted from Zookeeper."))
+    }
+  }
+
+  /**
+    * Generate a borker id by updating the broker sequence id path in ZK and 
return the version of the path.
 
 Review comment:
   nit: typo "borker"

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> move ZK metrics in KafkaHealthCheck to ZookeeperClient
> ------------------------------------------------------
>
>                 Key: KAFKA-6320
>                 URL: https://issues.apache.org/jira/browse/KAFKA-6320
>             Project: Kafka
>          Issue Type: Sub-task
>    Affects Versions: 1.0.0
>            Reporter: Jun Rao
>            Assignee: Jun Rao
>             Fix For: 1.1.0
>
>
> In KAFKA-5473, we will be de-commissioning the usage of KafkaHealthCheck. So, 
> we need to move the ZK metrics SessionState and ZooKeeper${eventType}PerSec 
> in that class to somewhere else (e.g. ZookeeperClient).



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to