Class SuccessData
- All Implemented Interfaces:
Serializable,org.apache.hadoop.fs.statistics.IOStatisticsSource
_SUCCESS marker file.
This provides an easy way to determine which committer was used
to commit work.
- File length == 0: classic
FileOutputCommitter. - Loadable as
SuccessData: An S3A committer with name in incommitterfield. - Not loadable? Something else.
org.apache.hadoop.mapreduce.lib.output.committer.manifest.files.ManifestSuccessData
The JSON format SHOULD be considered public and evolving with compatibility across versions.
All the Java serialization data is different and may change across versions with no stability guarantees other than "manifest summaries MAY be serialized between processes with the exact same version of this binary on their classpaths." That is sufficient for testing in Spark.
To aid with Java serialization, the maps and lists are
exclusively those which serialize well.
IOStatisticsSnapshot has a lot of complexity in marshalling
there; this class doesn't worry about concurrent access
so is simpler.
Note: to deal with scale issues, the S3A committers do not include any
more than the number of objects listed in
CommitConstants.SUCCESS_MARKER_FILE_LIMIT.
This is intended to suffice for basic integration tests.
Larger tests should examine the generated files themselves.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDiagnostic(String key, String value) Add a diagnostics entry.dumpDiagnostics(String prefix, String middle, String suffix) Dump the diagnostics (if any) to a string.dumpMetrics(String prefix, String middle, String suffix) Dump the metrics (if any) to a string.getDate()org.apache.hadoop.fs.statistics.IOStatisticsSnapshotgetJobId()getName()getStage()getState()booleanGet the success flag.longprotected static StringJoin any map of string to value into a string, sorting the keys first.static SuccessDataload(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) Load an instance from a file, then validate it.voidputDiagnostic(String key, String value) Add a diagnostics entry.voidrecordJobFailure(Throwable thrown) Note a failure by setting success flag to false, then add the exception to the diagnostics.org.apache.hadoop.fs.statistics.IOStatisticssave(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.util.JsonSerialization<SuccessData> serializer) Save to a hadoop filesystem.static org.apache.hadoop.util.JsonSerialization<SuccessData>Get a JSON serializer for this class.voidsetCommitter(String committer) voidvoidsetDescription(String description) voidsetDiagnostics(Map<String, String> diagnostics) voidsetFilenames(List<String> filenames) voidsetHostname(String hostname) voidsetIOStatistics(org.apache.hadoop.fs.statistics.IOStatisticsSnapshot ioStatistics) voidvoidsetJobIdSource(String jobIdSource) voidsetMetrics(Map<String, Long> metrics) voidvoidvoidsetSuccess(boolean success) Set the success flag.voidsetTimestamp(long timestamp) byte[]toBytes(org.apache.hadoop.util.JsonSerialization<SuccessData> serializer) Serialize to JSON and then to a byte array, after performing a preflight validation of the data to be saved.toString()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: 1. If this is changed the value ofserialVersionUIDwill change, to avoid deserialization problems.- See Also:
-
NAME
Name to include in persisted data, so as to differentiate from any other manifests: "org.apache.hadoop.fs.s3a.commit.files.SuccessData/1".- See Also:
-
-
Constructor Details
-
SuccessData
public SuccessData()
-
-
Method Details
-
validate
Description copied from class:PersistentCommitDataValidate the data: those fields which must be non empty, must be set.- Specified by:
validatein classPersistentCommitData<SuccessData>- Throws:
ValidationFailure- if the data is invalid
-
toBytes
public byte[] toBytes(org.apache.hadoop.util.JsonSerialization<SuccessData> 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<SuccessData>- 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<SuccessData> 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<SuccessData>- Parameters:
fs- filesystempath- pathserializer- serializer to use- Returns:
- IOStats from the output stream.
- Throws:
IOException- IO exception
-
toString
-
dumpMetrics
Dump the metrics (if any) to a string. The metrics are sorted for ease of viewing.- Parameters:
prefix- prefix before every entrymiddle- string between key and valuesuffix- suffix to each entry- Returns:
- the dumped string
-
dumpDiagnostics
Dump the diagnostics (if any) to a string.- Parameters:
prefix- prefix before every entrymiddle- string between key and valuesuffix- suffix to each entry- Returns:
- the dumped string
-
joinMap
Join any map of string to value into a string, sorting the keys first.- Parameters:
map- map to joinprefix- prefix before every entrymiddle- string between key and valuesuffix- suffix to each entry- Returns:
- a string for reporting.
-
load
public static SuccessData load(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException Load an instance from a file, then validate it.- Parameters:
fs- filesystempath- path- Returns:
- the loaded instance
- Throws:
IOException- IO failureValidationFailure- if the data is invalid
-
serializer
Get a JSON serializer for this class.- Returns:
- a serializer.
-
getName
-
setName
-
getTimestamp
public long getTimestamp()- Returns:
- timestamp of creation.
-
setTimestamp
public void setTimestamp(long timestamp) -
getDate
- Returns:
- timestamp as date; no expectation of parseability.
-
setDate
-
getHostname
- Returns:
- host which created the file (implicitly: committed the work).
-
setHostname
-
getCommitter
- Returns:
- committer name.
-
setCommitter
-
getDescription
- Returns:
- any description text.
-
setDescription
-
getMetrics
- Returns:
- any metrics.
-
setMetrics
-
getFilenames
- Returns:
- a list of filenames in the commit.
-
setFilenames
-
getDiagnostics
-
setDiagnostics
-
addDiagnostic
Add a diagnostics entry.- Parameters:
key- namevalue- value
-
getJobId
- Returns:
- Job ID, if known.
-
setJobId
-
getJobIdSource
-
setJobIdSource
-
getIOStatistics
public org.apache.hadoop.fs.statistics.IOStatisticsSnapshot getIOStatistics() -
setIOStatistics
public void setIOStatistics(org.apache.hadoop.fs.statistics.IOStatisticsSnapshot ioStatistics) -
setSuccess
public void setSuccess(boolean success) Set the success flag.- Parameters:
success- did the job succeed?
-
getSuccess
public boolean getSuccess()Get the success flag.- Returns:
- did the job succeed?
-
getState
-
setState
-
getStage
-
putDiagnostic
Add a diagnostics entry.- Parameters:
key- namevalue- value
-
recordJobFailure
Note a failure by setting success flag to false, then add the exception to the diagnostics.- Parameters:
thrown- throwable
-