Browse Source

HUE-2323 [oozie] Update endtime of running coordinator

krish 10 years ago
parent
commit
71b1531

+ 8 - 0
apps/oozie/src/oozie/forms.py

@@ -526,6 +526,14 @@ class BundleForm(forms.ModelForm):
       'schema_version': forms.widgets.HiddenInput(),
       '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'},
+                                                            date_format=DATE_FORMAT, time_format=TIME_FORMAT))
+
+  def __init__(self, *args, **kwargs):
+    super(UpdateEndTimeForm, self).__init__(*args, **kwargs)
+
 
 
 def design_form_by_type(node_type, user, workflow):
 def design_form_by_type(node_type, user, workflow):
   klass_form = _node_type_TO_FORM_CLS[node_type]
   klass_form = _node_type_TO_FORM_CLS[node_type]

+ 34 - 4
apps/oozie/src/oozie/templates/dashboard/list_oozie_coordinator.mako

@@ -93,7 +93,7 @@ ${ layout.menubar(section='coordinators', dashboard=True) }
               % endif
               % endif
               % endif
               % endif
 
 
-              % if has_job_edition_permission(oozie_coordinator, user) and oozie_coordinator.status not in ('KILLED', 'KILLED', 'SUCCEEDED'):
+              % if has_job_edition_permission(oozie_coordinator, user) and oozie_coordinator.status not in ('KILLED', 'SUCCEEDED'):
                 <li class="nav-header">${ _('Manage') }</li>
                 <li class="nav-header">${ _('Manage') }</li>
                 <li class="white">
                 <li class="white">
                   <div id="rerun-coord-modal" class="modal hide"></div>
                   <div id="rerun-coord-modal" class="modal hide"></div>
@@ -117,6 +117,16 @@ ${ layout.menubar(section='coordinators', dashboard=True) }
                      " style="margin-bottom: 5px">
                      " style="margin-bottom: 5px">
                     ${ _('Resume') }
                     ${ _('Resume') }
                   </button>
                   </button>
+                  <button title="${ _('Edit End Time') }" id="edit-endtime-btn"
+                     data-url="${ url('oozie:manage_oozie_jobs', job_id=oozie_coordinator.id, action='change') }"
+                     data-confirmation-message="${ _('Update End Time') }"
+                     class="btn btn-small confirmationModal
+                     % if not oozie_coordinator.is_running():
+                       hide
+                     % endif
+                     " style="margin-bottom: 5px">
+                    ${ _('Edit') }
+                  </button>
                   <br/>
                   <br/>
                   <button title="${_('Kill %(coordinator)s') % dict(coordinator=oozie_coordinator.id)}"
                   <button title="${_('Kill %(coordinator)s') % dict(coordinator=oozie_coordinator.id)}"
                    id="kill-btn"
                    id="kill-btn"
@@ -369,6 +379,9 @@ ${ layout.menubar(section='coordinators', dashboard=True) }
     <a href="#" class="close" data-dismiss="modal">&times;</a>
     <a href="#" class="close" data-dismiss="modal">&times;</a>
     <h3 class="message"></h3>
     <h3 class="message"></h3>
   </div>
   </div>
+  <div id="update-endtime" class="span10">
+    ${ utils.render_field_no_popover(update_endtime_form['end'], show_label=False) }
+  </div>
   <div class="modal-footer">
   <div class="modal-footer">
     <a href="#" class="btn" data-dismiss="modal">${_('No')}</a>
     <a href="#" class="btn" data-dismiss="modal">${_('No')}</a>
     <a class="btn btn-danger disable-feedback" href="javascript:void(0);">${_('Yes')}</a>
     <a class="btn btn-danger disable-feedback" href="javascript:void(0);">${_('Yes')}</a>
@@ -382,9 +395,9 @@ ${ layout.menubar(section='coordinators', dashboard=True) }
 <script src="/static/ext/js/codemirror-3.11.js"></script>
 <script src="/static/ext/js/codemirror-3.11.js"></script>
 <link rel="stylesheet" href="/static/ext/css/codemirror.css">
 <link rel="stylesheet" href="/static/ext/css/codemirror.css">
 <script src="/static/ext/js/codemirror-xml.js"></script>
 <script src="/static/ext/js/codemirror-xml.js"></script>
