kar*_*tik 1 java shell hadoop mapreduce oozie
我有一个以下shell脚本:
DATE= date +"%d%b%y" -d "-1 days"
Run Code Online (Sandbox Code Playgroud)
我如何传递DATE给Java动作?
您可以从shell脚本捕获输出并将其传递给java action.在shell脚本中,回显属性,如'dateVariable = $ {DATE}',并在shell操作中添加capture-output元素.这将允许您从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>
Run Code Online (Sandbox Code Playgroud)
在shell脚本中,回显如下的值
echo "dateVariable=${dateValue}"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6029 次 |
| 最近记录: |