You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ew...@apache.org on 2017/06/27 00:06:47 UTC

kafka git commit: MINOR: Make JmxMixin wait for the monitored process to be listening on the JMX port before launching JmxTool

Repository: kafka
Updated Branches:
  refs/heads/trunk 226583480 -> e45c767d5


MINOR: Make JmxMixin wait for the monitored process to be listening on the JMX port before launching JmxTool

Author: Ewen Cheslack-Postava <me...@ewencp.org>

Reviewers: Apurva Mehta <ap...@confluent.io>, Ismael Juma <is...@juma.me.uk>

Closes #3437 from ewencp/wait-jmx-listening


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/e45c767d
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/e45c767d
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/e45c767d

Branch: refs/heads/trunk
Commit: e45c767d5344c4d0a42c444840ad81a82fcc9f7f
Parents: 2265834
Author: Ewen Cheslack-Postava <me...@ewencp.org>
Authored: Mon Jun 26 17:06:38 2017 -0700
Committer: Ewen Cheslack-Postava <me...@ewencp.org>
Committed: Mon Jun 26 17:06:38 2017 -0700

----------------------------------------------------------------------
 tests/kafkatest/services/monitor/jmx.py           | 9 +++++++++
 tests/kafkatest/tests/produce_consume_validate.py | 6 ------
 2 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/e45c767d/tests/kafkatest/services/monitor/jmx.py
----------------------------------------------------------------------
diff --git a/tests/kafkatest/services/monitor/jmx.py b/tests/kafkatest/services/monitor/jmx.py
index e64d03a..0859bb4 100644
--- a/tests/kafkatest/services/monitor/jmx.py
+++ b/tests/kafkatest/services/monitor/jmx.py
@@ -50,6 +50,15 @@ class JmxMixin(object):
             self.logger.debug("%s: jmx tool has been started already on this node" % node.account)
             return
 
+        # JmxTool is not particularly robust to slow-starting processes. In order to ensure JmxTool doesn't fail if the
+        # process we're trying to monitor takes awhile before listening on the JMX port, wait until we can see that port
+        # listening before even launching JmxTool
+        def check_jmx_port_listening():
+            return 0 == node.account.ssh("nc -z 127.0.0.1 %d" % self.jmx_port, allow_fail=True)
+
+        wait_until(check_jmx_port_listening, timeout_sec=30, backoff_sec=.1,
+                   err_msg="%s: Never saw JMX port for %s start listening" % (node.account, self))
+
         cmd = "%s kafka.tools.JmxTool " % self.path.script("kafka-run-class.sh", node)
         cmd += "--reporting-interval 1000 --jmx-url service:jmx:rmi:///jndi/rmi://127.0.0.1:%d/jmxrmi" % self.jmx_port
         for jmx_object_name in self.jmx_object_names:

http://git-wip-us.apache.org/repos/asf/kafka/blob/e45c767d/tests/kafkatest/tests/produce_consume_validate.py
----------------------------------------------------------------------
diff --git a/tests/kafkatest/tests/produce_consume_validate.py b/tests/kafkatest/tests/produce_consume_validate.py
index 079305c..7a78da3 100644
--- a/tests/kafkatest/tests/produce_consume_validate.py
+++ b/tests/kafkatest/tests/produce_consume_validate.py
@@ -59,12 +59,6 @@ class ProduceConsumeValidateTest(Test):
                        err_msg="Consumer process took more than %d s to fork" %\
                        self.consumer_init_timeout_sec)
             end = int(time.time())
-            # If `JMXConnectFactory.connect` is invoked during the
-            # initialization of the JMX server, it may fail to throw the
-            # specified IOException back to the calling code. The sleep is a
-            # workaround that should allow initialization to complete before we
-            # try to connect. See KAFKA-4620 for more details.
-            time.sleep(1)
             remaining_time = self.consumer_init_timeout_sec - (end - start)
             if remaining_time < 0 :
                 remaining_time = 0