Class PersistentCommitData<T extends PersistentCommitData>
java.lang.Object
org.apache.hadoop.fs.s3a.commit.files.PersistentCommitData<T>
- All Implemented Interfaces:
Serializable,org.apache.hadoop.fs.statistics.IOStatisticsSource
- Direct Known Subclasses:
PendingSet,SinglePendingCommit,SuccessData
@Private
@Unstable
public abstract class PersistentCommitData<T extends PersistentCommitData>
extends Object
implements Serializable, org.apache.hadoop.fs.statistics.IOStatisticsSource
Class for single/multiple commit data structures.
The mapreduce hierarchy
AbstractManifestData is a fork
of this; the Success data JSON format must stay compatible- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends PersistentCommitData>
Tload(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.FileStatus status, org.apache.hadoop.util.JsonSerialization<T> serializer) Load an instance from a status, then validate it.abstract org.apache.hadoop.fs.statistics.IOStatisticssave(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.util.JsonSerialization<T> serializer) Save to a hadoop filesystem.static <T extends PersistentCommitData>
org.apache.hadoop.fs.statistics.IOStatisticssaveFile(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, T instance, org.apache.hadoop.util.JsonSerialization<T> serializer, boolean performance) Save to a file.static <T extends PersistentCommitData>
org.apache.hadoop.fs.statistics.IOStatisticssaveToStream(org.apache.hadoop.fs.Path path, T instance, org.apache.hadoop.fs.FSDataOutputStreamBuilder builder, org.apache.hadoop.util.JsonSerialization<T> serializer) Save to a file.abstract byte[]Serialize to JSON and then to a byte array, after performing a preflight validation of the data to be saved.abstract voidvalidate()Validate the data: those fields which must be non empty, must be set.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.fs.statistics.IOStatisticsSource
getIOStatistics
-
Field Details
-
VERSION
public static final int VERSIONSupported version value: 2. If this is changed the value ofserialVersionUIDwill change, to avoid deserialization problems.- See Also:
-
-
Constructor Details
-
PersistentCommitData
public PersistentCommitData()
-
-
Method Details
-
validate
Validate the data: those fields which must be non empty, must be set.- Throws:
ValidationFailure- if the data is invalid
-
toBytes
public abstract byte[] toBytes(org.apache.hadoop.util.JsonSerialization<T> serializer) throws IOException Serialize to JSON and then to a byte array, after performing a preflight validation of the data to be saved.- Parameters:
serializer- serializer to use- Returns:
- the data in a persistable form.
- Throws:
IOException- serialization problem or validation failure.
-
save
public abstract org.apache.hadoop.fs.statistics.IOStatistics save(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.util.JsonSerialization<T> serializer) throws IOException Save 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.- Parameters:
fs- filesystempath- pathserializer- serializer to use- Returns:
- IOStats from the output stream.
- Throws:
IOException- IO exception
-
load
public static <T extends PersistentCommitData> T load(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.FileStatus status, org.apache.hadoop.util.JsonSerialization<T> serializer) throws IOException Load an instance from a status, then validate it. This uses the openFile() API, which S3A supports for faster load and declaring sequential access, always- Type Parameters:
T- type of persistent format- Parameters:
fs- filesystemstatus- status of file to loadserializer- serializer to use- Returns:
- the loaded instance
- Throws:
IOException- IO failureValidationFailure- if the data is invalid
-
saveFile
public static <T extends PersistentCommitData> org.apache.hadoop.fs.statistics.IOStatistics saveFile(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, T instance, org.apache.hadoop.util.JsonSerialization<T> serializer, boolean performance) throws IOException Save to a file. This uses the createFile() API, which S3A supports for faster load and declaring sequential access, always- Type Parameters:
T- type of persistent format- Parameters:
fs- filesystempath- path to save toinstance- data to saveserializer- serializer to useperformance- skip all safety check on the write- Returns:
- any IOStatistics from the output stream, or null
- Throws:
IOException- IO failure
-
saveToStream
public static <T extends PersistentCommitData> org.apache.hadoop.fs.statistics.IOStatistics saveToStream(org.apache.hadoop.fs.Path path, T instance, org.apache.hadoop.fs.FSDataOutputStreamBuilder builder, org.apache.hadoop.util.JsonSerialization<T> serializer) throws IOException Save to a file. This uses the createFile() API, which S3A supports for faster load and declaring sequential access, always- Type Parameters:
T- type of persistent format- Parameters:
path- path to save to (used for logging)instance- data to savebuilder- builder already prepared for the writeserializer- serializer to use- Returns:
- any IOStatistics from the output stream, or null
- Throws:
IOException- IO failure
-