【问题标题】:Passing parameters from one action to another in Oozie在 Oozie 中将参数从一个动作传递到另一个动作
【发布时间】:2015-09-01 15:27:32
【问题描述】:

我有以下 shell 脚本:

DATE= date +"%d%b%y" -d "-1 days"

如何将DATE 传递给 Java 操作?

【问题讨论】:

    标签: java shell hadoop mapreduce oozie


    【解决方案1】:

    您可以从 shell 脚本捕获输出并将其传递给 java 操作。在 shell 脚本中,回显类似 'dateVariable=${DATE}' 的属性,并在 shell 操作中添加捕获输出元素。这将让您从 shell 脚本中捕获 dateVariable。在 java 操作中,您可以将捕获的变量作为参数传递为 ${wf:actionData('shellAction')['dateVariable']} 其中 shellAction 是 shell 动作名称。

    示例工作流程:-

    <?xml version="1.0" encoding="UTF-8"?>
    <workflow-app xmlns="uri:oozie:workflow:0.4"
        name="Test workflow">
        <start to="shellAction" />
        <action name="shellAction">
            <shell xmlns="uri:oozie:shell-action:0.1">
                <job-tracker>${jobTracker}</job-tracker>
                <name-node>${nameNode}</name-node>
                <exec>test_script.sh</exec> <file>${nameNode}/${workFlowLocation}/Scripts/test_script.sh#test_script.sh</file>          
                <capture-output />
            </shell>
            <ok to="JavaAction" />
            <error to="fail" />
        </action>
    
        <action name="JavaAction">
            <java>
                <main-class>com.test.TestDriver</main-class>
                <arg>${wf:actionData('shellAction')['dateVariable']}</arg>
                <capture-output />
            </java>
            <ok to="end" />
            <error to="fail" />
        </action>
    
        <kill name="fail">
            <message>Job failed, error
                message[${wf:errorMessage(wf:lastErrorNode())}]</message>
        </kill>
        <end name="end" />
    </workflow-app>
    

    在shell脚本中,回显如下值

     echo "dateVariable=${dateValue}"
    

    【讨论】:

    • 当我这样做时,我得到一个空值作为参数。你能告诉我为什么会这样吗?
    • 您不应该在 shell 中导出变量而不是回显它吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-02
    • 1970-01-01
    • 2018-06-27
    • 2012-02-19
    相关资源
    最近更新 更多