def _get_status_until_coordinator_updated(self): status_output = self.run_prestoadmin('server status') if 'the coordinator has not yet discovered this node' in status_output: raise PrestoError('Coordinator has not discovered all nodes yet: ' '%s' % status_output) if 'Roles: coordinator): Running\n\tNo information available: ' \ 'unable to query coordinator' in status_output: raise PrestoError('Coordinator not started up properly yet.' '\nOutput: %s' % status_output) return status_output
def _get_status_until_coordinator_updated(self, check_connectors=False, extra_arguments=''): status_output = self.run_prestoadmin('server status' + extra_arguments) if 'the coordinator has not yet discovered this node' in status_output: raise PrestoError('Coordinator has not discovered all nodes yet: ' '%s' % status_output) if 'Roles: coordinator): Running\n\tNo information available: ' \ 'unable to query coordinator' in status_output: raise PrestoError('Coordinator not started up properly yet.' '\nOutput: %s' % status_output) if check_connectors and 'Connectors:' not in status_output: raise PrestoError('Connectors not loaded yet: %s' % status_output) return status_output
def get_query_id(self, sql, host=None): client = self.create_presto_client(host) client.run_sql(sql) query_runtime_info = client.run_sql( 'SELECT query_id FROM system.runtime.queries WHERE query = \'%s\'' % (sql, )) if not query_runtime_info: raise PrestoError('Presto not started up yet.') for row in query_runtime_info: return row[0]
def get_query_id(self, sql, host=None): ips = self.cluster.get_ip_address_dict() if host is None: host = self.cluster.master client = PrestoClient(ips[host], 'root') run_sql(client, sql) query_runtime_info = run_sql(client, 'SELECT query_id FROM ' 'system.runtime.queries ' 'WHERE query = \'' + sql + '\'') if not query_runtime_info: raise PrestoError('Presto not started up yet.') for row in query_runtime_info: return row[0]
def get_connector_info(self): output = self.cluster.exec_cmd_on_host( self.cluster.master, "curl --silent -X POST http://localhost:8080/v1/statement -H " "'X-Presto-User:$USER' -H 'X-Presto-Schema:metadata' -H " "'X-Presto-Catalog:system' -d 'select catalog_name from catalogs'") data = self.get_key_value(output, 'data') next_uri = self.get_key_value(output, 'nextUri') while not data and next_uri: output = self.cluster.exec_cmd_on_host( self.cluster.master, 'curl --silent %s' % self.get_key_value(output, 'nextUri')) data = self.get_key_value(output, 'data') next_uri = self.get_key_value(output, 'nextUri') if not data: raise PrestoError('Could not get catalogs from json output. ' 'Output was: \n%s' % output) return data