Search in sources :

Example 1 with TaskAttemptContext

use of org.apache.hadoop.mapred.TaskAttemptContext in project flink by apache.

the class HadoopUtils method instantiateTaskAttemptContext.

public static TaskAttemptContext instantiateTaskAttemptContext(JobConf jobConf, TaskAttemptID taskAttemptID) throws Exception {
    try {
        // for Hadoop 1.xx
        Class<?> clazz = null;
        if (!TaskAttemptContext.class.isInterface()) {
            clazz = Class.forName("org.apache.hadoop.mapred.TaskAttemptContext", true, Thread.currentThread().getContextClassLoader());
        } else // for Hadoop 2.xx
        {
            clazz = Class.forName("org.apache.hadoop.mapred.TaskAttemptContextImpl", true, Thread.currentThread().getContextClassLoader());
        }
        Constructor<?> constructor = clazz.getDeclaredConstructor(JobConf.class, TaskAttemptID.class);
        // for Hadoop 1.xx
        constructor.setAccessible(true);
        TaskAttemptContext context = (TaskAttemptContext) constructor.newInstance(jobConf, taskAttemptID);
        return context;
    } catch (Exception e) {
        throw new Exception("Could not create instance of TaskAttemptContext.", e);
    }
}
Also used : TaskAttemptContext(org.apache.hadoop.mapred.TaskAttemptContext)

Example 2 with TaskAttemptContext

use of org.apache.hadoop.mapred.TaskAttemptContext in project ignite by apache.

the class HadoopV1OutputCollector method commit.

/**
 * Commit task.
 *
 * @throws IOException In failed.
 */
public void commit() throws IOException {
    if (writer != null) {
        OutputCommitter outputCommitter = jobConf.getOutputCommitter();
        TaskAttemptContext taskCtx = new TaskAttemptContextImpl(jobConf, attempt);
        if (outputCommitter.needsTaskCommit(taskCtx))
            outputCommitter.commitTask(taskCtx);
    }
}
Also used : OutputCommitter(org.apache.hadoop.mapred.OutputCommitter) TaskAttemptContextImpl(org.apache.hadoop.mapred.TaskAttemptContextImpl) TaskAttemptContext(org.apache.hadoop.mapred.TaskAttemptContext)

Aggregations

TaskAttemptContext (org.apache.hadoop.mapred.TaskAttemptContext)2 OutputCommitter (org.apache.hadoop.mapred.OutputCommitter)1 TaskAttemptContextImpl (org.apache.hadoop.mapred.TaskAttemptContextImpl)1