Example usage for org.apache.hadoop.mapred RunningJob getJobState

List of usage examples for org.apache.hadoop.mapred RunningJob getJobState

Introduction

In this page you can find the example usage for org.apache.hadoop.mapred RunningJob getJobState.

Prototype

public int getJobState() throws IOException;

Source Link

Document

Returns the current state of the Job.

Usage

From source file:org.sleuthkit.web.sampleapp.server.SampleServiceImpl.java

License:Open Source License

/**
 * process a hadoop job - maintain only "highest order" job info for each image
 * @param tableOfJobs job list/*from ww w  . j  a va 2 s  .c  o  m*/
 * @param parsedJobName job name from hadoop parsed into 4 parts based on naming convention "TP$imageHash$imageId$step"
 * @param js hadoop job status
 * @param rj hadoop running job
 * @throws Exception
 */
private void processJob(List<String[]> tableOfJobs, String[] parsedJobName, JobStatus js, RunningJob rj)
        throws IOException {

    String[] row = findOrCreateJobRow(tableOfJobs, parsedJobName[1], parsedJobName[2]);
    int jobInd = (row[IMAGE_ID] == null) ? -1 : getJobIndex(row[IMAGE_ID]);
    int thisJobInd = getJobIndex(parsedJobName[3]);

    //need to update the same job index too to report progress
    row[IMAGE_ID] = parsedJobName[1]; //hash
    row[JOB_NAME] = parsedJobName[2]; //id

    if (thisJobInd < 0) {
        //ignore it if we already have a task
        //this should not happen: report error and continue
        System.err.println("Unknown job step " + parsedJobName[3] + " for image hash " + parsedJobName[1]);
        row[CUR_TASK] = parsedJobName[3]; //state
        row[TASK_STATUS] = getSimpleJobStatus(rj.getJobState()); //status
        setRowData(row, js);
    } else if (thisJobInd >= jobInd) {
        row[CUR_TASK] = parsedJobName[3]; //state
        row[TASK_STATUS] = getJobStatus(jobStepNames[jobStepNames.length - 1].compareTo(parsedJobName[3]) == 0,
                rj.getJobState(), parsedJobName[1]); //status
        setRowData(row, js);
    }
}

From source file:org.springframework.data.hadoop.mapreduce.JobUtils.java

License:Apache License

/**
 * Returns the status of the given job. May return null indicating accessing the job
 * caused exceptions. /*from   ww  w  .jav  a2  s .c  o m*/
 * 
 * @param job
 * @return the job status
 */
public static JobStatus getStatus(Job job) {
    if (job == null) {
        return JobStatus.UNKNOWN;
    }

    // go first for the running info
    RunningJob runningJob = getRunningJob(job);
    if (runningJob != null) {
        try {
            return JobStatus.fromRunState(runningJob.getJobState());
        } catch (IOException ex) {
            return JobStatus.UNKNOWN;
        }
    }

    // no running info found, assume it's being defined
    return JobStatus.DEFINED;
}