org.apache.hadoop.mapreduce
Class OutputCommitter

java.lang.Object
  extended by org.apache.hadoop.mapreduce.OutputCommitter
Direct Known Subclasses:
FileOutputCommitter, OutputCommitter

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract class OutputCommitter
extends Object

OutputCommitter describes the commit of task output for a Map-Reduce job.

The Map-Reduce framework relies on the OutputCommitter of the job to:

  1. Setup the job during initialization. For example, create the temporary output directory for the job during the initialization of the job.
  2. Cleanup the job after the job completion. For example, remove the temporary output directory after the job completion.
  3. Setup the task temporary output.
  4. Check whether a task needs a commit. This is to avoid the commit procedure if a task does not need commit.
  5. Commit of the task output.
  6. Discard the task commit.
The methods in this class can be called from several different processes and from several different contexts. It is important to know which process and which context each is called from. Each method should be marked accordingly in its documentation.

See Also:
FileOutputCommitter, JobContext, TaskAttemptContext

Constructor Summary
OutputCommitter()
           
 
Method Summary
 void abortJob(JobContext jobContext, org.apache.hadoop.mapreduce.JobStatus.State state)
          For aborting an unsuccessful job's output.
abstract  void abortTask(TaskAttemptContext taskContext)
          Discard the task output.
 void cleanupJob(JobContext jobContext)
          Deprecated. Use commitJob(JobContext) and abortJob(JobContext, JobStatus.State) instead.
 void commitJob(JobContext jobContext)
          For committing job's output after successful job completion.
abstract  void commitTask(TaskAttemptContext taskContext)
          To promote the task's temporary output to final output location.
 boolean isRecoverySupported()
          Is task output recovery supported for restarting jobs? If task output recovery is supported, job restart can be done more efficiently.
abstract  boolean needsTaskCommit(TaskAttemptContext taskContext)
          Check whether task needs a commit.
 void recoverTask(TaskAttemptContext taskContext)
          Recover the task output.
abstract  void setupJob(JobContext jobContext)
          For the framework to setup the job output during initialization.
abstract  void setupTask(TaskAttemptContext taskContext)
          Sets up output for the task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputCommitter

public OutputCommitter()
Method Detail

setupJob

public abstract void setupJob(JobContext jobContext)
                       throws IOException
For the framework to setup the job output during initialization. This is called from the application master process for the entire job.

Parameters:
jobContext - Context of the job whose output is being written.
Throws:
IOException - if temporary output could not be created

cleanupJob

@Deprecated
public void cleanupJob(JobContext jobContext)
                throws IOException
Deprecated. Use commitJob(JobContext) and abortJob(JobContext, JobStatus.State) instead.

For cleaning up the job's output after job completion. This is called from the application master process for the entire job.

Parameters:
jobContext - Context of the job whose output is being written.
Throws:
IOException

commitJob

public void commitJob(JobContext jobContext)
               throws IOException
For committing job's output after successful job completion. Note that this is invoked for jobs with final runstate as SUCCESSFUL. This is called from the application master process for the entire job.

Parameters:
jobContext - Context of the job whose output is being written.
Throws:
IOException

abortJob

public void abortJob(JobContext jobContext,
                     org.apache.hadoop.mapreduce.JobStatus.State state)
              throws IOException
For aborting an unsuccessful job's output. Note that this is invoked for jobs with final runstate as JobStatus.State.FAILED or JobStatus.State.KILLED. This is called from the application master process for the entire job.

Parameters:
jobContext - Context of the job whose output is being written.
state - final runstate of the job
Throws:
IOException

setupTask

public abstract void setupTask(TaskAttemptContext taskContext)
                        throws IOException
Sets up output for the task. This is called from each individual task's process that will output to HDFS, and it is called just for that task.

Parameters:
taskContext - Context of the task whose output is being written.
Throws:
IOException

needsTaskCommit

public abstract boolean needsTaskCommit(TaskAttemptContext taskContext)
                                 throws IOException
Check whether task needs a commit. This is called from each individual task's process that will output to HDFS, and it is called just for that task.

Parameters:
taskContext -
Returns:
true/false
Throws:
IOException

commitTask

public abstract void commitTask(TaskAttemptContext taskContext)
                         throws IOException
To promote the task's temporary output to final output location. If needsTaskCommit(TaskAttemptContext) returns true and this task is the task that the AM determines finished first, this method is called to commit an individual task's output. This is to mark that tasks output as complete, as commitJob(JobContext) will also be called later on if the entire job finished successfully. This is called from a task's process.

Parameters:
taskContext - Context of the task whose output is being written.
Throws:
IOException - if commit is not successful.

abortTask

public abstract void abortTask(TaskAttemptContext taskContext)
                        throws IOException
Discard the task output. This is called from a task's process to clean up a single task's output that can not yet been committed.

Parameters:
taskContext -
Throws:
IOException

isRecoverySupported

public boolean isRecoverySupported()
Is task output recovery supported for restarting jobs? If task output recovery is supported, job restart can be done more efficiently.

Returns:
true if task output recovery is supported, false otherwise
See Also:
recoverTask(TaskAttemptContext)

recoverTask

public void recoverTask(TaskAttemptContext taskContext)
                 throws IOException
Recover the task output. The retry-count for the job will be passed via the MRJobConfig.APPLICATION_ATTEMPT_ID key in JobContext.getConfiguration() for the OutputCommitter. This is called from the application master process, but it is called individually for each task. If an exception is thrown the task will be attempted again.

Parameters:
taskContext - Context of the task whose output is being recovered
Throws:
IOException


Copyright © 2012 Apache Software Foundation. All Rights Reserved.