Class StagingCommitter
java.lang.Object
org.apache.hadoop.mapreduce.OutputCommitter
org.apache.hadoop.mapreduce.lib.output.PathOutputCommitter
org.apache.hadoop.fs.s3a.commit.AbstractS3ACommitter
org.apache.hadoop.fs.s3a.commit.staging.StagingCommitter
- All Implemented Interfaces:
org.apache.hadoop.fs.statistics.IOStatisticsSource
- Direct Known Subclasses:
DirectoryStagingCommitter,PartitionedStagingCommitter
Committer based on the contributed work of the
Netflix multipart committers.
- The working directory of each task is actually under a temporary path in the local filesystem; jobs write directly into it.
- Task Commit: list all files under the task working dir, upload each of them but do not commit the final operation. Persist the information for each pending commit into the cluster for enumeration and commit by the job committer.
- Task Abort: recursive delete of task working dir.
- Job Commit: list all pending PUTs to commit; commit them.
- Job Abort: list all pending PUTs to commit; abort them. Delete all task attempt directories.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.fs.s3a.commit.AbstractS3ACommitter
AbstractS3ACommitter.ActiveCommit, AbstractS3ACommitter.JobUUIDSource -
Field Summary
FieldsFields inherited from class org.apache.hadoop.fs.s3a.commit.AbstractS3ACommitter
E_SELF_GENERATED_JOB_UUID, THREAD_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionStagingCommitter(org.apache.hadoop.fs.Path outputPath, org.apache.hadoop.mapreduce.TaskAttemptContext context) Committer for a single task attempt. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidabortJobInternal(CommitContext commitContext, boolean suppressExceptions) The internal job abort operation; can be overridden in tests.voidabortTask(org.apache.hadoop.mapreduce.TaskAttemptContext context) Abort the task.protected voidcleanup(CommitContext commitContext, boolean suppressExceptions) Staging committer cleanup includes calling wrapped committer's cleanup method, and removing staging uploads path and all destination paths in the final filesystem.voidClean up any staging directories.voidcommitTask(org.apache.hadoop.mapreduce.TaskAttemptContext context) protected intcommitTaskInternal(org.apache.hadoop.mapreduce.TaskAttemptContext context, List<? extends org.apache.hadoop.fs.FileStatus> taskOutput, CommitContext commitContext) Commit the task by uploading all created files and then writing a pending entry for them.protected org.apache.hadoop.mapreduce.lib.output.FileOutputCommittercreateWrappedCommitter(org.apache.hadoop.mapreduce.JobContext context, org.apache.hadoop.conf.Configuration conf) Create the wrapped committer.protected voiddeleteDestinationPaths(org.apache.hadoop.mapreduce.JobContext context) Delete the working paths of a job.protected voiddeleteStagingUploadsParentDirectory(org.apache.hadoop.mapreduce.JobContext context) Delete the multipart upload staging directory.protected voiddeleteTaskWorkingPathQuietly(org.apache.hadoop.mapreduce.JobContext context) Delete the working path of a task; no-op if there is none, that is: this is a job.protected org.apache.hadoop.fs.PathExistsExceptionfailDestinationExists(org.apache.hadoop.fs.Path path, String description) Generate aPathExistsExceptionbecause the destination exists.org.apache.hadoop.fs.PathgetBaseTaskAttemptPath(org.apache.hadoop.mapreduce.TaskAttemptContext context) Return the local work path as the destination for writing work.protected org.apache.hadoop.fs.PathgetCommittedTaskPath(int appAttemptId, org.apache.hadoop.mapreduce.TaskAttemptContext context) Compute the path where the output of a committed task is stored until the entire job is committed for a specific application attempt.org.apache.hadoop.fs.PathgetCommittedTaskPath(org.apache.hadoop.mapreduce.TaskAttemptContext context) Compute the path where the output of a committed task is stored until the entire job is committed.static StringgetConfictModeOption(org.apache.hadoop.mapreduce.JobContext context, org.apache.hadoop.conf.Configuration fsConf, String defVal) Get the conflict mode option string.final ConflictResolutiongetConflictResolutionMode(org.apache.hadoop.mapreduce.JobContext context, org.apache.hadoop.conf.Configuration fsConf) Returns theConflictResolutionmode for this commit.protected StringgetFinalKey(String relative, org.apache.hadoop.mapreduce.JobContext context) Returns the final S3 key for a relative path.protected final org.apache.hadoop.fs.PathgetFinalPath(String relative, org.apache.hadoop.mapreduce.JobContext context) Returns the final S3 location for a relative path as a HadoopPath.org.apache.hadoop.fs.FileSystemgetJobAttemptFileSystem(org.apache.hadoop.mapreduce.JobContext context) Get the filesystem for the job attempt.protected org.apache.hadoop.fs.PathgetJobAttemptPath(int appAttemptId) Compute the path where the output of a given job attempt will be placed.org.apache.hadoop.fs.PathgetJobAttemptPath(org.apache.hadoop.mapreduce.JobContext context) For a job attempt path, the staging committer returns that of the wrapped committer.static org.apache.hadoop.fs.PathgetJobAttemptPath(org.apache.hadoop.mapreduce.JobContext context, org.apache.hadoop.fs.Path out) Compute the path where the output of a given job attempt will be placed.protected org.apache.hadoop.fs.PathCompute the path under which all job attempts will be placed.getName()Get the name of this committer.static org.apache.hadoop.fs.PathgetTaskAttemptPath(org.apache.hadoop.mapreduce.TaskAttemptContext context, org.apache.hadoop.fs.Path out) Compute the path where the output of a task attempt is stored until that task is committed.protected List<org.apache.hadoop.fs.LocatedFileStatus>getTaskOutput(org.apache.hadoop.mapreduce.TaskAttemptContext context) Lists the output of a task under the task attempt path.org.apache.hadoop.fs.PathgetTempTaskAttemptPath(org.apache.hadoop.mapreduce.TaskAttemptContext context) Get a temporary directory for data.protected voidinitFileOutputCommitterOptions(org.apache.hadoop.mapreduce.JobContext context) Init the context config with everything needed for the file output committer.protected AbstractS3ACommitter.ActiveCommitlistPendingUploads(CommitContext commitContext, boolean suppressExceptions) Get the list of pending uploads for this job attempt.protected AbstractS3ACommitter.ActiveCommitlistPendingUploadsToAbort(CommitContext commitContext) Get the list of pending uploads for this job attempt, swallowing exceptions.protected AbstractS3ACommitter.ActiveCommitlistPendingUploadsToCommit(CommitContext commitContext) Get the list of pending uploads for this job attempt.booleanneedsTaskCommit(org.apache.hadoop.mapreduce.TaskAttemptContext context) voidpreCommitJob(CommitContext commitContext, AbstractS3ACommitter.ActiveCommit pending) Pre-commit actions for a job.voidsetupJob(org.apache.hadoop.mapreduce.JobContext context) Set up the job, including calling the same method on the wrapped committer.voidsetupTask(org.apache.hadoop.mapreduce.TaskAttemptContext context) Task setup.toString()Is this committer using unique filenames?Methods inherited from class org.apache.hadoop.fs.s3a.commit.AbstractS3ACommitter
abortJob, abortPendingUploads, abortPendingUploads, abortPendingUploadsInCleanup, buildJobUUID, cleanupJob, commitJob, commitJobInternal, commitPendingUploads, deleteTaskAttemptPathQuietly, getAuditSpanSource, getCommitOperations, getConf, getDestFS, getDestinationFS, getDestS3AFS, getIOStatistics, getJobContext, getOutputPath, getRole, getTaskAttemptFilesystem, getTaskAttemptPath, getUUID, getUUIDSource, getWorkPath, initiateJobOperation, initiateTaskOperation, initOutput, jobCompleted, maybeCreateSuccessMarker, maybeCreateSuccessMarkerFromCommits, maybeIgnore, maybeIgnore, precommitCheckPendingFiles, recoverTask, requiresDelayedCommitOutputInFileSystem, setConf, setDestFS, setOutputPath, setWorkPath, startOperation, updateCommonContext, warnOnActiveUploadsMethods inherited from class org.apache.hadoop.mapreduce.lib.output.PathOutputCommitter
hasOutputPathMethods inherited from class org.apache.hadoop.mapreduce.OutputCommitter
isCommitJobRepeatable, isRecoverySupported, isRecoverySupported
-
Field Details
-
NAME
Name: "staging".- See Also:
-
-
Constructor Details
-
StagingCommitter
public StagingCommitter(org.apache.hadoop.fs.Path outputPath, org.apache.hadoop.mapreduce.TaskAttemptContext context) throws IOException Committer for a single task attempt.- Parameters:
outputPath- final output pathcontext- task context- Throws:
IOException- on a failure
-
-
Method Details
-
getName
Description copied from class:AbstractS3ACommitterGet the name of this committer.- Specified by:
getNamein classAbstractS3ACommitter- Returns:
- the committer name.
-
createWrappedCommitter
protected org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter createWrappedCommitter(org.apache.hadoop.mapreduce.JobContext context, org.apache.hadoop.conf.Configuration conf) throws IOException Create the wrapped committer. This includes customizing its options, and setting up the destination directory.- Parameters:
context- job/task context.conf- config- Returns:
- the inner committer
- Throws:
IOException- on a failure
-
initFileOutputCommitterOptions
protected void initFileOutputCommitterOptions(org.apache.hadoop.mapreduce.JobContext context) Init the context config with everything needed for the file output committer. In particular, this code currently only works with commit algorithm 1.- Parameters:
context- context to configure.
-
toString
- Overrides:
toStringin classAbstractS3ACommitter
-
useUniqueFilenames
Is this committer using unique filenames?- Returns:
- true if unique filenames are used.
-
getJobAttemptFileSystem
public org.apache.hadoop.fs.FileSystem getJobAttemptFileSystem(org.apache.hadoop.mapreduce.JobContext context) throws IOException Get the filesystem for the job attempt.- Parameters:
context- the context of the job. This is used to get the application attempt ID.- Returns:
- the FS to store job attempt data.
- Throws:
IOException- failure to create the FS.
-
getJobAttemptPath
public static org.apache.hadoop.fs.Path getJobAttemptPath(org.apache.hadoop.mapreduce.JobContext context, org.apache.hadoop.fs.Path out) Compute the path where the output of a given job attempt will be placed.- Parameters:
context- the context of the job. This is used to get the application attempt ID.out- the output path to place these in.- Returns:
- the path to store job attempt data.
-
getJobAttemptPath
protected org.apache.hadoop.fs.Path getJobAttemptPath(int appAttemptId) Description copied from class:AbstractS3ACommitterCompute the path where the output of a given job attempt will be placed.- Specified by:
getJobAttemptPathin classAbstractS3ACommitter- Parameters:
appAttemptId- the ID of the application attempt for this job.- Returns:
- the path to store job attempt data.
-
getJobPath
protected org.apache.hadoop.fs.Path getJobPath()Compute the path under which all job attempts will be placed.- Specified by:
getJobPathin classAbstractS3ACommitter- Returns:
- the path to store job attempt data.
-
getTaskAttemptPath
public static org.apache.hadoop.fs.Path getTaskAttemptPath(org.apache.hadoop.mapreduce.TaskAttemptContext context, org.apache.hadoop.fs.Path out) Compute the path where the output of a task attempt is stored until that task is committed.- Parameters:
context- the context of the task attempt.out- The output path to put things in.- Returns:
- the path where a task attempt should be stored.
-
getCommittedTaskPath
public org.apache.hadoop.fs.Path getCommittedTaskPath(org.apache.hadoop.mapreduce.TaskAttemptContext context) Compute the path where the output of a committed task is stored until the entire job is committed.- Parameters:
context- the context of the task attempt- Returns:
- the path where the output of a committed task is stored until the entire job is committed.
-
getCommittedTaskPath
protected org.apache.hadoop.fs.Path getCommittedTaskPath(int appAttemptId, org.apache.hadoop.mapreduce.TaskAttemptContext context) Compute the path where the output of a committed task is stored until the entire job is committed for a specific application attempt.- Parameters:
appAttemptId- the ID of the application attempt to usecontext- the context of any task.- Returns:
- the path where the output of a committed task is stored.
-
getTempTaskAttemptPath
public org.apache.hadoop.fs.Path getTempTaskAttemptPath(org.apache.hadoop.mapreduce.TaskAttemptContext context) Description copied from class:AbstractS3ACommitterGet a temporary directory for data. When a task is aborted/cleaned up, the contents of this directory are all deleted.- Specified by:
getTempTaskAttemptPathin classAbstractS3ACommitter- Parameters:
context- task context- Returns:
- a path for temporary data.
-
getTaskOutput
protected List<org.apache.hadoop.fs.LocatedFileStatus> getTaskOutput(org.apache.hadoop.mapreduce.TaskAttemptContext context) throws IOException Lists the output of a task under the task attempt path. Subclasses can override this method to change how output files are identified.This implementation lists the files that are direct children of the output path and filters hidden files (file names starting with '.' or '_').
The task attempt path is provided by
AbstractS3ACommitter.getTaskAttemptPath(TaskAttemptContext)- Parameters:
context- this task'sTaskAttemptContext- Returns:
- the output files produced by this task in the task attempt path
- Throws:
IOException- on a failure
-
getFinalKey
Returns the final S3 key for a relative path. Subclasses can override this method to upload files to a different S3 location.This implementation concatenates the relative path with the key prefix from the output path. If
CommitConstants.FS_S3A_COMMITTER_STAGING_UNIQUE_FILENAMESis set, then the task UUID is also included in the calculation- Parameters:
relative- the path of a file relative to the task attempt pathcontext- the JobContext or TaskAttemptContext for this job- Returns:
- the S3 key where the file will be uploaded
-
getFinalPath
protected final org.apache.hadoop.fs.Path getFinalPath(String relative, org.apache.hadoop.mapreduce.JobContext context) throws IOException Returns the final S3 location for a relative path as a HadoopPath. This is a final method that callsgetFinalKey(String, JobContext)to determine the final location.- Parameters:
relative- the path of a file relative to the task attempt pathcontext- the JobContext or TaskAttemptContext for this job- Returns:
- the S3 Path where the file will be uploaded
- Throws:
IOException- IO problem
-
getBaseTaskAttemptPath
public org.apache.hadoop.fs.Path getBaseTaskAttemptPath(org.apache.hadoop.mapreduce.TaskAttemptContext context) Return the local work path as the destination for writing work.- Specified by:
getBaseTaskAttemptPathin classAbstractS3ACommitter- Parameters:
context- the context of the task attempt.- Returns:
- a path in the local filesystem.
-
getJobAttemptPath
public org.apache.hadoop.fs.Path getJobAttemptPath(org.apache.hadoop.mapreduce.JobContext context) For a job attempt path, the staging committer returns that of the wrapped committer.- Overrides:
getJobAttemptPathin classAbstractS3ACommitter- Parameters:
context- the context of the job.- Returns:
- a path in HDFS.
-
setupJob
Set up the job, including calling the same method on the wrapped committer.- Overrides:
setupJobin classAbstractS3ACommitter- Parameters:
context- job context- Throws:
IOException- IO failure.
-
listPendingUploadsToCommit
protected AbstractS3ACommitter.ActiveCommit listPendingUploadsToCommit(CommitContext commitContext) throws IOException Get the list of pending uploads for this job attempt.- Specified by:
listPendingUploadsToCommitin classAbstractS3ACommitter- Parameters:
commitContext- job context- Returns:
- a list of pending uploads.
- Throws:
IOException- Any IO failure
-
listPendingUploadsToAbort
protected AbstractS3ACommitter.ActiveCommit listPendingUploadsToAbort(CommitContext commitContext) throws IOException Get the list of pending uploads for this job attempt, swallowing exceptions.- Parameters:
commitContext- commit context- Returns:
- a list of pending uploads. If an exception was swallowed, then this may not match the actual set of pending operations
- Throws:
IOException- shouldn't be raised, but retained for the compiler
-
listPendingUploads
protected AbstractS3ACommitter.ActiveCommit listPendingUploads(CommitContext commitContext, boolean suppressExceptions) throws IOException Get the list of pending uploads for this job attempt.- Parameters:
commitContext- commit contextsuppressExceptions- should exceptions be swallowed?- Returns:
- a list of pending uploads. If exceptions are being swallowed, then this may not match the actual set of pending operations
- Throws:
IOException- Any IO failure which wasn't swallowed.
-
cleanupStagingDirs
public void cleanupStagingDirs()Description copied from class:AbstractS3ACommitterClean up any staging directories. IOEs must be caught and swallowed.- Specified by:
cleanupStagingDirsin classAbstractS3ACommitter
-
cleanup
Staging committer cleanup includes calling wrapped committer's cleanup method, and removing staging uploads path and all destination paths in the final filesystem.- Overrides:
cleanupin classAbstractS3ACommitter- Parameters:
commitContext- commit contextsuppressExceptions- should exceptions be suppressed?- Throws:
IOException- IO failures if exceptions are not suppressed.
-
abortJobInternal
protected void abortJobInternal(CommitContext commitContext, boolean suppressExceptions) throws IOException Description copied from class:AbstractS3ACommitterThe internal job abort operation; can be overridden in tests. This must clean up operations; it is called when a commit fails, as well as in anAbstractS3ACommitter.abortJob(JobContext, JobStatus.State)call. The base implementation callsAbstractS3ACommitter.cleanup(CommitContext, boolean)so cleans up the filesystems and destroys the thread pool. Subclasses must always invoke this superclass method after their own operations. Creates and closes its own commit context.- Overrides:
abortJobInternalin classAbstractS3ACommitter- Parameters:
commitContext- commit contextsuppressExceptions- should exceptions be suppressed?- Throws:
IOException- any IO problem raised when suppressExceptions is false.
-
deleteStagingUploadsParentDirectory
protected void deleteStagingUploadsParentDirectory(org.apache.hadoop.mapreduce.JobContext context) throws IOException Delete the multipart upload staging directory.- Parameters:
context- job context- Throws:
IOException- IO failure
-
deleteDestinationPaths
protected void deleteDestinationPaths(org.apache.hadoop.mapreduce.JobContext context) throws IOException Delete the working paths of a job.$dest/__temporary- the local working directory for staged files
- Parameters:
context- job context- Throws:
IOException- IO failure
-
setupTask
Description copied from class:AbstractS3ACommitterTask setup. Fails if the the UUID was generated locally, and the same committer wasn't used for job setup.- Overrides:
setupTaskin classAbstractS3ACommitter- Throws:
IOException
-
needsTaskCommit
public boolean needsTaskCommit(org.apache.hadoop.mapreduce.TaskAttemptContext context) throws IOException - Specified by:
needsTaskCommitin classorg.apache.hadoop.mapreduce.OutputCommitter- Throws:
IOException
-
commitTask
- Specified by:
commitTaskin classorg.apache.hadoop.mapreduce.OutputCommitter- Throws:
IOException
-
commitTaskInternal
protected int commitTaskInternal(org.apache.hadoop.mapreduce.TaskAttemptContext context, List<? extends org.apache.hadoop.fs.FileStatus> taskOutput, CommitContext commitContext) throws IOException Commit the task by uploading all created files and then writing a pending entry for them.- Parameters:
context- task contexttaskOutput- list of files from the outputcommitContext- commit context- Returns:
- number of uploads committed.
- Throws:
IOException- IO Failures.
-
abortTask
Abort the task. The API specifies that the task has not yet been committed, so there are no uploads that need to be cancelled. Accordingly just delete files on the local FS, and call abortTask in the wrapped committer. Important: this may be called in the AM after a container failure. When that occurs and the failed container was on a different host in the cluster, the local files will not be deleted.- Specified by:
abortTaskin classorg.apache.hadoop.mapreduce.OutputCommitter- Parameters:
context- task context- Throws:
IOException- any failure
-
deleteTaskWorkingPathQuietly
protected void deleteTaskWorkingPathQuietly(org.apache.hadoop.mapreduce.JobContext context) Delete the working path of a task; no-op if there is none, that is: this is a job.- Parameters:
context- job/task context
-
getConflictResolutionMode
public final ConflictResolution getConflictResolutionMode(org.apache.hadoop.mapreduce.JobContext context, org.apache.hadoop.conf.Configuration fsConf) Returns theConflictResolutionmode for this commit.- Parameters:
context- the JobContext for this commitfsConf- filesystem config- Returns:
- the ConflictResolution mode
-
failDestinationExists
protected org.apache.hadoop.fs.PathExistsException failDestinationExists(org.apache.hadoop.fs.Path path, String description) Generate aPathExistsExceptionbecause the destination exists. Lists some of the child entries first, to help diagnose the problem.- Parameters:
path- path which existsdescription- description (usually task/job ID)- Returns:
- an exception to throw
-
getConfictModeOption
public static String getConfictModeOption(org.apache.hadoop.mapreduce.JobContext context, org.apache.hadoop.conf.Configuration fsConf, String defVal) Get the conflict mode option string.- Parameters:
context- context with the configfsConf- filesystem configdefVal- default value.- Returns:
- the trimmed configuration option, upper case.
-
preCommitJob
public void preCommitJob(CommitContext commitContext, AbstractS3ACommitter.ActiveCommit pending) throws IOException Pre-commit actions for a job. Loads all the pending files to verify they can be loaded and parsed.- Overrides:
preCommitJobin classAbstractS3ACommitter- Parameters:
commitContext- commit contextpending- pending commits- Throws:
IOException- any failure
-