Jobs abort list in sequencer

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Rajender
Participant
Posts: 24
Joined: Wed Mar 31, 2004 6:10 am

Jobs abort list in sequencer

Post by Rajender »

Hi Guys,

Requirement: - fetch the over all job status in a sequencer; send an email alert if any of the jobs aborts in the sequencer via control job.

I have a main control job which runs the sequencer in which I have around 30 job activities attached all running as multiple instances.

I believe I have to write this in a main control job that runs the sequencer, hence I was trying to get the over all sequencer status and write the email alert based on that, but the sequencer status is always (Finished OK) even the jobs inside the sequence aborts

Status = DSGetJobInfo(hJob2, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
reply= DSSendMail("From:x\nTo:y\nSubject:load failed\nServer:xx\nBody:%fullreport%")
end
reply= DSSendMail("From:x\nTo:y\nSubject:load success\nServer:xx\nBody:%fullreport%")

Kindly plz advice

Many thanks
R
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

That is due to the fact that you are handling it appropriately within your code. In your present code, you are checking the status and if it fails, you are sending out an email. According to the "Main Job", its executing all the statements properly and hence will not abort.
I think thats a good practice. The sequence finishes gracefully and you get a notification that a job failed. If you really want it to abort then you need to abort it within the code.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: Jobs abort list in sequencer

Post by gateleys »

Won't it fail if you make a call to UtilityAbortToLog after If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then ...? Try that if you want the Sequence to fail as well. But like DSGuru said, you have handled the exception by sending out an email, so it will not abort even if the attached job fails.

gateleys
Rajender
Participant
Posts: 24
Joined: Wed Mar 31, 2004 6:10 am

Post by Rajender »

Guys ,

Can you guide me how to abort the sequencer if any of the jobs inside it aborts, or else can we get the staus of the links or something that might help in this regard

many thanks
R
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What 7.x version? That will change the answers... but typically:

Exception Handler -> Notification Activity -> Routine Activity (UtilityAbortToLog)
-craig

"You can never have too many knives" -- Logan Nine Fingers
Rajender
Participant
Posts: 24
Joined: Wed Mar 31, 2004 6:10 am

Post by Rajender »

chulett,

Its 7.1, is there any other way than the suggested approach, since I have 30 jobs attached in a sequencer and linking all jobs to a exception and notification looks bit messy...

However is there any simple way to abort the main sequencer if any of the jobs inside it fails, so that I can right a simple peace of code in my control job and send the notification?

Many Thanks
R
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Within the job control, you need to use the "DSLogFatal subroutine". Look into it in DataStage Help.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

Rajender wrote:since I have 30 jobs attached in a sequencer and linking all jobs to a exception and notification looks bit messy...
No, you don't need connectors from any of the jobs to the Exception handler. Just add: ExceptionHandler--->Notification--->Terminator (or routine to call DSLogFatal) to your sequence, and check the 'Automatically handle errors' in the sequence properties.

gateleys
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Rajender wrote:However is there any simple way to abort the main sequencer if any of the jobs inside it fails, so that I can right a simple peace of code in my control job and send the notification?
Sure... upgrade. :wink:

Major changes to Sequence functionality in 7.5.x which you will find very helpful in this endeavor.

Gateleys - that advice only applies to 7.5.x versions, pretty sure someone on 7.1 is still stuck with the 'spider on crack' approach. :lol:
-craig

"You can never have too many knives" -- Logan Nine Fingers
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

Within job control, you may make a call after checking the job status-

Code: Select all

Call DSLogFail(SequenceName, 'Job Failed')
gateleys
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You mean DSLogFatal :wink:
Heres the syntax

Code: Select all

Call DSLogFatal (Message,CallingProgName)
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Rajender
Participant
Posts: 24
Joined: Wed Mar 31, 2004 6:10 am

Post by Rajender »

DSguru2b,

Sorry but not clear, how can I make DSLogFatal dynamic i mean it should only abort the main sequence once any of the embedded/attahced job fails

Many Thanks
R
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Ok, i think i am giving solution for aborting the Main Control Job.
If your controlling the process sequence using DS Basic coding, then you make an explicit call to DSLogFatal().
If you are controlling the process via sequence job, then you need to handle it within the sequence. I do not remember if you have routine activity stage in 7.1. If you do then you can call the routine UtilityAbortToLog() if any job fails. Then again, as Craig pointed out, you will have to do that via spider web.
Easy way out, an upgrade :P
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

Rajender wrote:DSguru2b,

Sorry but not clear, how can I make DSLogFatal dynamic i mean it should only abort the main sequence once any of the embedded/attahced job fails

Many Thanks
R
How have you coded your JobControl to attach each job? Now, from the above code that you have supplied, assuming the job handle hJob corresponds to each job currently under execution, then the sequence can be aborted with -

Code: Select all

Status = DSGetJobInfo(hJob, DSJ.JOBSTATUS) 
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then 
reply= DSSendMail("From:x\nTo:y\nSubject:load failed\nServer:xx\nBody:%fullreport%") 
Call DSLogFatal ("Sequence aborted due to failed job", hJob)
end 
gateleys
Post Reply