Multiple Wait for file stages not running simultaneously

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
rmcclure
Participant
Posts: 48
Joined: Fri Dec 01, 2006 7:50 am

Multiple Wait for file stages not running simultaneously

Post by rmcclure »

Hello,

I am having a problem with running 3 separate Wait for file stages in the same sequencer.

-I need to wait for 3 files
-As soon as all 3 files arrive I need to run a job
-If I don't have the three files in 60 minutes I need the job to timeout.

I put 3 wait for file stages each with a 60 minute timeout connected to a sequencer stage set to "All".
The problem is: It waits 60 minutes for file 1. Once it shows up it waits 60 minutes for file 2, then 60 minutes for file 3. That could take upto 3 hours. I need it to timeout in 60 minutes total.

Is there some way to get all 3 wait for files to run in the same sequence job at the same time or am I stuck creating 3 sequence jobs, one for each Wait for file?
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Re: Multiple Wait for file stages not running simultaneously

Post by qt_ky »

rmcclure wrote:Is there some way to get all 3 wait for files to run in the same sequence job at the same time...
No.
rmcclure wrote:...am I stuck creating 3 sequence jobs, one for each Wait for file?
Not necessarily. There are usually plenty of options. You could create a shell script having the logic you need and call that from a Sequence job.

To do this in a single Sequence job without a shell script would involve using the Start Loop Activity and End Loop Activity stages surrounding the following stages:

Wait For File Activity for file 1 linked to another for file 2 which in turn is linked to another for file 3. Set each one to wait for its file to appear with a timeout length of 00:00:00 for immediate checking. Do not check the "Do not timeout" option. Each of these has two output links, the first of which uses the trigger expression type of OK, the latter of which is set to Otherwise.

The OK links proceed to the next Wait For File stage, with the final OK leading to whatever type of stage or job you want to run after all files are present.

The Otherwise links all lead to the same Sequencer stage, set to Any, which leads to an Execute Command stage containing a sleep command for some number of seconds, perhaps "sleep 300" for 5 minutes. This is your polling interval.

Use a numeric loop to iterate from 1 to some number, perhaps 12 in case you want to check for all files once every 5 minutes for up to an hour.

Off the End Loop, link to a stage type based on what action you want to take place in case not all files are present after all the polling and looping completes.
Choose a job you love, and you will never have to work a day in your life. - Confucius
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Eric has given you a couple of great alternative designs for your requirement.

Sequence jobs are serial in nature (i.e. they complete one task before moving on to the next task).

You can prove this for yourself by looking at the generated BASIC code.

Even though you've visually laid out 3 "parallel" wait for file activities on the canvas, the serial nature produces the results that you observed.

Job activities are the same way, which is why a job sequence is never able to start multiple jobs at exactly the same instant. Job activity stages appear to be parallel simply because they start a job without waiting for it to finish, so it only takes a second or two before it moves on to starting the next job.

Mike
Post Reply