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

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

junrao 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_r158518126
 
 

 ##########
 File path: core/src/main/scala/kafka/zookeeper/ZooKeeperClient.scala
 ##########
 @@ -269,25 +313,20 @@ class ZooKeeperClient(connectString: String,
   private def initialize(): Unit = {
     if (!zooKeeper.getState.isAlive) {
       info(s"Initializing a new session to $connectString.")
-      var now = System.currentTimeMillis()
-      val threshold = now + connectionTimeoutMs
-      while (now < threshold) {
+      // retry forever until ZooKeeper can be instantiated
+      while (true) {
         try {
           zooKeeper.close()
           zooKeeper = new ZooKeeper(connectString, sessionTimeoutMs, 
ZooKeeperClientWatcher)
-          waitUntilConnected(threshold - now, TimeUnit.MILLISECONDS)
           return
         } catch {
-          case _: Exception =>
-            now = System.currentTimeMillis()
-            if (now < threshold) {
-              Thread.sleep(1000)
-              now = System.currentTimeMillis()
-            }
+          case e: Exception =>
+            info("Error when recreating ZooKeeper", e)
+            Thread.sleep(1000)
         }
       }
       info(s"Timed out waiting for connection during session initialization 
while in state: ${zooKeeper.getState}")
-      stateChangeHandlers.foreach {case (name, handler) => 
handler.onReconnectionTimeout()}
+      stateChangeHandlers.values.foreach(_.onReconnectionTimeout())
 
 Review comment:
   Good point. We can just remove the onReconnectionTimeout() callback.

----------------------------------------------------------------
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