You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Apurva Mehta (JIRA)" <ji...@apache.org> on 2017/01/12 00:08:16 UTC

[jira] [Created] (KAFKA-4620) Connection exceptions in JMXTool do not make it to the top level

Apurva Mehta created KAFKA-4620:
-----------------------------------

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


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
(v6.3.4#6332)