Checking for shutdown request

Archive of postings to DataStageUsers@Oliver.com. This forum intended only as a reference and cannot be posted to.

Moderators: chulett, rschirm

Locked
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Checking for shutdown request

Post by admin »

I have a job control job that usually needs to run all the time. It checks for various conditions, runs certain jobs based on those conditions, and then goes to sleep for an interval. Since it is trapped in a job control loop, it does not see requests for shutdown sent from the Director.

Other than the ol look for a record in a control file trick, is there any way to tell a job control to see if the Director has issued a shutdown request?

Regards,

Clif
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Cliff,

I did a bit of looking around and this bit of code might be useful. Realize that since Im actually looking into the engine it may change with future releases. I could not find a routine that would return this value that was out of the box (although there may be one I overlooked, if not it should be put on an enhancement list) Hope this helps..

-Allen

***
Open DS_JOBS TO DSJobs Else Call DSLogFatal(Cant open DS_JOBS file!,) ;! open the jobs file

Read Rec From DSJobs,DSJobName Else Call DSLogFatal(Cant read read my
jobname!,) ;! Read our job record to resolve the actual job number

Open RT_STATUS:Rec to RTStatus Else Call DSLogFatal(Cant open job status file!,) ; Open the respective RT_STATUS file

ForSomeTime = 5 ;! Seconds loop pause number in seconds

Execute SSELECT RT_STATUS:Rec:" WITH F1 = JOB BY-DSND @ID" ;!
Select the file by desending order (the current wave is on top - could also get the wave number)

ReadNext ID Else ID = ;Call DSLogFatal(Problem with reading RT_STATUS
file,) ;! this returnes the record ID on the top (Pops current id off of the result list)

Loop

Read Rec From RTStatus,ID Else Rec = ; Call DSLogFatal(failed to read RT_STATUS Record!,) ;! read the status record

Until Rec = 1 Do ;! if a Stop job has been executed Rec will be 1

! your loop logic to execute goes here




Sleep ForSomeTime

Repeat

*****

----- Original Message -----
From: "Moderator"
To:
Sent: Wednesday, May 30, 2001 11:26 AM
Subject: Checking for shutdown request


> I have a job control job that usually needs to run all the time. It
> checks for various conditions, runs certain jobs based on those
> conditions, and then goes to sleep for an interval. Since it is
> trapped in a job control loop, it does not see requests for shutdown
> sent from the Director.
>
> Other than the ol look for a record in a control file trick, is there
> any way to tell a job control to see if the Director has issued a
> shutdown request?
>
> Regards,
>
> Clif
>
>
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Allen,

How did you determine that field 6 of the JOB record is RT_STATUSnn is job control? I presume you looked in DSINCLUDE/RT_STATUS.H

Did you also look in DSINCLUDE/JOBCONTROL.H where you learn that DSGetJobInfo(hJob, DSJ.JOBCONTROL) returns this information?

Mayhap this is an easier approach?

Regards,
Ray
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

I feel like an altar boy trying to discuss Theology with the Arch Bishops--I dont even know which questions are worthy and which will cause eyes to roll upwards in disbelief. Oh, well. Such is the risk of digging into a new field of endeavor. Thanks in advance for your collective patience and muffled chuckles.

Ok. Ive looked at the DSGetJobInfo docs in the Server manual, chapters 12 and 14. It seems I can query "myself" as DSJ.ME in argument 1 (hJob). But I dont see any reference to DSJ.JOBCONTROL in the doc. (DSJ.JOBCONTROLLER, yes, but not DSJ.JOBCONTROL).

So am I looking for a return value from DSGetJobInfo that tells me if a stop request has been issued? Or a current "wave number" (whatever that is ) with which to apply Allens technique?

Or have I lost the thread of the discussion already? ;-)

Thanks for your help.

Regards,

Clif


Wednesday, May 30, 2001, 7:46:55 PM, you wrote:

> Allen,

> How did you determine that field 6 of the JOB record is RT_STATUSnn is
> job control? I presume you looked in DSINCLUDE/RT_STATUS.H

> Did you also look in DSINCLUDE/JOBCONTROL.H where you learn that
> DSGetJobInfo(hJob, DSJ.JOBCONTROL) returns this information?

> Mayhap this is an easier approach?

> Regards,
> Ray
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Ray is correct. There is some undocumented features to DSGetJobInfo... The following code segment will do the same as what I provided earlier.. So this is supported in the current release - albeit undocumented.

-Allen

***
ForSomeTime = 5 ;! Seconds

Loop

Result = DSGetJobInfo(DSJ.ME,DSJ.JOBCONTROL)

Until Result = 1 Do

! your loop logic to execute goes here

Sleep ForSomeTime

Repeat

**

----- Original Message -----
From: "Moderator"
To: "Ray Wurlod"
Cc: ;
Sent: Wednesday, May 30, 2001 6:47 PM
Subject: Re: Checking for shutdown request


>
>
> I feel like an altar boy trying to discuss Theology with the Arch
> Bishops--I dont even know which questions are worthy and which will
> cause eyes to roll upwards in disbelief. Oh, well. Such is the risk
> of digging into a new field of endeavor. Thanks in advance for your
> collective patience and muffled chuckles.
>
> Ok. Ive looked at the DSGetJobInfo docs in the Server manual,
> chapters 12 and 14. It seems I can query "myself" as DSJ.ME in
> argument 1 (hJob). But I dont see any reference to DSJ.JOBCONTROL in
> the doc. (DSJ.JOBCONTROLLER, yes, but not DSJ.JOBCONTROL).
>
> So am I looking for a return value from DSGetJobInfo that tells me if
> a stop request has been issued? Or a current "wave number" (whatever
> that is ) with which to apply Allens technique?
>
> Or have I lost the thread of the discussion already? ;-)
>
> Thanks for your help.
>
> Regards,
>
> Clif
>
>
> Wednesday, May 30, 2001, 7:46:55 PM, you wrote:
>
> > Allen,
>
> > How did you determine that field 6 of the JOB record is RT_STATUSnn
> > is
job
> > control?
> > I presume you looked in DSINCLUDE/RT_STATUS.H
>
> > Did you also look in DSINCLUDE/JOBCONTROL.H where you learn that
> > DSGetJobInfo(hJob, DSJ.JOBCONTROL) returns this information?
>
> > Mayhap this is an easier approach?
>
> > Regards,
> > Ray
>
>
Locked