Package org.jclouds.blobstore.internal
Class BaseBlobStore
- java.lang.Object
-
- org.jclouds.blobstore.internal.BaseBlobStore
-
- All Implemented Interfaces:
BlobStore
- Direct Known Subclasses:
AtmosBlobStore
,AzureBlobStore
,B2BlobStore
,GoogleCloudStorageBlobStore
,S3BlobStore
public abstract class BaseBlobStore extends Object implements BlobStore
-
-
Field Summary
Fields Modifier and Type Field Description protected BlobUtils
blobUtils
protected BlobStoreContext
context
protected com.google.common.base.Supplier<Location>
defaultLocation
protected com.google.common.base.Supplier<Set<? extends Location>>
locations
protected PayloadSlicer
slicer
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseBlobStore(BlobStoreContext context, BlobUtils blobUtils, com.google.common.base.Supplier<Location> defaultLocation, com.google.common.base.Supplier<Set<? extends Location>> locations, PayloadSlicer slicer)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description BlobBuilder
blobBuilder(String name)
invokesBlobUtilsImpl#blobBuilder
void
clearContainer(String containerName)
This implementation invokesclearContainer(java.lang.String)
with theListContainerOptions.recursive
option.void
clearContainer(String containerName, ListContainerOptions options)
This implementation invokesBlobUtilsImpl#clearContainer
String
copyBlob(String fromContainer, String fromName, String toContainer, String toName, CopyOptions options)
Copy blob from one container to another.long
countBlobs(String container)
This implementation invokescountBlobs(java.lang.String)
with theListContainerOptions.recursive
option.long
countBlobs(String containerName, ListContainerOptions options)
This implementation invokesBlobUtilsImpl#countBlobs
void
createDirectory(String containerName, String directory)
This implementation invokesBlobUtilsImpl#createDirectory
protected abstract boolean
deleteAndVerifyContainerGone(String container)
Delete a container if it is empty.void
deleteContainer(String container)
This implementation invokes#deleteAndEnsurePathGone
boolean
deleteContainerIfEmpty(String container)
Deletes a container if it is empty.void
deleteDirectory(String containerName, String directory)
This implementation invokesBlobUtilsImpl#deleteDirectory
.protected void
deletePathAndEnsureGone(String path)
boolean
directoryExists(String containerName, String directory)
This implementation invokesBlobUtilsImpl#directoryExists
void
downloadBlob(String container, String name, File destination)
void
downloadBlob(String container, String name, File destination, ExecutorService executor)
Blob
getBlob(String container, String key)
This implementation invokesBlobStore.getBlob(String,String,org.jclouds.blobstore.options.GetOptions)
BlobStoreContext
getContext()
PageSet<? extends StorageMetadata>
list(String container)
This implementation invokesBlobStore.list(String,org.jclouds.blobstore.options.ListContainerOptions)
Set<? extends Location>
listAssignableLocations()
The get locations command returns all the valid locations for containers.protected String
putMultipartBlob(String container, Blob blob, PutOptions overrides)
Upload using a user-provided executor, or the jclouds userExecutorprotected String
putMultipartBlob(String container, Blob blob, PutOptions overrides, com.google.common.util.concurrent.ListeningExecutorService executor)
void
removeBlobs(String container, Iterable<String> names)
Deletes multipleBlob
s representing the data at locationcontainer/name
InputStream
streamBlob(String container, String name)
InputStream
streamBlob(String container, String name, ExecutorService executor)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jclouds.blobstore.BlobStore
abortMultipartUpload, blobExists, blobMetadata, completeMultipartUpload, containerExists, createContainerInLocation, createContainerInLocation, getBlob, getBlobAccess, getContainerAccess, getMaximumMultipartPartSize, getMaximumNumberOfParts, getMinimumMultipartPartSize, initiateMultipartUpload, list, list, listMultipartUpload, listMultipartUploads, putBlob, putBlob, removeBlob, setBlobAccess, setContainerAccess, uploadMultipartPart
-
-
-
-
Field Detail
-
context
protected final BlobStoreContext context
-
blobUtils
protected final BlobUtils blobUtils
-
defaultLocation
protected final com.google.common.base.Supplier<Location> defaultLocation
-
slicer
protected final PayloadSlicer slicer
-
-
Constructor Detail
-
BaseBlobStore
protected BaseBlobStore(BlobStoreContext context, BlobUtils blobUtils, com.google.common.base.Supplier<Location> defaultLocation, com.google.common.base.Supplier<Set<? extends Location>> locations, PayloadSlicer slicer)
-
-
Method Detail
-
getContext
public BlobStoreContext getContext()
- Specified by:
getContext
in interfaceBlobStore
- Returns:
- a reference to the context that created this BlobStore.
-
blobBuilder
public BlobBuilder blobBuilder(String name)
invokesBlobUtilsImpl#blobBuilder
- Specified by:
blobBuilder
in interfaceBlobStore
- Returns:
- builder for creating new
Blob
s
-
list
public PageSet<? extends StorageMetadata> list(String container)
This implementation invokesBlobStore.list(String,org.jclouds.blobstore.options.ListContainerOptions)
-
directoryExists
public boolean directoryExists(String containerName, String directory)
This implementation invokesBlobUtilsImpl#directoryExists
- Specified by:
directoryExists
in interfaceBlobStore
- Parameters:
container
- container namedirectory
- virtual path
-
createDirectory
public void createDirectory(String containerName, String directory)
This implementation invokesBlobUtilsImpl#createDirectory
- Specified by:
createDirectory
in interfaceBlobStore
- Parameters:
container
- container namedirectory
- virtual path
-
removeBlobs
public void removeBlobs(String container, Iterable<String> names)
Description copied from interface:BlobStore
Deletes multipleBlob
s representing the data at locationcontainer/name
- Specified by:
removeBlobs
in interfaceBlobStore
- Parameters:
container
- container where this exists.names
- fully qualified names relative to the container.
-
countBlobs
public long countBlobs(String container)
This implementation invokescountBlobs(java.lang.String)
with theListContainerOptions.recursive
option.- Specified by:
countBlobs
in interfaceBlobStore
- Parameters:
container
- container name- Returns:
- a count of all blobs in the container, excluding directory markers
-
countBlobs
public long countBlobs(String containerName, ListContainerOptions options)
This implementation invokesBlobUtilsImpl#countBlobs
- Specified by:
countBlobs
in interfaceBlobStore
- Parameters:
container
- container name- Returns:
- a count of all blobs that are in a listing constrained by the options specified, excluding directory markers
-
clearContainer
public void clearContainer(String containerName)
This implementation invokesclearContainer(java.lang.String)
with theListContainerOptions.recursive
option.- Specified by:
clearContainer
in interfaceBlobStore
- Parameters:
container
- container name
-
clearContainer
public void clearContainer(String containerName, ListContainerOptions options)
This implementation invokesBlobUtilsImpl#clearContainer
- Specified by:
clearContainer
in interfaceBlobStore
- Parameters:
container
- container name
-
deleteDirectory
public void deleteDirectory(String containerName, String directory)
This implementation invokesBlobUtilsImpl#deleteDirectory
.- Specified by:
deleteDirectory
in interfaceBlobStore
- Parameters:
container
- container name
-
getBlob
public Blob getBlob(String container, String key)
This implementation invokesBlobStore.getBlob(String,String,org.jclouds.blobstore.options.GetOptions)
-
deleteContainer
public void deleteContainer(String container)
This implementation invokes#deleteAndEnsurePathGone
- Specified by:
deleteContainer
in interfaceBlobStore
- Parameters:
container
- bucket name
-
deleteContainerIfEmpty
public boolean deleteContainerIfEmpty(String container)
Description copied from interface:BlobStore
Deletes a container if it is empty.- Specified by:
deleteContainerIfEmpty
in interfaceBlobStore
- Parameters:
container
- name of the container to delete- Returns:
- true if the container was deleted or does not exist
-
deletePathAndEnsureGone
protected void deletePathAndEnsureGone(String path)
-
listAssignableLocations
public Set<? extends Location> listAssignableLocations()
Description copied from interface:BlobStore
The get locations command returns all the valid locations for containers. A location has a scope, which is typically region or zone. A region is a general area, like eu-west, where a zone is similar to a datacenter. If a location has a parent, that implies it is within that location. For example a location can be a rack, whose parent is likely to be a zone.- Specified by:
listAssignableLocations
in interfaceBlobStore
-
deleteAndVerifyContainerGone
protected abstract boolean deleteAndVerifyContainerGone(String container)
Delete a container if it is empty.- Parameters:
container
- what to delete- Returns:
- whether container was deleted
-
copyBlob
public String copyBlob(String fromContainer, String fromName, String toContainer, String toName, CopyOptions options)
Description copied from interface:BlobStore
Copy blob from one container to another. Some providers implement this more efficiently than corresponding getBlob and putBlob operations. Note: options are currently ignored
-
putMultipartBlob
@Beta protected String putMultipartBlob(String container, Blob blob, PutOptions overrides)
Upload using a user-provided executor, or the jclouds userExecutor- Parameters:
container
-blob
-overrides
-- Returns:
- the multipart blob etag
-
putMultipartBlob
@Beta protected String putMultipartBlob(String container, Blob blob, PutOptions overrides, com.google.common.util.concurrent.ListeningExecutorService executor)
-
downloadBlob
public void downloadBlob(String container, String name, File destination)
- Specified by:
downloadBlob
in interfaceBlobStore
-
downloadBlob
public void downloadBlob(String container, String name, File destination, ExecutorService executor)
- Specified by:
downloadBlob
in interfaceBlobStore
-
streamBlob
public InputStream streamBlob(String container, String name)
- Specified by:
streamBlob
in interfaceBlobStore
-
streamBlob
public InputStream streamBlob(String container, String name, ExecutorService executor)
- Specified by:
streamBlob
in interfaceBlobStore
-
-