kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ewe...@apache.org
Subject kafka git commit: MINOR: Make JmxMixin wait for the monitored process to be listening on the JMX port before launching JmxTool
Date Tue, 27 Jun 2017 00:06:59 GMT
Repository: kafka
Updated Branches:
  refs/heads/0.11.0 09accf27a -> d292cad53


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 <apurva@confluent.io>, Ismael Juma <ismael@juma.me.uk>

Closes #3437 from ewencp/wait-jmx-listening

(cherry picked from commit e45c767d5344c4d0a42c444840ad81a82fcc9f7f)
Signed-off-by: Ewen Cheslack-Postava <me@ewencp.org>


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

Branch: refs/heads/0.11.0
Commit: d292cad53ecd48fcebb36f7e31a1421a0faaffbe
Parents: 09accf2
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:55 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/d292cad5/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/d292cad5/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


Mime
View raw message