EliranA
EliranA

Reputation: 238

How do I get job counters in Hadoop 2.7.1?

Im trying to get all counters from specific job using java... I've wrote working code for Hadoop 0.23.1:

    JobClient client = new JobClient(new JobConf(createConfiguration()));
    RunningJob job;
    system.out.print("Looking for job with title containing the string '" + jobName + "'");
    List<JobStatus> jobStatusList = Arrays.asList(client.getAllJobs());

    Collections.sort(jobStatusList, new Comparator<JobStatus>() {

        @Override
        public int compare(JobStatus o1, JobStatus o2) {
            return (o1.getStartTime() < o2.getStartTime()) ? 1 : (o1.getStartTime() > o2.getStartTime() ? -1 : 0);
        }
    });

    for (JobStatus jobStatus : jobStatusList) {
        job = client.getJob(jobStatus.getJobID());
        if (job.getJobName().contains(jobName)) {
            system.out.print(String.format("Job Name '%s' was found in job ID: %s...", jobName, jobStatus.getJobID().toString()));
            return job.getCounters();
        }
    }
    system.out.print("Did not find job that contains the string '" + jobName + "'. Counters are set to null.");

Any idea why it's not working in 2.7.1?

Upvotes: 1

Views: 487

Answers (1)

EliranA
EliranA

Reputation: 238

Succeeded with REST API:

http://<history server http address:port>/ws/v1/history/mapreduce/jobs/{jobid}/counters

Upvotes: 1

Related Questions