Run Multiple Instance Parallelly

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
chetan.c
Participant
Posts: 112
Joined: Tue Jan 17, 2012 2:09 am
Location: Bangalore

Run Multiple Instance Parallelly

Post by chetan.c »

Hi,

Im trying to run a multiple instance job from a script.
The job instances should run parallely .

So to test it I developed a simple sequence job(Multiple Instance) with Only job activity stage .Its underlying parallel job(Also multiple Instance) reads from a sequential file and writes it to another file.

To trigger them parallely im using the script as below.Its running fine, but wanted to check it its a right way to do it.

Code: Select all

#!bin/bash
dshome='/opt/app/ibm/InformationServer/V87/Server/DSEngine'
cd $dshome

. ./dsenv

cd /etl/stage


function calljob {
  $dshome/bin/dsjob -authfile /home/logon -run -warn 0 -jobstatus -param Instance_number=$1 prjctname SEQ_MULTIPLE_INSTANCE.$1 &
 
}



for i in `ls -c1 Read*`
do
echo -e "Starting $1 instance \n`date +%Y%m%d%H%M%S`"
 calljob $i &
echo -e "Triggered $1 instance \n`date +%Y%m%d%H%M%S`"
done

wait 
In the script i am forking the dsjob command using &.

This is where i want to be check if its a right way to do it.


Thanks,
Chetan.C
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Post by zulfi123786 »

the theme of multiple instance is to make the job run simultaniously but differentiated with the invocation id.

your test should run fine
- Zulfi
chetan.c
Participant
Posts: 112
Joined: Tue Jan 17, 2012 2:09 am
Location: Bangalore

Post by chetan.c »

True.
But when I was testing it ,whats happening is ,the jobs get triggered and the script ends immediately after that wihtout waiting for the job status to return.

So trying to figure out to make the script wait untill all the jobs have completed and then only end the script.


Thanks,
Chetan.C
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Post by zulfi123786 »

You need to use -wait in the dsjob command. Even that will not help as you are forcing the command to be run in the background
- Zulfi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There's no reason to force them to the background, that happens automatically if you don't use one of the wait options. Then check dsjob -jobinfo in a loop until all jobs have completed and see what happened to each one.

It's easier from the BASIC API as you establish a handle to each job you want to run. You can start them all and then pass a comma delimited list of those handles to DSWaitForJob() which will automatically wait for all of them to complete before returning. You'll still have to check each one individually to determine their fate, however.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chetan.c
Participant
Posts: 112
Joined: Tue Jan 17, 2012 2:09 am
Location: Bangalore

Post by chetan.c »

chulett wrote:There's no reason to force them to the background ...
Hi Craig,

Actually i tried without forking the process ( with & removed) the execution of sequences happened sequentially.

But I want to run these instances parallely.So I went for this.
Thats where the wait problem is occuring.

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

Post by chulett »

You left off the most important part of that sentence, the one that said why that happened. Read up on the -jobstatus option.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply