def get_status_from_coordinator(): with closing(PrestoClient(get_coordinator_role()[0], env.user)) as client: try: coordinator_status = run_sql(client, SYSTEM_RUNTIME_NODES) catalog_status = get_catalog_info_from(client) except BaseException as e: # Just log errors that come from a missing port or anything else; if # we can't connect to the coordinator, we just want to print out a # minimal status anyway. _LOGGER.warn(e.message) coordinator_status = [] catalog_status = [] with settings(hide('running')): node_information = execute(collect_node_information, hosts=get_host_list()) for host in get_host_list(): if isinstance(node_information[host], Exception): external_ip = 'Unknown' is_running = False error_message = node_information[host].message else: (external_ip, is_running, error_message) = node_information[host] print_status_header(external_ip, is_running, host) if error_message: print('\t' + error_message) elif not coordinator_status: print( '\tNo information available: unable to query coordinator') elif not is_running: print('\tNo information available') else: version_string = get_presto_version() version = strip_tag(split_version(version_string)) query, processor = NODE_INFO_PER_URI_SQL.for_version(version) # just get the node_info row for the host if server is up node_info_row = run_sql(client, query % external_ip) node_status = processor(node_info_row) if node_status: print_node_info(node_status, catalog_status) else: print( '\tNo information available: the coordinator has not yet' ' discovered this node')
def get_status_from_coordinator(): client = PrestoClient(get_coordinator_role()[0], env.user) try: coordinator_status = run_sql(client, SYSTEM_RUNTIME_NODES) connector_status = get_connector_info_from(client) except BaseException as e: # Just log errors that come from a missing port or anything else; if # we can't connect to the coordinator, we just want to print out a # minimal status anyway. _LOGGER.warn(e.message) coordinator_status = [] connector_status = [] with settings(hide('running')): node_information = execute(collect_node_information, hosts=get_host_list()) for host in get_host_list(): if isinstance(node_information[host], Exception): external_ip = 'Unknown' is_running = False error_message = node_information[host].message else: (external_ip, is_running, error_message) = node_information[host] print_status_header(external_ip, is_running, host) if error_message: print('\t' + error_message) elif not coordinator_status: print('\tNo information available: unable to query coordinator') elif not is_running: print('\tNo information available') else: version_string = get_presto_version() version = strip_tag(split_version(version_string)) query, processor = NODE_INFO_PER_URI_SQL.for_version(version) # just get the node_info row for the host if server is up node_info_row = run_sql(client, query % external_ip) node_status = processor(node_info_row) if node_status: print_node_info(node_status, connector_status) else: print('\tNo information available: the coordinator has not yet' ' discovered this node')
def test_split(self): self.assertEqual(['1', '2', '3'], split_version(' \t 1.2.3 \t ')) self.assertEqual(['0', '115t'], split_version('0.115t'))
def test_split(self): self.assertEqual(['1', '2', '3'], split_version(' \t 1.2.3 \t ')) self.assertEqual(['0', '115t'], split_version('0.115t')) self.assertEqual(['0', '115t', 'SNAPSHOT'], split_version('0.115t-SNAPSHOT'))