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

Kowshik Prakasam commented on KAFKA-4620:
-----------------------------------------

My observation is that it seems this issue is resolved now, as I see the 
following code: 
[https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/tools/JmxTool.scala#L131-L154]
 . 

Perhaps this was fixed as early as in this PR: 
[https://github.com/apache/kafka/pull/3547 
.|https://github.com/apache/kafka/pull/3547]

> Connection exceptions in JMXTool do not make it to the top level
> ----------------------------------------------------------------
>
>                 Key: KAFKA-4620
>                 URL: https://issues.apache.org/jira/browse/KAFKA-4620
>             Project: Kafka
>          Issue Type: Bug
>            Reporter: Apurva Mehta
>            Assignee: Apurva Mehta
>            Priority: Major
>
> If you run JMXTool before the target process is initialized, the JMX 
> connection is refused and the tool quits. 
> Adding the following retry :
> {code:java}
>     while (retries < maxNumRetries && !connected) {
>       try {
>         System.err.println("Trying to connect to JMX url: %s".format(url))
>         jmxc = JMXConnectorFactory.connect(url, null)
>         mbsc = jmxc.getMBeanServerConnection()
>         connected = true
>       } catch {
>         case e : Exception => {
>           System.err.println("Could not connect to JMX url: %s. Exception 
> %s".format(url, e.getMessage))
>           retries += 1
>           Thread.sleep(500)
>         }
>       }
>     }
> {code}
> does not work because the exceptions do not make it to the top level. Running 
> the above code results in the following output on stderr
> {noformat}
> Trying to connect to JMX url: 
> service:jmx:rmi:///jndi/rmi://127.0.0.1:9192/jmxrmi
> Jan 11, 2017 8:20:33 PM ClientCommunicatorAdmin restart
> WARNING: Failed to restart: java.io.IOException: Failed to get a RMI stub: 
> javax.naming.ServiceUnavailableException [Root exception is 
> java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested 
> exception is:
>         java.net.ConnectException: Connection refused]
> Jan 11, 2017 8:20:33 PM RMIConnector RMIClientCommunicatorAdmin-doStop
> WARNING: Failed to call the method close():java.rmi.ConnectException: 
> Connection refused to host: 172.31.15.109; nested exception is:
>         java.net.ConnectException: Connection refused
> Jan 11, 2017 8:20:33 PM ClientCommunicatorAdmin Checker-run
> WARNING: Failed to check connection: java.net.ConnectException: Connection 
> refused
> Jan 11, 2017 8:20:33 PM ClientCommunicatorAdmin Checker-run
> WARNING: stopping
> {noformat}
> We need to add working retry logic to JMXTool so that it can start correctly 
> even if the target process is not ready initially. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to