Class FilterBlobContainer
java.lang.Object
org.elasticsearch.common.blobstore.support.FilterBlobContainer
- All Implemented Interfaces:
BlobContainer
public abstract class FilterBlobContainer extends java.lang.Object implements BlobContainer
-
Constructor Summary
Constructors Constructor Description FilterBlobContainer(BlobContainer delegate) -
Method Summary
Modifier and Type Method Description booleanblobExists(java.lang.String blobName)Tests whether a blob with the given blob name exists in the container.java.util.Map<java.lang.String,BlobContainer>children()Lists all child containers under this container.DeleteResultdelete()Deletes this container and all its contents from the repository.voiddeleteBlobsIgnoringIfNotExists(java.util.List<java.lang.String> blobNames)Deletes the blobs with given names.java.util.Map<java.lang.String,BlobMetadata>listBlobs()Lists all blobs in the container.java.util.Map<java.lang.String,BlobMetadata>listBlobsByPrefix(java.lang.String blobNamePrefix)Lists all blobs in the container that match the specified prefix.BlobPathpath()Gets theBlobPaththat defines the implementation specific paths to where the blobs are contained.java.io.InputStreamreadBlob(java.lang.String blobName)Creates a newInputStreamfor the given blob name.java.io.InputStreamreadBlob(java.lang.String blobName, long position, long length)Creates a newInputStreamthat can be used to read the given blob starting from a specificpositionin the blob.longreadBlobPreferredLength()Provides a hint to clients for a suitable length to use withBlobContainer.readBlob(String, long, long).protected abstract BlobContainerwrapChild(BlobContainer child)voidwriteBlob(java.lang.String blobName, java.io.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(java.lang.String blobName, java.io.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.
-
Constructor Details
-
Method Details
-
wrapChild
-
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
public boolean blobExists(java.lang.String blobName) throws java.io.IOExceptionDescription copied from interface:BlobContainerTests whether a blob with the given blob name exists in the container.- Specified by:
blobExistsin interfaceBlobContainer- Parameters:
blobName- The name of the blob whose existence is to be determined.- Returns:
trueif a blob exists in theBlobContainerwith the given name, andfalseotherwise.- Throws:
java.io.IOException
-
readBlob
public java.io.InputStream readBlob(java.lang.String blobName) throws java.io.IOExceptionDescription copied from interface:BlobContainerCreates a newInputStreamfor the given blob name.- Specified by:
readBlobin interfaceBlobContainer- Parameters:
blobName- The name of the blob to get anInputStreamfor.- Returns:
- The
InputStreamto read the blob. - Throws:
java.nio.file.NoSuchFileException- if the blob does not existjava.io.IOException- if the blob can not be read.
-
readBlob
public java.io.InputStream readBlob(java.lang.String blobName, long position, long length) throws java.io.IOExceptionDescription 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:
blobName- 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:
java.nio.file.NoSuchFileException- if the blob does not existjava.io.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(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(java.lang.String blobName, java.io.InputStream inputStream, long blobSize, boolean failIfAlreadyExists) throws java.io.IOExceptionDescription 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:
blobName- 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. 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:
java.nio.file.FileAlreadyExistsException- if failIfAlreadyExists is true and a blob by the same name already existsjava.io.IOException- if the input stream could not be read, or the target blob could not be written to.
-
writeBlobAtomic
public void writeBlobAtomic(java.lang.String blobName, java.io.InputStream inputStream, long blobSize, boolean failIfAlreadyExists) throws java.io.IOExceptionDescription 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. 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:
writeBlobAtomicin interfaceBlobContainer- Parameters:
blobName- 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. 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:
java.nio.file.FileAlreadyExistsException- if failIfAlreadyExists is true and a blob by the same name already existsjava.io.IOException- if the input stream could not be read, or the target blob could not be written to.
-
delete
Description copied from interface:BlobContainerDeletes this container and all its contents from the repository.- Specified by:
deletein interfaceBlobContainer- Returns:
- delete result
- Throws:
java.io.IOException- on failure
-
deleteBlobsIgnoringIfNotExists
public void deleteBlobsIgnoringIfNotExists(java.util.List<java.lang.String> blobNames) throws java.io.IOExceptionDescription 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:
blobNames- The names of the blob to delete.- Throws:
java.io.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:
java.io.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- Returns:
- Map of name of the child container to child container
- Throws:
java.io.IOException- on failure to list child containers
-
listBlobsByPrefix
public java.util.Map<java.lang.String,BlobMetadata> listBlobsByPrefix(java.lang.String blobNamePrefix) throws java.io.IOExceptionDescription copied from interface:BlobContainerLists all blobs in the container that match the specified prefix.- Specified by:
listBlobsByPrefixin interfaceBlobContainer- Parameters:
blobNamePrefix- 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:
java.io.IOException- if there were any failures in reading from the blob container.
-