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

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

Introduction

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

Prototype

@Deprecated
public void killTask(String taskId, boolean shouldFail) throws IOException;

Source Link

Usage

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

License:Apache License

/**
 * In our cluster with hadoop-0.20.2-cdh3u4a, runtime exception is thrown to Child but mapper status doesn't change
 * to failed. We fail this task to make sure our fail-over can make job successful.
 *///from   w w  w.  j av a2  s.  c o  m
private void failTask(Throwable t, Configuration conf) {
    LOG.error("failtask: Killing task: {} ", conf.get(GuaguaMapReduceConstants.MAPRED_TASK_ID));
    try {
        org.apache.hadoop.mapred.JobClient jobClient = new org.apache.hadoop.mapred.JobClient(
                (org.apache.hadoop.mapred.JobConf) conf);
        JobID jobId = JobID.forName(conf.get(GuaguaMapReduceConstants.MAPRED_JOB_ID));
        RunningJob job = jobClient.getJob(jobId);
        job.killTask(TaskAttemptID.forName(conf.get(GuaguaMapReduceConstants.MAPRED_TASK_ID)), true);
    } catch (IOException ioe) {
        throw new GuaguaRuntimeException(ioe);
    }
}