Class BaseWriteChannel<ServiceOptionsT,EntityT> (2.38.1)

public abstract class BaseWriteChannel<ServiceOptionsT,EntityT> implements WriteChannel

Base implementation for a WriteChannel.

Inheritance

java.lang.Object > BaseWriteChannel<ServiceOptionsT,EntityT>

Implements

WriteChannel

Type Parameters

Name Description
ServiceOptionsT
EntityT

Constructors

BaseWriteChannel(ServiceOptionsT options, EntityT entity, String uploadId)

protected BaseWriteChannel(ServiceOptionsT options, EntityT entity, String uploadId)
Parameters
Name Description
options ServiceOptionsT
entity EntityT
uploadId String

Methods

capture()

public RestorableState<WriteChannel> capture()

Captures the write channel state so that it can be saved and restored afterwards. The original WriteChannel and the restored one should not both be used. Closing one channel causes the other channel to close; subsequent writes will fail.

Returns
Type Description
RestorableState<WriteChannel>

close()

public final void close()
Exceptions
Type Description
IOException

flushBuffer(int length, boolean last)

protected abstract void flushBuffer(int length, boolean last)

Writes length bytes of #getBuffer() to the #getUploadId() URL.

Parameters
Name Description
length int

the number of bytes to write from #getBuffer()

last boolean

if true the resumable session is closed

getBuffer()

protected byte[] getBuffer()
Returns
Type Description
byte[]

getChunkSize()

protected int getChunkSize()
Returns
Type Description
int

getDefaultChunkSize()

protected int getDefaultChunkSize()
Returns
Type Description
int

getEntity()

protected EntityT getEntity()
Returns
Type Description
EntityT

getLimit()

protected int getLimit()
Returns
Type Description
int

getMinChunkSize()

protected int getMinChunkSize()
Returns
Type Description
int

getOptions()

protected ServiceOptionsT getOptions()
Returns
Type Description
ServiceOptionsT

getPosition()

protected long getPosition()
Returns
Type Description
long

getUploadId()

protected String getUploadId()
Returns
Type Description
String

isOpen()

public boolean isOpen()
Returns
Type Description
boolean

restore(BaseWriteChannel.BaseState state)

protected void restore(BaseWriteChannel.BaseState state)

Restores the state of the current write channel given a BaseState object.

Parameter
Name Description
state BaseState

setChunkSize(int chunkSize)

public final void setChunkSize(int chunkSize)

Sets 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.

Parameter
Name Description
chunkSize int

stateBuilder()

protected abstract BaseWriteChannel.BaseState.Builder<ServiceOptionsT,EntityT> stateBuilder()

Creates a BaseState.Builder for the current write channel.

Returns
Type Description
Builder<ServiceOptionsT,EntityT>

write(ByteBuffer byteBuffer)

public final int write(ByteBuffer byteBuffer)
Parameter
Name Description
byteBuffer ByteBuffer
Returns
Type Description
int
Exceptions
Type Description
IOException