Преглед изворни кода

HUE-1656 [oozie] Create empty SLA on new nodes

Second node will use the same values for now.
Romain Rigaux пре 12 година
родитељ
комит
6e99fe4

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

@@ -115,7 +115,7 @@ ${ layout.menubar(section='sla', dashboard=True) }
         $.post("${ url('oozie:list_oozie_sla') }?format=json", $("#searchForm").serialize(), function(data) {
           slaTable.fnClearTable();
           if (data['oozie_slas']) {
-            slaTable.fnAddData(data['oozie_slas']);
+            slaTable.fnAddData(data['oozie_slas']); ## Should put a class on status, links to oozie job ids...
           } 
         });
       }, 300);

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

@@ -556,7 +556,6 @@ ${ layout.menubar(section='workflows', dashboard=True) }
 
     function resizeLogs() {
       $("#log pre").css("overflow", "auto").height($(window).height() - $("#log pre").position().top - 80);
-      $("#log pre").css("overflow", "auto").height($(window).height() - $("#log pre").position().top - 80);
     }
 
   });

+ 0 - 4
apps/oozie/src/oozie/templates/editor/edit_workflow.mako

@@ -82,10 +82,6 @@ ${ layout.menubar(section='workflows') }
     <div id="properties" class="section hide">
     <div class="card card-small">
     
-            
-    
-
-    
       <div class="alert alert-info"><h3 data-bind="text: name()"></h3></div>
       <div class="card-body">
         <p>

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

@@ -3254,9 +3254,11 @@ class TestDashboard(OozieMockBase):
 
     response = self.c.get(reverse('oozie:list_oozie_sla') + "?format=json")
     for sla in MockOozieApi.WORKFLOWS_SLAS:
-      assert_true(sla[u'slaStatus'] in response.content, response.content) #{"oozie_slas": []}
-      
-    # TODO, POST
+      assert_equal({"oozie_slas": []}, json.loads(response.content), response.content)
+
+    response = self.c.post(reverse('oozie:list_oozie_sla') + "?format=json", {'job_name': 'kochang'})
+    for sla in MockOozieApi.WORKFLOWS_SLAS:
+      assert_true('MISS' in response.content, response.content)
 
 
 class GeneralTestsWithOozie(OozieBase):

+ 40 - 26
apps/oozie/static/js/workflow.models.js

@@ -19,6 +19,20 @@
 // These serialized values are also stored in the backend.
 var MODEL_FIELDS_JSON = ['parameters', 'job_properties', 'files', 'archives', 'prepares', 'params',
                    'deletes', 'mkdirs', 'moves', 'chmods', 'touchzs'];