+<script src="/static/ext/js/moment.min.js" type="text/javascript" charset="utf-8"></script>
 
 
 % if oozie_coordinator.has_sla:
 % if oozie_coordinator.has_sla:
-<script src="/static/ext/js/moment.min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/oozie/static/js/sla.utils.js" type="text/javascript" charset="utf-8"></script>
 <script src="/oozie/static/js/sla.utils.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/jquery/plugins/jquery.flot.min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/jquery/plugins/jquery.flot.min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/jquery/plugins/jquery.flot.selection.min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/jquery/plugins/jquery.flot.selection.min.js" type="text/javascript" charset="utf-8"></script>
@@ -636,6 +649,13 @@ ${ layout.menubar(section='coordinators', dashboard=True) }
       var _this = $(this);
       var _this = $(this);
       $("#confirmation .message").text(_this.attr("data-confirmation-message"));
       $("#confirmation .message").text(_this.attr("data-confirmation-message"));
       $("#confirmation").modal("show");
       $("#confirmation").modal("show");
+
+      if (_this.attr("id") == "edit-endtime-btn") {
+        $("#update-endtime").show();
+      } else {
+        $("#update-endtime").hide();
+      }
+
       $("#confirmation a.btn-danger").click(function() {
       $("#confirmation a.btn-danger").click(function() {
         _this.trigger('confirmation');
         _this.trigger('confirmation');
         $(this).attr("data-loading-text", $(this).text() + " ...");
         $(this).attr("data-loading-text", $(this).text() + " ...");
@@ -645,8 +665,16 @@ ${ layout.menubar(section='coordinators', dashboard=True) }
 
 
     $(".confirmationModal").bind('confirmation', function() {
     $(".confirmationModal").bind('confirmation', function() {
       var _this = this;
       var _this = this;
-      $.post($(this).attr("data-url"),
-        { 'notification': $(this).attr("data-message") },
+      var IN_DATETIME_FORMAT = "MM/DD/YYYY hh:mm A";
+      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(),
+                                        IN_DATETIME_FORMAT).format(OUT_DATETIME_FORMAT);
+      }
+
+      $.post($(this).attr("data-url"), params,
         function(response) {
         function(response) {
           if (response['status'] != 0) {
           if (response['status'] != 0) {
             $(document).trigger("error", "${ _('Problem: ') }" + response['data']);
             $(document).trigger("error", "${ _('Problem: ') }" + response['data']);
@@ -777,4 +805,6 @@ ${ layout.menubar(section='coordinators', dashboard=True) }
   });
   });
 </script>
 </script>
 
 
+${ utils.decorate_datetime_fields() }
+
 ${ commonfooter(messages) | n,unicode }
 ${ commonfooter(messages) | n,unicode }

+ 1 - 1
apps/oozie/src/oozie/urls.py

@@ -134,7 +134,7 @@ urlpatterns += patterns(
   url(r'^rerun_oozie_job/(?P<job_id>[-\w]+)/(?P<app_path>.+?)$', 'rerun_oozie_job', name='rerun_oozie_job'),
   url(r'^rerun_oozie_job/(?P<job_id>[-\w]+)/(?P<app_path>.+?)$', 'rerun_oozie_job', name='rerun_oozie_job'),
   url(r'^rerun_oozie_coord/(?P<job_id>[-\w]+)/(?P<app_path>.+?)$', 'rerun_oozie_coordinator', name='rerun_oozie_coord'),
   url(r'^rerun_oozie_coord/(?P<job_id>[-\w]+)/(?P<app_path>.+?)$', 'rerun_oozie_coordinator', name='rerun_oozie_coord'),
   url(r'^rerun_oozie_bundle/(?P<job_id>[-\w]+)/(?P<app_path>.+?)$', 'rerun_oozie_bundle', name='rerun_oozie_bundle'),
   url(r'^rerun_oozie_bundle/(?P<job_id>[-\w]+)/(?P<app_path>.+?)$', 'rerun_oozie_bundle', name='rerun_oozie_bundle'),
-  url(r'^manage_oozie_jobs/(?P<job_id>[-\w]+)/(?P<action>(start|suspend|resume|kill|rerun))$', 'manage_oozie_jobs', name='manage_oozie_jobs'),
+  url(r'^manage_oozie_jobs/(?P<job_id>[-\w]+)/(?P<action>(start|suspend|resume|kill|rerun|change))$', 'manage_oozie_jobs', name='manage_oozie_jobs'),
   url(r'^bulk_manage_oozie_jobs/$', 'bulk_manage_oozie_jobs', name='bulk_manage_oozie_jobs'),
   url(r'^bulk_manage_oozie_jobs/$', 'bulk_manage_oozie_jobs', name='bulk_manage_oozie_jobs'),
 
 
   url(r'^submit_external_job/(?P<application_path>.+?)$', 'submit_external_job', name='submit_external_job'),
   url(r'^submit_external_job/(?P<application_path>.+?)$', 'submit_external_job', name='submit_external_job'),

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

@@ -43,7 +43,7 @@ from liboozie.submittion import Submission
 from liboozie.types import Workflow as OozieWorkflow, Coordinator as CoordinatorWorkflow, Bundle as BundleWorkflow
 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.conf import OOZIE_JOBS_COUNT, ENABLE_CRON_SCHEDULING, ENABLE_V2
-from oozie.forms import RerunForm, ParameterForm, RerunCoordForm, RerunBundleForm
+from oozie.forms import RerunForm, ParameterForm, RerunCoordForm, RerunBundleForm, UpdateEndTimeForm
 from oozie.models import Workflow, Job, utc_datetime_format, Bundle, Coordinator, get_link, History as OldHistory
 from oozie.models import Workflow, Job, utc_datetime_format, Bundle, Coordinator, get_link, History as OldHistory
 from oozie.models2 import History
 from oozie.models2 import History
 from oozie.settings import DJANGO_APPS
 from oozie.settings import DJANGO_APPS
@@ -84,7 +84,12 @@ def manage_oozie_jobs(request, job_id, action):
 
 
   try:
   try:
     oozie_api = get_oozie(request.user)
     oozie_api = get_oozie(request.user)
-    response['data'] = oozie_api.job_control(job_id, action)
+    if action == 'change':
+      end_time = 'endtime=%s' % (request.POST.get('end_time'))
+      response['data'] = oozie_api.job_control(job_id, action, parameters={'value': end_time})
+    else:
+      response['data'] = oozie_api.job_control(job_id, action)
+
     response['status'] = 0
     response['status'] = 0
     if 'notification' in request.POST:
     if 'notification' in request.POST:
       request.info(_(request.POST.get('notification')))
       request.info(_(request.POST.get('notification')))
@@ -340,6 +345,7 @@ def list_oozie_coordinator(request, job_id):
     oozie_slas = oozie_api.get_oozie_slas(**params)
     oozie_slas = oozie_api.get_oozie_slas(**params)
 
 
   enable_cron_scheduling = ENABLE_CRON_SCHEDULING.get()
   enable_cron_scheduling = ENABLE_CRON_SCHEDULING.get()
+  update_endtime_form = UpdateEndTimeForm()
 
 
   return render('dashboard/list_oozie_coordinator.mako', request, {
   return render('dashboard/list_oozie_coordinator.mako', request, {
     'oozie_coordinator': oozie_coordinator,
     'oozie_coordinator': oozie_coordinator,
@@ -350,6 +356,7 @@ def list_oozie_coordinator(request, job_id):
     'show_all_actions': show_all_actions,
     'show_all_actions': show_all_actions,
     'MAX_COORD_ACTIONS': MAX_COORD_ACTIONS,
     'MAX_COORD_ACTIONS': MAX_COORD_ACTIONS,
     'enable_cron_scheduling': enable_cron_scheduling,
     'enable_cron_scheduling': enable_cron_scheduling,
+    'update_endtime_form': update_endtime_form,
   })
   })
 
 
 
 

+ 1 - 1
desktop/libs/liboozie/src/liboozie/oozie_api.py

@@ -184,7 +184,7 @@ class OozieApi(object):
     job_control(jobid, action) -> None
     job_control(jobid, action) -> None
     Raise RestException on error.
     Raise RestException on error.
     """
     """
-    if action not in ('start', 'suspend', 'resume', 'kill', 'rerun', 'coord-rerun', 'bundle-rerun'):
+    if action not in ('start', 'suspend', 'resume', 'kill', 'rerun', 'coord-rerun', 'bundle-rerun', 'change'):
       msg = 'Invalid oozie job action: %s' % (action,)
       msg = 'Invalid oozie job action: %s' % (action,)
       LOG.error(msg)
       LOG.error(msg)
       raise ValueError(msg)
       raise ValueError(msg)