Class PendingSet
java.lang.Object
org.apache.hadoop.fs.s3a.commit.files.PersistentCommitData<PendingSet>
org.apache.hadoop.fs.s3a.commit.files.PendingSet
- All Implemented Interfaces:
Serializable,org.apache.hadoop.fs.statistics.IOStatisticsSource
Persistent format for multiple pending commits.
Contains 0 or more
SinglePendingCommit entries; validation logic
checks those values on load.
The statistics published through the IOStatisticsSource
interface are the static ones marshalled with the commit data;
they may be empty.
As single commits are added via add(SinglePendingCommit),
any statistics from those commits are merged into the aggregate
statistics, and those of the single commit cleared.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(SinglePendingCommit commit) Add a commit.org.apache.hadoop.fs.statistics.IOStatisticsSnapshotgetJobId()intstatic PendingSetload(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, 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<PendingSet> serializer) Save to a hadoop filesystem.static org.apache.hadoop.util.JsonSerialization<PendingSet>Get a shared JSON serializer for this class.voidsetCommits(List<SinglePendingCommit> commits) voidsetIOStatistics(org.apache.hadoop.fs.statistics.IOStatisticsSnapshot ioStatistics) voidvoidsetVersion(int version) intsize()Number of commits.byte[]toBytes(org.apache.hadoop.util.JsonSerialization<PendingSet> serializer) Serialize to JSON and then to a byte array, after performing a preflight validation of the data to be saved.final 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, saveToStream
-
Field Details
-
VERSION
public static final int VERSIONSupported version value: 3. If this is changed the value ofserialVersionUIDwill change, to avoid deserialization problems.- See Also:
-
-
Constructor Details
-
PendingSet
public PendingSet() -
PendingSet
public PendingSet(int size)
-
-
Method Details
-
serializer
Get a shared JSON serializer for this class.- Returns:
- a serializer.
-
load
public static PendingSet load(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, @Nullable org.apache.hadoop.fs.FileStatus status) throws IOException Load an instance from a file, then validate it.- Parameters:
fs- filesystempath- pathstatus- status of file to load- Returns:
- the loaded instance
- Throws:
IOException- IO failureValidationFailure- if the data is invalid
-
add
Add a commit.- Parameters:
commit- the single commit
-
validate
Validate the data: those fields which must be non empty, must be set.- Specified by:
validatein classPersistentCommitData<PendingSet>- Throws:
ValidationFailure- if the data is invalid
-
toBytes
public byte[] toBytes(org.apache.hadoop.util.JsonSerialization<PendingSet> 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<PendingSet>- Parameters:
serializer- serializer to use- Returns:
- the data in a persistable form.
- Throws:
IOException- serialization problem or validation failure.
-
size
public int size()Number of commits.- Returns:
- the number of commits in this structure.
-
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<PendingSet> 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<PendingSet>- Parameters:
fs- filesystempath- pathserializer- serializer to use- Returns:
- IOStats from the output stream.
- Throws:
IOException- IO exception
-
getVersion
public int getVersion()- Returns:
- the version marker.
-
setVersion
public void setVersion(int version) -
getCommits
- Returns:
- commit list.
-
setCommits
-
putExtraData
Set/Update an extra data entry.- Parameters:
key- keyvalue- value
-
getJobId
- Returns:
- Job ID, if known.
-
setJobId
-
getIOStatistics
public org.apache.hadoop.fs.statistics.IOStatisticsSnapshot getIOStatistics() -
setIOStatistics
public void setIOStatistics(org.apache.hadoop.fs.statistics.IOStatisticsSnapshot ioStatistics)
-