+var DEFAULT_SLA = [
+    {'key': 'enabled', 'value': false},
+    {'key': 'nominal-time', 'value': ''},
+    {'key': 'should-start', 'value': ''},
+    {'key': 'should-end', 'value': ''},
+    {'key': 'max-duration', 'value': ''},
+    {'key': 'alert-events', 'value': ''},
+    {'key': 'alert-contact', 'value': ''}
+];
+
+function getDefaultSla() {
+ return jQuery.extend(true, [], DEFAULT_SLA);
+}
+
 function normalize_model_fields(node_model) {
   $.each(MODEL_FIELDS_JSON, function(index, field) {
     if (field in node_model && $.isArray(node_model[field])) {
@@ -47,7 +61,7 @@ var map_params = function(options, subscribe) {
 
 // Maps JSON strings to fields in the view model.
 var MAPPING_OPTIONS = {
-  ignore: ['initialize', 'toString', 'copy'],
+  ignore: ['initialize', 'toString', 'copy', 'sla'], // Do not support cancel edit on SLA
   job_properties: {
     create: function(options) {
       var parent = options.parent;
@@ -273,21 +287,21 @@ var MAPPING_OPTIONS = {
    touchzs: {
      create: function(options) {
        var parent = options.parent;
-        var subscribe = function(mapping) {
-          mapping.name.subscribe(function(value) {
-            parent.touchzs.valueHasMutated();
-          });
-        };
-        return map_params(options, subscribe);
+       var subscribe = function(mapping) {
+         mapping.name.subscribe(function(value) {
+           parent.touchzs.valueHasMutated();
+         });
+       };
+       return map_params(options, subscribe);
      },
      update: function(options) {
        var parent = options.parent;
-        var subscribe = function(mapping) {
-          mapping.name.subscribe(function(value) {
-            parent.touchzs.valueHasMutated();
-          });
-        };
-        return map_params(options, subscribe);
+       var subscribe = function(mapping) {
+         mapping.name.subscribe(function(value) {
+           parent.touchzs.valueHasMutated();
+         });
+       };
+       return map_params(options, subscribe);
      }
    }
 };
@@ -338,7 +352,7 @@ $.extend(WorkflowModel.prototype, {
   is_shared: true,
   parameters: '[]',
   job_xml: '',
-  sla: []
+  sla: getDefaultSla()
 });
 
 var NodeModel = ModelModule($);
@@ -383,7 +397,7 @@ $.extend(DistCPModel.prototype, {
   job_xml: '',
   params: '[]',
   child_links: [],
-  sla: []
+  sla: getDefaultSla()
 });
 
 var MapReduceModel = ModelModule($);
@@ -400,7 +414,7 @@ $.extend(MapReduceModel.prototype, {
   prepares: '[]',
   job_xml: '',
   child_links: [],
-  sla: []
+  sla: getDefaultSla()
 });
 
 var StreamingModel = ModelModule($);
@@ -416,7 +430,7 @@ $.extend(StreamingModel.prototype, {
   mapper: '',
   reducer: '',
   child_links: [],
-  sla: []
+  sla: getDefaultSla()
 });
 
 var JavaModel = ModelModule($);
@@ -437,7 +451,7 @@ $.extend(JavaModel.prototype, {
   java_opts: '',
   capture_output: false,
   child_links: [],
-  sla: []
+  sla: getDefaultSla()
 });
 
 var PigModel = ModelModule($);
@@ -455,7 +469,7 @@ $.extend(PigModel.prototype, {
   params: '[]',
   script_path: '',
   child_links: [],
-  sla: []
+  sla: getDefaultSla()
 });
 
 var HiveModel = ModelModule($);
@@ -473,7 +487,7 @@ $.extend(HiveModel.prototype, {
   params: '[]',
   script_path: '',
   child_links: [],
-  sla: []
+  sla: getDefaultSla()
 });
 
 var SqoopModel = ModelModule($);
@@ -491,7 +505,7 @@ $.extend(SqoopModel.prototype, {
   params: '[]',
   script_path: '',
   child_links: [],
-  sla: []
+  sla: getDefaultSla()
 });
 
 var ShellModel = ModelModule($);
@@ -510,7 +524,7 @@ $.extend(ShellModel.prototype, {
   command: '',
   capture_output: false,
   child_links: [],
-  sla: []
+  sla: getDefaultSla()
 });
 
 var SshModel = ModelModule($);
@@ -526,7 +540,7 @@ $.extend(SshModel.prototype, {
   command: '',
   capture_output: false,
   child_links: [],
-  sla: []
+  sla: getDefaultSla()
 });
 
 var FsModel = ModelModule($);
@@ -542,7 +556,7 @@ $.extend(FsModel.prototype, {
   chmods: '[]',
   touchzs: '[]',
   child_links: [],
-  sla: []
+  sla: getDefaultSla()
 });
 
 var EmailModel = ModelModule($);
@@ -557,7 +571,7 @@ $.extend(EmailModel.prototype, {
   subject: '',
   body: '',
   child_links: [],
-  sla: []
+  sla: getDefaultSla()
 });
 
 var SubWorkflowModel = ModelModule($);
@@ -571,7 +585,7 @@ $.extend(SubWorkflowModel.prototype, {
   propagate_configuration: true,
   job_properties: '[]',
   child_links: [],
-  sla: []
+  sla: getDefaultSla()
 });
 
 var GenericModel = ModelModule($);

+ 1 - 1
apps/oozie/static/js/workflow.node.js

@@ -211,7 +211,7 @@ var NodeModule = function($, IdGeneratorTable, NodeFields) {
       var self = this;
 
       // @see http://knockoutjs.com/documentation/plugins-mapping.html
-      // MAPPING_OPTIONS comes from /oozie/static/js/models.js
+      // MAPPING_OPTIONS comes from /oozie/static/js/workflow.models.js
       var mapping = ko.mapping.fromJS(model, MAPPING_OPTIONS);
 
       $.extend(self, mapping);

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

@@ -45,7 +45,7 @@ def get_oozie(user, api_version=API_VERSION):
   if _api_cache is None or _api_cache.api_version != api_version:
     _api_cache_lock.acquire()
     try:
-      if _api_cache is None:
+      if _api_cache is None or _api_cache.api_version != api_version:
         secure = SECURITY_ENABLED.get()
         _api_cache = OozieApi(OOZIE_URL.get(), secure, api_version)
     finally: