Package com.exasol.bucketfs
Class SyncAwareBucket
- java.lang.Object
-
- com.exasol.bucketfs.ReadEnabledBucket
-
- com.exasol.bucketfs.WriteEnabledBucket
-
- com.exasol.bucketfs.SyncAwareBucket
-
- All Implemented Interfaces:
Bucket,ReadOnlyBucket,UnsynchronizedBucket
public class SyncAwareBucket extends WriteEnabledBucket implements Bucket
An abstraction for a bucket inside Exasol's BucketFS.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSyncAwareBucket.Builder<T extends SyncAwareBucket.Builder<T>>Builder forSyncAwareBucketobjects.
-
Field Summary
-
Fields inherited from class com.exasol.bucketfs.ReadEnabledBucket
bucketName, host, port, readPassword, serviceName, uploadHistory
-
Fields inherited from interface com.exasol.bucketfs.UnsynchronizedBucket
SUPPORTED_ARCHIVE_EXTENSIONS
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSyncAwareBucket(SyncAwareBucket.Builder<? extends SyncAwareBucket.Builder<?>> builder)Sync aware bucket.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SyncAwareBucket.Builder<? extends SyncAwareBucket.Builder<?>>builder()Create builder for aSyncAwareBucket.booleanisObjectSynchronized(String pathInBucket, BucketFsMonitor.State state)Check if the object with the given path is marked as synchronized after a given point in time.voiduploadFile(Path localPath, String pathInBucket)Upload a file to the bucket.voiduploadInputStream(Supplier<InputStream> inputStreamSupplier, String pathInBucket)Upload the contents of an input stream to the bucket.voiduploadStringContent(String content, String pathInBucket)Upload the contents of a string to the bucket.-
Methods inherited from class com.exasol.bucketfs.WriteEnabledBucket
createUploadInterruptedException, createUploadIoException, deleteFileNonBlocking, getWritePassword, recordUploadInHistory, setUploadNecessityCheckStrategy, uploadFileNonBlocking, uploadInputStreamNonBlocking, uploadStringContentNonBlocking, uploadWithBodyPublisher
-
Methods inherited from class com.exasol.bucketfs.ReadEnabledBucket
downloadFile, downloadFileAsString, extendPathInBucketDownToFilename, getBucketFsName, getBucketName, getClient, getFullyQualifiedBucketName, getReadPassword, listContents, listContents, listContentsRecursively, listContentsRecursively, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.exasol.bucketfs.ReadOnlyBucket
downloadFile, downloadFileAsString, getBucketFsName, getBucketName, getFullyQualifiedBucketName, getReadPassword, listContents, listContents, listContentsRecursively, listContentsRecursively
-
Methods inherited from interface com.exasol.bucketfs.UnsynchronizedBucket
deleteFileNonBlocking, getWritePassword, setUploadNecessityCheckStrategy, uploadFileNonBlocking, uploadInputStreamNonBlocking, uploadStringContentNonBlocking
-
-
-
-
Constructor Detail
-
SyncAwareBucket
protected SyncAwareBucket(SyncAwareBucket.Builder<? extends SyncAwareBucket.Builder<?>> builder)
Sync aware bucket.- Parameters:
builder- builder
-
-
Method Detail
-
isObjectSynchronized
public boolean isObjectSynchronized(String pathInBucket, BucketFsMonitor.State state) throws BucketAccessException
Description copied from interface:BucketCheck if the object with the given path is marked as synchronized after a given point in time.The timestamp helps telling subsequent synchronizations appart.
- Specified by:
isObjectSynchronizedin interfaceBucket- Parameters:
pathInBucket- path to the object inside the bucketstate- state after which the synchronization needs to happen.- Returns:
trueif the object is synchronized- Throws:
BucketAccessException- if the object at the reference does not exist or is inaccessible
-
uploadFile
public void uploadFile(Path localPath, String pathInBucket) throws TimeoutException, BucketAccessException, FileNotFoundException
Description copied from interface:BucketUpload a file to the bucket.Upload a file from a given local path to a URI pointing to a BucketFS bucket. If the bucket URI ends in a slash, that URI is interpreted as a directory inside the bucket and the original filename is appended.
This call blocks until the uploaded file is synchronized in BucketFS or a timeout occurs.
- Specified by:
uploadFilein interfaceBucket- Parameters:
localPath- path of the file to be uploadedpathInBucket- path inside the bucket- Throws:
TimeoutException- if the synchronization check takes too longBucketAccessException- if the file cannot be uploaded to the given URIFileNotFoundException- if the source file is not found
-
uploadStringContent
public void uploadStringContent(String content, String pathInBucket) throws InterruptedException, BucketAccessException, TimeoutException
Description copied from interface:BucketUpload the contents of a string to the bucket.This method is intended for writing small objects in BucketFS dynamically like for example configuration files. For large payload use
Bucket.uploadFile(Path, String)instead.This call blocks until the uploaded file is synchronized in BucketFS or a timeout occurs.
- Specified by:
uploadStringContentin interfaceBucket- Parameters:
content- string to writepathInBucket- path inside the bucket- Throws:
InterruptedException- if the upload is interruptedBucketAccessException- if the file cannot be uploaded to the given URITimeoutException- if synchronization takes too long
-
uploadInputStream
public void uploadInputStream(Supplier<InputStream> inputStreamSupplier, String pathInBucket) throws BucketAccessException, TimeoutException
Description copied from interface:BucketUpload the contents of an input stream to the bucket.- Specified by:
uploadInputStreamin interfaceBucket- Parameters:
inputStreamSupplier- supplier that provides the input streampathInBucket- path inside the bucket- Throws:
BucketAccessException- if the file cannot be uploaded to the given URITimeoutException- if synchronization takes too long
-
builder
public static SyncAwareBucket.Builder<? extends SyncAwareBucket.Builder<?>> builder()
Create builder for aSyncAwareBucket.- Returns:
- builder
-
-