Class WriteEnabledBucket
- java.lang.Object
-
- com.exasol.bucketfs.ReadEnabledBucket
-
- com.exasol.bucketfs.WriteEnabledBucket
-
- All Implemented Interfaces:
ReadOnlyBucket,UnsynchronizedBucket
- Direct Known Subclasses:
SyncAwareBucket
public class WriteEnabledBucket extends ReadEnabledBucket implements UnsynchronizedBucket
An abstraction for a bucket inside Exasol's BucketFS.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWriteEnabledBucket.Builder<T extends WriteEnabledBucket.Builder<T>>Builder forWriteEnabledBucketobjects.
-
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 protectedWriteEnabledBucket(WriteEnabledBucket.Builder<? extends WriteEnabledBucket.Builder<?>> builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static WriteEnabledBucket.Builder<? extends WriteEnabledBucket.Builder<?>>builder()Create builder for aWriteEnabledBucket.protected BucketAccessExceptioncreateUploadInterruptedException(URI uri)Create UploadInterruptedException.protected BucketAccessExceptioncreateUploadIoException(URI uri, IOException exception)Create UploadIoException.voiddeleteFileNonBlocking(String filenameInBucket)Delete a file from BucketFS.StringgetWritePassword()Get the write password for the bucket.protected voidrecordUploadInHistory(String pathInBucket)Record the upload in the internal upload history of this bucket object.voidsetUploadNecessityCheckStrategy(UploadNecessityCheckStrategy uploadNecessityCheckStrategy)Set anUploadNecessityCheckStrategy.UploadResultuploadFileNonBlocking(Path localPath, String pathInBucket)Upload a file to the bucket.voiduploadInputStreamNonBlocking(Supplier<InputStream> inputStreamSupplier, String pathInBucket)Upload the contents of an input stream to the bucket non-blocking.voiduploadStringContentNonBlocking(String content, String pathInBucket)Upload the contents of a string to the bucket.protected voiduploadWithBodyPublisher(URI uri, HttpRequest.BodyPublisher publisher, String what)Upload with body publisher.-
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
-
-
-
-
Constructor Detail
-
WriteEnabledBucket
protected WriteEnabledBucket(WriteEnabledBucket.Builder<? extends WriteEnabledBucket.Builder<?>> builder)
- Parameters:
builder- builder
-
-
Method Detail
-
getWritePassword
public String getWritePassword()
Description copied from interface:UnsynchronizedBucketGet the write password for the bucket.- Specified by:
getWritePasswordin interfaceUnsynchronizedBucket- Returns:
- write password.
-
uploadFileNonBlocking
public UploadResult uploadFileNonBlocking(Path localPath, String pathInBucket) throws BucketAccessException, FileNotFoundException
Description copied from interface:UnsynchronizedBucketUpload 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 immediately returns without checking whether or not the file is actually synchronized in the in BucketFS.
- Specified by:
uploadFileNonBlockingin interfaceUnsynchronizedBucket- Parameters:
localPath- path of the file to be uploadedpathInBucket- path inside the bucket- Returns:
UploadResultdescribing the status of the upload- Throws:
BucketAccessException- if the file cannot be uploaded to the given URIFileNotFoundException- in case the source file is not found
-
uploadWithBodyPublisher
protected void uploadWithBodyPublisher(URI uri, HttpRequest.BodyPublisher publisher, String what) throws BucketAccessException
Upload with body publisher.- Parameters:
uri- uripublisher- publisherwhat- what- Throws:
BucketAccessException- BucketAccessException
-
createUploadIoException
protected BucketAccessException createUploadIoException(URI uri, IOException exception)
Create UploadIoException.- Parameters:
uri- uriexception- exception- Returns:
- BucketAccessException
-
createUploadInterruptedException
protected BucketAccessException createUploadInterruptedException(URI uri)
Create UploadInterruptedException.- Parameters:
uri- uri- Returns:
- BucketAccessException
-
recordUploadInHistory
protected void recordUploadInHistory(String pathInBucket)
Record the upload in the internal upload history of this bucket object.This is mainly necessary to work around issues with detecting repeated uploads. Under certain circumstances they need to be delayed and the upload history helps with that.
- Parameters:
pathInBucket- path in the bucket to which an upload happened.
-
uploadStringContentNonBlocking
public void uploadStringContentNonBlocking(String content, String pathInBucket) throws BucketAccessException, TimeoutException
Description copied from interface:UnsynchronizedBucketUpload 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
UnsynchronizedBucket.uploadFileNonBlocking(Path, String)instead.This call immediately returns without checking whether or not the file is actually synchronized in the in BucketFS.
- Specified by:
uploadStringContentNonBlockingin interfaceUnsynchronizedBucket- Parameters:
content- string to writepathInBucket- path inside the bucket- Throws:
BucketAccessException- if the file cannot be uploaded to the given URITimeoutException- if synchronization takes too long
-
uploadInputStreamNonBlocking
public void uploadInputStreamNonBlocking(Supplier<InputStream> inputStreamSupplier, String pathInBucket) throws BucketAccessException, TimeoutException
Description copied from interface:UnsynchronizedBucketUpload the contents of an input stream to the bucket non-blocking.- Specified by:
uploadInputStreamNonBlockingin interfaceUnsynchronizedBucket- 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 WriteEnabledBucket.Builder<? extends WriteEnabledBucket.Builder<?>> builder()
Create builder for aWriteEnabledBucket.- Returns:
- builder
-
deleteFileNonBlocking
public void deleteFileNonBlocking(String filenameInBucket) throws BucketAccessException
Description copied from interface:UnsynchronizedBucketDelete a file from BucketFS.Warning: If you try to upload a file shortly (less than about 30s) after you deleted it, the upload will fail with access denied.
- Specified by:
deleteFileNonBlockingin interfaceUnsynchronizedBucket- Parameters:
filenameInBucket- file path- Throws:
BucketAccessException- if delete failed
-
setUploadNecessityCheckStrategy
public void setUploadNecessityCheckStrategy(UploadNecessityCheckStrategy uploadNecessityCheckStrategy)
Description copied from interface:UnsynchronizedBucketSet anUploadNecessityCheckStrategy.This class uses the strategy during file upload to decide if the file should really be uploaded.
- Specified by:
setUploadNecessityCheckStrategyin interfaceUnsynchronizedBucket- Parameters:
uploadNecessityCheckStrategy- strategy to use from now on
-
-