<!--***************************************************************************
Oozie workflow xml file: workflow.xml
*****************************************************************************-->


<workflow-app name="AirawatSampleCoordJobDSDep" xmlns="uri:oozie:workflow:0.1">
  <start to="inputAvailableCheckDecision"/>
        <decision name="inputAvailableCheckDecision">
                <switch>
                        <case to="sqoopAction">
                                ${sqoopInputRecordCount gt minRequiredRecordCount}
                        </case>
                        <default to="end"/>
                </switch>
        </decision>
	<action name="sqoopAction">
                <sqoop xmlns="uri:oozie:sqoop-action:0.2">
                        <job-tracker>${jobTracker}</job-tracker>
                        <name-node>${nameNode}</name-node>
                        <configuration>
                                <property>
                                        <name>oozie.libpath</name>
                                        <value>${oozieLibPath}</value>
                                </property>
                        </configuration>
                        <command>export --connect jdbc:mysql://${mysqlServer}/${mysqlServerDB} --username ${mysqlServerDBUID} --password ${mysqlServerDBPwd} --table Logged_Process_Count_B
y_Year  --direct --export-dir ${triggerDatasetDir} --fields-terminated-by "\t"</command>
                </sqoop>
                <ok to="end"/>
                <error to="sendErrorEmail"/>
        </action>
    	<action name="sendErrorEmail">
    		<email xmlns="uri:oozie:email-action:0.1">
                        <to>${toEmailAddress}</to>
                        <subject>Status of workflow ${wf:id()}</subject>
                        <body>The workflow ${wf:name()} with id -${wf:id()}, had issues and will be killed;  The error logged is: ${wf:errorMessage(wf:lastErrorNode());}</body>
                </email>
                <ok to="killJobAction"/>
                <error to="killJobAction"/>
	</action>
	<kill name="killJobAction">
                <message>"Killed job due to error: ${wf:errorMessage(wf:lastErrorNode())}"</message>
  </kill>
         <end name="end" />
</workflow-app>