How to get the name
of current action
in oozie workflow?
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. However, the workaround would be:
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. variable to point to that file. Just parse the XML with sed and voila .
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.