浏览代码

HUE-3308 [oozie] Generate the workflow from the save document

Romain Rigaux 9 年之前
父节点
当前提交
2f0d543

+ 19 - 30
apps/oozie/src/oozie/models2.py

@@ -746,6 +746,16 @@ class Node():
                  % (len(links), len(self.data['children']), links, self.data['children']))
         self.data['children'] = links
 
+    if self.data['type'] == 'java-document':
+      #notebook = Notebook(document=Document2.objects.get_by_uuid(user=self.user, uuid=self.data['properties']['uuid']))
+      notebook = Notebook(document=Document2.objects.get(uuid=self.data['properties']['uuid']))
+      properties = notebook.get_data()['snippets'][0]['properties']
+
+      self.data['properties']['main_class'] = properties['class']
+      self.data['properties']['app_jar'] = properties['app_jar'] # Not used here
+      self.data['properties']['files'] = [{'value': f['path']} for f in properties['files']]
+      self.data['properties']['arguments'] = [{'value': prop} for prop in properties['arguments']]
+
     data = {
       'node': self.data,
       'mapping': mapping,
@@ -2915,9 +2925,9 @@ class WorkflowBuilder():
       name = _('Schedule of ') + document.name or document.type
 
     if document.type == 'query-java':
-      node = self.get_java_document_node(document, name, document.uuid)
+      node = self.get_java_document_node(document, name)
     else:
-      node = self.get_hive_document_node(document, name, document.uuid, user)
+      node = self.get_hive_document_node(document, name, user)
 
     workflow_doc = self.get_workflow(node, name, document.uuid, user, managed=managed)
     workflow_doc.dependencies.add(document)
@@ -2925,7 +2935,7 @@ class WorkflowBuilder():
     return workflow_doc
 
 
-  def get_hive_document_node(self, document, name, doc_uuid, parameters, user):
+  def get_hive_document_node(self, document, name, parameters, user):
     api = get_oozie(user)
 
     credentials = [HiveDocumentAction.DEFAULT_CREDENTIALS] if api.security_enabled else []
@@ -2940,7 +2950,7 @@ class WorkflowBuilder():
         u'properties': {
             u'files': [],
             u'job_xml': u'',
-            u'uuid': doc_uuid,
+            u'uuid': document.uuid,
             u'parameters': parameters,
             u'retry_interval': [],
             u'retry_max': [],
@@ -2971,37 +2981,16 @@ class WorkflowBuilder():
         u'actionParameters': [],
     }
 
-  def get_java_document_node(self, document, name, doc_uuid):
+  def get_java_document_node(self, document, name):
     credentials = []
 
-    # To pick up from props
-    java_class = 'org.apache.solr.hadoop.MapReduceIndexerTool'
-    arguments = [
-        {"value": "--morphline-file"},
-        {"value": "morphline.conf"},
-        {"value": "--output-dir"},
-        {"value": "${nameNode}${outputDir}"},
-        {"value": "--log4j"},
-        {"value": "log4j.properties"},
-        {"value": "--verbose"},
-        {"value": "--go-live"},
-        {"value": "--zk-host"},
-        {"value": "${zkHost}"},
-        {"value": "--collection"},
-        {"value": "${collectionName}"},
-        {"value": "${nameNode}${filePath}"}
-    ]
-    files = [
-        {"value": "morphline.conf#morphline.conf"},
-        {"value": "log4j.properties#log4j.properties"},
-    ]
-
     return {
          "id":"0aec471d-2b7c-d93d-b22c-2110fd17ea2c",
          "name":"doc-1",
          "type":"java-document-widget",
          "properties":{
-              "files": files,
+#               "files": files,
+              u'uuid': document.uuid,
               "job_xml":[],
               "jar_path": "",
               "java_opts":[],
@@ -3009,8 +2998,8 @@ class WorkflowBuilder():
               "retry_interval":[],
               "job_properties":[],
               "capture_output": False,
-              "main_class": java_class,
-              "arguments": arguments,
+#               "main_class": java_class,
+#               "arguments": arguments,
               "prepares":[],
               "credentials": credentials,
               "sla":[{"value":False, "key":"enabled"}, {"value":"${nominal_time}", "key":"nominal-time"}, {"value":"", "key":"should-start"}, {"value":"${30 * MINUTES}", "key":"should-end"}, {"value":"", "key":"max-duration"}, {"value":"", "key":"alert-events"}, {"value":"", "key":"alert-contact"}, {"value":"", "key":"notification-msg"}, {"value":"", "key":"upstream-apps"}],

+ 10 - 1
desktop/libs/liboozie/src/liboozie/submission2.py

@@ -200,7 +200,16 @@ class Submission(object):
 
           self._create_file(deployment_dir, action.data['name'] + '.sql', notebook.get_str())
         elif action.data['type'] == 'java-document':
-          print action.data['properties']
+          from notebook.models import Notebook
+          notebook = Notebook(document=Document2.objects.get_by_uuid(user=self.user, uuid=action.data['properties']['uuid']))
+          properties = notebook.get_data()['snippets'][0]['properties']
+    
+          if properties.get('app_jar'):          
+            LOG.debug("Adding to oozie.libpath %s" % properties['app_jar'])
+            paths = [properties['app_jar']]
+            if self.properties.get('oozie.libpath'):
+              paths.append(self.properties['oozie.libpath'])
+            self.properties['oozie.libpath'] = ','.join(paths)
 
     oozie_xml = self.job.to_xml(self.properties)
     self._do_as(self.user.username, self._copy_files, deployment_dir, oozie_xml, self.properties)

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

@@ -999,7 +999,7 @@
         setTimeout(function () {
           self.fetchResultData(rows, false);
         }, 500);
-      } else if (! self.isSqlDialect() && notebook.snippets()[notebook.snippets().length - 1] == self) {
+      } else if (! vm.editorMode() && notebook.snippets()[notebook.snippets().length - 1] == self) {
         notebook.newSnippet();
       }
     };