def check_get_version(self): """Check default and override behavior of get_version""" node = None assert get_version(node) == DEV_BRANCH node = Mock() node.version = None assert get_version(node) == DEV_BRANCH node = Mock() node.version = V_0_8_2_2 assert get_version(node) == V_0_8_2_2
def start_jmx_tool(self, idx, node): if self.jmx_object_names is None: self.logger.debug( "%s: Not starting jmx tool because no jmx objects are defined" % node.account) return if self.started[idx - 1]: 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)) # To correctly wait for requested JMX metrics to be added we need the --wait option for JmxTool. This option was # not added until 0.11.0.1, so any earlier versions need to use JmxTool from a newer version. use_jmxtool_version = get_version(node) if use_jmxtool_version <= V_0_11_0_0: use_jmxtool_version = DEV_BRANCH cmd = "%s %s " % (self.path.script( "kafka-run-class.sh", use_jmxtool_version), self.jmx_class_name()) cmd += "--reporting-interval %d --jmx-url service:jmx:rmi:///jndi/rmi://127.0.0.1:%d/jmxrmi" % ( self.jmx_poll_ms, self.jmx_port) cmd += " --wait" for jmx_object_name in self.jmx_object_names: cmd += " --object-name %s" % jmx_object_name cmd += " --attributes " for jmx_attribute in self.jmx_attributes: cmd += "%s," % jmx_attribute cmd += " 1>> %s" % self.jmx_tool_log cmd += " 2>> %s &" % self.jmx_tool_err_log self.logger.debug("%s: Start JmxTool %d command: %s" % (node.account, idx, cmd)) node.account.ssh(cmd, allow_fail=False) wait_until(lambda: self._jmx_has_output(node), timeout_sec=30, backoff_sec=.5, err_msg="%s: Jmx tool took too long to start" % node.account) self.started[idx - 1] = True
def start_jmx_tool(self, idx, node): if self.jmx_object_names is None: self.logger.debug("%s: Not starting jmx tool because no jmx objects are defined" % node.account) return if self.started[idx-1]: 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)) # To correctly wait for requested JMX metrics to be added we need the --wait option for JmxTool. This option was # not added until 0.11.0.1, so any earlier versions need to use JmxTool from a newer version. use_jmxtool_version = get_version(node) if use_jmxtool_version <= V_0_11_0_0: use_jmxtool_version = DEV_BRANCH cmd = "%s %s " % (self.path.script("kafka-run-class.sh", use_jmxtool_version), self.jmx_class_name()) cmd += "--reporting-interval 1000 --jmx-url service:jmx:rmi:///jndi/rmi://127.0.0.1:%d/jmxrmi" % self.jmx_port cmd += " --wait" for jmx_object_name in self.jmx_object_names: cmd += " --object-name %s" % jmx_object_name cmd += " --attributes " for jmx_attribute in self.jmx_attributes: cmd += "%s," % jmx_attribute cmd += " 1>> %s" % self.jmx_tool_log cmd += " 2>> %s &" % self.jmx_tool_err_log self.logger.debug("%s: Start JmxTool %d command: %s" % (node.account, idx, cmd)) node.account.ssh(cmd, allow_fail=False) wait_until(lambda: self._jmx_has_output(node), timeout_sec=10, backoff_sec=.5, err_msg="%s: Jmx tool took too long to start" % node.account) self.started[idx-1] = True
def _version(self, node_or_version): if isinstance(node_or_version, KafkaVersion): return node_or_version else: return get_version(node_or_version)