Amit Kumar Kannaujiya
Amit Kumar Kannaujiya

Reputation: 122

how to delay workflow action with oozie coordinator

I have one oozie coordinator and workflow jobs, when my one of workflow action's completed , i need to start next action after some time lets say 50 minutes. Can i configure that from oozie workflow or oozie coordinator to wait for some time to execute next action(depended on previous action and some async task started by previous) .

coordinator xml

<coordinator-app name="ods-ds-cms-coordinator" start="${startTime}" end="${endTime}"
                 frequency="${coord:days(1)}" timezone="${timeZone}" xmlns="uri:oozie:coordinator:0.5">
    <action>
        <workflow>
            <app-path>${exampleDir}/ods-ds-cms-workflow.workflow</app-path>
            <configuration>
                <property>
                    <name>nameNode</name>
                    <value>${nameNode}</value>
                </property>
                <property>
                    <name>jobTracker</name>
                    <value>${jobTracker}</value>
                </property>
                <property>
                    <name>exampleDir</name>
                    <value>${nameNode}/custom/oozie</value>
                </property>
            </configuration>
        </workflow>
    </action>
</coordinator-app>

workflow.xml

<?xml version="1.0" encoding="UTF-8"?>

<workflow-app xmlns="uri:oozie:workflow:0.5" name="ods-ds-cms-workflow.workflow">
  <global>
    <job-tracker>${jobTracker}</job-tracker>
    <name-node>${nameNode}</name-node>
    <configuration>
      <property>
        <name>mapred.job.queue.name</name>
        <value>${queue}</value>
      </property>
    </configuration>
  </global>
  <start to="cms-checker"/>
  <action name="cms-checker">
    <java>
      <main-class>com.insense.helper.CMSPullChecker</main-class>
      <arg>${cmsChecker}</arg>
      <arg>${cmsType}</arg>
      <capture-output/>
    </java>
    <ok to="trigger_next_job"/>
    <error to="kill"/>
  </action>
  <action name="trigger_next_job"> // need to start this after some time
    <sub-workflow>
      <app-path>${exampleDir}/ods-ds-bank.workflow</app-path>
      <propagate-configuration/>
    </sub-workflow>
  <ok to="end"/>
  <error to="kill"/>
  </action>

How can i archive that with oozie framwork, I can do this using java action with Thread.sleep(50*60*1000), is better way to do with oozie ?

Upvotes: 0

Views: 2573

Answers (1)

Mrgr8m4
Mrgr8m4

Reputation: 502

You can create another workflow with only one job - Shell job. Then you should create shell script with one command:

sleep 50m

When one workflow will be completed, you should execute this workflow with sleep command. Next workflow will start after 50 minutes.

Example.

workflow.xml

<workflow-app name="My_Workflow" xmlns="uri:oozie:workflow:0.5">
<start to="shell-3322"/>
<kill name="Kill">
    <message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<action name="shell-3322">
    <shell xmlns="uri:oozie:shell-action:0.1">
        <job-tracker>${jobTracker}</job-tracker>
        <name-node>${nameNode}</name-node>
        <exec>sleep.sh</exec>
        <file>sleep.sh#sleep.sh</file>
          <capture-output/>
    </shell>
    <ok to="End"/>
    <error to="Kill"/>
</action>
<end name="End"/>

sleep.sh

sleep 50m

Upvotes: 2

Related Questions