How to pause job execution for availability of the job

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
katragadda86
Participant
Posts: 1
Joined: Thu Oct 08, 2009 4:18 pm

How to pause job execution for availability of the job

Post by katragadda86 »

Hi All,

we have a scenario where job A will be used by sequencers X and Y and we can not make job A multiple instance because of a limitation with the ABAP stage RFC connections.

If X and Y sequencers are started at the same time, one of the sequencers will fail because job A will already be in 'running' status from the other sequencer.

Is there a way we can make the second sequencer wait for the job to become available instead of aborting? something like get job status, if it is not in ready to run status, wait for 30 seconds and re check the job status...

We don't have any external scheduling tools...we run our jobs from director, on demand.

Appreciate your help!


Thanks.
Preethi
Preethi Katragadda
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You could write a custom routine, use the API to check the status of the status of the job in question and then do whatever seems appropriate should it be running. Sleep, check again... repeat as needed. Use a routine activity stage before the job that may need to wait.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Oddly enough, I wrote a function today that does exactly that (although it uses a list of jobs).
The basic skeleton, without the error handling and other calls typed in from memory so there might be some syntax errors is:

Code: Select all

JobHandle=DSAttachJob("YourJobToWaitFor",DSJ.ERRNONE)
Ans = -1
LOOP UNTIL(JobHandle=0)
   JobStatus = DSGetJobInfo(JobHandle,DSJ.JOBSTATUS)
   IF JobStatus <> DSJS.JOBRUNNING
   THEN
      JobHandle = DSDetachJob(JobHandle)
      JobHandle = 0 ;** so we exit the loop
      Ans = 0 ;** return OK status
   END
   ELSE SLEEP 10 ;** sleep 10 seconds before checkig again
REPEAT
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post by arunkumarmm »

Is it not possible to make another copy of the job?

If not maybe you can also simply create a dummy file 'running.txt' at the beginning of the job and delete it in after job sub routine. And use wait for file activity's 'wait for file to disappear' in either of the job sequence to determine the completion of the job.
Arun
Post Reply