Class SinglePendingCommit
java.lang.Object
org.apache.hadoop.fs.s3a.commit.files.PersistentCommitData<SinglePendingCommit>
org.apache.hadoop.fs.s3a.commit.files.SinglePendingCommit
- All Implemented Interfaces:
Serializable,Iterable<UploadEtag>,org.apache.hadoop.fs.statistics.IOStatisticsSource
@Private
@Unstable
public final class SinglePendingCommit
extends PersistentCommitData<SinglePendingCommit>
implements Iterable<UploadEtag>
This is the serialization format for uploads yet to be committed.
It's marked as Serializable so that it can be passed in RPC
calls; for this to work it relies on the fact that java.io ArrayList
and LinkedList are serializable. If any other list type is used for etags,
it must also be serialized. Jackson expects lists, and it is used
to persist to disk.
The statistics published through the IOStatisticsSource
interface are the static ones marshalled with the commit data;
they may be empty.
- See Also:
-
Field Summary
Fields inherited from class org.apache.hadoop.fs.s3a.commit.files.PersistentCommitData
VERSION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbindCommitData(List<software.amazon.awssdk.services.s3.model.CompletedPart> parts) Set the commit data.org.apache.hadoop.fs.PathBuild the destination path of the object.longWhen was the upload created?getDate()Timestamp as date; no expectation of parseability.getEtags()Any custom extra data committer subclasses may choose to add.This is the filename of the pending file itself.org.apache.hadoop.fs.statistics.IOStatisticsSnapshotgetJobId()longDestination file size.intGet the number of etags.longgetSaved()When was the upload saved?getText()Arbitrary notes.getUri()intiterator()Iterate over the etags.static SinglePendingCommitload(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.fs.FileStatus status, org.apache.hadoop.util.JsonSerialization<SinglePendingCommit> serDeser) Load an instance from a file, then validate it.static SinglePendingCommitload(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.util.JsonSerialization<SinglePendingCommit> serDeser, org.apache.hadoop.fs.FileStatus status) Load an instance from a file, then validate it.voidputExtraData(String key, String value) Set/Update an extra data entry.org.apache.hadoop.fs.statistics.IOStatisticssave(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.util.JsonSerialization<SinglePendingCommit> serializer) Save to a hadoop filesystem.static org.apache.hadoop.util.JsonSerialization<SinglePendingCommit>Get a JSON serializer for this class.voidvoidsetCreated(long created) voidvoidsetDestinationKey(String destinationKey) voidsetEtags(List<UploadEtag> etags) voidsetExtraData(Map<String, String> extraData) voidsetFilename(String filename) voidsetIOStatistics(org.apache.hadoop.fs.statistics.IOStatisticsSnapshot ioStatistics) voidvoidsetLength(long length) voidsetSaved(long saved) voidvoidvoidsetUploadId(String uploadId) voidvoidsetVersion(int version) byte[]toBytes(org.apache.hadoop.util.JsonSerialization<SinglePendingCommit> serializer) Serialize to JSON and then to a byte array, after performing a preflight validation of the data to be saved.toString()voidtouch(long millis) Set the various timestamp fields to the supplied value.voidvalidate()Validate the data: those fields which must be non empty, must be set.Methods inherited from class org.apache.hadoop.fs.s3a.commit.files.PersistentCommitData
load, saveFile, saveToStreamMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
SinglePendingCommit
public SinglePendingCommit()
-
-
Method Details
-
serializer
Get a JSON serializer for this class.- Returns:
- a serializer.
-
load
public static SinglePendingCommit load(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.fs.FileStatus status, org.apache.hadoop.util.JsonSerialization<SinglePendingCommit> serDeser) throws IOException Load an instance from a file, then validate it.- Parameters:
fs- filesystempath- pathstatus- nullable status of file to loadserDeser- serializer; if null use the shared static one.- Returns:
- the loaded instance
- Throws:
IOException- IO failureValidationFailure- if the data is invalid
-
load
public static SinglePendingCommit load(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.util.JsonSerialization<SinglePendingCommit> serDeser, @Nullable org.apache.hadoop.fs.FileStatus status) throws IOException Load an instance from a file, then validate it.- Parameters:
fs- filesystempath- pathserDeser- deserializerstatus- status of file to load or null- Returns:
- the loaded instance
- Throws:
IOException- IO failureValidationFailure- if the data is invalid
-
touch
public void touch(long millis) Set the various timestamp fields to the supplied value.- Parameters:
millis- time in milliseconds
-
bindCommitData
public void bindCommitData(List<software.amazon.awssdk.services.s3.model.CompletedPart> parts) throws ValidationFailure Set the commit data.- Parameters:
parts- ordered list of etags.- Throws:
ValidationFailure- if the data is invalid
-
validate
Description copied from class:PersistentCommitDataValidate the data: those fields which must be non empty, must be set.- Specified by:
validatein classPersistentCommitData<SinglePendingCommit>- Throws:
ValidationFailure- if the data is invalid
-
toString
-
toBytes
public byte[] toBytes(org.apache.hadoop.util.JsonSerialization<SinglePendingCommit> serializer) throws IOException Description copied from class:PersistentCommitDataSerialize to JSON and then to a byte array, after performing a preflight validation of the data to be saved.- Specified by:
toBytesin classPersistentCommitData<SinglePendingCommit>- Parameters:
serializer- serializer to use- Returns:
- the data in a persistable form.
- Throws:
IOException- serialization problem or validation failure.
-
save
public org.apache.hadoop.fs.statistics.IOStatistics save(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.util.JsonSerialization<SinglePendingCommit> serializer) throws IOException Description copied from class:PersistentCommitDataSave to a hadoop filesystem. The destination file is overwritten, and on s3a stores the performance flag is set to turn off all existence checks and parent dir cleanup. The assumption here is: the job knows what it is doing.- Specified by:
savein classPersistentCommitData<SinglePendingCommit>- Parameters:
fs- filesystempath- pathserializer- serializer to use- Returns:
- IOStats from the output stream.
- Throws:
IOException- IO exception
-
destinationPath
public org.apache.hadoop.fs.Path destinationPath()Build the destination path of the object.- Returns:
- the path
- Throws:
IllegalStateException- if the URI is invalid
-
getPartCount
public int getPartCount()Get the number of etags.- Returns:
- the size of the etag list.
-
iterator
Iterate over the etags.- Specified by:
iteratorin interfaceIterable<UploadEtag>- Returns:
- an iterator.
-
getVersion
public int getVersion()- Returns:
- version marker.
-
setVersion
public void setVersion(int version) -
getFilename
This is the filename of the pending file itself. Used during processing; it's persistent value, if any, is ignored.- Returns:
- filename
-
setFilename
-
getUri
- Returns:
- path URI of the destination.
-
setUri
-
getUploadId
- Returns:
- ID of the upload.
-
setUploadId
-
getBucket
- Returns:
- destination bucket.
-
setBucket
-
getDestinationKey
- Returns:
- destination key in the bucket.
-
setDestinationKey
-
getCreated
public long getCreated()When was the upload created?- Returns:
- timestamp
-
setCreated
public void setCreated(long created) -
getSaved
public long getSaved()When was the upload saved?- Returns:
- timestamp
-
setSaved
public void setSaved(long saved) -
getDate
Timestamp as date; no expectation of parseability.- Returns:
- date string
-
setDate
-
getJobId
- Returns:
- Job ID, if known.
-
setJobId
-
getTaskId
- Returns:
- Task ID, if known.
-
setTaskId
-
getText
Arbitrary notes.- Returns:
- any notes
-
setText
-
getEtags
- Returns:
- ordered list of etags.
-
setEtags
-
getExtraData
Any custom extra data committer subclasses may choose to add.- Returns:
- custom data
-
setExtraData
-
putExtraData
Set/Update an extra data entry.- Parameters:
key- keyvalue- value
-
getLength
public long getLength()Destination file size.- Returns:
- size of destination object
-
setLength
public void setLength(long length) -
getIOStatistics
public org.apache.hadoop.fs.statistics.IOStatisticsSnapshot getIOStatistics()- Specified by:
getIOStatisticsin interfaceorg.apache.hadoop.fs.statistics.IOStatisticsSource
-
setIOStatistics
public void setIOStatistics(org.apache.hadoop.fs.statistics.IOStatisticsSnapshot ioStatistics)
-