Class MagicS3GuardCommitter
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.magic.MagicS3GuardCommitter
- All Implemented Interfaces:
org.apache.hadoop.fs.statistics.IOStatisticsSource
This is a dedicated committer which requires the "magic" directory feature
of the S3A Filesystem to be enabled; it then uses paths for task and job
attempts in magic paths, so as to ensure that the final output goes direct
to the destination directory.
-
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
ConstructorsConstructorDescriptionMagicS3GuardCommitter(org.apache.hadoop.fs.Path outputPath, org.apache.hadoop.mapreduce.TaskAttemptContext context) Create a task committer. -
Method Summary
Modifier and TypeMethodDescriptionvoidabortTask(org.apache.hadoop.mapreduce.TaskAttemptContext context) Abort a task.voidDelete the magic directory.voidcommitTask(org.apache.hadoop.mapreduce.TaskAttemptContext context) protected final org.apache.hadoop.fs.PathgetBaseTaskAttemptPath(org.apache.hadoop.mapreduce.TaskAttemptContext context) Compute the base path where the output of a task attempt is written.protected final org.apache.hadoop.fs.PathgetJobAttemptPath(int appAttemptId) 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.final org.apache.hadoop.fs.PathgetTaskAttemptPath(org.apache.hadoop.mapreduce.TaskAttemptContext context) Compute the path where the output of a task attempt is stored until that task is committed.org.apache.hadoop.fs.PathgetTempTaskAttemptPath(org.apache.hadoop.mapreduce.TaskAttemptContext context) Get a temporary directory for data.protected AbstractS3ACommitter.ActiveCommitlistPendingUploadsToCommit(CommitContext commitContext) Get the list of pending uploads for this job attempt, by listing all .pendingset files in the job attempt directory.protected PendingSetloadPendingCommits(org.apache.hadoop.mapreduce.TaskAttemptContext context) Loads pending commits from either memory or from the remote store (S3) based on the config.booleanneedsTaskCommit(org.apache.hadoop.mapreduce.TaskAttemptContext context) Did this task write any files in the work directory?protected booleanRequire magic paths in the FS client.voidsetupJob(org.apache.hadoop.mapreduce.JobContext context) Base job setup (optionally) deletes the success marker and always creates the destination directory.toString()Methods inherited from class org.apache.hadoop.fs.s3a.commit.AbstractS3ACommitter
abortJob, abortJobInternal, abortPendingUploads, abortPendingUploads, abortPendingUploadsInCleanup, buildJobUUID, cleanup, cleanupJob, commitJob, commitJobInternal, commitPendingUploads, deleteTaskAttemptPathQuietly, getAuditSpanSource, getCommitOperations, getConf, getDestFS, getDestinationFS, getDestS3AFS, getIOStatistics, getJobAttemptPath, getJobContext, getOutputPath, getRole, getTaskAttemptFilesystem, getUUID, getUUIDSource, getWorkPath, initiateJobOperation, initiateTaskOperation, initOutput, jobCompleted, maybeCreateSuccessMarker, maybeCreateSuccessMarkerFromCommits, maybeIgnore, maybeIgnore, precommitCheckPendingFiles, preCommitJob, recoverTask, setConf, setDestFS, setOutputPath, setupTask, 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: "magic".- See Also:
-
-
Constructor Details
-
MagicS3GuardCommitter
public MagicS3GuardCommitter(org.apache.hadoop.fs.Path outputPath, org.apache.hadoop.mapreduce.TaskAttemptContext context) throws IOException Create a task committer.- Parameters:
outputPath- the job's output pathcontext- the task's 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.
-
requiresDelayedCommitOutputInFileSystem
protected boolean requiresDelayedCommitOutputInFileSystem()Require magic paths in the FS client.- Overrides:
requiresDelayedCommitOutputInFileSystemin classAbstractS3ACommitter- Returns:
- true, always.
-
setupJob
Description copied from class:AbstractS3ACommitterBase job setup (optionally) deletes the success marker and always creates the destination directory. When objects are committed that dest dir marker will inevitably be deleted; creating it now ensures there is something at the end while the job is in progress -and if nothing is created, that it is still there.The option
InternalCommitterConstants.FS_S3A_COMMITTER_UUIDis set to the job UUID; if generated locallyInternalCommitterConstants.SPARK_WRITE_UUIDis also patched. The fieldAbstractS3ACommitter.jobSetupis set to true to note that this specific committer instance was used to set up a job.- Overrides:
setupJobin classAbstractS3ACommitter- Parameters:
context- context- Throws:
IOException- IO failure
-
listPendingUploadsToCommit
protected AbstractS3ACommitter.ActiveCommit listPendingUploadsToCommit(CommitContext commitContext) throws IOException Get the list of pending uploads for this job attempt, by listing all .pendingset files in the job attempt directory.- Specified by:
listPendingUploadsToCommitin classAbstractS3ACommitter- Parameters:
commitContext- job context- Returns:
- a list of pending commits.
- Throws:
IOException- Any IO failure
-
cleanupStagingDirs
public void cleanupStagingDirs()Delete the magic directory.- Specified by:
cleanupStagingDirsin classAbstractS3ACommitter
-
needsTaskCommit
public boolean needsTaskCommit(org.apache.hadoop.mapreduce.TaskAttemptContext context) throws IOException Did this task write any files in the work directory? Probes for a task existing by looking to see if the attempt dir exists. This adds more HTTP requests to the call. It may be better just to return true and rely on the commit task doing the work.- Specified by:
needsTaskCommitin classorg.apache.hadoop.mapreduce.OutputCommitter- Parameters:
context- the task's context- Returns:
- true if the attempt path exists
- Throws:
IOException- failure to list the path
-
commitTask
- Specified by:
commitTaskin classorg.apache.hadoop.mapreduce.OutputCommitter- Throws:
IOException
-
loadPendingCommits
protected PendingSet loadPendingCommits(org.apache.hadoop.mapreduce.TaskAttemptContext context) throws IOException Loads pending commits from either memory or from the remote store (S3) based on the config.- Parameters:
context- TaskAttemptContext- Returns:
- All pending commit data for the given TaskAttemptContext
- Throws:
IOException- if there is an error trying to read the commit data
-
abortTask
Abort a task. Attempt load then abort all pending files, then try to delete the task attempt path. This method may be called on the job committer, rather than the task one (such as in the MapReduce AM after a task container failure). It must extract all paths and state from the passed in context.- Specified by:
abortTaskin classorg.apache.hadoop.mapreduce.OutputCommitter- Parameters:
context- task context- Throws:
IOException- if there was some problem querying the path other than it not actually existing.
-
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.
-
getJobAttemptPath
protected final org.apache.hadoop.fs.Path getJobAttemptPath(int appAttemptId) Compute the path where the output of a given job attempt will be placed. For the magic committer, the path includes the job UUID.- Specified by:
getJobAttemptPathin classAbstractS3ACommitter- Parameters:
appAttemptId- the ID of the application attempt for this job.- Returns:
- the path to store job attempt data.
-
getTaskAttemptPath
public final org.apache.hadoop.fs.Path getTaskAttemptPath(org.apache.hadoop.mapreduce.TaskAttemptContext context) Compute the path where the output of a task attempt is stored until that task is committed.- Overrides:
getTaskAttemptPathin classAbstractS3ACommitter- Parameters:
context- the context of the task attempt.- Returns:
- the path where a task attempt should be stored.
-
getBaseTaskAttemptPath
protected final org.apache.hadoop.fs.Path getBaseTaskAttemptPath(org.apache.hadoop.mapreduce.TaskAttemptContext context) Description copied from class:AbstractS3ACommitterCompute the base path where the output of a task attempt is written. This is the path which will be deleted when a task is cleaned up and aborted.- Specified by:
getBaseTaskAttemptPathin classAbstractS3ACommitter- Parameters:
context- the context of the task attempt.- Returns:
- the path where a task attempt should be stored.
-
getTempTaskAttemptPath
public org.apache.hadoop.fs.Path getTempTaskAttemptPath(org.apache.hadoop.mapreduce.TaskAttemptContext context) Get 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.
-
toString
- Overrides:
toStringin classAbstractS3ACommitter
-