Class CommitContext
java.lang.Object
org.apache.hadoop.fs.s3a.commit.impl.CommitContext
- All Implemented Interfaces:
Closeable,AutoCloseable
Commit context.
It is used to manage the final commit sequence where files become
visible.
Once the commit operation has completed, it must be closed.
It MUST NOT be reused.
Audit integration: job and task attributes are added to the thread local context
on create, removed on close().
JSON Serializers are created on demand, on a per thread basis.
A
WeakReferenceThreadMap is used here; a GC may lose the
references, but they will recreated as needed.-
Constructor Summary
ConstructorsConstructorDescriptionCommitContext(CommitOperations commitOperations, org.apache.hadoop.conf.Configuration conf, String jobId, int committerThreads, org.apache.hadoop.fs.statistics.IOStatisticsContext ioStatisticsContext) Create for testing.CommitContext(CommitOperations commitOperations, org.apache.hadoop.mapreduce.JobContext jobContext, int committerThreads, org.apache.hadoop.fs.statistics.IOStatisticsContext ioStatisticsContext) Create. -
Method Summary
Modifier and TypeMethodDescriptionvoidabortMultipartCommit(String destKey, String uploadId) voidabortSingleCommit(SinglePendingCommit commit) voidclose()commit(SinglePendingCommit commit, String origin) Commit a single pending commit; exceptions are caught and converted to an outcome.voidcommitOrFail(SinglePendingCommit commit) Commit the operation, throwing an exception on any failure.org.apache.hadoop.conf.ConfigurationgetConf()Job configuration.org.apache.hadoop.util.functional.TaskPool.SubmitterReturn a submitter.org.apache.hadoop.fs.statistics.IOStatisticsContextIOStatistics context of the created thread.org.apache.hadoop.mapreduce.JobContextJob Context.getJobId()Get the job ID.org.apache.hadoop.util.functional.TaskPool.SubmitterReturn a submitter.org.apache.hadoop.util.JsonSerialization<PendingSet>Get a serializer for .pendingset files.org.apache.hadoop.util.JsonSerialization<SinglePendingCommit>Get a serializer for .pending files.booleanCollecting thread level IO statistics?voidReset the IOStatistics context if statistics are being collected.voidrevertCommit(SinglePendingCommit commit) voidSwitch to the context IOStatistics context, if needed.toString()
-
Constructor Details
-
CommitContext
public CommitContext(CommitOperations commitOperations, org.apache.hadoop.mapreduce.JobContext jobContext, int committerThreads, org.apache.hadoop.fs.statistics.IOStatisticsContext ioStatisticsContext) Create.- Parameters:
commitOperations- commit callbacksjobContext- job contextcommitterThreads- number of commit threadsioStatisticsContext- IOStatistics context of current thread
-
CommitContext
public CommitContext(CommitOperations commitOperations, org.apache.hadoop.conf.Configuration conf, String jobId, int committerThreads, org.apache.hadoop.fs.statistics.IOStatisticsContext ioStatisticsContext) Create for testing. This has no job context; instead the values are set explicitly.- Parameters:
commitOperations- commit callbacksconf- job confjobId- IDcommitterThreads- number of commit threadsioStatisticsContext- IOStatistics context of current thread
-
-
Method Details
-
commitOrFail
Commit the operation, throwing an exception on any failure. SeeCommitOperations#commitOrFail(SinglePendingCommit).- Parameters:
commit- commit to execute- Throws:
IOException- on a failure
-
commit
Commit a single pending commit; exceptions are caught and converted to an outcome. SeeCommitOperations.commit(SinglePendingCommit, String).- Parameters:
commit- entry to commitorigin- origin path/string for outcome text- Returns:
- the outcome
-
abortSingleCommit
- Parameters:
commit- pending commit to abort- Throws:
FileNotFoundException- if the abort ID is unknownIOException- on any failure
-
revertCommit
- Parameters:
commit- pending commit- Throws:
IOException- failure
-
abortMultipartCommit
- Parameters:
destKey- destination keyuploadId- upload to cancel- Throws:
FileNotFoundException- if the abort ID is unknownIOException- on any failure
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
toString
-
getJobContext
public org.apache.hadoop.mapreduce.JobContext getJobContext()Job Context.- Returns:
- job context.
-
getOuterSubmitter
public org.apache.hadoop.util.functional.TaskPool.Submitter getOuterSubmitter()Return a submitter. If created with 0 threads, this returns null so TaskPool knows to run it in the current thread.- Returns:
- a submitter or null
-
getInnerSubmitter
public org.apache.hadoop.util.functional.TaskPool.Submitter getInnerSubmitter()Return a submitter. As this pool is used less often, create it on demand. If created with 0 threads, this returns null so TaskPool knows to run it in the current thread.- Returns:
- a submitter or null
-
getSinglePendingFileSerializer
public org.apache.hadoop.util.JsonSerialization<SinglePendingCommit> getSinglePendingFileSerializer()Get a serializer for .pending files.- Returns:
- a serializer.
-
getPendingSetSerializer
Get a serializer for .pendingset files.- Returns:
- a serializer.
-
getConf
public org.apache.hadoop.conf.Configuration getConf()Job configuration.- Returns:
- configuration (never null)
-
getJobId
Get the job ID.- Returns:
- job ID.
-
isCollectIOStatistics
public boolean isCollectIOStatistics()Collecting thread level IO statistics?- Returns:
- true if thread level IO stats should be collected.
-
getIOStatisticsContext
public org.apache.hadoop.fs.statistics.IOStatisticsContext getIOStatisticsContext()IOStatistics context of the created thread.- Returns:
- the IOStatistics.
-
switchToIOStatisticsContext
public void switchToIOStatisticsContext()Switch to the context IOStatistics context, if needed. -
maybeResetIOStatisticsContext
public void maybeResetIOStatisticsContext()Reset the IOStatistics context if statistics are being collected. Logs at info.
-