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);
}
}
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);
}
}
Aggregations