简体   繁体   中英

How to pass arguments in a java action within an oozie workflow?

I'm trying to create a Oozie workflow with one action, a java action to launch a program to parse an excel file inside HDFS, so, in order to this java program parse the file I need to pass it the location of the file, without the oozie workflow I just call the jar file with the arguments I need like:

   java -jar myJarFile.jar hdfs:///path/to/the/file.xlsx 

Now in the java action inside the oozie workflow I need to write something like:

<action name="parse-file">
 <java>
  <job-tracker>${jobTracker}</job-tracker>
  <name-node>${nameNode}</name-node>
  <main-class>parseFile</main-class>
  <arg>path/to.the/file.xlsx</arg>
  <file>lib/myJarFile.jar#myJarFile.jar</file>
 </java>
 <ok to="sen-success-email"/>
 <error to="failed-notification-email"/>
</action>

Is this approach correct?

  • The java action will execute the public static void main(String[] args) of your class. Make sure you use fully specified package name. For example abcMainClass
  • You don't need the <file> tag if you store myJarFile.jar in a lib directory next your workflow.xml on HDFS. For example:
workflow_dir/workflow.xml
workflow_dir/lib
workflow_dir/lib/myJarFile.jar
  • Make sure you also upload all dependencies with your workflow.

References:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM