oozie系列-Java action 输出变量下一级action调用

步骤描述

  1. workflow xml 配置
  2. java 代码输出

workflow xml 配置

备注: 必须添加 <capture-output/>

<workflow-app xmlns='uri:oozie:workflow:0.1' name='java-wf'>
    <start to='java1' />
    <action name='java1'>
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <configuration>
               <property>
                    <name>mapred.job.queue.name</name>
                    <value>${queueName}</value>
                </property>
            </configuration>
            <main-class>org.apache.oozie.test.MyTest</main-class>
            <arg>${outputFileName}</arg>
            <capture-output/>
        </java>
        <ok to="hive2" />
        <error to="fail" />
    </action>
<action name="hive2" cred="hive2">
        <hive2 xmlns="uri:oozie:hive2-action:0.1">
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <jdbc-url>${hiveServer2Uri}/${db}</jdbc-url>
            <password>${password}</password>
            <script>rinse.sql</script>
            <param>rinse=${wf:actionData("java-1")["PASS_ME"]}</param>
        </hive2>
        <ok to="End"/>
        <error to="Kill"/>
    </action>
    <kill name="fail">
        <message>Hive2 failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    <end name='end' />
</workflow-app>

Java 代码输出

备注: The main() method writes a Property file to the path specified in the 'oozie.action.output.properties' ENVIRONMENT variable.

package org.apache.oozie.test;

import java.io.*;
import java.util.Properties;

public class MyTest {

   ////////////////////////////////
   // Do whatever you want in here
   ////////////////////////////////
   public static void main (String[] args)
   {
      String fileName = args[0];
      try{
         File file = new File(System.getProperty("oozie.action.output.properties"));
         Properties props = new Properties();
         props.setProperty("PASS_ME", "123456");

         OutputStream os = new FileOutputStream(file);
         props.store(os, "");
         os.close();
         System.out.println(file.getAbsolutePath());
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值