Class SuccessData

All Implemented Interfaces:
Serializable, org.apache.hadoop.fs.statistics.IOStatisticsSource

@Private @Unstable public class SuccessData extends PersistentCommitData<SuccessData>
Summary data saved into a _SUCCESS marker file. This provides an easy way to determine which committer was used to commit work.
  1. File length == 0: classic FileOutputCommitter.
  2. Loadable as SuccessData: An S3A committer with name in in committer field.
  3. Not loadable? Something else.
This should be considered public, and MUST stay compatible at the JSON format level with that of 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 Details

    • VERSION

      public static final int VERSION
      Supported version value: 1. If this is changed the value of serialVersionUID will change, to avoid deserialization problems.
      See Also:
    • NAME

      public static final String 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

      public void validate() throws ValidationFailure
      Description copied from class: PersistentCommitData
      Validate the data: those fields which must be non empty, must be set.
      Specified by:
      validate in class PersistentCommitData<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: PersistentCommitData
      Serialize to JSON and then to a byte array, after performing a preflight validation of the data to be saved.
      Specified by:
      toBytes in class PersistentCommitData<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: PersistentCommitData
      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.
      Specified by:
      save in class PersistentCommitData<SuccessData>
      Parameters:
      fs - filesystem
      path - path
      serializer - serializer to use
      Returns:
      IOStats from the output stream.
      Throws:
      IOException - IO exception
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • dumpMetrics

      public String dumpMetrics(String prefix, String middle, String suffix)
      Dump the metrics (if any) to a string. The metrics are sorted for ease of viewing.
      Parameters:
      prefix - prefix before every entry
      middle - string between key and value
      suffix - suffix to each entry
      Returns:
      the dumped string
    • dumpDiagnostics

      public String dumpDiagnostics(String prefix, String middle, String suffix)
      Dump the diagnostics (if any) to a string.
      Parameters:
      prefix - prefix before every entry
      middle - string between key and value
      suffix - suffix to each entry
      Returns:
      the dumped string
    • joinMap

      protected static String joinMap(Map<String,?> map, String prefix, String middle, String suffix)
      Join any map of string to value into a string, sorting the keys first.
      Parameters:
      map - map to join
      prefix - prefix before every entry
      middle - string between key and value
      suffix - 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 - filesystem
      path - path
      Returns:
      the loaded instance
      Throws:
      IOException - IO failure
      ValidationFailure - if the data is invalid
    • serializer

      public static org.apache.hadoop.util.JsonSerialization<SuccessData> serializer()
      Get a JSON serializer for this class.
      Returns:
      a serializer.
    • getName

      public String getName()
    • setName

      public void setName(String name)
    • getTimestamp

      public long getTimestamp()
      Returns:
      timestamp of creation.
    • setTimestamp

      public void setTimestamp(long timestamp)
    • getDate

      public String getDate()
      Returns:
      timestamp as date; no expectation of parseability.
    • setDate

      public void setDate(String date)
    • getHostname

      public String getHostname()
      Returns:
      host which created the file (implicitly: committed the work).
    • setHostname

      public void setHostname(String hostname)
    • getCommitter

      public String getCommitter()
      Returns:
      committer name.
    • setCommitter

      public void setCommitter(String committer)
    • getDescription

      public String getDescription()
      Returns:
      any description text.
    • setDescription

      public void setDescription(String description)
    • getMetrics

      public Map<String,Long> getMetrics()
      Returns:
      any metrics.
    • setMetrics

      public void setMetrics(Map<String,Long> metrics)
    • getFilenames

      public List<String> getFilenames()
      Returns:
      a list of filenames in the commit.
    • setFilenames

      public void setFilenames(List<String> filenames)
    • getDiagnostics

      public Map<String,String> getDiagnostics()
    • setDiagnostics

      public void setDiagnostics(Map<String,String> diagnostics)
    • addDiagnostic

      public void addDiagnostic(String key, String value)
      Add a diagnostics entry.
      Parameters:
      key - name
      value - value
    • getJobId

      public String getJobId()
      Returns:
      Job ID, if known.
    • setJobId

      public void setJobId(String jobId)
    • getJobIdSource

      public String getJobIdSource()
    • setJobIdSource

      public void setJobIdSource(String jobIdSource)
    • 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

      public String getState()
    • setState

      public void setState(String state)
    • getStage

      public String getStage()
    • putDiagnostic

      public void putDiagnostic(String key, String value)
      Add a diagnostics entry.
      Parameters:
      key - name
      value - value
    • recordJobFailure

      public void recordJobFailure(Throwable thrown)
      Note a failure by setting success flag to false, then add the exception to the diagnostics.
      Parameters:
      thrown - throwable