Bläddra i källkod

HUE-8509 [jb] Clean-up of the listing of remote jobs

Romain Rigaux 7 år sedan
förälder
incheckning
d26915e10d

+ 8 - 5
apps/jobbrowser/src/jobbrowser/apis/data_eng_api.py

@@ -29,6 +29,9 @@ from jobbrowser.apis.base_api import Api
 LOG = logging.getLogger(__name__)
 
 
+RUNNING_STATES = ('QUEUED', 'RUNNING', 'SUBMITTING')
+
+
 class DataEngClusterApi(Api):
 
   def apps(self, filters):
@@ -113,12 +116,12 @@ class DataEngJobApi(Api):
     return {
       'apps': [{
         'id': app['jobId'],
-        'name': app['creationDate'],
+        'name': app['jobName'],
         'status': app['status'],
         'apiStatus': self._api_status(app['status']),
         'type': 'Altus %(jobType)s' % app,
         'user': '',
-        'progress': 100,
+        'progress': 50 if self._api_status(app['status']) == 'RUNNING' else 100,
         'duration': 10 * 3600,
         'submitted': app['creationDate'],
         'canWrite': True
@@ -133,10 +136,10 @@ class DataEngJobApi(Api):
 
     common = {
         'id': job['jobId'],
-        'name': job['jobId'],
+        'name': job['jobName'],
         'status': job['status'],
         'apiStatus': self._api_status(job['status']),
-        'progress': 50,
+        'progress': 50 if self._api_status(job['status']) == 'RUNNING' else 100,
         'duration': 10 * 3600,
         'submitted': job['creationDate'],
         'type': 'dataeng-job-%s' % job['jobType'],
@@ -162,7 +165,7 @@ class DataEngJobApi(Api):
     return {}
 
   def _api_status(self, status):
-    if status in ['CREATING', 'CREATED', 'TERMINATING']:
+    if status in RUNNING_STATES:
       return 'RUNNING'
     elif status in ['COMPLETED']:
       return 'SUCCEEDED'

+ 3 - 3
apps/oozie/src/oozie/views/editor2.py

@@ -405,11 +405,11 @@ def _submit_workflow_helper(request, workflow, submit_action):
       if '/submit_single_action/' in submit_action:
         mapping['submit_single_action'] = True
 
-      if cluster.get('type') == 'altus-de':
+      if 'altus' in cluster.get('type', ''):
         notebook = {}
-        snippet = {'statement': 'SELECT 1'}
+        snippet = {'statement': 'SELECT 1', 'type': 'hive'}
         handle = DataEngApi(user=request.user, request=request, cluster_name=cluster.get('name')).execute(notebook, snippet)
-        return JsonResponse({'status': 0, 'job_id': handle.get('id'), 'type': 'workflow'}, safe=False)
+        return JsonResponse({'status': 0, 'job_id': handle.get('id'), 'type': 'Altus HIVE'}, safe=False)
 
       try:
         job_id = _submit_workflow(request.user, request.fs, request.jt, workflow, mapping)

+ 1 - 1
desktop/libs/notebook/src/notebook/connectors/altus.py

@@ -53,7 +53,7 @@ def _exec(service, command, parameters=None):
     resp = api.call_api(command, parameters)
     LOG.info(resp)
     json_resp = resp.json()
-    LOG.debug(json_resp )
+    LOG.debug(json_resp)
     return json_resp
   except Exception, e:
     raise PopupException(e, title=_('Error accessing'))

+ 5 - 4
desktop/libs/notebook/src/notebook/connectors/dataeng.py

@@ -25,14 +25,12 @@ from metadata.workload_analytics_client import WorkfloadAnalyticsClient
 
 from notebook.connectors.altus import DataEngApi as AltusDataEngApi
 from notebook.connectors.base import Api, QueryError
+from jobbrowser.apis.data_eng_api import RUNNING_STATES
 
 
 LOG = logging.getLogger(__name__)
 
 
-RUNNING_STATES = ('QUEUED', 'RUNNING', 'SUBMITTING')
-
-
 class DataEngApi(Api):
 
   def __init__(self, user, cluster_name, interpreter=None, request=None):
@@ -41,7 +39,6 @@ class DataEngApi(Api):
 
 
   def execute(self, notebook, snippet):
-    statement = snippet['statement']
 
     if snippet['type'] == 'spark2':
       handle = AltusDataEngApi(self.user).submit_spark_job(
@@ -53,8 +50,12 @@ class DataEngApi(Api):
 #           properties_file
       )
     else:
+      statement = snippet['statement']
       handle = AltusDataEngApi(self.user).submit_hive_job(self.cluster_name, statement, params=None, job_xml=None)
 
+    if 'jobs' not in handle:
+      raise QueryError('Submission failure: %s' % handle)
+
     job = handle['jobs'][0]
 
     if job['status'] not in RUNNING_STATES: