Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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.
Labels (2)
10 Replies
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

Hi
Got you.
You can link tStatCatcher with tJavaRow. And save root_pid into a context variable.
Regards,
Pedro
Anonymous
Not applicable
Author

it works and it was easy to think too 0683p000009MACn.png
thank you very much!
_AnonymousUser
Specialist III
Specialist III

You can use pid public vars of your job: 
    this.pid
    this.fatherPid
    this.rootPid
and assign to tMap columns
_AnonymousUser
Specialist III
Specialist III

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.
Anonymous
Not applicable
Author

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

Anonymous
Not applicable
Author

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.

Anonymous
Not applicable
Author

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