Explorar o código

[oozie] Add kill command to oozie coordinator dashboard

abec %!s(int64=13) %!d(string=hai) anos
pai
achega
29e7fb7

+ 25 - 1
apps/oozie/src/oozie/templates/dashboard/list_oozie_coordinator.mako

@@ -55,7 +55,7 @@ ${ layout.menubar(section='dashboard') }
           </tr>
           <tr>
             <td>${ _('Status') }</td>
-            <td><span class="label ${ utils.get_status(oozie_coordinator.status) }">${ oozie_coordinator.status }</span></td>
+            <td><span class="label ${ utils.get_status(oozie_coordinator.status) }">${ oozie_coordinator.status }</span>&nbsp;</td>
           </tr>
           <tr>
             <td>${ _('Next Materialized Time') }</td>
@@ -73,6 +73,16 @@ ${ layout.menubar(section='dashboard') }
               </tr>
             % endfor
           % endif
+          <tr>
+            <td>${ _('Manage') }</td>
+            <td>
+            % if oozie_coordinator.is_running():
+              <button type="button" class="btn manage-oozie-job-btn" data-url="${ url('oozie:manage_oozie_jobs', job_id=oozie_coordinator.id, action='kill') }"  data-message="The coordinator was killed!">
+                ${ _('Kill') }
+              </button>
+            % endif
+            </td>
+          </tr>
         </tbody>
       </table>
     </div>
@@ -184,6 +194,20 @@ ${ layout.menubar(section='dashboard') }
 
 <script>
   $("a[data-row-selector='true']").jHueRowSelector();
+  $(".manage-oozie-job-btn").click(function() {
+    var _this = this;
+    $.post($(this).attr("data-url"),
+      { 'notification': $(this).attr("data-message") },
+      function(response) {
+        if (response['status'] != 0) {
+          $.jHueNotify.error("${ _('Problem: ') }" + response['data']);
+        } else {
+          window.location.reload();
+        }
+      }
+    );
+    return false;
+  });
 </script>
 
 ${commonfooter(messages)}

+ 24 - 15
apps/oozie/src/oozie/templates/dashboard/list_oozie_workflow.mako

@@ -76,12 +76,6 @@ ${ layout.menubar(section='dashboard') }
     </div>
     <div class="span3">
       <span class="label ${ utils.get_status(oozie_workflow.status) }">${ oozie_workflow.status }</span>
-      % if oozie_workflow.is_running():
-        &nbsp;
-        <button type="button" class="btn manage-oozie-job-btn" data-url="${ url('oozie:manage_oozie_jobs', job_id=oozie_workflow.id, action='kill') }">
-          ${ _('Kill') }
-        </button>
-      % endif
     </div>
   </div>
 
@@ -113,6 +107,19 @@ ${ layout.menubar(section='dashboard') }
     % endfor
   % endif
 
+  <div class="row-fluid">
+    <div class="span3">
+      ${ _('Manage') }
+    </div>
+    <div class="span3">
+      % if oozie_workflow.is_running():
+        <button class="btn manage-oozie-job-btn" data-url="${ url('oozie:manage_oozie_jobs', job_id=oozie_workflow.id, action='kill') }" data-message="The workflow was killed!">
+          ${ _('Kill') }
+        </button>
+      % endif
+    </div>
+  </div>
+
   <br/><br/>
 
     <ul class="nav nav-tabs">
@@ -259,16 +266,18 @@ ${ layout.menubar(section='dashboard') }
       window.location = $(this).attr('data-edit');
     });
     $(".manage-oozie-job-btn").click(function() {
-       $.post($(this).attr("data-url"),
-          function(response) {
-            if (response['status'] != 0) {
-              $.jHueNotify.error("${ _('Problem: ') }" + response['data']);
-            } else {
-              window.location.reload();
-            }
+      var _this = this;
+      $.post($(this).attr("data-url"),
+        { 'notification': $(this).attr("data-message") },
+        function(response) {
+          if (response['status'] != 0) {
+            $.jHueNotify.error("${ _('Error: ') }" + response['data']);
+          } else {
+            window.location.reload();
           }
-        );
-        return false;
+        }
+      );
+      return false;
     });
 
     $("a[data-row-selector='true']").jHueRowSelector();

+ 19 - 8
apps/oozie/src/oozie/tests.py

@@ -45,7 +45,7 @@ class MockOozieApi:
                         {u'status': u'SUCCEEDED', u'run': 0, u'startTime': u'Mon, 30 Jul 2012 22:16:58 GMT', u'appName': u'WordCount4', u'lastModTime': u'Mon, 30 Jul 2012 22:18:10 GMT', u'actions': [], u'acl': None, u'appPath': None, u'externalId': None, u'consoleUrl': u'http://runreal:11000/oozie?job=0000008-120725142744176-oozie-oozi-W', u'conf': None, u'parentId': None, u'createdTime': u'Mon, 30 Jul 2012 22:16:58 GMT', u'toString': u'Workflow id[0000008-120725142744176-oozie-oozi-W] status[SUCCEEDED]', u'endTime': u'Mon, 30 Jul 2012 22:18:10 GMT', u'id': u'0000008-120725142744176-oozie-oozi-W', u'group': None, u'user': u'romain'}]
   WORKFLOW_IDS = [wf['id'] for wf in JSON_WORKFLOW_LIST]
 
