有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

hadoop将值从Java操作传递到Oozie工作流中的下一个Java操作

我在Oozie工作流中编写了两个java操作。xml。我想将第一个java操作的输出传递给下一个java操作以供重用

我知道这需要使用“oozie.action.output.properties”来完成。在第一个操作中,我设置输出参数“buildFileName”,如下所示:

File file = new File(System.getProperty("oozie.action.output.properties"));
LOGGER.info("SystemGetProperty:" + System.getProperty("oozie.action.output.properties").toString());
Properties props = new Properties();
props.setProperty("buildFileName", buildFileName);
OutputStream os= new FileOutputStream(file);
props.store(os, "");
os.close();

但不幸的是,在第二个动作中,我无法使用参数值。应用程序作业正在获得成功,但参数值为空

我的第一个java操作如下所示:

<action name="java-action1">
    <java>
        <main-class>XYZ.MyJavaAction</main-class>
        <arg>Args</arg>
        <capture-output />
    </java>
<ok to="java-action2"/> 
<error to="fail"/> 

我的第二个java操作如下所示:

<action name="java-action2">
    <java>
        <main-class>XYZ.MyJavaAction</main-class>
        <arg>{"outputFileName":"${wf:actionData('java-action1')['buildFileName']}"}</arg>
    </java>
<ok to="End"/> 
<error to="fail"/> 

谁能帮我解决一下我这里缺少的问题


共 (1) 个答案

  1. # 1 楼答案

    谷歌在oozie capture_output java上的搜索直接指向Java Cookbook部分“捕获输出元素”,引用:

    • In this example, we pass a the PASS_ME variable between the JAVA action and the PIG action.
    • The PASS_ME variable is given the value 123456 in the JAVA action ...
      The main() method writes a Property file to the path specified in the oozie.action.output.properties ENVIRONMENT variable ...
     Properties props = new Properties();
     props.setProperty("PASS_ME", "123456");
     File file = new File(System.getProperty("oozie.action.output.properties"));
     OutputStream os = new FileOutputStream(file);
     props.store(os, "");
     os.close();
    
    • The PIG action subsequently reads the value of the PASS_ME variable and passes it to the PIG script ...
      <param>MY_VAR=${wf:actionData('java1')['PASS_ME']}</param>