public class CacheSupplementedGoogleCloudStorage extends Object implements GoogleCloudStorage
DirectoryListCache and wraps the create/copy/delete/list methods to provide
immediate same-client consistency for "list" operations following a "create/copy/delete". See
DirectoryListCache for details of consistency semantics.PATH_DELIMITER| Constructor and Description |
|---|
CacheSupplementedGoogleCloudStorage(GoogleCloudStorage gcsDelegate,
DirectoryListCache resourceCache)
Constructs a CacheSupplementedGoogleCloudStorage which should be usable anywhere a
GoogleCloudStorage interface is used and which supplements missing listObject/listBucket
results from an in-memory cache of known GCS resources which may not have propagated into
the eventually-consistent remote "list" index yet.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Pure pass-through.
|
void |
copy(String srcBucketName,
List<String> srcObjectNames,
String dstBucketName,
List<String> dstObjectNames)
Adds the copied destination items to the list cache, without their associated metadata;
supplementing with the cache will have to populate the metadata on-demand.
|
WritableByteChannel |
create(StorageResourceId resourceId)
Wraps the delegate's returned WritableByteChannel in a helper which will update the
resourceCache when close() is called.
|
WritableByteChannel |
create(StorageResourceId resourceId,
CreateObjectOptions options)
Creates and opens an object for writing.
|
void |
create(String bucketName)
Updates cache with bucketName.
|
void |
createEmptyObject(StorageResourceId resourceId)
Records the resourceId after delegating.
|
void |
createEmptyObject(StorageResourceId resourceId,
CreateObjectOptions options)
Creates an empty object, useful for placeholders representing, for example, directories.
|
void |
createEmptyObjects(List<StorageResourceId> resourceIds)
Records the resourceIds after delegating.
|
void |
createEmptyObjects(List<StorageResourceId> resourceIds,
CreateObjectOptions options)
Creates a list of empty objects; see
GoogleCloudStorage.createEmptyObject(StorageResourceId) for
the single-item version of this method. |
void |
deleteBuckets(List<String> bucketNames)
Removes buckets from cache, if they exist.
|
void |
deleteObjects(List<StorageResourceId> fullObjectNames)
Removes objects from cache, if they exist.
|
GoogleCloudStorageItemInfo |
getItemInfo(StorageResourceId resourceId)
Pure pass-through.
|
List<GoogleCloudStorageItemInfo> |
getItemInfos(List<StorageResourceId> resourceIds)
Pure pass-through.
|
List<GoogleCloudStorageItemInfo> |
listBucketInfo()
Supplements the list returned by the delegate with cached bucket infos; may trigger fetching
of any metadata not already available in the cache.
|
List<String> |
listBucketNames()
Supplements the list returned by the delegate with cached bucket names; won't trigger
any fetching of metadata.
|
List<GoogleCloudStorageItemInfo> |
listObjectInfo(String bucketName,
String objectNamePrefix,
String delimiter)
Supplements the list returned by the delegate with cached object infos; may trigger fetching
of any metadata not already available in the cache.
|
List<String> |
listObjectNames(String bucketName,
String objectNamePrefix,
String delimiter)
Supplements the list returned by the delegate with cached object names; won't trigger
any fetching of metadata.
|
SeekableReadableByteChannel |
open(StorageResourceId resourceId)
Pure pass-through.
|
List<GoogleCloudStorageItemInfo> |
updateItems(List<UpdatableItemInfo> itemInfoList)
Attempt to update metadata of the objects referenced within the passed itemInfo objects.
|
void |
waitForBucketEmpty(String bucketName)
Pure pass-through.
|
public CacheSupplementedGoogleCloudStorage(GoogleCloudStorage gcsDelegate, DirectoryListCache resourceCache)
gcsDelegate - The GoogleCloudStorage to be used for normal API interactions, before
supplementing with in-memory info.public WritableByteChannel create(StorageResourceId resourceId) throws IOException
create in interface GoogleCloudStorageresourceId - identifies a StorageObjectIOException - on IO errorpublic WritableByteChannel create(StorageResourceId resourceId, CreateObjectOptions options) throws IOException
GoogleCloudStoragecreate in interface GoogleCloudStorageresourceId - identifies a StorageObjectoptions - Options to use when creating the objectIOException - on IO errorpublic void createEmptyObject(StorageResourceId resourceId) throws IOException
createEmptyObject in interface GoogleCloudStorageresourceId - identifies a StorageObjectIOException - on IO errorpublic void createEmptyObject(StorageResourceId resourceId, CreateObjectOptions options) throws IOException
GoogleCloudStoragecreateEmptyObject in interface GoogleCloudStorageresourceId - identifies a StorageObjectoptions - options to use when creating the objectIOException - on IO errorpublic void createEmptyObjects(List<StorageResourceId> resourceIds) throws IOException
createEmptyObjects in interface GoogleCloudStorageIOExceptionpublic void createEmptyObjects(List<StorageResourceId> resourceIds, CreateObjectOptions options) throws IOException
GoogleCloudStorageGoogleCloudStorage.createEmptyObject(StorageResourceId) for
the single-item version of this method. Implementations may use different flow than the
single-item version for greater efficiency.createEmptyObjects in interface GoogleCloudStorageIOExceptionpublic SeekableReadableByteChannel open(StorageResourceId resourceId) throws IOException
open in interface GoogleCloudStorageresourceId - identifies a StorageObjectIOException - if object exists but cannot be openedpublic void create(String bucketName) throws IOException
create in interface GoogleCloudStoragebucketName - name of the bucket to createIOException - on IO errorpublic void deleteBuckets(List<String> bucketNames) throws IOException
deleteBuckets in interface GoogleCloudStoragebucketNames - name of the buckets to deleteIOException - on IO errorpublic void deleteObjects(List<StorageResourceId> fullObjectNames) throws IOException
deleteObjects in interface GoogleCloudStoragefullObjectNames - names of objects to delete with their respective bucketNames.IOException - if object exists but cannot be deletedpublic void copy(String srcBucketName, List<String> srcObjectNames, String dstBucketName, List<String> dstObjectNames) throws IOException
copy in interface GoogleCloudStoragesrcBucketName - name of the bucket containing the objects to copysrcObjectNames - names of the objects to copydstBucketName - name of the bucket to copy todstObjectNames - names of the objects after copyIOException - in all other error casespublic List<String> listBucketNames() throws IOException
listBucketNames in interface GoogleCloudStorageIOExceptionpublic List<GoogleCloudStorageItemInfo> listBucketInfo() throws IOException
listBucketInfo in interface GoogleCloudStorageIOExceptionpublic List<String> listObjectNames(String bucketName, String objectNamePrefix, String delimiter) throws IOException
listObjectNames in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desireddelimiter - delimiter to use (typically "/"), otherwise nullIOException - on IO errorpublic List<GoogleCloudStorageItemInfo> listObjectInfo(String bucketName, String objectNamePrefix, String delimiter) throws IOException
listObjectInfo in interface GoogleCloudStoragebucketName - bucket nameobjectNamePrefix - object name prefix or null if all objects in the bucket are desireddelimiter - delimiter to use (typically "/"), otherwise nullIOException - on IO errorpublic List<GoogleCloudStorageItemInfo> getItemInfos(List<StorageResourceId> resourceIds) throws IOException
getItemInfos in interface GoogleCloudStorageresourceIds - names of the GCS StorageObjects or Buckets for which to retrieve info.IOException - on IO errorpublic List<GoogleCloudStorageItemInfo> updateItems(List<UpdatableItemInfo> itemInfoList) throws IOException
GoogleCloudStorageupdateItems in interface GoogleCloudStorageIOException - on IO errorpublic GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId) throws IOException
getItemInfo in interface GoogleCloudStorageresourceId - identifies either root, a Bucket, or a StorageObjectIOException - on IO errorpublic void close()
close in interface GoogleCloudStoragepublic void waitForBucketEmpty(String bucketName) throws IOException
waitForBucketEmpty in interface GoogleCloudStorageIOExceptionCopyright © 2015. All rights reserved.