getting root_pid

One Star

getting root_pid

Hello,
I saw in the tStatCatcher that Talend creates a pid for each job executing.
If I have a job which calls some subjobs, pid are of 3 kinds:
- pid
- father_pid
- root_pid
I need, from every subjob to get the root_pid cause I need to put it in some tMaps.
Is it possible?
Thanks in advance.
One Star

Re: getting root_pid

Hi
The root_pids of the main job and subjobs are the same. It is the pid of main job.
Or I misunderstand what you mean?
Regards,
Pedro
One Star

Re: getting root_pid

This is a tStatCatcher line for one subjob:
2012-05-14 18:52:57|qTZYuj|gsFcBS|gsFcBS|15376|<Job_Name>|<Subjob_Name>|_gdIUwJp3EeGVbY8mRw3pmg|0.1|Default||end|success|12546
I noted the the 3rd,4rd and the 5th code are different because are referred to:
- the pid of the current subjob executing
- the pid of the father who called the subjob which is executing
- the pid of the root job (the main job)
I want the root job (the fifth code).
I saw I can get the 3rd code by using the variable "pid".
Is there a way to get the root_pid code?
I hope to have been clear.
Thanks
One Star

Re: getting root_pid

Hi
Got you.
You can link tStatCatcher with tJavaRow. And save root_pid into a context variable.
Regards,
Pedro
One Star

Re: getting root_pid

it works and it was easy to think too Smiley Happy
thank you very much!
One Star

Re: getting root_pid

You can use pid public vars of your job: 
    this.pid
    this.fatherPid
    this.rootPid
and assign to tMap columns
One Star

Re: getting root_pid

I just want to know that root pid is always unique ..its means in every instance can talend generate unique root pid.
I want to add job id in my job but i'm not getting any variable for that in Talend.
Seven Stars

Re: getting root_pid

In which way I can do it? 

I have linked tStatLogCatcher to tJava. In tJava I have: context.pid = input_row.pid, but id does not work

Sixteen Stars

Re: getting root_pid

This looks like it is getting a bit obfuscated. The pids are very simple. They are also available in ALL jobs. Lets look at a basic job. A single level job.

 

If you add a tJava in a simple job with the following code....

System.out.println(pid);
System.out.println(fatherPid);
System.out.println(rootPid);

....they will all print the same thing.

 

Let's say you have a parent job and a child job. Add the same code in the child job and the rootPid and fatherPid will have the same output, the pid will be different. The pid corresponds to the process id of the actual job that is running. The fatherPid corresponds to the job containing the job that is running. The rootPid corresponds to the top level job that is running.

 

Top level Job (pid=1234)
|

Second level Job (pid=5678)

|

Third level Job (pid=abcd)

|

Fourth level Job (pid = efgh)

 

Top level Job's pid = 1234, its fatherPid = 1234 and its rootPid is 1234

Second level Job's pid = 5678, its fatherPid = 1234 and its rootPid is 1234

Third level Job's pid = abcd, its fatherPid = 5678 and its rootPid is 1234

Fourth level Job's pid = efgh, its fatherPid = abcd and its rootPid is 1234

 

You can access the pid, fatherPid and rootPid easily just by using those variables in all jobs.

Seven Stars

Re: getting root_pid

Thank you very much for the explanation! Truly helpul!!

Four Stars

Re: getting root_pid

You can use pid public vars of your job : 

this.pid
this.fatherPid
this.rootPid

and use it in tjava or assign to tMap columns ...

It works with Talend 6 at least.
(thanks to jordimorato)

 

PS : I found all this variables who could be utiles :

this.jobName
this.jobVersion
this.projectName
this.contextStr