浏览代码

HUE-3797 [scheduler] Plugin-in all the job action

Romain 6 年之前
父节点
当前提交
9073c5614b

+ 0 - 1
apps/jobbrowser/src/jobbrowser/apis/bundle_api.py

@@ -127,4 +127,3 @@ class BundleApi(Api):
       return 'SUCCEEDED'
     else:
       return 'FAILED' # DONEWITHERROR, KILLED, FAILED
-

+ 1 - 1
apps/jobbrowser/src/jobbrowser/apis/job_api.py

@@ -211,7 +211,7 @@ class YarnApi(Api):
         try:
           response = kill_job(MockDjangoRequest(self.user), job=app_id)
           if isinstance(response, JsonResponse) and json.loads(response.content).get('status') == 0:
-             kills.append(app_id)
+            kills.append(app_id)
         except MessageException:
           kills.append(app_id)
       return {'kills': kills, 'status': len(app_ids) - len(kills), 'message': _('Stop signal sent to %s') % kills}

+ 3 - 3
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -1707,11 +1707,11 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
         </ul>
       </div>
     </div>
-    <div data-bind="css:{'span10': !$root.isMini(), 'span12 no-margin': $root.isMini() }">
+    <div data-bind="css: {'span10': !$root.isMini(), 'span12 no-margin': $root.isMini() }">
 
       <ul class="nav nav-pills margin-top-20">
         <li>
-          <a href="#livy-session-page-statements${ SUFFIX }" data-bind="click: function(){ fetchProfile('properties'); $('a[href=\'#livy-session-page-statements${ SUFFIX }\']').tab('show'); }">
+          <a href="#celery-beat-page-statements${ SUFFIX }" data-bind="click: function(){ fetchProfile('properties'); $('a[href=\'#celery-beat-page-statements${ SUFFIX }\']').tab('show'); }">
             ${ _('Properties') }
           </a>
         </li>
@@ -1721,7 +1721,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
       <div class="clearfix"></div>
 
       <div class="tab-content">
-        <div class="tab-pane active" id="livy-session-page-statements${ SUFFIX }">
+        <div class="tab-pane active" id="celery-beat-page-statements${ SUFFIX }">
           <table id="actionsTable" class="datatables table table-condensed">
             <thead>
             <tr>

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook/app.js

@@ -1234,7 +1234,7 @@ huePubSub.subscribe('app.dom.loaded', app => {
       data => {
         viewModel.selectedNotebook().viewSchedulerId(data.job_id);
         $('.submit-modal-editor').modal('hide');
-        huePubSub.publish('show.jobs.panel', { id: data.job_id, interface: 'workflows' });
+        huePubSub.publish('show.jobs.panel', { id: data.job_id, interface: data.type });
       },
       HUE_PUB_SUB_EDITOR_ID
     );

+ 2 - 1
desktop/core/src/desktop/lib/scheduler/api.py

@@ -69,7 +69,8 @@ def submit_schedule(request, doc_id):
         message = force_unicode(str(e))
         return JsonResponse({'status': -1, 'message': message}, safe=False)
       if jsonify:
-        return JsonResponse({'status': 0, 'job_id': job_id, 'type': 'schedule'}, safe=False)
+        schedule_type = 'celery-beat' if interface == 'beat' else 'schedule'
+        return JsonResponse({'status': 0, 'job_id': job_id, 'type': schedule_type}, safe=False)
       else:
         request.info(_('Schedule submitted.'))
         return redirect(reverse('oozie:list_oozie_coordinator', kwargs={'job_id': job_id}))

+ 9 - 12
desktop/core/src/desktop/lib/scheduler/lib/beat.py

@@ -68,7 +68,7 @@ class CeleryBeatApi(Api):
     task.enabled=True
     task.save()
 
-    return task
+    return task.id
 
 
   def list_tasks(self, user):
@@ -81,18 +81,15 @@ class CeleryBeatApi(Api):
     return self._get_task(PeriodicTask.objects.get(id=task_id))
 
 
-  def action(self, schedule_id, schedule_ids=None, action='pause'):
-    if schedule_ids is None:
-      schedule_ids = [schedule_id]
-
-    task = PeriodicTask.objects.get(id__in=schedule_ids, description=user.username)
-
-    if action == 'pause':
+  def action(self, schedule_id, action='suspend'):
+    task = PeriodicTask.objects.get(id=schedule_id, description=self.user.username)
+    print schedule_id, action, task
+    if action == 'suspend':
       task.enabled = False
-      task.saved()
+      task.save()
     elif action == 'resume':
-      task.enabled = False
-      task.saved()
+      task.enabled = True
+      task.save()
     elif action == 'kill':
       task.delete()
 
@@ -120,4 +117,4 @@ class CeleryBeatApi(Api):
         'interval_name': task.interval,
         'crontab': task.crontab,
         'solar': task.solar
-      }
+    }