Package com.google.cloud.hadoop.gcsio
Class GoogleCloudStorageClientImpl
- java.lang.Object
-
- com.google.cloud.hadoop.gcsio.ForwardingGoogleCloudStorage
-
- com.google.cloud.hadoop.gcsio.GoogleCloudStorageClientImpl
-
- All Implemented Interfaces:
GoogleCloudStorage
public class GoogleCloudStorageClientImpl extends ForwardingGoogleCloudStorage
Provides read/write access to Google Cloud Storage (GCS), using Java nio channel semantics. This is a basic implementation of the GoogleCloudStorage interface that mostly delegates through to the appropriate API call(s) google-cloud-storage client.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGoogleCloudStorageClientImpl.Builder-
Nested classes/interfaces inherited from interface com.google.cloud.hadoop.gcsio.GoogleCloudStorage
GoogleCloudStorage.ListPage<T>
-
-
Field Summary
-
Fields inherited from interface com.google.cloud.hadoop.gcsio.GoogleCloudStorage
LIST_MAX_RESULTS, MAX_COMPOSE_OBJECTS, MAX_RESULTS_UNLIMITED, PATH_DELIMITER
-
-
Method Summary
-
Methods inherited from class com.google.cloud.hadoop.gcsio.ForwardingGoogleCloudStorage
createFolder, deleteFolders, getDelegate, getFolderInfo, getOptions, getStatistics, isHnBucket, listFolderInfoForPrefixPage, listObjectInfo, listObjectInfoPage, listObjectInfoStartingFrom, renameHnFolder
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.cloud.hadoop.gcsio.GoogleCloudStorage
create, createBucket, listObjectInfo, listObjectInfoPage, listObjectInfoStartingFrom, open, open
-
-
-
-
Method Detail
-
create
public WritableByteChannel create(StorageResourceId resourceId, CreateObjectOptions options) throws IOException
Description copied from interface:GoogleCloudStorageCreates and opens an object for writing. The bucket must already exist. IfresourceIdcontains a known generationId or a generationId of 0, it is used instead of any "overwrite" settings in the providedCreateObjectOptions(overwrite will only succeed if the provided generationId matches the existing object, where a generationId of 0 indicates no existing object expected).- Specified by:
createin interfaceGoogleCloudStorage- Overrides:
createin classForwardingGoogleCloudStorage- Parameters:
resourceId- identifies a StorageObjectoptions- Options to use when creating the object- Returns:
- a channel for writing to the given object
- Throws:
IOException- on IO error
-
createBucket
public void createBucket(String bucketName, CreateBucketOptions options) throws IOException
SeeGoogleCloudStorage.createBucket(String, CreateBucketOptions)for details about expected behavior.- Specified by:
createBucketin interfaceGoogleCloudStorage- Overrides:
createBucketin classForwardingGoogleCloudStorage- Parameters:
bucketName- name of the bucket to createoptions- options to use when creating bucket- Throws:
IOException- on IO error
-
createEmptyObject
public void createEmptyObject(StorageResourceId resourceId) throws IOException
SeeGoogleCloudStorage.createEmptyObject(StorageResourceId)for details about expected behavior.- Specified by:
createEmptyObjectin interfaceGoogleCloudStorage- Overrides:
createEmptyObjectin classForwardingGoogleCloudStorage- Parameters:
resourceId- identifies a StorageObject- Throws:
IOException- on IO error
-
createEmptyObject
public void createEmptyObject(StorageResourceId resourceId, CreateObjectOptions options) throws IOException
SeeGoogleCloudStorage.createEmptyObject(StorageResourceId, CreateObjectOptions)for details about expected behavior.- Specified by:
createEmptyObjectin interfaceGoogleCloudStorage- Overrides:
createEmptyObjectin classForwardingGoogleCloudStorage- Parameters:
resourceId- identifies a StorageObjectoptions- options to use when creating the object- Throws:
IOException- on IO error
-
createEmptyObjects
public void createEmptyObjects(List<StorageResourceId> resourceIds) throws IOException
SeeGoogleCloudStorage.createEmptyObjects(List)for details about expected behavior.- Specified by:
createEmptyObjectsin interfaceGoogleCloudStorage- Overrides:
createEmptyObjectsin classForwardingGoogleCloudStorage- Throws:
IOException
-
createEmptyObjects
public void createEmptyObjects(List<StorageResourceId> resourceIds, CreateObjectOptions options) throws IOException
SeeGoogleCloudStorage.createEmptyObjects(List, CreateObjectOptions)for details about expected behavior.- Specified by:
createEmptyObjectsin interfaceGoogleCloudStorage- Overrides:
createEmptyObjectsin classForwardingGoogleCloudStorage- Throws:
IOException
-
copy
public void copy(String srcBucketName, List<String> srcObjectNames, String dstBucketName, List<String> dstObjectNames) throws IOException
SeeGoogleCloudStorage.copy(String, List, String, List)for details about expected behavior.- Specified by:
copyin interfaceGoogleCloudStorage- Overrides:
copyin classForwardingGoogleCloudStorage- Parameters:
srcBucketName- 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 copy- Throws:
FileNotFoundException- if the source object or the destination bucket does not existIOException- in all other error cases
-
move
public void move(Map<StorageResourceId,StorageResourceId> sourceToDestinationObjectsMap) throws IOException
SeeGoogleCloudStorage#move(Mapfor details about expected behavior.) - Specified by:
movein interfaceGoogleCloudStorage- Overrides:
movein classForwardingGoogleCloudStorage- Parameters:
sourceToDestinationObjectsMap- map of destination objects to be moved, keyed by source- Throws:
FileNotFoundException- if the source object or the destination bucket does not existIOException- in all other error cases
-
copy
public void copy(Map<StorageResourceId,StorageResourceId> sourceToDestinationObjectsMap) throws IOException
SeeGoogleCloudStorage.copy(String, List, String, List)for details about expected behavior.- Specified by:
copyin interfaceGoogleCloudStorage- Overrides:
copyin classForwardingGoogleCloudStorage- Parameters:
sourceToDestinationObjectsMap- map of destination objects to be copied, keyed by source- Throws:
FileNotFoundException- if the source object or the destination bucket does not existIOException- in all other error cases
-
listBucketNames
public List<String> listBucketNames() throws IOException
SeeGoogleCloudStorage.listBucketNames()for details about expected behavior.- Specified by:
listBucketNamesin interfaceGoogleCloudStorage- Overrides:
listBucketNamesin classForwardingGoogleCloudStorage- Throws:
IOException
-
listBucketInfo
public List<GoogleCloudStorageItemInfo> listBucketInfo() throws IOException
SeeGoogleCloudStorage.listBucketInfo()for details about expected behavior.- Specified by:
listBucketInfoin interfaceGoogleCloudStorage- Overrides:
listBucketInfoin classForwardingGoogleCloudStorage- Throws:
IOException
-
deleteObjects
public void deleteObjects(List<StorageResourceId> fullObjectNames) throws IOException
SeeGoogleCloudStorage.deleteObjects(List)for details about the expected behavior.- Specified by:
deleteObjectsin interfaceGoogleCloudStorage- Overrides:
deleteObjectsin classForwardingGoogleCloudStorage- Parameters:
fullObjectNames- names of objects to delete with their respective bucketNames.- Throws:
FileNotFoundException- if the given object does not existIOException- if object exists but cannot be deleted
-
deleteBuckets
public void deleteBuckets(List<String> bucketNames) throws IOException
SeeGoogleCloudStorage.deleteBuckets(List)for details about expected behavior.- Specified by:
deleteBucketsin interfaceGoogleCloudStorage- Overrides:
deleteBucketsin classForwardingGoogleCloudStorage- Parameters:
bucketNames- name of the buckets to delete- Throws:
FileNotFoundException- if the given bucket does not existIOException- on IO error
-
getItemInfos
public List<GoogleCloudStorageItemInfo> getItemInfos(List<StorageResourceId> resourceIds) throws IOException
SeeGoogleCloudStorage.getItemInfos(List)for details about expected behavior.- Specified by:
getItemInfosin interfaceGoogleCloudStorage- Overrides:
getItemInfosin classForwardingGoogleCloudStorage- Parameters:
resourceIds- names of the GCS StorageObjects or Buckets for which to retrieve info.- Returns:
- information about the given resourceIds.
- Throws:
IOException- on IO error
-
getItemInfo
public GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId) throws IOException
SeeGoogleCloudStorage.getItemInfo(StorageResourceId)for details about expected behavior.- Specified by:
getItemInfoin interfaceGoogleCloudStorage- Overrides:
getItemInfoin classForwardingGoogleCloudStorage- Parameters:
resourceId- identifies either root, a Bucket, or a StorageObject- Returns:
- information about the given item
- Throws:
IOException- on IO error
-
open
public SeekableByteChannel open(StorageResourceId resourceId, GoogleCloudStorageReadOptions readOptions) throws IOException
Description copied from interface:GoogleCloudStorageOpens an object for reading.- Specified by:
openin interfaceGoogleCloudStorage- Overrides:
openin classForwardingGoogleCloudStorage- Parameters:
resourceId- identifies a StorageObjectreadOptions- Fine-grained options for behaviors of retries, buffering, etc.- Returns:
- a channel for reading from the given object
- Throws:
FileNotFoundException- if the given object does not existIOException- if object exists but cannot be opened
-
open
public SeekableByteChannel open(GoogleCloudStorageItemInfo itemInfo, GoogleCloudStorageReadOptions readOptions) throws IOException
Description copied from interface:GoogleCloudStorageOpens an object for reading using GoogleCloudStorageItemInfo.- Specified by:
openin interfaceGoogleCloudStorage- Overrides:
openin classForwardingGoogleCloudStorage- Parameters:
itemInfo- identifies a StorageObjectreadOptions- Fine-grained options for behaviors of retries, buffering, etc.- Returns:
- a channel for reading from the given object
- Throws:
FileNotFoundException- if the given object does not existIOException- if object exists but cannot be opened
-
close
public void close()
Description copied from interface:GoogleCloudStorageReleases resources used by this instance.- Specified by:
closein interfaceGoogleCloudStorage- Overrides:
closein classForwardingGoogleCloudStorage
-
updateItems
public List<GoogleCloudStorageItemInfo> updateItems(List<UpdatableItemInfo> itemInfoList) throws IOException
Description copied from interface:GoogleCloudStorageAttempt to update metadata of the objects referenced within the passed itemInfo objects.- Specified by:
updateItemsin interfaceGoogleCloudStorage- Overrides:
updateItemsin classForwardingGoogleCloudStorage- Returns:
- Updated GoogleCloudStorageItemInfo objects for the referenced objects.
- Throws:
IOException- on IO error
-
compose
public void compose(String bucketName, List<String> sources, String destination, String contentType) throws IOException
Description copied from interface:GoogleCloudStorageComposes inputs into a single GCS object. This performs a GCS Compose. Objects will be composed according to the order they appear in the input. The destination object, if already present, will be overwritten. Sources and destination are assumed to be in the same bucket.- Specified by:
composein interfaceGoogleCloudStorage- Overrides:
composein classForwardingGoogleCloudStorage- Parameters:
bucketName- name of the bucket containing the sources and the destinationsources- names of the objects to be composeddestination- name of the resulting objectcontentType- content-type of composed object- Throws:
IOException- if the Compose operation was unsuccessful
-
composeObjects
public GoogleCloudStorageItemInfo composeObjects(List<StorageResourceId> sources, StorageResourceId destination, CreateObjectOptions options) throws IOException
SeeGoogleCloudStorage.composeObjects(List, StorageResourceId, CreateObjectOptions)} for details about expected behavior.- Specified by:
composeObjectsin interfaceGoogleCloudStorage- Overrides:
composeObjectsin classForwardingGoogleCloudStorage- Throws:
IOException
-
builder
public static GoogleCloudStorageClientImpl.Builder builder()
-
-