Sequencer status inside another sequencer

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

Moderators: chulett, rschirm, roy

bond88
Participant
Posts: 109
Joined: Mon Oct 15, 2012 10:05 am
Location: USA

Sequencer status inside another sequencer

Post 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,
Bhanu
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Sequencer status inside another sequencer

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post 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,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
bond88
Participant
Posts: 109
Joined: Mon Oct 15, 2012 10:05 am
Location: USA

Post 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.
Bhanu
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
bond88
Participant
Posts: 109
Joined: Mon Oct 15, 2012 10:05 am
Location: USA

Post 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,
Bhanu
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post 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.
Arun
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
bond88
Participant
Posts: 109
Joined: Mon Oct 15, 2012 10:05 am
Location: USA

Post 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,
Last edited by bond88 on Thu Sep 26, 2013 2:57 pm, edited 1 time in total.
Bhanu
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Four routine activities.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply