How to get file name dynamically in decision node in OOZIE? How to get file name dynamically in decision node in OOZIE? shell shell

How to get file name dynamically in decision node in OOZIE?


The solution for the above question is, we have to get the date value from coordination job like below code ,inside the coordination job.

<property>    <name>today</name>    <value>${coord:formatTime(coord:dateTzOffset(coord:nominalTime(), "America/Los_Angeles"), 'yyyyMMdd')}</value>  </property>

We can check the file exist or not in given HDFS location with the help fs:exists i.e

${fs:exists(concat(concat(nameNode, path),today))}

And in workflow we have to pass the parameter of the coordination job date value “today” like below code

<workflow-app name="HIVECoWorkflow" xmlns="uri:oozie:workflow:0.5"><start to="CheckFile"/><decision name="CheckFile">     <switch>        <case to="nextOozieTask">          ${fs:exists(concat(concat(nameNode, path),today))}        </case>         <case to="nextOozieTask1">          ${fs:exists(concat(concat(nameNode, path),yesterday))}        </case>        <default to="MailActionFileMissing" />     </switch>  </decision><action name="MailActionFileMissing" cred="hive2">    <hive2 xmlns="uri:oozie:hive2-action:0.1">        <job-tracker>${jobTracker}</job-tracker>        <name-node>${nameNode}</name-node>        <jdbc-url>jdbc:hive2://quickstart.cloudera:10000/default</jdbc-url>        <script>/user/cloudera/email/select.hql</script>        <file>/user/cloudera/hive-site.xml</file>    </hive2>    <ok to="End"/>    <error to="Kill"/></action><action name="nextOozieTask" cred="hive2">    <hive2 xmlns="uri:oozie:hive2-action:0.1">        <job-tracker>${jobTracker}</job-tracker>        <name-node>${nameNode}</name-node>        <jdbc-url>jdbc:hive2://quickstart.cloudera:10000/default</jdbc-url>        <script>/user/cloudera/email/select1.hql</script>        <file>/user/cloudera/hive-site.xml</file>    </hive2>    <ok to="End"/>    <error to="Kill"/></action><kill name="Kill">    <message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message></kill><end name="End"/>

in job.properties we can declare all static values like below.

jobStart=2016-08-23T09:50ZjobEnd=2016-08-23T10:26ZtzOffset=-8initialDataset=2016-08-23T09:50Zoozie.use.system.libpath=Truesecurity_enabled=Falsedryrun=TruejobTracker=localhost:8032nameNode=hdfs://quickstart.cloudera:8020test=${nameNode}/user/cloudera/email1                oozie.coord.application.path=${nameNode}/user/cloudera/email1/add-partition-coord-app.xmlpath=/user/cloudera/file/input/ravi_


May be you can write a shell script which does the hdfs file exists check. Upon success return 0 else 1. Based on this rewrite oozie workflow success and error nodes...