Class FilterBlobContainer
- All Implemented Interfaces:
BlobContainer
wrapChild(org.elasticsearch.common.blobstore.BlobContainer) so
that the abstraction is complete: so that the internal BlobContainer instance cannot leak out of this wrapper.
Inheritors can safely modify needed methods while continuing to have access to a complete BlobContainer implementation beneath.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.blobstore.BlobContainer
BlobContainer.BlobMultiPartInputStreamProvider -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanblobExists(OperationPurpose purpose, String blobName) Tests whether a blob with the given blob name exists in the container.children(OperationPurpose purpose) Lists all child containers under this container.voidcompareAndExchangeRegister(OperationPurpose purpose, String key, BytesReference expected, BytesReference updated, ActionListener<OptionalBytesReference> listener) Atomically sets the value stored at the given key toupdatedif thecurrent value == expected.voidcompareAndSetRegister(OperationPurpose purpose, String key, BytesReference expected, BytesReference updated, ActionListener<Boolean> listener) Atomically sets the value stored at the given key toupdatedif thecurrent value == expected.voidcopyBlob(OperationPurpose purpose, BlobContainer sourceBlobContainer, String sourceBlobName, String blobName, long blobSize) Copy a blob into this container from a source blob container and name.delete(OperationPurpose purpose) Deletes this container and all its contents from the repository.voiddeleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) Deletes the blobs with given names.voidgetRegister(OperationPurpose purpose, String key, ActionListener<OptionalBytesReference> listener) Gets the value set byBlobContainer.compareAndSetRegister(org.elasticsearch.common.blobstore.OperationPurpose, java.lang.String, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.action.ActionListener<java.lang.Boolean>)orBlobContainer.compareAndExchangeRegister(org.elasticsearch.common.blobstore.OperationPurpose, java.lang.String, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.action.ActionListener<org.elasticsearch.common.blobstore.OptionalBytesReference>)for a given key.listBlobs(OperationPurpose purpose) Lists all blobs in the container.listBlobsByPrefix(OperationPurpose purpose, String blobNamePrefix) Lists all blobs in the container that match the specified prefix.path()Gets theBlobPaththat defines the implementation specific paths to where the blobs are contained.readBlob(OperationPurpose purpose, String blobName) Creates a newInputStreamfor the given blob name.readBlob(OperationPurpose purpose, String blobName, long position, long length) Creates a newInputStreamthat can be used to read the given blob starting from a specificpositionin the blob.longProvides a hint to clients for a suitable length to use withBlobContainer.readBlob(OperationPurpose, String, long, long).booleanIndicates if the implementation supports writing large blobs using concurrent multipart uploads.protected abstract BlobContainerwrapChild(BlobContainer child) Wraps up any instances of the internal BlobContainer type in another BlobContainer type (presumably the implementation's type).voidwriteBlob(OperationPurpose purpose, String blobName, InputStream inputStream, long blobSize, boolean failIfAlreadyExists) Reads blob content from the input stream and writes it to the container in a new blob with the given name.voidwriteBlobAtomic(OperationPurpose purpose, String blobName, long blobSize, BlobContainer.BlobMultiPartInputStreamProvider provider, boolean failIfAlreadyExists) Reads the blob's content by calling an input stream provider multiple times, in order to split the blob's content into multiple parts that can be written to the container concurrently before being assembled into the final blob, using an atomic write operation if the implementation supports it.voidwriteBlobAtomic(OperationPurpose purpose, String blobName, InputStream inputStream, long blobSize, boolean failIfAlreadyExists) Reads blob content from the input stream and writes it to the container in a new blob with the given name, using an atomic write operation if the implementation supports it.voidwriteBlobAtomic(OperationPurpose purpose, String blobName, BytesReference bytes, boolean failIfAlreadyExists) Reads blob content from aBytesReferenceand writes it to the container in a new blob with the given name, using an atomic write operation if the implementation supports it.voidwriteMetadataBlob(OperationPurpose purpose, String blobName, boolean failIfAlreadyExists, boolean atomic, CheckedConsumer<OutputStream, IOException> writer) Write a blob by providing a consumer that will write its contents to an output stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.common.blobstore.BlobContainer
writeBlob
-
Constructor Details
-
FilterBlobContainer
-
-
Method Details
-
wrapChild
Wraps up any instances of the internal BlobContainer type in another BlobContainer type (presumably the implementation's type). Ensures that the internaldelegatetype never leaks out of the BlobContainer wrapper type. -
path
Description copied from interface:BlobContainerGets theBlobPaththat defines the implementation specific paths to where the blobs are contained.- Specified by:
pathin interfaceBlobContainer- Returns:
- the BlobPath where the blobs are contained
-
blobExists
Description copied from interface:BlobContainerTests whether a blob with the given blob name exists in the container.- Specified by:
blobExistsin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationblobName- The name of the blob whose existence is to be determined.- Returns:
trueif a blob exists in theBlobContainerwith the given name, andfalseotherwise.- Throws:
IOException
-
readBlob
Description copied from interface:BlobContainerCreates a newInputStreamfor the given blob name.- Specified by:
readBlobin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationblobName- The name of the blob to get anInputStreamfor.- Returns:
- The
InputStreamto read the blob. - Throws:
IOException- if the blob can not be read.
-
readBlob
public InputStream readBlob(OperationPurpose purpose, String blobName, long position, long length) throws IOException Description copied from interface:BlobContainerCreates a newInputStreamthat can be used to read the given blob starting from a specificpositionin the blob. Thelengthis an indication of the number of bytes that are expected to be read from theInputStream.- Specified by:
readBlobin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationblobName- The name of the blob to get anInputStreamfor.position- The position in the blob where the next byte will be read.length- An indication of the number of bytes to be read.- Returns:
- The
InputStreamto read the blob. - Throws:
IOException- if the blob can not be read.
-
readBlobPreferredLength
public long readBlobPreferredLength()Description copied from interface:BlobContainerProvides a hint to clients for a suitable length to use withBlobContainer.readBlob(OperationPurpose, String, long, long). Some blob containers have nontrivial costs attached to each readBlob call, so it is a good idea for consumers to speculatively request more data than they need right now and to re-use this stream for future needs if possible. Also, some blob containers return streams that are expensive to close before the stream has been fully consumed, and the cost may depend on the length of the data that was left unconsumed. For these containers it's best to bound the cost of a partial read by bounding the length of the data requested.- Specified by:
readBlobPreferredLengthin interfaceBlobContainer- Returns:
- a hint to consumers regarding the length of data to request if there is a good chance that future reads can be satisfied from the same stream.
-
writeBlob
public void writeBlob(OperationPurpose purpose, String blobName, InputStream inputStream, long blobSize, boolean failIfAlreadyExists) throws IOException Description copied from interface:BlobContainerReads blob content from the input stream and writes it to the container in a new blob with the given name. This method assumes the container does not already contain a blob of the same blobName. If a blob by the same name already exists, the operation will fail and anIOExceptionwill be thrown.- Specified by:
writeBlobin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationblobName- The name of the blob to write the contents of the input stream to.inputStream- The input stream from which to retrieve the bytes to write to the blob.blobSize- The size of the blob to be written, in bytes. Must be the amount of bytes in the input stream. It is implementation dependent whether this value is used in writing the blob to the repository.failIfAlreadyExists- whether to throw a FileAlreadyExistsException if the given blob already exists- Throws:
IOException- if the input stream could not be read, or the target blob could not be written to.
-
writeMetadataBlob
public void writeMetadataBlob(OperationPurpose purpose, String blobName, boolean failIfAlreadyExists, boolean atomic, CheckedConsumer<OutputStream, IOException> writer) throws IOExceptionDescription copied from interface:BlobContainerWrite a blob by providing a consumer that will write its contents to an output stream. This method allows serializing a blob's contents directly to the blob store without having to materialize the serialized version in full before writing. This method is only used for streaming serialization of repository metadata that is known to be of limited size at any point in time and across all concurrent invocations of this method.- Specified by:
writeMetadataBlobin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationblobName- the name of the blob to writefailIfAlreadyExists- whether to throw a FileAlreadyExistsException if the given blob already existsatomic- whether the write should be atomic in case the implementation supports itwriter- consumer for an output stream that will write the blob contents to the stream- Throws:
IOException
-
supportsConcurrentMultipartUploads
public boolean supportsConcurrentMultipartUploads()Description copied from interface:BlobContainerIndicates if the implementation supports writing large blobs using concurrent multipart uploads.- Specified by:
supportsConcurrentMultipartUploadsin interfaceBlobContainer- Returns:
trueif the implementation supports writing large blobs using concurrent multipart uploads,falseotherwise
-
writeBlobAtomic
public void writeBlobAtomic(OperationPurpose purpose, String blobName, long blobSize, BlobContainer.BlobMultiPartInputStreamProvider provider, boolean failIfAlreadyExists) throws IOException Description copied from interface:BlobContainerReads the blob's content by calling an input stream provider multiple times, in order to split the blob's content into multiple parts that can be written to the container concurrently before being assembled into the final blob, using an atomic write operation if the implementation supports it. The number and the size of the parts depends of the implementation. Note: the method {linkBlobContainer.supportsConcurrentMultipartUploads()} must be checked before calling this method.- Specified by:
writeBlobAtomicin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationblobName- The name of the blob to write the contents of the input stream to.blobSize- The size of the blob to be written, in bytes. Must be the amount of bytes in the input stream. It is implementation dependent whether this value is used in writing the blob to the repository.provider- The input stream provider that is used to read the blob contentfailIfAlreadyExists- whether to throw a FileAlreadyExistsException if the given blob already exists- Throws:
IOException- if the input stream could not be read, or the target blob could not be written to.
-
writeBlobAtomic
public void writeBlobAtomic(OperationPurpose purpose, String blobName, InputStream inputStream, long blobSize, boolean failIfAlreadyExists) throws IOException Description copied from interface:BlobContainerReads blob content from the input stream and writes it to the container in a new blob with the given name, using an atomic write operation if the implementation supports it.- Specified by:
writeBlobAtomicin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationblobName- The name of the blob to write the contents of the input stream to.inputStream- The input stream from which to retrieve the bytes to write to the blob.blobSize- The size of the blob to be written, in bytes. Must be the amount of bytes in the input stream. It is implementation dependent whether this value is used in writing the blob to the repository.failIfAlreadyExists- whether to throw a FileAlreadyExistsException if the given blob already exists- Throws:
IOException- if the input stream could not be read, or the target blob could not be written to.
-
writeBlobAtomic
public void writeBlobAtomic(OperationPurpose purpose, String blobName, BytesReference bytes, boolean failIfAlreadyExists) throws IOException Description copied from interface:BlobContainerReads blob content from aBytesReferenceand writes it to the container in a new blob with the given name, using an atomic write operation if the implementation supports it.- Specified by:
writeBlobAtomicin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationblobName- The name of the blob to write the contents of the input stream to.bytes- The bytes to writefailIfAlreadyExists- whether to throw a FileAlreadyExistsException if the given blob already exists- Throws:
IOException- if the input stream could not be read, or the target blob could not be written to.
-
copyBlob
public void copyBlob(OperationPurpose purpose, BlobContainer sourceBlobContainer, String sourceBlobName, String blobName, long blobSize) throws IOException Description copied from interface:BlobContainerCopy a blob into this container from a source blob container and name. If copy is unavailable then throws UnsupportedOperationException. It may be unavailable either because the blob container has no copy implementation or because the target blob container is not on the same store as the source. If the destination blob already exists, this operation will overwrite it.- Specified by:
copyBlobin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationsourceBlobContainer- The blob container to copy the blob intosourceBlobName- The name of the blob to copy fromblobName- The name of the blob to copy toblobSize- The size of the source blob in bytes (needed because some object stores use different implementations for very large blobs)- Throws:
IOException- If the operation generates an IO error
-
delete
Description copied from interface:BlobContainerDeletes this container and all its contents from the repository.- Specified by:
deletein interfaceBlobContainer- Parameters:
purpose- The purpose of the operation- Returns:
- delete result
- Throws:
IOException- on failure
-
deleteBlobsIgnoringIfNotExists
public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator<String> blobNames) throws IOException Description copied from interface:BlobContainerDeletes the blobs with given names. This method will not throw an exception when one or multiple of the given blobs don't exist and simply ignore this case.- Specified by:
deleteBlobsIgnoringIfNotExistsin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationblobNames- the names of the blobs to delete- Throws:
IOException- if a subset of blob exists but could not be deleted.
-
listBlobs
Description copied from interface:BlobContainerLists all blobs in the container.- Specified by:
listBlobsin interfaceBlobContainer- Returns:
- A map of all the blobs in the container. The keys in the map are the names of the blobs and
the values are
BlobMetadata, containing basic information about each blob. - Throws:
IOException- if there were any failures in reading from the blob container.
-
children
Description copied from interface:BlobContainerLists all child containers under this container. A child container is defined as a container whoseBlobContainer.path()method returns a path that has this containersBlobContainer.path()return as its prefix and has one more path element than the current container's path.- Specified by:
childrenin interfaceBlobContainer- Parameters:
purpose- The purpose of the operation- Returns:
- Map of name of the child container to child container
- Throws:
IOException- on failure to list child containers
-
listBlobsByPrefix
public Map<String,BlobMetadata> listBlobsByPrefix(OperationPurpose purpose, String blobNamePrefix) throws IOException Description copied from interface:BlobContainerLists all blobs in the container that match the specified prefix.- Specified by:
listBlobsByPrefixin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationblobNamePrefix- The prefix to match against blob names in the container.- Returns:
- A map of the matching blobs in the container. The keys in the map are the names of the blobs
and the values are
BlobMetadata, containing basic information about each blob. - Throws:
IOException- if there were any failures in reading from the blob container.
-
compareAndExchangeRegister
public void compareAndExchangeRegister(OperationPurpose purpose, String key, BytesReference expected, BytesReference updated, ActionListener<OptionalBytesReference> listener) Description copied from interface:BlobContainerAtomically sets the value stored at the given key toupdatedif thecurrent value == expected. If a key has not yet been used as a register, its initial value is an emptyBytesReference.This operation, together with
BlobContainer.compareAndSetRegister(org.elasticsearch.common.blobstore.OperationPurpose, java.lang.String, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.action.ActionListener<java.lang.Boolean>), must have linearizable semantics: a collection of such operations must act as if they operate serially, with each operation taking place at some instant in between its invocation and its completion.If the listener completes exceptionally then the write operation should be considered as continuing to run and may therefore appear to occur at some later point in time.
- Specified by:
compareAndExchangeRegisterin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationkey- key of the value to updateexpected- the expected valueupdated- the new valuelistener- a listener, completed with the value read from the register (before it was updated) orOptionalBytesReference.MISSINGif the value could not be read due to concurrent activity.
-
compareAndSetRegister
public void compareAndSetRegister(OperationPurpose purpose, String key, BytesReference expected, BytesReference updated, ActionListener<Boolean> listener) Description copied from interface:BlobContainerAtomically sets the value stored at the given key toupdatedif thecurrent value == expected. If a key has not yet been used as a register, its initial value is an emptyBytesReference.This operation, together with
BlobContainer.compareAndExchangeRegister(org.elasticsearch.common.blobstore.OperationPurpose, java.lang.String, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.action.ActionListener<org.elasticsearch.common.blobstore.OptionalBytesReference>), must have linearizable semantics: a collection of such operations must act as if they operate serially, with each operation taking place at some instant in between its invocation and its completion.If the listener completes exceptionally then the write operation should be considered as continuing to run and may therefore appear to occur at some later point in time.
- Specified by:
compareAndSetRegisterin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationkey- key of the value to updateexpected- the expected valueupdated- the new valuelistener- a listener which is completed withBoolean.TRUEif successful,Boolean.FALSEif the expected value did not match the updated value or the value could not be read due to concurrent activity
-
getRegister
public void getRegister(OperationPurpose purpose, String key, ActionListener<OptionalBytesReference> listener) Description copied from interface:BlobContainerGets the value set byBlobContainer.compareAndSetRegister(org.elasticsearch.common.blobstore.OperationPurpose, java.lang.String, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.action.ActionListener<java.lang.Boolean>)orBlobContainer.compareAndExchangeRegister(org.elasticsearch.common.blobstore.OperationPurpose, java.lang.String, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.action.ActionListener<org.elasticsearch.common.blobstore.OptionalBytesReference>)for a given key. If a key has not yet been used as a register, its initial value is an emptyBytesReference.This operation has read-after-write consistency with respect to writes performed using
BlobContainer.compareAndExchangeRegister(org.elasticsearch.common.blobstore.OperationPurpose, java.lang.String, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.action.ActionListener<org.elasticsearch.common.blobstore.OptionalBytesReference>)andBlobContainer.compareAndSetRegister(org.elasticsearch.common.blobstore.OperationPurpose, java.lang.String, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.action.ActionListener<java.lang.Boolean>), but does not guarantee full linearizability. In particular, agetRegisterperformed during one of these write operations may return either the old or the new value, and a caller may therefore observe the old value after observing the new value, as long as both such read operations take place before the success of the write operation.Write operations which complete exceptionally may behave as if they continue to run, thus yielding old or new values for an extended period of time. If multiple writes fail then
getRegistermay return any of the written values.- Specified by:
getRegisterin interfaceBlobContainer- Parameters:
purpose- The purpose of the operationkey- key of the value to getlistener- a listener, completed with the value read from the register orOptionalBytesReference#MISSINGif the value could not be read due to concurrent activity (which should not happen).
-