Page 1 of 2

How to run a job in multiple instances

Posted: Sat Aug 06, 2005 6:40 am
by irajasekharhexa
Hi,

i have a question that is it possible to run a single job in multiple instances , i mean is it possible to run a job in a multithreading way, as of i know if we open same job repeatedly it displays some message like ' Job is using some other person' .

So can u any body clarify this.

Regds

Posted: Sat Aug 06, 2005 7:47 am
by ArndW
irajasekharhexa ,

DataStage jobs can be declared as "multi instance" and can run any number of times in parallel. Since these jobs are completely separate from each other you need to make sure that they don't attempt to write to the same sequential files or have similar concurrency-related issues.

You can use the "search" facility to see many post on multi-instantiation.

Posted: Thu Aug 11, 2005 10:11 am
by sportclimber
I tried checking "Allow multiple instances" in the job that is called by other jobs. However, when two jobs call my shared job, one will fail while the other is accessing the shared job. The shared job is fully parameterized so that no source files, hash files or target files are overwritten.

Any suggestions?

Thanks much,
Pam

Posted: Thu Aug 11, 2005 10:54 am
by ArndW
Sport,

each job calling the multi-instance job has to use a different instance name.

Posted: Thu Aug 11, 2005 11:04 am
by Titto
ArndW,

I am have same situation. I have JOBSEQ-A calling JOB-B, I created JOB-B as Multi instance job, while i am testing I can provide Invocation Id, but in production how this Invocation Id will popultaed?

Do I need to make JOBSEQ-A and JOB-B as multi instance jobs?

Any help appreciated!

Thanks

Posted: Thu Aug 11, 2005 11:17 am
by ArndW
Titto,

the instance id is alway provided by the caller, either in a Job Sequence (if you call a multi-instance job the job-activity will let you enter an instance, which may be a variable or a parameter; or when you start a job from the Director or even command-line you may also give it an instance name.

The calling jobs do not need to be multi-instance in order to call a multi-instance job.

Posted: Fri Aug 12, 2005 8:54 am
by Titto
Hi ArndW
I am little confused, as you said we need to provide invocation id if we run from director, but my question is if we schedule this job and it is running automatically how the system will provide unique invocation id/parameter.
Hope i am asking correct question..

Thanks,

Posted: Fri Aug 12, 2005 8:56 am
by ArndW
How about using the system time as the invocation ID, or some other value.

Posted: Fri Aug 12, 2005 9:10 am
by ArndW
I should have added you can call the job using {YourJobName}.{Instance}, so you just have to modify your scheduler's command line to include a differing instance.

Posted: Fri Dec 16, 2005 1:07 am
by adarsh shrinagesh
ArndW wrote:How about using the system time as the invocation ID, or some other value.
Hi
We're calling a common job (multiple instance toggled on) from a routine which may be called parallely

My doubt is even if do use the time returned by a timedate() function, it does not guarantee uniqueness of invocation id value...timedate gives me a value to the second not microseconds...

Is there any other way to fetch the lowest free invocation id value...

any Ideas?

Posted: Fri Dec 16, 2005 2:24 am
by ArndW
The invocation ID is a string value, and you would be retrieving from a sequencer, so you might have timing issues there as well. You can use a combination of system date/time and the PID of the sequencer. I'm not at a DS machine now, but I think you could get this either through a command stage or a routine - if you look in the BASIC manual under the SYSTEM() function you will see that one of them returns your process id. That, coupled with a timestamp, will be guaranteed to be unique.

Posted: Fri Dec 16, 2005 11:38 am
by ameyvaidya
Or the

Code: Select all

RND (expression)
should give you a unique number everytime.

Posted: Fri Dec 16, 2005 11:54 am
by kcbland
ameyvaidya wrote:Or the

Code: Select all

RND (expression)
should give you a unique number everytime.
Have you tried it? Are you sure 100% of the time two simultaneous processes won't generate the same random number? What will prevent that?


The easiest solution is to use the process ID. Two job control processes will be executing under their own process ID (PID), so you're safe to use that.

Posted: Fri Dec 16, 2005 3:44 pm
by ameyvaidya
Sorry People(And thanks Ken),
I had not tried it out and it does not work for multipe parallel processes.

It generates the same numbers for multiple processes running in parallel.

The way out is to use the randomize(@NULL) before calling rnd().

Posted: Sat Dec 17, 2005 2:37 am
by ArndW
Using RANDOMIZE(@NULL) will not do what you expect. You should use a seed to ensure the beginning position in your random number sequence is as random as possible, and @NULL will always return the same series. I usually seed a random series with @DATE+@TIME+@USERNO and this will get a different number every time.

Please note that random numbers by their nature are repeatable; so by adding a random number to your unique identifier you are reducing the likelihood of a collision but not guaranteeing it. If you stick with the UNIX PID you are guaranteeing uniqueness and it is simpler to understand as well.

There are some great uses for pseudo-random number generators. This is not one of them.