Browse Source

[oozie] Update the list of jobs seen as 'RUNNING'

Add is_running() to the Oozie Job model
Update the code with Job.is_running()
i18n the kill popup of the workflows and coordinator pages
Add a OOZIE_JOBS_COUNT configuration parameter set to 100
Romain Rigaux 13 years ago
parent
commit
f971054

+ 6 - 0
apps/oozie/src/oozie/conf.py

@@ -51,3 +51,9 @@ SHARE_JOBS = Config(
   type=coerce_bool,
   help=_('Share workflows and coordinators information with all users. If set to false, '
        'they will be visible only to the owner and administrators.'))
+
+OOZIE_JOBS_COUNT = Config(
+  key='oozie_jobs_count',
+  default=100,
+  type=int,
+  help=_('Maximum of Oozie workflows or coodinators to retrieve in one API call.'))

+ 2 - 2
apps/oozie/src/oozie/models.py

@@ -138,7 +138,7 @@ class WorkflowManager(models.Manager):
     workflow.end = end
     workflow.save()
 
-    # Recheck if deployement dir exists 
+    # Recheck if deployement dir exists
     oozie_setup.create_data_dir(fs)
     Submission(workflow.owner, workflow, fs, {})._create_deployment_dir()
 
@@ -366,7 +366,7 @@ class Workflow(Job):
     copy.start = old_nodes_mapping[self.start.id]
     copy.end = old_nodes_mapping[self.end.id]
     copy.save()
-    
+
     try:
       fs.copy_remote_dir(source_deployment_dir, copy.deployment_dir, owner=copy.owner)
     except WebHdfsException, e:

+ 19 - 19
apps/oozie/src/oozie/templates/dashboard/list_oozie_coordinators.mako

@@ -80,9 +80,9 @@ ${layout.menubar(section='dashboard')}
             <td>${ job.user }</td>
             <td><a href="${ job.get_absolute_url() }" data-row-selector="true"></a>${ job.id }</td>
             <td>
-               <a type="button" class="btn manage-oozie-job-btn" data-url="${ url('oozie:manage_oozie_jobs', job_id=job.id, action='kill') }">
-                 ${ _('Kill') }
-               </button>
+              <a type="button" class="btn manage-oozie-job-btn" data-url="${ url('oozie:manage_oozie_jobs', job_id=job.id, action='kill') }">
+                ${ _('Kill') }
+              </button>
            </td>
           </tr>
         %endfor
@@ -111,7 +111,7 @@ ${layout.menubar(section='dashboard')}
               <span class="label
                % if job.status == 'SUCCEEDED':
                  label-success
-               % elif job.status == 'RUNNING':
+               % elif job.is_running():
                   label-warning
                % else:
                  label-important
@@ -224,21 +224,21 @@ ${layout.menubar(section='dashboard')}
     $("a[data-row-selector='true']").jHueRowSelector();
 
     $(".manage-oozie-job-btn").click(function() {
-       // are you sure?
-       var row = $(this).closest("tr");
-       $.post($(this).attr("data-url"),
-          function(response) {
-            if (response['status'] != 0) {
-              alert('Problem :' + response['data']);
-            } else {
-              $.jHueNotify.error('Killed !')
-              row.remove();
-            }
-          }
-        );
-        return false;
-    });
+        // are you sure?
+        var row = $(this).closest("tr");
+        $.post($(this).attr("data-url"),
+           function(response) {
+             if (response['status'] != 0) {
+               $.jHueNotify.error('${ _('Problem :') }' + response['data']);
+             } else {
+               $.jHueNotify.info('${ _('Killed !') }');
+               row.remove();
+             }
+           }
+         );
+         return false;
+     });
   });
 </script>
 
-${commonfooter(messages)}
+${ commonfooter(messages) }

+ 1 - 1
apps/oozie/src/oozie/templates/dashboard/list_oozie_workflow.mako

@@ -76,7 +76,7 @@ ${ layout.menubar(section='dashboard') }
     </div>
     <div class="span3">
       <span class="label ${ utils.get_status(oozie_workflow.status) }">${ oozie_workflow.status }</span>
-      % if oozie_workflow.status == 'RUNNING':
+      % 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') }

+ 7 - 7
apps/oozie/src/oozie/templates/dashboard/list_oozie_workflows.mako

@@ -80,9 +80,9 @@ ${ layout.menubar(section='dashboard') }
             <td>${ job.user }</td>
             <td><a href="${ job.get_absolute_url() }" data-row-selector="true"></a>${ job.id }</td>
             <td>
-               <a type="button" class="btn manage-oozie-job-btn" data-url="${ url('oozie:manage_oozie_jobs', job_id=job.id, action='kill') }">
-                 ${ _('Kill') }
-               </button>
+              <a type="button" class="btn manage-oozie-job-btn" data-url="${ url('oozie:manage_oozie_jobs', job_id=job.id, action='kill') }">
+                ${ _('Kill') }
+              </button>
            </td>
           </tr>
         % endfor
@@ -111,7 +111,7 @@ ${ layout.menubar(section='dashboard') }
               <span class="label
                % if job.status == 'SUCCEEDED':
                  label-success
-               % elif job.status == 'RUNNING':
+               % elif job.is_running():
                   label-warning
                % else:
                  label-important
@@ -228,9 +228,9 @@ ${ layout.menubar(section='dashboard') }
        $.post($(this).attr("data-url"),
           function(response) {
             if (response['status'] != 0) {
-              alert('Problem :' + response['data']);
+              $.jHueNotify.error('${ _('Problem :') }' + response['data']);
             } else {
-              $.jHueNotify.error('Killed !')
+              $.jHueNotify.info('${ _('Killed !') }');
               row.remove();
             }
           }
@@ -240,4 +240,4 @@ ${ layout.menubar(section='dashboard') }
   });
 </script>
 
-${commonfooter(messages)}
+${ commonfooter(messages) }

+ 1 - 1
apps/oozie/src/oozie/templates/utils.inc.mako

@@ -127,7 +127,7 @@
 <%def name="get_status(status)">
    % if status in ('SUCCEEDED', 'OK'):
      label-success
-   % elif status in ('RUNNING', 'PREP', 'WAITING'):
+   % elif status in ('RUNNING', 'PREP', 'WAITING', 'SUSPENDED', 'PREPSUSPENDED', 'PREPPAUSED', 'PAUSED'):
       label-warning
    % elif status == 'READY':
       label-success

+ 4 - 3
apps/oozie/src/oozie/views/dashboard.py

@@ -30,6 +30,7 @@ from desktop.lib.rest.http_client import RestException
 from desktop.log.access import access_warn
 from liboozie.oozie_api import get_oozie
 
+from oozie.conf import OOZIE_JOBS_COUNT
 from oozie.models import History
 from oozie.views.editor import can_access_job_or_exception
 
@@ -73,7 +74,7 @@ def show_oozie_error(view_func):
 
 @show_oozie_error
 def list_oozie_workflows(request):
-  kwargs = {'cnt': 50,}
+  kwargs = {'cnt': OOZIE_JOBS_COUNT.get(),}
   if not request.user.is_superuser:
     kwargs['user'] = request.user.username
 
@@ -87,7 +88,7 @@ def list_oozie_workflows(request):
 
 @show_oozie_error
 def list_oozie_coordinators(request):
-  kwargs = {'cnt': 50,}
+  kwargs = {'cnt': OOZIE_JOBS_COUNT.get(),}
   if not request.user.is_superuser:
     kwargs['user'] = request.user.username
 
@@ -172,7 +173,7 @@ def split_oozie_jobs(oozie_jobs):
   jobs_completed = []
 
   for job in oozie_jobs:
-    if job.status == 'RUNNING':
+    if job.is_running():
       jobs_running.append(job)
     else:
       jobs_completed.append(job)

+ 9 - 2
desktop/libs/liboozie/src/liboozie/types.py

@@ -186,6 +186,9 @@ class WorkflowAction(Action):
 
 
 class Job(object):
+  RUNNING_STATUSES = set(['PREP', 'RUNNING', 'SUSPENDED', 'PREP', # Workflow
+                          'RUNNING', 'PREPSUSPENDED', 'SUSPENDED', 'PREPPAUSED', 'PAUSED' # Coordinator
+                          ])
   """
   Accessing log and definition will trigger Oozie API calls.
   """
@@ -251,9 +254,9 @@ class Job(object):
     available_actions() -> Zero or more of [ 'start', 'suspend', 'resume', 'kill' ]
     """
     if self.status in ('SUCCEEDED', 'KILLED', 'FAILED'):
-      return [ ]
+      return []
 
-    res = [ ]
+    res = []
     if self.status == 'PREP':
       res.append('start')
     if self.status == 'RUNNING':
@@ -279,6 +282,10 @@ class Job(object):
   def get_working_actions(self):
     return [action for action in self.actions if not ControlFlowAction.is_control_flow(action.type)]
 
+  def is_running(self):
+    return self.status in Job.RUNNING_STATUSES
+
+
 class Coordinator(Job):
   _ATTRS = [
     'acl',