简体   繁体   English

在 oozie 工作流(HUE)中,如何将参数从 shell 动作传递到 HDFS fs 动作

[英]In oozie workflow (HUE), how to pass parameter from shell action to HDFS fs action

In My workflow, I have one shell action and an HDFS fs action在我的工作流程中,我有一个 shell 操作和一个 HDFS fs 操作

  1. Shell action echos date.壳牌行动回显日期。 (date=2016-10-06) (日期=2016-10-06)

  2. I want to set the above date parameter in HDFS fs action mkdir path.我想在 HDFS fs action mkdir 路径中设置上述日期参数。 Following is the action definition.以下是动作定义。

     <action name="fs-a347"> <fs> <mkdir path='${nameNode}/user/kylin/${wf:actionData("shell-e424")["date"]}'/> </fs> <ok to="End"/> <error to="Kill"/> </action>

I get the following error.我收到以下错误。

EL_ERROR    Encountered "&", expected one of [<INTEGER_LITERAL>, <FLOATING_POINT_LITERAL>, <STRING_LITERAL>, "true", "false", "null", "(", ")", "-", "not", "!", "empty", <IDENTIFIER>]

You need to concate the two strings to form the complete path.您需要连接两个字符串以形成完整路径。

String concat(String s1, String s2)

It returns the concatenation of 2 strings.它返回 2 个字符串的连接。 A string with null value is considered as an empty string.具有空值的字符串被视为空字符串。

<mkdir path='concat(${nameNode}/user/kylin/, ${wf:actionData("shell-e424")["date"]})'/>

In order to capture the output from your script or any Oozie action node, you need to utilize the <capture-output/> tag at the end of your node definition.为了捕获脚本或任何 Oozie 操作节点的输出,您需要在节点定义的末尾使用<capture-output/>标记。

From the Oozie documentation:来自 Oozie 文档:

If the capture-output element is present, it indicates Oozie to capture output >of the STDOUT of the shell command execution.如果存在 capture-output 元素,则表示 Oozie 捕获 shell 命令执行的 STDOUT 的输出。 The Shell command output must be >in Java Properties file format and it must not exceed 2KB. Shell 命令输出必须是>Java 属性文件格式,并且不得超过 2KB。 From within the >workflow definition, the output of an Shell action node is accessible via the >String action:output(String node, String key) function (Refer to section '4.2.6 >Action EL Functions').在 >workflow 定义中,Shell 操作节点的输出可通过 >String action:output(String node, String key) 函数访问(请参阅“4.2.6 >Action EL 函数”部分)。

The syntax and full specifications can be found on the Oozie documentation for Shell actions here:http://oozie.apache.org/docs/4.0.0/DG_ShellActionExtension.html有关 Shell 操作的 Oozie 文档可以在此处找到语法和完整规范:http ://oozie.apache.org/docs/4.0.0/DG_ShellActionExtension.html

I ran into the same situation, and it's most likely to do with the vagaries of the XML parsing interacting with the wf:actionData() EL function.我遇到了同样的情况,这很可能与 XML 解析与 wf:actionData() EL 函数交互的变幻莫测有关。 Instead of using double quotes for the map, swap to single quotes, like so:不是对地图使用双引号,而是换成单引号,如下所示:

<action name="fs-a347">
    <fs>
        <mkdir path="${nameNode}/user/kylin/${wf:actionData('shell-e424')['date']}"/>
    </fs>
    <ok to="End"/>
    <error to="Kill"/>
</action>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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