Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

what is the Java API to get current Hadoop Job Id ?

what is the Java API to get current Hadoop Job Id ?

New Contributor

what is the Java API to get current Hadoop Job Id ?

4 REPLIES 4

Re: what is the Java API to get current Hadoop Job Id ?

Super Mentor

@Gopal Krishna

Can you please check if you are looking out for this kind of APIs "JobStatus[] getAllJobStatuses()"

https://github.com/apache/hadoop/blob/release-3.0.0-RC1/hadoop-mapreduce-project/hadoop-mapreduce-cl...

.

Similar discussion you can find here, please check if that helps: https://stackoverflow.com/questions/29644998/how-to-programmatically-get-all-running-jobs-in-a-hadoo...

Re: what is the Java API to get current Hadoop Job Id ?

New Contributor

We are using Oozie scheduler to run our hadoop jobs. We can get job id in ambari when we run job through oozie.

When we are running hadoop jobs manually in putty , we are not able to see job id on the screen.

We are using the below java code to display job id on the screen.

Job job = Job.getInstance(dtsfBatchCleanupUtil.getHadoopConfig());

System.out.println("************ Job :: "+job.toString());

System.out.println("************ Job ID :: "+job.getJobID());


But we are getting IllegaleStateException : Job is in DEFINED State.


Please help on this...

Re: what is the Java API to get current Hadoop Job Id ?

New Contributor

We are using Oozie scheduler to run our hadoop jobs. We can get job id if the job runs through oozie. But we are not able see job id if we run the job manually through putty.

We are using the below code to diplay the job id when we run the job manually.

Job job = Job.getInstance(dtsfBatchCleanupUtil.getHadoopConfig());

System.out.println("************ Job :: "+job.toString());

System.out.println("************ Job ID :: "+job.getJobID());

But we are getting IllegalStateException : Job is in DEFINED state.

Please help on this.

Re: what is the Java API to get current Hadoop Job Id ?

Contributor

I recommend Rest API than Java API, because Java API version problems can make you crazy.

https://hadoop.apache.org/docs/r2.4.1/hadoop-yarn/hadoop-yarn-site/HistoryServerRest.html