Browse Source

HUE-2580 [oozie] Update configuration of running coordinator

Modified Edit dialog to accomodate 'concurreny' and 'pauseTime' changes
Displaying the previously set values for all three params
EndTime and Concurrency have default values but pauseTime can be None, hence included a 'clearPauseTime' field.
krish 10 years ago
parent
commit
7e99fd7

+ 20 - 4
apps/oozie/src/oozie/forms.py

@@ -17,6 +17,7 @@
 
 import logging
 from datetime import datetime,  timedelta
+from time import mktime, struct_time
 
 from django import forms
 from django.core.exceptions import ValidationError
@@ -526,13 +527,28 @@ class BundleForm(forms.ModelForm):
       'schema_version': forms.widgets.HiddenInput(),
     }
 
-class UpdateEndTimeForm(forms.Form):
-  end = forms.SplitDateTimeField(input_time_formats=[TIME_FORMAT], required=False, initial=datetime.today() + timedelta(days=3),
-                                 widget=SplitDateTimeWidget(attrs={'class': 'input-small', 'id': 'update_endtime'},
+class UpdateCoordinatorForm(forms.Form):
+  endTime = forms.SplitDateTimeField(label='End Time', input_time_formats=[TIME_FORMAT], required=False, initial=datetime.today() + timedelta(days=3),
+                                 widget=SplitDateTimeWidget(attrs={'class': 'input-small fa fa-calendar', 'id': 'update_endtime'},
+                                                            date_format=DATE_FORMAT, time_format=TIME_FORMAT))
+
+  pauseTime = forms.SplitDateTimeField(label='Pause Time', input_time_formats=[TIME_FORMAT], required=False, initial=None,
+                                 widget=SplitDateTimeWidget(attrs={'class': 'input-small fa fa-calendar', 'id': 'update_pausetime'},
                                                             date_format=DATE_FORMAT, time_format=TIME_FORMAT))
 
+  clearPauseTime = forms.BooleanField(label='Clear Pause Time', initial=False)
+
+  concurrency = forms.IntegerField(label='Concurrency', initial=1)
+
   def __init__(self, *args, **kwargs):
-    super(UpdateEndTimeForm, self).__init__(*args, **kwargs)
+    oozie_coordinator = kwargs.pop('oozie_coordinator')
+    super(UpdateCoordinatorForm, self).__init__(*args, **kwargs)
+
+    self.fields['endTime'].initial = datetime.fromtimestamp(mktime(oozie_coordinator.endTime))
+    if type(oozie_coordinator.pauseTime) == struct_time:
+      self.fields['pauseTime'].initial = datetime.fromtimestamp(mktime(oozie_coordinator.pauseTime))
+    self.fields['concurrency'].initial = oozie_coordinator.concurrency
+
 
 
 def design_form_by_type(node_type, user, workflow):

+ 32 - 9
apps/oozie/src/oozie/templates/dashboard/list_oozie_coordinator.mako

@@ -119,9 +119,10 @@ ${ layout.menubar(section='coordinators', dashboard=True) }
                      " style="margin-bottom: 5px">
                     ${ _('Resume') }
                   </button>
-                  <button title="${ _('Edit End Time') }" id="edit-endtime-btn"
+                  <button title="${ _('Update Coordinator Job properties') }" id="edit-coord-btn"
                      data-url="${ url('oozie:manage_oozie_jobs', job_id=oozie_coordinator.id, action='change') }"
-                     data-confirmation-header="${ _('Update End Time') }"
+                     data-message="${ _('Successfully updated Coordinator Job Properties') }"
+                     data-confirmation-header="${ _('Update Coordinator Job Properties') }"
                      data-confirmation-footer="update"
                      class="btn btn-small confirmationModal
                      % if not oozie_coordinator.is_running():
@@ -190,6 +191,7 @@ ${ layout.menubar(section='coordinators', dashboard=True) }
                       </button>
                       <ul class="dropdown-menu"> <li data-bind="enable: selectedActions().length > 0">
                           <a href='#' class="ignore-btn confirmationModal" data-url="${ url('oozie:manage_oozie_jobs', job_id=oozie_coordinator.id, action='ignore') }"
+                              data-message="${ _('Successfully ignored selected action(s)') }"
                               data-confirmation-body="${ _('Are you sure you want to ignore the action(s)?')}"
                               data-confirmation-footer="normal"
                               data-confirmation-header="${ _('Note: You can only ignore a FAILED, KILLED or TIMEDOUT action' )}" > ${ _('Ignore') } </a></li>
@@ -340,6 +342,16 @@ ${ layout.menubar(section='coordinators', dashboard=True) }
                     <td>${ _('End time') }</td>
                     <td>${ utils.format_time(oozie_coordinator.endTime) }</td>
                   </tr>
+                  % if oozie_coordinator.pauseTime:
+                  <tr>
+                    <td>${ _('Pause time') }</td>
+                    <td>${ utils.format_time(oozie_coordinator.pauseTime) }</td>
+                  </tr>
+                  %endif
+                  <tr>
+                    <td>${ _('Concurrency') }</td>
+                    <td>${ oozie_coordinator.concurrency }</td>
+                  </tr>
                 </tbody>
               </table>
             </div>
@@ -408,8 +420,11 @@ ${ layout.menubar(section='coordinators', dashboard=True) }
     <a href="#" class="close" data-dismiss="modal">&times;</a>
     <h3 class="confirmation_header"></h3>
   </div>
-  <div id="update-endtime" class="span10">
-    ${ utils.render_field_no_popover(update_endtime_form['end'], show_label=False) }
+  <div id="update-coord" class="span10">
+    ${ utils.render_field_no_popover(update_coord_form['endTime'], show_label=True) }
+    ${ utils.render_field_no_popover(update_coord_form['pauseTime'], show_label=True) }
+    ${ utils.render_field_no_popover(update_coord_form['clearPauseTime'], show_label=True) }
+    ${ utils.render_field_no_popover(update_coord_form['concurrency'], show_label=True) }
   </div>
   <div class="modal-body">
       <p class="confirmation_body"></p>
@@ -697,10 +712,10 @@ ${ layout.menubar(section='coordinators', dashboard=True) }
       $("#confirmation .modal-footer." + _this.attr("data-confirmation-footer")).removeClass("hide");
       $("#confirmation").modal("show");
 
-      if (_this.attr("id") == "edit-endtime-btn") {
-        $("#update-endtime").show();
+      if (_this.attr("id") == "edit-coord-btn") {
+        $("#update-coord").show();
       } else {
-        $("#update-endtime").hide();
+        $("#update-coord").hide();
       }
 
       $("#confirmation a.btn-confirm").unbind();
@@ -717,9 +732,17 @@ ${ layout.menubar(section='coordinators', dashboard=True) }
       var OUT_DATETIME_FORMAT = "YYYY-MM-DD[T]HH:mm[Z]";
 
       var params = { 'notification': $(_this).attr("data-message") };
-      if ($(this).attr("id") == "edit-endtime-btn") {
-        params['end_time'] = moment($("input[name='end_0']").val() + " " + $("input[name='end_1']").val(),
+      if ($(this).attr("id") == "edit-coord-btn") {
+        params['end_time'] = moment($("input[name='endTime_0']").val() + " " + $("input[name='endTime_1']").val(),
             IN_DATETIME_FORMAT).format(OUT_DATETIME_FORMAT);
+        if ($("input[name='pauseTime_0']").val() && $("input[name='pauseTime_1']").val()) {
+          params['pause_time'] = moment($("input[name='pauseTime_0']").val() + " " + $("input[name='pauseTime_1']").val(),
+                                            IN_DATETIME_FORMAT).format(OUT_DATETIME_FORMAT);
+        } else {
+          params['pause_time'] = ''
+        }
+        params['clear_pause_time'] = $("input[name='clearPauseTime']").is(':checked')
+        params['concurrency'] = $("input[name='concurrency']").val()
       }
       else if ($(this).hasClass("ignore-btn")) {
         params['actions'] = viewModel.selectedActions().join(' ');

+ 5 - 4
apps/oozie/src/oozie/tests.py

@@ -3395,13 +3395,14 @@ class TestDashboard(OozieMockBase):
     data = json.loads(response.content)
     assert_equal(0, data['status'])
 
-    params = {'end_time': u'12:00 AM'}
-    response = self.c.post(reverse('oozie:manage_oozie_jobs', args=[MockOozieApi.COORDINATOR_IDS[0], 'change']), params)
+    params = {'actions': '1 2 3'}
+    response = self.c.post(reverse('oozie:manage_oozie_jobs', args=[MockOozieApi.COORDINATOR_IDS[0], 'ignore']), params)
     data = json.loads(response.content)
     assert_equal(0, data['status'])
 
-    params = {'actions': '1 2 3'}
-    response = self.c.post(reverse('oozie:manage_oozie_jobs', args=[MockOozieApi.COORDINATOR_IDS[0], 'ignore']), params)
+    params = {'end_time': u'Mon, 30 Jul 2012 22:35:48 GMT', 'pause_time': u'Mon, 30 Jul 2012 22:35:48 GMT',
+              'concurrency': '1', 'clear_pause_time': 'True'}
+    response = self.c.post(reverse('oozie:manage_oozie_jobs', args=[MockOozieApi.COORDINATOR_IDS[0], 'change']), params)
     data = json.loads(response.content)
     assert_equal(0, data['status'])
 

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

@@ -45,7 +45,7 @@ from liboozie.submittion import Submission
 from liboozie.types import Workflow as OozieWorkflow, Coordinator as CoordinatorWorkflow, Bundle as BundleWorkflow
 
 from oozie.conf import OOZIE_JOBS_COUNT, ENABLE_CRON_SCHEDULING, ENABLE_V2
-from oozie.forms import RerunForm, ParameterForm, RerunCoordForm, RerunBundleForm, UpdateEndTimeForm
+from oozie.forms import RerunForm, ParameterForm, RerunCoordForm, RerunBundleForm, UpdateCoordinatorForm
 from oozie.models import Workflow as OldWorkflow, Job, utc_datetime_format, Bundle, Coordinator, get_link, History as OldHistory
 from oozie.models2 import History, Workflow, WORKFLOW_NODE_PROPERTIES
 from oozie.settings import DJANGO_APPS
@@ -103,7 +103,13 @@ def manage_oozie_jobs(request, job_id, action):
     params = None
 
     if action == 'change':
-      params = {'value': 'endtime=%s' % (request.POST.get('end_time'))}
+      pause_time_val = request.POST.get('pause_time')
+      if request.POST.get('clear_pause_time') == 'true':
+        pause_time_val = ''
+
+      params = {'value': 'endtime=%s' % (request.POST.get('end_time')) + ';'
+                            'pausetime=%s' % (pause_time_val) + ';'
+                            'concurrency=%s' % (request.POST.get('concurrency'))}
     elif action == 'ignore':
       oozie_api = get_oozie(request.user, api_version="v2")
       params = {
@@ -439,7 +445,7 @@ def list_oozie_coordinator(request, job_id):
     oozie_slas = oozie_api.get_oozie_slas(**params)
 
   enable_cron_scheduling = ENABLE_CRON_SCHEDULING.get()
-  update_endtime_form = UpdateEndTimeForm()
+  update_coord_form = UpdateCoordinatorForm(oozie_coordinator=oozie_coordinator)
 
   return render('dashboard/list_oozie_coordinator.mako', request, {
     'oozie_coordinator': oozie_coordinator,
@@ -448,7 +454,7 @@ def list_oozie_coordinator(request, job_id):
     'oozie_bundle': oozie_bundle,
     'has_job_edition_permission': has_job_edition_permission,
     'enable_cron_scheduling': enable_cron_scheduling,
-    'update_endtime_form': update_endtime_form,
+    'update_coord_form': update_coord_form,
   })
 
 
@@ -965,6 +971,8 @@ def massaged_oozie_jobs_for_json(oozie_jobs, user, just_sla=False):
         'nextMaterializedTimeInMillis': hasattr(job, 'nextMaterializedTime') and job.nextMaterializedTime and time.mktime(job.nextMaterializedTime) or 0,
         'timeOut': hasattr(job, 'timeOut') and job.timeOut or None,
         'endTime': job.endTime and format_time(job.endTime) or None,
+        'pauseTime': hasattr(job, 'pauseTime') and job.pauseTime and format_time(job.endTime) or None,
+        'concurrency': hasattr(job, 'concurrency') and job.concurrency or None,
         'endTimeInMillis': job.endTime and time.mktime(job.endTime) or 0,
         'status': job.status,
         'isRunning': job.is_running(),

+ 4 - 0
desktop/libs/liboozie/src/liboozie/types.py

@@ -501,6 +501,10 @@ class Coordinator(Job):
     else:
       self.nextMaterializedTime = self.startTime
 
+    if self.pauseTime:
+      self.pauseTime = parse_timestamp(self.pauseTime)
+
+
     # For when listing/mixing all the jobs together
     self.id = self.coordJobId
     self.appName = self.coordJobName