Page 1 of 2

Sequencer status inside another sequencer

Posted: Tue Sep 10, 2013 2:21 pm
by bond88
Hi,
I need to run 5 sequencers and I schedule all these under run director daily. But there is no control of one sequencer over another. I want to kickoff last sequencer if only first 4 sequencers run successfully. I scheduled sequencers like below.

Sequencer 1 - 02:00 am
Sequencer 2 - 03:30 am
Sequencer 3 - 04:45 am
Sequencer 4 - 05:00 am
Sequencer 5 - 06:45 am

Sequencer 5 has to run if sequencer 1 to 4 run successful. Please suggest me a way to achieve this.

Thank you,

Posted: Tue Sep 10, 2013 3:22 pm
by chulett
A custom routine in #5 can use the API to "get job info" to check the last run status for the previous four and pass back the result. A trigger can then decide if the fifth one should do anything or not.

Re: Sequencer status inside another sequencer

Posted: Tue Sep 10, 2013 4:16 pm
by ray.wurlod
bond88 wrote:I need to run 5 sequencers
No you don't. You need to run five sequences.
A Sequencer is something you use within a Sequence to bring flows of logic together - it has the big blue arrow and three "lights" as its icon.

Indeed, a Sequencer may hold your solution. In your master sequence, which runs these five sequences using Job activities, take Success triggers from the first four into an "All" Sequencer, and the fifth sequence is downstream of that.

Posted: Tue Sep 10, 2013 4:37 pm
by chulett
Would have gone that route except for the time component to the scheduling. Hence the suggestion to have the Sequence job that runs last at 6:45am first check the status of the other four to see if (when it runs) if it needs to actually do anything or just shut down and wait for next time.

Me, I'd probably have it send out an email saying it couldn't run due to failures in the previous jobs rather than doing literally nothing, although that is certainly an option.

Posted: Wed Sep 11, 2013 7:18 am
by roy
I bet the time of the scheduals is derived from the need to sequence them one after the other.
By the way, if your using any schedualer (organization wide) you can also define those dependancies there.
IHTH,

Posted: Thu Sep 12, 2013 2:59 pm
by bond88
Thank you Craig,
Could you please throw some light on me regarding custom routine? I haven't had a chance to work with routines. Do I need to define each routine in 4 different sequencers and one in final one or just only in final sequencer.

Posted: Thu Sep 12, 2013 3:29 pm
by chulett
Just one routine at the start of the final Sequence. Look into the DSGetJobInfo function with an InfoType of DSJ.JOBSTATUS, one call for each of the previous four Sequence jobs. Each should return DSJS.RUNOK for the routine to pass back an "Ans" that you would check in the attached trigger.

Other functions you'll need (they're all in the link above):

DSAttachJob
DSAttachJob


I'd suggest passing back a 0 if all JobInfo calls return "ran ok" (which will be seen as success) or a 1 if any of them fail, which will be seen as a "failure" of the routine. Or you can pass back a 'Y' or 'N', whatever works for you. Good result back? Move on to the rest of the steps. Bad result? End the Sequence or perhaps send out an email that it couldn't run.

Posted: Thu Sep 12, 2013 3:39 pm
by chulett
An exact search here for "dsgetjobinfo" and/or "dsj.jobstatus" should turn up code samples you can steal as a starting point. :wink:

For example, here. Cherry pick the parts out of that and/or other posts and put some effort into getting something together you think is close. Post your resulting code here and we'll take a look at it.

Posted: Thu Sep 12, 2013 3:59 pm
by bond88
Craig,
It looks like a silly question. But I didn't get the starting point to look in to routine and code writable area. Just to make sure is it Routine Activity stage or something else? Routine activity stage is under sequence Palette.

Thank you,

Posted: Thu Sep 12, 2013 5:07 pm
by chulett
Yes, you would create a custom routine and then use a Routine Activity stage in the last Sequence job to run it... first. Depending on what it returns, you either execute all the stuff you have in there now (whatever that is) or do nothing.

Posted: Fri Sep 13, 2013 8:47 am
by arunkumarmm
Or what I will do is, create a small server job with just a transformer and a hashed file and update the status of each job sequence by calling this job in each of the 4 job sequences at success or failure ends and use UtilityHashLookUp in my 5th job sequence to see the status of the other 4.

Posted: Fri Sep 13, 2013 10:16 am
by chulett
This may just be me but I consider routine writing an essential skill needed by a DataStage developer. But then so is knowing when to use a Server job for something. :wink:

This would be pretty simple as far routines go so (IMHO) a good place to start the learning ball rolling.

Posted: Thu Sep 26, 2013 2:56 pm
by bond88
Hi Craig,

I designed a server routine with type: Transform_function and in the code section I wrote below code

$INCLUDE DSINCLUDE JOBCONTROL.H
handle=DSAttachJob (Arg1,DSJ.ERRFATAL)
if handle <> 0 Then
jobName=DSGetJobInfo(handle,DSJ.JOBNAME)
jobStatus=DSGetJobInfo(handle,DSJ.JOBSTATUS)
Ans=jobStatus
End

and when I run this routine it is asking arguments and when I gave 4 sequencer names as arguments in 4 lines it is returning 1 in all rows. Now how can I implement this in 5th sequencer. Please advise me.

Thank you,

Posted: Fri Sep 27, 2013 1:08 am
by ray.wurlod
Four routine activities.

Posted: Fri Sep 27, 2013 7:26 am
by chulett
Or just one. I for one see no need for this to be any kind of 'generic' routine that you call four times. In your shoes I would have one dedicated routine that (one after the other) checks all four by name and then decides what to pass back based on the result. Did all four run successfully? Pass back your 'go' condition, whatever you decide that should be. One or more did not run successfully? Return your 'do not go' condition.

As to your question and regardless which design you use - call it first and have a trigger that checks for whatever success looks like running to the next (formerly first) activity, in your current design that sounds like it would be four success results strung together. If all you need to do is NOT run anything when there are failures, that's all you need - the routine will run but nothing else will and the fifth sequence will simply end. If you need to do something - abort, email - when there are failures, add another trigger with an Otherwise condition to catch that.