Class ChecksumUploadNecessityCheckStrategy
- java.lang.Object
-
- com.exasol.bucketfs.uploadnecessity.ChecksumUploadNecessityCheckStrategy
-
- All Implemented Interfaces:
UploadNecessityCheckStrategy
public class ChecksumUploadNecessityCheckStrategy extends Object implements UploadNecessityCheckStrategy
ThisUploadNecessityCheckStrategycompares the checksum of the local file and the file on BucketFS and only uploads the file if the checksums differ or if the file does not exist in BucketFS. For performance reasons this strategy always uploads files with a size less or equal 1 MB.
-
-
Constructor Summary
Constructors Constructor Description ChecksumUploadNecessityCheckStrategy(Connection sqlConnection)Create a new instance ofChecksumUploadNecessityCheckStrategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetSha512Checksum(String fileInBucketFs, ReadOnlyBucket bucket)Get the SHA-512-checksum of a file in BucketFS.booleanisUploadNecessary(Path file, String fullFileNameInBucketFs, ReadOnlyBucket bucket)Decide if it is necessary to upload a file to BucketFS.
-
-
-
Constructor Detail
-
ChecksumUploadNecessityCheckStrategy
public ChecksumUploadNecessityCheckStrategy(Connection sqlConnection)
Create a new instance ofChecksumUploadNecessityCheckStrategy.This strategy uses a User Defined Function (UDF) to create the checksum of the file in BucketFS. Therefore it requires a database connection.
- Parameters:
sqlConnection- SQL connection to the Exasol database
-
-
Method Detail
-
isUploadNecessary
public boolean isUploadNecessary(Path file, String fullFileNameInBucketFs, ReadOnlyBucket bucket) throws BucketAccessException
Description copied from interface:UploadNecessityCheckStrategyDecide if it is necessary to upload a file to BucketFS.- Specified by:
isUploadNecessaryin interfaceUploadNecessityCheckStrategy- Parameters:
file- local filefullFileNameInBucketFs- path to the file in BucketFSbucket- bucket the file is uploaded to- Returns:
trueif the file should get uploaded- Throws:
BucketAccessException- if the necessity check cannot be executed
-
getSha512Checksum
public String getSha512Checksum(String fileInBucketFs, ReadOnlyBucket bucket) throws BucketAccessException
Get the SHA-512-checksum of a file in BucketFS.- Parameters:
fileInBucketFs- path to a file in bucketFsbucket- bucket the file is stored in- Returns:
- sha 512 checksum
- Throws:
BucketAccessException- if checksum calculation failed
-
-