Multiple Instances of a Batch

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
mnevotti
Participant
Posts: 10
Joined: Wed Nov 13, 2002 11:02 am

Multiple Instances of a Batch

Post by mnevotti »

Hi everyone,

I am trying to create multiple instances of a batch which call a datastage job. Both the batch and the job have multiple instances enabled. I created the multiple instances of the batch with the invocation Ids, but when the two instances run at the same time, one of the instances gets a "job not in a runnable state" error when it tries to run the job because one of the instances already has it running. Both instances of the batch need to pass in different parameters. Do I need to create multiple instances of the job too? If so, how do I get instance 001 of the batch to call instance 001 of the job and instance 002 of the batch to call instance 002 of the job?

-Melinda
mnevotti
Participant
Posts: 10
Joined: Wed Nov 13, 2002 11:02 am

Post by mnevotti »

I tried somethings and I believe I got it to work. But I am still looking for input from others if anyone has a better way to do this.

In the batch program, here's what I did:
JobID = DSGetJobInfo(DSJ.ME, DSJ.JOBINVOCATIONID)
If JobID NE '' THEN
hDNLoad = DSAttachJob("DNLoad.":JobID, DSJ.ERRFATAL)
End Else
hDNLoad = DSAttachJob("DNLoad", DSJ.ERRFATAL)
End

So I interrogate the batch job for it's invocationid and then use it as the same invocationid for the job.


-Melinda
rwolancz
Participant
Posts: 14
Joined: Fri May 31, 2002 1:30 am
Location: Japan

Post by rwolancz »

You've got the good solution above.

Let me add that if you're using job sequence, you can use macro DSJobInvocationId in the invocation id field of the main job properties.

However, I am having problems running released versions of these jobs. See other thread I created.



Edited by - rwolancz on 12/29/2002 21:26:10
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

If you have two instances of a batch job running at once you can run child jobs in parallel or code a loop to ensure a child job is only run by one of the batch jobs at any one time.

For single instance child jobs retrieve the status of the job, if it is not ready to run you wait a few seconds then try again. Put in a timeout in case the job never becomes runnable.

For the child jobs which are themselves multiple instances just pass through the batch jobs invocationID to those child jobs so they are all easy to identify as belonging to that batch. You set your child job parameters as normal but when you refer to the child job name append the invocation ID onto the end so it attaches a new instance.

regards
Vincent
luca
Participant
Posts: 81
Joined: Wed May 14, 2003 11:34 pm

Post by luca »

Hi All,

I had the same issue and manage to solve it with this topic.

I have one job sequencer (multiple instance) running 3 child jobs (multiple instance too).
In all the job Activities of the job sequencer, I am using one of the job sequencer parameter for "Invocation Id Expression" value.
First question:
Can I use a concatenation of 3 parameters instead of only one parameter? (seems not possible by the choice given by the menu).

Then, when I schedule the job sequencer to run, I have to fill both "Invocation Id" field and the parameter value. In my case, it's entering twice the same.
2nd question:
Is there a way for exemple to use the value of one parameter for the "Invocation Id" ?

Any other information around this is welcomed.

Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The only way to achieve this is to modify the code generated by the sequencer, as I know you do in other jobs.
The new adaptation generates the value needed for one parameter from the other parameter whose value you enter when scheduling the job.
This approach also solves the "concatenation of three parameters" question.

Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

You can use concatenated parameters in sequence jobs. Write a generic concatenate routine, example ConcatParams, with a few input parameters. Add it to your sequence job with a descriptive stage name - Concat3JobParams - and pass it the three parameters.

This routine would accept multiple input parameters, it would concatenate them together and return the result. Blank input parameters would be ignored so only the 3 values passed in are returned.

You could could then use this ConcatMultiParams.ReturnedValue as the value for child job parameters.

Vincent McBurney
Data Integration Services
www.intramatix.com
luca
Participant
Posts: 81
Joined: Wed May 14, 2003 11:34 pm

Post by luca »

Good idea, thanks for your suggestion.
Post Reply