Search code examples
oozieeventtriggeroozie-coordinatorcrontrigger

Oozie trigger-file based coordinator. trigger file is not from hourly folders


I'm trying to create a coordinator with a dependency file - trigger file. Frequency of my coordinator is 5 minutes. Timeout is 4 minutes.

My goal is that, the coordinator should execute the workflow only if the trigger file specified is created. In case trigger-file was not created coordinator should wait till the file is created and time-out at the end of 4th minute. The workflow deletes the trigger file once the workflow is triggered by coordinator. The trigger file comes whenever the source data is updated and so we have to run workflow again.

The trigger file may come multiple times a day, so I'm setting the coordinator frequency to 5 minutes. I have tried with the following code:

<coordinator-app name="transform_data_if_exists_coord" frequency="${freqMin}" start="${startDate}" end="${endDate}" timezone="${timeZone}" xmlns="uri:oozie:coordinator:0.1">
    <controls>
        <timeout>${timeOutMin}</timeout>
        <concurrency>${concurrencyCount}</concurrency>
    </controls>
    <datasets>
        <dataset name="input1" frequency="${coord:minutes(${freqMin})}" initial-instance="${startDate}" timezone="${timeZone}">
        <uri-template>maprfs:////idn/home/deploy/inputdata/file</uri-template>
        <done-flag>trigger</done-flag>
        </dataset>
   </datasets>

   <action>
      <workflow>
         <app-path>/idn/home/deploy/triggerEmail/triggerEmail_wf.xml</app-path>
      </workflow>
   </action>
</coordinator-app>

With below properties:

startDate=2016-01-26T18:20Z
endDate=2017-01-17T06:00Z
timeZone=UTC
freqMin=5
timeOutMin=4
concurrencyCount=1

Solution

  • You need to add an input event and property WaitForThisInputData in action

        <input-events>
                <data-in name="check_for_input" dataset="input1">
                <instance>${startTime2}</instance>
                </data-in>
         </input-events>
    
      <action>
          <workflow>
             <app-path>/idn/home/deploy/triggerEmail/triggerEmail_wf.xml</app-path>
    <configuration>
                    <property><name>WaitForThisInputData</name><value>${coord:dataIn('check_for_input')}</value></property>
    </configuration>
          </workflow>
       </action
    

    >