Package org.apache.hadoop.fs.s3a.impl
Class ChangeTracker
java.lang.Object
org.apache.hadoop.fs.s3a.impl.ChangeTracker
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionChangeTracker(String uri, ChangeDetectionPolicy policy, ChangeTrackerStatistics versionMismatches, S3ObjectAttributes s3ObjectAttributes) Create a change tracker. -
Method Summary
Modifier and TypeMethodDescriptionlongbooleanmaybeApplyConstraint(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.booleanmaybeApplyConstraint(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.booleanmaybeApplyConstraint(software.amazon.awssdk.services.s3.model.HeadObjectRequest.Builder requestBuilder) voidprocessException(software.amazon.awssdk.core.exception.SdkException e, String operation) Process an exception generated against the change policy.voidprocessMetadata(software.amazon.awssdk.services.s3.model.GetObjectResponse getObjectResponse, String operation) Process the response from server for validation against the change policy.voidprocessMetadata(software.amazon.awssdk.services.s3.model.HeadObjectResponse metadata, String operation) Process metadata response from server for validation against the change policy.voidprocessResponse(software.amazon.awssdk.services.s3.model.CopyObjectResponse copyObjectResponse) Process the response from the server for validation against the change policy.voidprocessResponse(software.amazon.awssdk.services.s3.model.GetObjectResponse object, String operation, long pos) Process the response from the server for validation against the change policy.toString()
-
Field Details
-
CHANGE_REPORTED_BY_S3
- See Also:
-
-
Constructor Details
-
ChangeTracker
public ChangeTracker(String uri, ChangeDetectionPolicy policy, ChangeTrackerStatistics versionMismatches, S3ObjectAttributes s3ObjectAttributes) Create a change tracker.- Parameters:
uri- URI of object being trackedpolicy- policy to track.versionMismatches- reference to the version mismatch counters3ObjectAttributes- attributes of the object, potentially including an eTag or versionId to match depending onpolicy
-
-
Method Details
-
getRevisionId
-
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 failureRemoteFileChangedException- 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 failureRemoteFileChangedException- 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 throwsRemoteFileChangedExceptionwith the original exception as the cause.- Parameters:
e- the exceptionoperation- 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 serveroperation- operation in progress- Throws:
org.apache.hadoop.fs.PathIOException- raised on failureRemoteFileChangedException- 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 serveroperation- operation in progress- Throws:
org.apache.hadoop.fs.PathIOException- raised on failureRemoteFileChangedException- if the remote file has changed.
-
toString
-