How to run a job in multiple instances

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

irajasekharhexa
Premium Member
Premium Member
Posts: 82
Joined: Fri Jun 03, 2005 5:23 am
Location: Bangalore
Contact:

How to run a job in multiple instances

Post 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
Rajasekhar
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
sportclimber
Charter Member
Charter Member
Posts: 15
Joined: Mon Jan 31, 2005 1:53 pm
Location: CO, USA

Post 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
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Sport,

each job calling the multi-instance job has to use a different instance name.
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post 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
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post 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,
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

How about using the system time as the invocation ID, or some other value.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
adarsh shrinagesh
Premium Member
Premium Member
Posts: 68
Joined: Sat Feb 05, 2005 4:59 am
Location: India

Post 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?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
ameyvaidya
Charter Member
Charter Member
Posts: 166
Joined: Wed Mar 16, 2005 6:52 am
Location: Mumbai, India

Post by ameyvaidya »

Or the

Code: Select all

RND (expression)
should give you a unique number everytime.
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post 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.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ameyvaidya
Charter Member
Charter Member
Posts: 166
Joined: Wed Mar 16, 2005 6:52 am
Location: Mumbai, India

Post 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().
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
Post Reply