Class ChangeTracker

java.lang.Object
org.apache.hadoop.fs.s3a.impl.ChangeTracker

@Private @Unstable public class ChangeTracker extends Object
Change tracking for input streams: the version ID or etag of the object is tracked and compared on open/re-open. An initial version ID or etag may or may not be available. Self-contained for testing and use in different streams.
  • Field Details

  • Constructor Details

    • ChangeTracker

      public ChangeTracker(String uri, ChangeDetectionPolicy policy, ChangeTrackerStatistics versionMismatches, S3ObjectAttributes s3ObjectAttributes)
      Create a change tracker.
      Parameters:
      uri - URI of object being tracked
      policy - policy to track.
      versionMismatches - reference to the version mismatch counter
      s3ObjectAttributes - attributes of the object, potentially including an eTag or versionId to match depending on policy
  • Method Details

    • getRevisionId

      public String getRevisionId()
    • getSource

      public ChangeDetectionPolicy.Source getSource()
    • getVersionMismatches

      @VisibleForTesting public long getVersionMismatches()
    • maybeApplyConstraint

      public boolean maybeApplyConstraint(software.amazon.awssdk.services.s3.model.GetObjectRequest.Builder builder)
      Apply any revision control set by the policy if it is to be enforced on the server.
      Parameters:
      builder - request builder to modify
      Returns:
      true iff a constraint was added.
    • maybeApplyConstraint

      public boolean maybeApplyConstraint(software.amazon.awssdk.services.s3.model.CopyObjectRequest.Builder requestBuilder)
      Apply any revision control set by the policy if it is to be enforced on the server.
      Parameters:
      requestBuilder - copy object request builder to modify
      Returns:
      true iff a constraint was added.
    • maybeApplyConstraint

      public boolean maybeApplyConstraint(software.amazon.awssdk.services.s3.model.HeadObjectRequest.Builder requestBuilder)
    • processResponse

      public void processResponse(software.amazon.awssdk.services.s3.model.GetObjectResponse object, String operation, long pos) throws org.apache.hadoop.fs.PathIOException
      Process the response from the server for validation against the change policy.
      Parameters:
      object - object returned; may be null.
      operation - operation in progress.
      pos - offset of read
      Throws:
      org.apache.hadoop.fs.PathIOException - raised on failure
      RemoteFileChangedException - if the remote file has changed.
    • processResponse

      public void processResponse(software.amazon.awssdk.services.s3.model.CopyObjectResponse copyObjectResponse) throws org.apache.hadoop.fs.PathIOException
      Process the response from the server for validation against the change policy.
      Parameters:
      copyObjectResponse - response of a copy operation
      Throws:
      org.apache.hadoop.fs.PathIOException - raised on failure
      RemoteFileChangedException - if the remote file has changed.
    • processException

      public void processException(software.amazon.awssdk.core.exception.SdkException e, String operation) throws RemoteFileChangedException
      Process an exception generated against the change policy. If the exception indicates the file has changed, this method throws RemoteFileChangedException with the original exception as the cause.
      Parameters:
      e - the exception
      operation - the operation performed when the exception was generated (e.g. "copy", "read").
      Throws:
      RemoteFileChangedException - if the remote file has changed.
    • processMetadata

      public void processMetadata(software.amazon.awssdk.services.s3.model.HeadObjectResponse metadata, String operation) throws org.apache.hadoop.fs.PathIOException
      Process metadata response from server for validation against the change policy.
      Parameters:
      metadata - metadata returned from server
      operation - operation in progress
      Throws:
      org.apache.hadoop.fs.PathIOException - raised on failure
      RemoteFileChangedException - if the remote file has changed.
    • processMetadata

      public void processMetadata(software.amazon.awssdk.services.s3.model.GetObjectResponse getObjectResponse, String operation) throws org.apache.hadoop.fs.PathIOException
      Process the response from server for validation against the change policy.
      Parameters:
      getObjectResponse - response returned from server
      operation - operation in progress
      Throws:
      org.apache.hadoop.fs.PathIOException - raised on failure
      RemoteFileChangedException - if the remote file has changed.
    • toString

      public String toString()
      Overrides:
      toString in class Object