Package org.apache.hadoop.fs.s3a.impl
Class ChangeDetectionPolicy
java.lang.Object
org.apache.hadoop.fs.s3a.impl.ChangeDetectionPolicy
Object change detection policy.
Determines which attribute is used to detect change and what to do when
change is detected.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhat to do when change is detected.static enumThe S3 object attribute used to detect change. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedChangeDetectionPolicy(ChangeDetectionPolicy.Mode mode, boolean requireVersion) -
Method Summary
Modifier and TypeMethodDescriptionabstract voidapplyRevisionConstraint(software.amazon.awssdk.services.s3.model.CopyObjectRequest.Builder requestBuilder, String revisionId) Applies the givenrevisionIdas a server-side qualification on theCopyObjectRequest.abstract voidapplyRevisionConstraint(software.amazon.awssdk.services.s3.model.GetObjectRequest.Builder request, String revisionId) Applies the givenrevisionIdas a server-side qualification on theGetObjectRequest.Builder.abstract voidapplyRevisionConstraint(software.amazon.awssdk.services.s3.model.HeadObjectRequest.Builder requestBuilder, String revisionId) Applies the givenrevisionIdas a server-side qualification on theGetObjectMetadataRequest.static ChangeDetectionPolicycreatePolicy(ChangeDetectionPolicy.Mode mode, ChangeDetectionPolicy.Source source, boolean requireVersion) Create a policy.org.apache.hadoop.fs.store.LogExactlyOncegetMode()static ChangeDetectionPolicygetPolicy(org.apache.hadoop.conf.Configuration configuration) Reads the change detection policy from Configuration.abstract StringgetRevisionId(S3ObjectAttributes s3Attributes) Like {getRevisionId(HeadObjectResponse, String)}, but retrieves the revision identifier fromS3ObjectAttributes.abstract StringgetRevisionId(software.amazon.awssdk.services.s3.model.CopyObjectResponse copyObjectResponse) Like {getRevisionId(HeadObjectResponse, String)}, but retrieves the revision identifier fromCopyObjectResponse.abstract StringgetRevisionId(software.amazon.awssdk.services.s3.model.GetObjectResponse getObjectResponse, String uri) Like {getRevisionId(HeadObjectResponse, String)}, but retrieves the * revision identifier fromGetObjectResponse.abstract StringgetRevisionId(software.amazon.awssdk.services.s3.model.HeadObjectResponse objectMetadata, String uri) Pulls the attribute this policy uses to detect change out of the S3 object metadata.abstract ChangeDetectionPolicy.Sourcebooleanorg.apache.commons.lang3.tuple.ImmutablePair<Boolean,RemoteFileChangedException> onChangeDetected(String revisionId, String newRevisionId, String uri, long position, String operation, long timesAlreadyDetected) Takes appropriate action based onmodewhen a change has been detected.toString()String value for logging.
-
Field Details
-
CHANGE_DETECTED
- See Also:
-
-
Constructor Details
-
ChangeDetectionPolicy
-
-
Method Details
-
getMode
-
getSource
-
isRequireVersion
public boolean isRequireVersion() -
getLogNoVersionSupport
public org.apache.hadoop.fs.store.LogExactlyOnce getLogNoVersionSupport() -
getPolicy
Reads the change detection policy from Configuration.- Parameters:
configuration- the configuration- Returns:
- the policy
-
createPolicy
@VisibleForTesting public static ChangeDetectionPolicy createPolicy(ChangeDetectionPolicy.Mode mode, ChangeDetectionPolicy.Source source, boolean requireVersion) Create a policy.- Parameters:
mode- mode pf checkssource- source of changerequireVersion- throw exception when no version available?- Returns:
- the policy
-
toString
String value for logging. -
getRevisionId
public abstract String getRevisionId(software.amazon.awssdk.services.s3.model.HeadObjectResponse objectMetadata, String uri) Pulls the attribute this policy uses to detect change out of the S3 object metadata. The policy generically refers to this attribute asrevisionId.- Parameters:
objectMetadata- the s3 object metadatauri- the URI of the object- Returns:
- the revisionId string as interpreted by this policy, or potentially null if the attribute is unavailable (such as when the policy says to use versionId but object versioning is not enabled for the bucket).
-
getRevisionId
public abstract String getRevisionId(software.amazon.awssdk.services.s3.model.GetObjectResponse getObjectResponse, String uri) Like {getRevisionId(HeadObjectResponse, String)}, but retrieves the * revision identifier fromGetObjectResponse.- Parameters:
getObjectResponse- the response instanceuri- the URI of the object- Returns:
- the revisionId string as interpreted by this policy, or potentially null if the attribute is unavailable (such as when the policy says to use versionId but object versioning is not enabled for the bucket).
-
getRevisionId
Like {getRevisionId(HeadObjectResponse, String)}, but retrieves the revision identifier fromS3ObjectAttributes.- Parameters:
s3Attributes- the object attributes- Returns:
- the revisionId string as interpreted by this policy, or potentially null if the attribute is unavailable (such as when the policy says to use versionId but object versioning is not enabled for the bucket).
-
getRevisionId
public abstract String getRevisionId(software.amazon.awssdk.services.s3.model.CopyObjectResponse copyObjectResponse) Like {getRevisionId(HeadObjectResponse, String)}, but retrieves the revision identifier fromCopyObjectResponse.- Parameters:
copyObjectResponse- the copy response- Returns:
- the revisionId string as interpreted by this policy, or potentially null if the attribute is unavailable (such as when the policy says to use versionId but object versioning is not enabled for the bucket).
-
applyRevisionConstraint
public abstract void applyRevisionConstraint(software.amazon.awssdk.services.s3.model.GetObjectRequest.Builder request, String revisionId) Applies the givenrevisionIdas a server-side qualification on theGetObjectRequest.Builder.- Parameters:
request- the requestrevisionId- the revision id
-
applyRevisionConstraint
public abstract void applyRevisionConstraint(software.amazon.awssdk.services.s3.model.CopyObjectRequest.Builder requestBuilder, String revisionId) Applies the givenrevisionIdas a server-side qualification on theCopyObjectRequest.- Parameters:
requestBuilder- the copy object request builderrevisionId- the revision id
-
applyRevisionConstraint
public abstract void applyRevisionConstraint(software.amazon.awssdk.services.s3.model.HeadObjectRequest.Builder requestBuilder, String revisionId) Applies the givenrevisionIdas a server-side qualification on theGetObjectMetadataRequest.- Parameters:
requestBuilder- the head object request builderrevisionId- the revision id
-
onChangeDetected
public org.apache.commons.lang3.tuple.ImmutablePair<Boolean,RemoteFileChangedException> onChangeDetected(String revisionId, String newRevisionId, String uri, long position, String operation, long timesAlreadyDetected) Takes appropriate action based onmodewhen a change has been detected.- Parameters:
revisionId- the expected revision idnewRevisionId- the detected revision iduri- the URI of the object being accessedposition- the position being read in the objectoperation- the operation being performed on the object (e.g. open or re-open) that triggered the change detectiontimesAlreadyDetected- number of times a change has already been detected on the current stream- Returns:
- a pair of: was a change detected, and any exception to throw. If the change was detected, this updates a counter in the stream statistics; If an exception was returned it is thrown after the counter update.
-