Package com.google.cloud
Class BaseWriteChannel<ServiceOptionsT extends ServiceOptions<?,ServiceOptionsT>,EntityT extends Serializable>
java.lang.Object
com.google.cloud.BaseWriteChannel<ServiceOptionsT,EntityT>
- Type Parameters:
ServiceOptionsT- the service options used by the channel to issue RPC requestsEntityT- the entity this channel writes data to. Possibly with additional configuration
- All Implemented Interfaces:
Restorable<WriteChannel>,WriteChannel,Closeable,AutoCloseable,Channel,WritableByteChannel
public abstract class BaseWriteChannel<ServiceOptionsT extends ServiceOptions<?,ServiceOptionsT>,EntityT extends Serializable>
extends Object
implements WriteChannel
Base implementation for a
WriteChannel.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classBaseWriteChannel.BaseState<ServiceOptionsT extends ServiceOptions<?,ServiceOptionsT>, EntityT extends Serializable> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseWriteChannel(ServiceOptionsT options, EntityT entity, String uploadId) -
Method Summary
Modifier and TypeMethodDescriptioncapture()Captures the write channel state so that it can be saved and restored afterwards.final voidclose()protected abstract voidflushBuffer(int length, boolean last) protected byte[]protected intprotected intprotected EntityTprotected intgetLimit()protected intprotected ServiceOptionsTprotected longprotected StringbooleanisOpen()protected voidRestores the state of the current write channel given aBaseWriteChannel.BaseStateobject.final voidsetChunkSize(int chunkSize) Sets the minimum size that will be written by a single RPC.protected abstract BaseWriteChannel.BaseState.Builder<ServiceOptionsT,EntityT> Creates aBaseWriteChannel.BaseState.Builderfor the current write channel.final intwrite(ByteBuffer byteBuffer)
-
Constructor Details
-
BaseWriteChannel
@InternalApi("This class should only be extended within google-cloud-java") protected BaseWriteChannel(ServiceOptionsT options, EntityT entity, String uploadId)
-
-
Method Details
-
getMinChunkSize
protected int getMinChunkSize() -
getDefaultChunkSize
protected int getDefaultChunkSize() -
flushBuffer
protected abstract void flushBuffer(int length, boolean last) - Parameters:
length- the number of bytes to write fromgetBuffer()last- iftruethe resumable session is closed
-
getOptions
-
getEntity
-
getUploadId
-
getPosition
protected long getPosition() -
getBuffer
protected byte[] getBuffer() -
getLimit
protected int getLimit() -
getChunkSize
protected int getChunkSize() -
setChunkSize
public final void setChunkSize(int chunkSize) Description copied from interface:WriteChannelSets the minimum size that will be written by a single RPC. Written data will be buffered and only flushed upon reaching this size or closing the channel.- Specified by:
setChunkSizein interfaceWriteChannel
-
write
- Specified by:
writein interfaceWritableByteChannel- Throws:
IOException
-
isOpen
public boolean isOpen() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
stateBuilder
Creates aBaseWriteChannel.BaseState.Builderfor the current write channel. -
capture
Description copied from interface:WriteChannelCaptures the write channel state so that it can be saved and restored afterwards. The originalWriteChanneland the restored one should not both be used. Closing one channel causes the other channel to close; subsequent writes will fail.- Specified by:
capturein interfaceRestorable<ServiceOptionsT extends ServiceOptions<?,ServiceOptionsT>> - Specified by:
capturein interfaceWriteChannel- Returns:
- a
RestorableStateobject that contains the write channel state and can restore it afterwards.
-
restore
Restores the state of the current write channel given aBaseWriteChannel.BaseStateobject.
-