ServiceOptionsT
- the service options used by the channel to issue RPC requestsEntityT
- the entity this channel writes data to. Possibly with additional configurationpublic abstract class BaseWriteChannel<ServiceOptionsT extends ServiceOptions<?,ServiceOptionsT>,EntityT extends Serializable> extends Object implements WriteChannel
WriteChannel
.Modifier and Type | Class and Description |
---|---|
protected static class |
BaseWriteChannel.BaseState<ServiceOptionsT extends ServiceOptions<?,ServiceOptionsT>,EntityT extends Serializable> |
Modifier | Constructor and Description |
---|---|
protected |
BaseWriteChannel(ServiceOptionsT options,
EntityT entity,
String uploadId) |
Modifier and Type | Method and Description |
---|---|
RestorableState<WriteChannel> |
capture()
Captures the write channel state so that it can be saved and restored afterwards.
|
void |
close() |
protected abstract void |
flushBuffer(int length,
boolean last)
|
protected byte[] |
getBuffer() |
protected int |
getChunkSize() |
protected int |
getDefaultChunkSize() |
protected EntityT |
getEntity() |
protected int |
getLimit() |
protected int |
getMinChunkSize() |
protected ServiceOptionsT |
getOptions() |
protected long |
getPosition() |
protected String |
getUploadId() |
boolean |
isOpen() |
protected void |
restore(BaseWriteChannel.BaseState state)
Restores the state of the current write channel given a
BaseWriteChannel.BaseState object. |
void |
setChunkSize(int chunkSize)
Sets the minimum size that will be written by a single RPC.
|
protected abstract BaseWriteChannel.BaseState.Builder<ServiceOptionsT,EntityT> |
stateBuilder()
Creates a
BaseWriteChannel.BaseState.Builder for the current write channel. |
int |
write(ByteBuffer byteBuffer) |
@InternalApi(value="This class should only be extended within google-cloud-java") protected BaseWriteChannel(ServiceOptionsT options, EntityT entity, String uploadId)
protected int getMinChunkSize()
protected int getDefaultChunkSize()
protected abstract void flushBuffer(int length, boolean last)
length
- the number of bytes to write from getBuffer()
last
- if true
the resumable session is closedprotected ServiceOptionsT getOptions()
protected EntityT getEntity()
protected String getUploadId()
protected long getPosition()
protected byte[] getBuffer()
protected int getLimit()
protected int getChunkSize()
public final void setChunkSize(int chunkSize)
WriteChannel
setChunkSize
in interface WriteChannel
public final int write(ByteBuffer byteBuffer) throws IOException
write
in interface WritableByteChannel
IOException
public final void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface Channel
IOException
protected abstract BaseWriteChannel.BaseState.Builder<ServiceOptionsT,EntityT> stateBuilder()
BaseWriteChannel.BaseState.Builder
for the current write channel.public RestorableState<WriteChannel> capture()
WriteChannel
WriteChannel
and the restored one should not both be used. Closing one channel causes
the other channel to close; subsequent writes will fail.capture
in interface Restorable<WriteChannel>
capture
in interface WriteChannel
RestorableState
object that contains the write channel state and can restore
it afterwards.protected void restore(BaseWriteChannel.BaseState state)
BaseWriteChannel.BaseState
object.Copyright © 2019 Google LLC. All rights reserved.