def get_jobs(self, notebook, snippet, logs): jobs = [] if snippet['type'] == 'hive': engine = self._get_hive_execution_engine(notebook, snippet) jobs_with_state = parse_out_jobs(logs, engine=engine, with_state=True) jobs = [{ 'name': job.get('job_id', ''), 'url': reverse('jobbrowser.views.single_job', kwargs={'job': job.get('job_id', '')}), 'started': job.get('started', False), 'finished': job.get('finished', False) } for job in jobs_with_state] elif snippet['type'] == 'impala' and ENABLE_QUERY_BROWSER.get(): query_id = unpack_guid_base64(snippet['result']['handle']['guid']) progress = min(self.progress(notebook, snippet, logs), 99) if snippet['status'] != 'available' and snippet[ 'status'] != 'success' else 100 jobs = [{ 'name': query_id, 'url': '/hue/jobbrowser#!id=%s' % query_id, 'started': True, 'finished': False, 'percentJob': progress }] return jobs
def get_jobs(self, notebook, snippet, logs): jobs = [] if snippet['type'] == 'hive': engine = self._get_hive_execution_engine(notebook, snippet) jobs_with_state = parse_out_jobs(logs, engine=engine, with_state=True) jobs = [{ 'name': job.get('job_id', ''), 'url': reverse('jobbrowser.views.single_job', kwargs={'job': job.get('job_id', '')}), 'started': job.get('started', False), 'finished': job.get('finished', False) } for job in jobs_with_state] elif snippet['type'] == 'impala' and ENABLE_QUERY_BROWSER.get(): query_id = "%x:%x" % struct.unpack( b"QQ", snippet['result']['handle']['guid']) jobs = [{ 'name': query_id, 'url': '/hue/jobbrowser#!id=%s' % query_id, 'started': True, 'finished': False }] return jobs
LOG.warn('Hive and HiveServer2 interfaces are not enabled: %s' % e) hive_settings = None try: from impala import api # Force checking if Impala is enabled from impala.conf import CONFIG_WHITELIST as impala_settings from impala.server import get_api as get_impalad_api, ImpalaDaemonApiException, _get_impala_server_url except ImportError as e: LOG.warn("Impala app is not enabled") impala_settings = None try: from jobbrowser.views import get_job from jobbrowser.conf import ENABLE_QUERY_BROWSER from jobbrowser.apis.query_api import _get_api has_query_browser = ENABLE_QUERY_BROWSER.get() except (AttributeError, ImportError) as e: LOG.warn("Job Browser app is not enabled") has_query_browser = False DEFAULT_HIVE_ENGINE = 'mr' def query_error_handler(func): def decorator(*args, **kwargs): try: return func(*args, **kwargs) except StructuredException as e: message = force_unicode(str(e)) if 'timed out' in message: raise OperationTimeout(e)