Datastage Multiple instance job to run 'n' times using parm

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

Moderators: chulett, rschirm, roy

Chandrathdsx
Participant
Posts: 59
Joined: Sat Jul 05, 2008 11:32 am

Datastage Multiple instance job to run 'n' times using parm

Post by Chandrathdsx »

Hi,

I have a datastage multiple instance job with name 'JobA', it has a parameter 'ParmA'. I want to run the job number of times of the value of ParmA. Example, if the ParmA value is = 2, the JobA has to run two times with instance id 1 and instance id2. If the ParmA value is 5, The job should run 5 instances simultaneously. I now how to run in loop (runs sequential) or run manually using invocation id 1 to 5. But I want to automate to run the number of times simultaneously depending on the passed parameter ParmA value.

Any help with this on how to implement this use Datastage Sequence?.
The challenge I am having is the value of ParmA is dynamic and it can be 2 or 5 or 10, based on this value those many instances of JobA should run simultaneously.

Thank you!
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Re: Datastage Multiple instance job to run 'n' times using p

Post by kris007 »

You will have to put JobA within another Job Sequence and then use the looping logic with Counter value set to the ParamA value. That way, JobA will run as many times you want with the correct instance ID's.

Hope that helps.
Kris

Where's the "Any" key?-Homer Simpson
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

How will the number of times the job needs to run be determined? Sounds like 'ParamA' needs to be in the Sequence but wondering what 'fills it out'.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

Using loop is 'sequential' but using multi-instance is 'concurrency'. You can achieve this using loop.

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

Post by ray.wurlod »

Using a loop will be sequential. You need to design a separate sequence for each value of N (number of parallel iterations) and a sequence to determine N and select the correct one of these.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You need to use the parameter at the sequence level to determine number of times the job must run.

Use loop activity to iterate through the counter.

Within the loop, branch into 2 stages - one your job and another a sequencer (dummy placeholder).

Join both into another sequencer with 'ANY' option and link this to your end-loop.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Please read the original post a little more carefully.

I know how to run in loop (runs sequential) or run manually using invocation id 1 to 5. But I want to automate to run the number of times simultaneously depending on the passed parameter ParmA value.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Having the ANY sequencer will ensure that all instances will run simultaneously - i.e. in parallel.

Am I missing something ? :roll:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yes, it would seem so. How does "iterating through a loop" get anything running simultaneously? Adding those two stages inside the loop doesn't change the basic functionality of the loop at all, each iteration still runs one job and it all happens in a sequential fashion. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

Its not an easy task if the ParamA is dynamic with no Max value.

In case you have a max value. Use a user variable activity and pass ParamA to a variable. Place as many Job activity as the maximum value.

In trigger define
ParamA>=1
ParamA>=2
ParamA>=3
.
.
.
ParamA>=n

Hence it will trigger as many instances a ParamA at the same time.

In case the value is too high, you can define like 10 at a time and put it in loop with sufficient conditions.


or

call a shell script which triggers a job in loop without -wait or -jobstatus specified (with invocation id as loop counter). and then checks the status in loop too every 5-10 seconds or so.

or

write your own job control.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Exactly, this all comes down to writing your own job control code. That's the only way to fire them off and not start to wait until all have started. The fun part of that would be keeping an array of handles in memory and checking them all properly over and over. :wink:
-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:

Post by ray.wurlod »

Actually that's easy, and is exactly what the job control code generated by compiling a job sequence does. In summary, it makes use of the fact that the DSWaitForJob routine can wait for an array (a dynamic array) of job handles. It returns any time any of the jobs finishes, the code can return to a wait state after that finish has been dealt with until there are no more jobs (activities) being waited for.
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 »

I believe I used the word 'fun' not 'hard'... it is a great learning experience. And a fun problem to solve. :wink:

Oh, and interesting factoid about DSWaitForJob(), I wonder if that has always been the case? For whatever reason and after that had-coded job control, it's something I ever realized or recall being mentioned here. Old dog, meet new trick. :D
-craig

"You can never have too many knives" -- Logan Nine Fingers
creatingfusion
Participant
Posts: 46
Joined: Tue Jul 20, 2010 1:26 pm
Location: USA
Contact:

Re: Datastage Multiple instance job to run 'n' times using p

Post by creatingfusion »

kris007 wrote:You will have to put JobA within another Job Sequence and then use the looping logic with Counter value set to the ParamA value. That way, JobA will run as many times you want with the correct instance ID's.

Hope that helps.
It would be better in this situation to run the job in multiple sequence using Unix Shell Scripting.....
Let the script be rundsjob.sh and the parameter be 'n' notifying the number of instances the job needs to run.
so from unix command promt you call the script as:
sh rundsjob.sh n
where n would be a numeric value you want the job to run the number of times.

now the shell script would be written as under:

#!/bin/sh
#Usage: rundsjob.sh n
i=1
while [ "$i" -le "$1" ]
do
dsjob -run <DataStage_Job_Name>.$i
#Where <DataStage_Job_Name> is the name of the DataStage job you #want to run
done
exit 0

---------------------------------------------------

Hope this solution helps....
Abhijit
IBM Certified Solution Developer Infosphere DataStage
mctny
Charter Member
Charter Member
Posts: 166
Joined: Thu Feb 02, 2006 6:55 am

Post by mctny »

So what is the resolution. I have the same requirement ; running multi instance job N times simultaneously based on the job parameter N.

Is it possible to do it with a job sequence? or it has to be a job control job?
Post Reply