-  JSON_COORDINATOR_LIST = [{u'startTime': u'Sun, 01 Jul 2012 00:00:00 GMT', u'actions': [], u'frequency': 1, u'concurrency': 1, u'pauseTime': None, u'group': None, u'toString': u'Coornidator application id[0000041-120717205528122-oozie-oozi-C] status[DONEWITHERROR]', u'consoleUrl': None, u'mat_throttling': 0, u'status': u'DONEWITHERROR', u'conf': None, u'user': u'romain', u'timeOut': 120, u'coordJobPath': u'hdfs://localhost:8020/user/romain/demo2', u'timeUnit': u'DAY', u'coordJobId': u'0000041-120717205528122-oozie-oozi-C', u'coordJobName': u'DailyWordCount1', u'nextMaterializedTime': u'Wed, 04 Jul 2012 00:00:00 GMT', u'coordExternalId': None, u'acl': None, u'lastAction': u'Wed, 04 Jul 2012 00:00:00 GMT', u'executionPolicy': u'FIFO', u'timeZone': u'America/Los_Angeles', u'endTime': u'Wed, 04 Jul 2012 00:00:00 GMT'},
+  JSON_COORDINATOR_LIST = [{u'startTime': u'Sun, 01 Jul 2012 00:00:00 GMT', u'actions': [], u'frequency': 1, u'concurrency': 1, u'pauseTime': None, u'group': None, u'toString': u'Coornidator application id[0000041-120717205528122-oozie-oozi-C] status[RUNNING]', u'consoleUrl': None, u'mat_throttling': 0, u'status': u'RUNNING', u'conf': None, u'user': u'romain', u'timeOut': 120, u'coordJobPath': u'hdfs://localhost:8020/user/romain/demo2', u'timeUnit': u'DAY', u'coordJobId': u'0000041-120717205528122-oozie-oozi-C', u'coordJobName': u'DailyWordCount1', u'nextMaterializedTime': u'Wed, 04 Jul 2012 00:00:00 GMT', u'coordExternalId': None, u'acl': None, u'lastAction': u'Wed, 04 Jul 2012 00:00:00 GMT', u'executionPolicy': u'FIFO', u'timeZone': u'America/Los_Angeles', u'endTime': u'Wed, 04 Jul 2012 00:00:00 GMT'},
                            {u'startTime': u'Sun, 01 Jul 2012 00:00:00 GMT', u'actions': [], u'frequency': 1, u'concurrency': 1, u'pauseTime': None, u'group': None, u'toString': u'Coornidator application id[0000011-120706144403213-oozie-oozi-C] status[DONEWITHERROR]', u'consoleUrl': None, u'mat_throttling': 0, u'status': u'DONEWITHERROR', u'conf': None, u'user': u'romain', u'timeOut': 120, u'coordJobPath': u'hdfs://localhost:8020/user/hue/jobsub/_romain_-design-2', u'timeUnit': u'DAY', u'coordJobId': u'0000011-120706144403213-oozie-oozi-C', u'coordJobName': u'DailyWordCount2', u'nextMaterializedTime': u'Thu, 05 Jul 2012 00:00:00 GMT', u'coordExternalId': None, u'acl': None, u'lastAction': u'Thu, 05 Jul 2012 00:00:00 GMT', u'executionPolicy': u'FIFO', u'timeZone': u'America/Los_Angeles', u'endTime': u'Wed, 04 Jul 2012 18:54:00 GMT'},
                            {u'startTime': u'Sun, 01 Jul 2012 00:00:00 GMT', u'actions': [], u'frequency': 1, u'concurrency': 1, u'pauseTime': None, u'group': None, u'toString': u'Coornidator application id[0000010-120706144403213-oozie-oozi-C] status[DONEWITHERROR]', u'consoleUrl': None, u'mat_throttling': 0, u'status': u'DONEWITHERROR', u'conf': None, u'user': u'romain', u'timeOut': 120, u'coordJobPath': u'hdfs://localhost:8020/user/hue/jobsub/_romain_-design-2', u'timeUnit': u'DAY', u'coordJobId': u'0000010-120706144403213-oozie-oozi-C', u'coordJobName': u'DailyWordCount3', u'nextMaterializedTime': u'Thu, 05 Jul 2012 00:00:00 GMT', u'coordExternalId': None, u'acl': None, u'lastAction': u'Thu, 05 Jul 2012 00:00:00 GMT', u'executionPolicy': u'FIFO', u'timeZone': u'America/Los_Angeles', u'endTime': u'Wed, 04 Jul 2012 18:54:00 GMT'},
                            {u'startTime': u'Sun, 01 Jul 2012 00:00:00 GMT', u'actions': [], u'frequency': 1, u'concurrency': 1, u'pauseTime': None, u'group': None, u'toString': u'Coornidator application id[0000009-120706144403213-oozie-oozi-C] status[DONEWITHERROR]', u'consoleUrl': None, u'mat_throttling': 0, u'status': u'DONEWITHERROR', u'conf': None, u'user': u'romain', u'timeOut': 120, u'coordJobPath': u'hdfs://localhost:8020/user/hue/jobsub/_romain_-design-2', u'timeUnit': u'DAY', u'coordJobId': u'0000009-120706144403213-oozie-oozi-C', u'coordJobName': u'DailyWordCount4', u'nextMaterializedTime': u'Thu, 05 Jul 2012 00:00:00 GMT', u'coordExternalId': None, u'acl': None, u'lastAction': u'Thu, 05 Jul 2012 00:00:00 GMT', u'executionPolicy': u'FIFO', u'timeZone': u'America/Los_Angeles', u'endTime': u'Wed, 04 Jul 2012 18:54:00 GMT'}]
@@ -116,13 +116,6 @@ class TestEditor:
     pass
 
 
-  def test_manage_workflow(self):
-    # Kill button in response
-    response = self.c.get(reverse('oozie:list_oozie_workflow', args=[MockOozieApi.WORKFLOW_IDS[0]]), {}, follow=True)
-    assert_true(('%s/kill' % MockOozieApi.WORKFLOW_IDS[0]) in response.content)
-    assert_false(('%s/kill' % MockOozieApi.WORKFLOW_IDS[1]) in response.content)
-
-
   def test_move_up(self):
     action1 = Node.objects.get(name='action-name-1')
     action2 = Node.objects.get(name='action-name-2')
@@ -771,6 +764,24 @@ class TestDashboard:
     self.wf = create_workflow()
 
 
+  def test_manage_workflow_dashboard(self):
+    # Kill button in response
+    response = self.c.get(reverse('oozie:list_oozie_workflow', args=[MockOozieApi.WORKFLOW_IDS[0]]), {}, follow=True)
+    assert_true(('%s/kill' % MockOozieApi.WORKFLOW_IDS[0]) in response.content, response.content)
+
+    response = self.c.get(reverse('oozie:list_oozie_workflow', args=[MockOozieApi.WORKFLOW_IDS[1]]), {}, follow=True)
+    assert_false(('%s/kill' % MockOozieApi.WORKFLOW_IDS[1]) in response.content, response.content)
+
+
+  def test_manage_coordinator_dashboard(self):
+    # Kill button in response
+    response = self.c.get(reverse('oozie:list_oozie_coordinator', args=[MockOozieApi.COORDINATOR_IDS[0]]), {}, follow=True)
+    assert_true(('%s/kill' % MockOozieApi.COORDINATOR_IDS[0]) in response.content, response.content)
+
+    response = self.c.get(reverse('oozie:list_oozie_coordinator', args=[MockOozieApi.COORDINATOR_IDS[1]]), {}, follow=True)
+    assert_false(('%s/kill' % MockOozieApi.COORDINATOR_IDS[1]) in response.content, response.content)
+
+
   def test_list_workflows(self):
     response = self.c.get(reverse('oozie:list_oozie_workflows'))
     for wf_id in MockOozieApi.WORKFLOW_IDS:

+ 2 - 1
apps/oozie/src/oozie/views/dashboard.py

@@ -56,7 +56,8 @@ def manage_oozie_jobs(request, job_id, action):
   try:
     response['data'] = get_oozie().job_control(job_id, action)
     response['status'] = 0
-    request.info(_('Action %(action)s was performed on job %(job_id)s') % {'action': action, 'job_id': job_id})
+    if 'notification' in request.POST:
+      request.info(_(request.POST.get('notification')))
   except RestException, ex:
     response['data'] = _("Error performing %s on Oozie job %s: %s") % (action, job_id, ex.message)