Example usage for org.apache.hadoop.mapreduce.lib.jobcontrol ControlledJob getJobState

List of usage examples for org.apache.hadoop.mapreduce.lib.jobcontrol ControlledJob getJobState

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce.lib.jobcontrol ControlledJob getJobState.

Prototype

public synchronized State getJobState() 

Source Link

Usage

From source file:ml.shifu.guagua.mapreduce.GuaguaMapReduceClient.java

License:Apache License

/**
 * Returns the progress of a Job j which is part of a submitted JobControl object. The progress is for this Job. So
 * it has to be scaled down by the number of jobs that are present in the JobControl.
 * //  w  ww .  j a v  a 2  s. co m
 * @param cjob
 *            - The Job for which progress is required
 * @param jobClient
 *            - the JobClient to which it has been submitted
 * @return Returns the percentage progress of this Job
 * @throws IOException
 *             In case any IOException connecting to JobTracker.
 */
protected double progressOfRunningJob(ControlledJob cjob, JobClient jobClient) throws IOException {
    @SuppressWarnings("deprecation")
    RunningJob rj = jobClient.getJob(cjob.getJob().getJobID().toString());
    if (rj == null && cjob.getJobState() == ControlledJob.State.SUCCESS)
        return 1;
    else if (rj == null)
        return 0;
    else {
        return rj.mapProgress();
    }
}