class ImpaladProcess(BaseImpalaProcess): def __init__(self, cmd, container_id=None, port_map=None): super(ImpaladProcess, self).__init__(cmd, container_id, port_map) self.service = ImpaladService(self.hostname, self.get_webserver_port(), self.__get_beeswax_port(), self.__get_be_port(), self.__get_hs2_port(), self._get_webserver_certificate_file()) def _get_default_webserver_port(self): return DEFAULT_IMPALAD_WEBSERVER_PORT def __get_beeswax_port(self): return int(self._get_port('beeswax_port', DEFAULT_BEESWAX_PORT)) def __get_be_port(self): return int(self._get_port('be_port', DEFAULT_BE_PORT)) def __get_hs2_port(self): return int(self._get_port('hs2_port', DEFAULT_HS2_PORT)) def start(self, wait_until_ready=True): """Starts the impalad and waits until the service is ready to accept connections.""" restart_args = self.cmd[1:] LOG.info( "Starting Impalad process with args: {0}".format(restart_args)) run_daemon("impalad", restart_args) if wait_until_ready: self.service.wait_for_metric_value('impala-server.ready', expected_value=1, timeout=30) def wait_for_catalog(self): """Waits for a catalog copy to be received by the impalad. When its received, additionally waits for client ports to be opened.""" start_time = time.time() beeswax_port_is_open = False hs2_port_is_open = False num_dbs = 0 num_tbls = 0 while ((time.time() - start_time < CLUSTER_WAIT_TIMEOUT_IN_SECONDS) and not (beeswax_port_is_open and hs2_port_is_open)): try: num_dbs, num_tbls = self.service.get_metric_values( ["catalog.num-databases", "catalog.num-tables"]) beeswax_port_is_open = self.service.beeswax_port_is_open() hs2_port_is_open = self.service.hs2_port_is_open() except Exception: LOG.exception( ("Client services not ready. Waiting for catalog cache: " "({num_dbs} DBs / {num_tbls} tables). Trying again ..." ).format(num_dbs=num_dbs, num_tbls=num_tbls)) sleep(0.5) if not hs2_port_is_open or not beeswax_port_is_open: raise RuntimeError( "Unable to open client ports within {num_seconds} seconds.". format(num_seconds=CLUSTER_WAIT_TIMEOUT_IN_SECONDS))
class ImpaladProcess(BaseImpalaProcess): def __init__(self, cmd, container_id=None, port_map=None): super(ImpaladProcess, self).__init__(cmd, container_id, port_map) self.service = ImpaladService(self.hostname, self.get_webserver_port(), self.__get_beeswax_port(), self.__get_be_port(), self.__get_hs2_port(), self._get_webserver_certificate_file()) def _get_default_webserver_port(self): return DEFAULT_IMPALAD_WEBSERVER_PORT def __get_beeswax_port(self): return int(self._get_port('beeswax_port', DEFAULT_BEESWAX_PORT)) def __get_be_port(self): return int(self._get_port('be_port', DEFAULT_BE_PORT)) def __get_hs2_port(self): return int(self._get_port('hs2_port', DEFAULT_HS2_PORT)) def start(self, wait_until_ready=True): """Starts the impalad and waits until the service is ready to accept connections.""" restart_args = self.cmd[1:] LOG.info("Starting Impalad process with args: {0}".format(restart_args)) run_daemon("impalad", restart_args) if wait_until_ready: self.service.wait_for_metric_value('impala-server.ready', expected_value=1, timeout=30) def wait_for_catalog(self): """Waits for a catalog copy to be received by the impalad. When its received, additionally waits for client ports to be opened.""" start_time = time.time() beeswax_port_is_open = False hs2_port_is_open = False num_dbs = 0 num_tbls = 0 while ((time.time() - start_time < CLUSTER_WAIT_TIMEOUT_IN_SECONDS) and not (beeswax_port_is_open and hs2_port_is_open)): try: num_dbs, num_tbls = self.service.get_metric_values( ["catalog.num-databases", "catalog.num-tables"]) beeswax_port_is_open = self.service.beeswax_port_is_open() hs2_port_is_open = self.service.hs2_port_is_open() except Exception: LOG.exception(("Client services not ready. Waiting for catalog cache: " "({num_dbs} DBs / {num_tbls} tables). Trying again ...").format( num_dbs=num_dbs, num_tbls=num_tbls)) sleep(0.5) if not hs2_port_is_open or not beeswax_port_is_open: raise RuntimeError( "Unable to open client ports within {num_seconds} seconds.".format( num_seconds=CLUSTER_WAIT_TIMEOUT_IN_SECONDS))