Эх сурвалжийг харах

HUE-4821 [oozie] Support arguments in Hive2 workflow action

Romain Rigaux 9 жил өмнө
parent
commit
4d6e893325

+ 12 - 0
apps/oozie/src/oozie/models2.py

@@ -884,6 +884,9 @@ def _upgrade_older_node(node):
   if node['type'] == 'spark-widget' and 'files' not in node['properties']:
     node['properties']['files'] = []
 
+  if (node['type'] == 'hive2-widget' or node['type'] == 'hive-document-widget') and 'arguments' not in node['properties']:
+    node['properties']['arguments'] = []
+
 
 class Action(object):
 
@@ -1186,6 +1189,13 @@ class HiveServer2Action(Action):
           'help_text': _('The %(type)s parameters of the script. E.g. N=5, INPUT=${inputDir}')  % {'type': TYPE.title()},
           'type': ''
      },
+     'arguments': {
+          'name': 'arguments',
+          'label': _('Arguments'),
+          'value': [],
+          'help_text': _('Arguments for beeline. E.g. --showHeader=true, -Djavax.net.ssl.trustStore=/etc/cdep-ssl-conf/CA_STANDARD/truststore.jks'),
+          'type': []
+     },
      # Common
      'jdbc_url': {
           'name': 'jdbc_url',
@@ -3368,6 +3378,8 @@ class WorkflowBuilder():
             u'retry_interval': [],
             u'retry_max': [],
             u'job_properties': [],
+            u'arguments': [],
+            u'parameters': [],
             u'sla': [
                 {u'key': u'enabled', u'value': False},
                 {u'key': u'nominal-time', u'value': u'${nominal_time}'},

+ 10 - 0
apps/oozie/src/oozie/models2_tests.py

@@ -1024,6 +1024,16 @@ class TestModelAPI(OozieMockBase):
     assert_equal(len(_data['workflow']['nodes']), 4)
 
 
+  def test_gen_hive_xml(self):
+    notebook = make_notebook(name='Browse', editor_type='hive', statement='SHOW TABLES', status='ready')
+    notebook_doc, save_as = _save_notebook(notebook.get_data(), self.user)
+
+    workflow_doc = WorkflowBuilder().create_workflow(document=notebook_doc, user=self.user, managed=True)
+
+    workflow = Workflow(document=workflow_doc, user=self.user)
+    assert_true(re.search('<script>\$\{wf:appPath\(\)}/hive\-....\.sql</script>', workflow.to_xml({'output': '/path'})))
+
+
   def test_gen_workflow_from_notebook(self):
     snippets = [
       {

+ 19 - 0
apps/oozie/src/oozie/templates/editor2/common_workflow.mako

@@ -717,6 +717,25 @@
           <span data-bind="text: $root.workflow_properties.password.label"></span>
           <input type="text" data-bind="value: properties.password, attr: { placeholder: $root.workflow_properties.password.help_text }" />
           <br/>
+          <a class="pointer" data-bind="click: function(){ properties.arguments.push(ko.mapping.fromJS({'value': ''})); $(document).trigger('drawArrows') }">
+            ${ _('Arguments') } <i class="fa fa-plus"></i>
+          </a>
+          <div class="row-fluid">
+            <ul class="unstyled white sortable-arguments" data-bind="visible: properties.arguments().length > 0, sortable: { data: properties.arguments, options: { axis: 'y', containment: 'parent' }}">
+              <li>
+                <span class="muted move-widget">
+                  <i class="fa fa-arrows"></i>
+                </span>
+                <input type="text" class="input-xlarge filechooser-input seventy" data-bind="filechooser: value, filechooserOptions: globalFilechooserOptions, hdfsAutocomplete: value, attr: { placeholder:  $root.workflow_properties.arguments.help_text }" validate="nonempty"/>
+                <span data-bind='template: { name: "common-fs-link", data: {path: value, with_label: false}}'></span>
+                <a href="#" data-bind="click: function(){ $parent.properties.arguments.remove(this); $(document).trigger('drawArrows') }">
+                  <i class="fa fa-minus"></i>
+                </a>
+              </li>
+            </ul>
+            <em data-bind="visible: properties.arguments().length == 0">${ _('No arguments defined.') }</em>
+          </div>
+          <br/>
           <span data-bind="template: { name: 'common-action-properties' }"></span>
           <br/>
           <br/>

+ 3 - 0
apps/oozie/src/oozie/templates/editor2/gen/workflow-hive-document.xml.mako

@@ -37,6 +37,9 @@
             % for param in node['properties']['parameters']:
               <param>${ param['value'] }</param>
             % endfor
+            % for param in node['properties']['arguments']:
+              <argument>${ param['value'] }</argument>
+            % endfor
 
             ${ common.distributed_cache(node['properties']['files'], node['properties']['archives']) }
         </hive2>

+ 3 - 0
apps/oozie/src/oozie/templates/editor2/gen/workflow-hive2.xml.mako

@@ -37,6 +37,9 @@
             % for param in node['properties']['parameters']:
               <param>${ param['value'] }</param>
             % endfor
+            % for param in node['properties']['arguments']:
+              <argument>${ param['value'] }</argument>
+            % endfor
 
             ${ common.distributed_cache(node['properties']['files'], node['properties']['archives']) }
         </hive2>

+ 1 - 0
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -209,6 +209,7 @@
       properties['settings'] = [];
       properties['files'] = [];
       properties['functions'] = [];
+      properties['arguments'] = [];
     }
     else if (snippetType == 'impala') {
       properties['settings'] = [];