简体   繁体   English

Oozie Workflow:如何获取当前动作节点名称?

[英]Oozie Workflow : How to get current action node name?

How to get the name of current action in oozie workflow? 如何在oozie工作流中获取当前actionname

Eg : 例如:

<action name="hello_action">
    <shell xmlns="uri:oozie:shell-action:0.1">
        <job-tracker>${jobTracker}</job-tracker>
        <name-node>${nameNode}</name-node>
        <exec>/user/nz/printActionName.sh</exec>
        <argument><!-- PASS current action name i.e. hello_action  --></argument>
        <file>/user/nz/printActionName.sh#printActionName.sh</file>
        <capture-output/>
    </shell>
    <ok to="end"/>
    <error to="fail"/>
</action>

Currently there is no way in Oozie to get the current action node name. 当前,Oozie中无法获取当前操作节点名称。 However, the workaround would be: 但是,解决方法是:

  1. Get workflowId using EL function; 使用EL函数获取workflowId;
  2. Query the workflow status using Oozie API; 使用Oozie API查询工作流程状态;
  3. Get the name of the ID that is running; 获取正在运行的ID的名称;
  4. Split by '@'.,which is your step name 用“ @”分隔,这是您的步骤名称

When Oozie submits the Shell Action to YARN, it ships a XML file with some information about the current Workflow and Action, and sets an env. 当Oozie将Shell Action提交给YARN时,它将附带一个XML文件,其中包含有关当前Workflow和Action的一些信息,并设置一个env。 variable to point to that file. 指向该文件的变量。 Just parse the XML with sed and voila . 只需使用sedvoila解析XML。

if [[ "$CONTAINER_ID" != "" && "$OOZIE_ACTION_CONF_XML" != "" ]]
then
  RawDump=$(/bin/sed -n '/<name>mapreduce.job.name<\/name>/ { N ; s/^.*<value>oozie:action:/:/ ; s/<\/value>.*$/:/ ; p}' "$OOZIE_ACTION_CONF_XML")
  MyOozieWorkflow=$(/bin/echo "$RawDump" | /bin/sed -n '/:W=[^:]*:/ { s/^.*W=// ; s/:.*$// ; p }')
  MyOozieJobId=$(   /bin/echo "$RawDump" | /bin/sed -n '/:ID=[^:]*:/ { s/^.*ID=// ; s/:.*$// ; p }')
  MyOozieAction=$(  /bin/echo "$RawDump" | /bin/sed -n '/:A=[^:]*:/ { s/^.*A=// ; s/:.*$// ; p }')
else
  MyOozieWorkflow='None'
  MyOozieJobId='None'
  MyOozieAction='None'
fi

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

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