Package com.google.cloud.hadoop.gcsio
Class GoogleCloudStorageWriteChannel
- java.lang.Object
-
- com.google.cloud.hadoop.util.AbstractGoogleAsyncWriteChannel<com.google.api.services.storage.model.StorageObject>
-
- com.google.cloud.hadoop.gcsio.GoogleCloudStorageWriteChannel
-
- All Implemented Interfaces:
GoogleCloudStorageItemInfo.Provider,Closeable,AutoCloseable,Channel,WritableByteChannel
public class GoogleCloudStorageWriteChannel extends AbstractGoogleAsyncWriteChannel<com.google.api.services.storage.model.StorageObject> implements GoogleCloudStorageItemInfo.Provider
Implements WritableByteChannel to provide write access to GCS.
-
-
Field Summary
-
Fields inherited from class com.google.cloud.hadoop.util.AbstractGoogleAsyncWriteChannel
channelOptions, cumulativeCrc32cHasher, logger, threadPool, uploadOperation
-
-
Constructor Summary
Constructors Constructor Description GoogleCloudStorageWriteChannel(com.google.api.services.storage.Storage gcs, ClientRequestHelper<com.google.api.services.storage.model.StorageObject> requestHelper, ExecutorService uploadThreadPool, AsyncWriteChannelOptions channelOptions, StorageResourceId resourceId, CreateObjectOptions createOptions, ObjectWriteConditions writeConditions)Constructs an instance of GoogleCloudStorageWriteChannel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.api.services.storage.model.StorageObjectcreateResponseFromException(IOException e)Derived classes may optionally intercept an IOException thrown from theexecute()method of a prepared request that came fromcreateRequest(com.google.api.client.http.InputStreamContent), and return a reconstituted "response" object if the IOException can be handled as a success; for example, if the caller already has an identifier for an object, and the response is used solely for obtaining the same identifier, and the IOException is a handled "409 Already Exists" type of exception, then the derived class may override this method to return the expected "identifier" response.protected StringgetContentType()GoogleCloudStorageItemInfogetItemInfo()Returns non-null only if close() has been called and the underlying object has been successfully committed.protected StringgetResourceString()voidhandleResponse(com.google.api.services.storage.model.StorageObject response)voidstartUpload(InputStream pipeSource)-
Methods inherited from class com.google.cloud.hadoop.util.AbstractGoogleAsyncWriteChannel
close, initialize, isDirectUploadEnabled, isOpen, write
-
-
-
-
Constructor Detail
-
GoogleCloudStorageWriteChannel
public GoogleCloudStorageWriteChannel(com.google.api.services.storage.Storage gcs, ClientRequestHelper<com.google.api.services.storage.model.StorageObject> requestHelper, ExecutorService uploadThreadPool, AsyncWriteChannelOptions channelOptions, StorageResourceId resourceId, CreateObjectOptions createOptions, ObjectWriteConditions writeConditions)Constructs an instance of GoogleCloudStorageWriteChannel.- Parameters:
gcs- storage object instanceuploadThreadPool- thread pool to use for running the upload operationrequestHelper- a ClientRequestHelper to set extra headerschannelOptions- write channel optionsresourceId- object to createcreateOptions- object creation optionswriteConditions- conditions on which write should be allowed to continue
-
-
Method Detail
-
startUpload
public void startUpload(InputStream pipeSource) throws IOException
- Specified by:
startUploadin classAbstractGoogleAsyncWriteChannel<com.google.api.services.storage.model.StorageObject>- Throws:
IOException
-
handleResponse
public void handleResponse(com.google.api.services.storage.model.StorageObject response) throws IOException- Overrides:
handleResponsein classAbstractGoogleAsyncWriteChannel<com.google.api.services.storage.model.StorageObject>- Throws:
IOException
-
createResponseFromException
public com.google.api.services.storage.model.StorageObject createResponseFromException(IOException e)
Derived classes may optionally intercept an IOException thrown from theexecute()method of a prepared request that came fromcreateRequest(com.google.api.client.http.InputStreamContent), and return a reconstituted "response" object if the IOException can be handled as a success; for example, if the caller already has an identifier for an object, and the response is used solely for obtaining the same identifier, and the IOException is a handled "409 Already Exists" type of exception, then the derived class may override this method to return the expected "identifier" response. Return null to let the exception propagate through correctly.
-
getContentType
protected String getContentType()
-
getResourceString
protected String getResourceString()
- Specified by:
getResourceStringin classAbstractGoogleAsyncWriteChannel<com.google.api.services.storage.model.StorageObject>
-
getItemInfo
public GoogleCloudStorageItemInfo getItemInfo()
Returns non-null only if close() has been called and the underlying object has been successfully committed.- Specified by:
getItemInfoin interfaceGoogleCloudStorageItemInfo.Provider
-
-