java.io.Closeable, java.lang.AutoCloseablepublic abstract static class DataBlocks.DataBlock
extends java.lang.Object
implements java.io.Closeable
| Modifier and Type | Class | Description |
|---|---|---|
static class |
DataBlocks.DataBlock.DestState |
| Modifier | Constructor | Description |
|---|---|---|
protected |
DataBlock(long index,
BlockUploadStatistics statistics) |
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
blockAllocated() |
A block has been allocated.
|
protected void |
blockReleased() |
A block has been released.
|
void |
close() |
|
abstract int |
dataSize() |
Return the current data size.
|
protected boolean |
enterClosedState() |
Enter the closed state.
|
protected void |
enterState(DataBlocks.DataBlock.DestState current,
DataBlocks.DataBlock.DestState next) |
Atomically enter a state, verifying current state.
|
void |
flush() |
Flush the output.
|
long |
getIndex() |
|
DataBlocks.DataBlock.DestState |
getState() |
Current state.
|
protected BlockUploadStatistics |
getStatistics() |
|
boolean |
hasData() |
Predicate to check if there is data in the block.
|
protected void |
innerClose() |
Inner close logic for subclasses to implement.
|
abstract int |
remainingCapacity() |
The remaining capacity in the block before it is full.
|
DataBlocks.BlockUploadData |
startUpload() |
Switch to the upload state and return a stream for uploading.
|
protected void |
verifyState(DataBlocks.DataBlock.DestState expected) |
Verify that the block is in the declared state.
|
int |
write(byte[] buffer,
int offset,
int length) |
Write a series of bytes from the buffer, from the offset.
|
protected DataBlock(long index,
BlockUploadStatistics statistics)
protected final void enterState(DataBlocks.DataBlock.DestState current, DataBlocks.DataBlock.DestState next) throws java.lang.IllegalStateException
current - current state. null means "no check"next - next statejava.lang.IllegalStateException - if the current state is not as expectedprotected final void verifyState(DataBlocks.DataBlock.DestState expected) throws java.lang.IllegalStateException
expected - expected state.java.lang.IllegalStateException - if the DataBlock is in the wrong statepublic final DataBlocks.DataBlock.DestState getState()
public abstract int dataSize()
public boolean hasData()
public abstract int remainingCapacity()
public int write(byte[] buffer,
int offset,
int length)
throws java.io.IOException
Writing.
Base class verifies the state but does no writing.buffer - buffer.offset - offset.length - length of write.java.io.IOException - troublepublic void flush()
throws java.io.IOException
Writing.
In the base class, this is a no-opjava.io.IOException - any IO problem.public DataBlocks.BlockUploadData startUpload() throws java.io.IOException
enterState(DestState, DestState) to
manage the state machine.java.io.IOException - troubleprotected boolean enterClosedState()
public void close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.io.Closeablejava.io.IOExceptionprotected void innerClose()
throws java.io.IOException
java.io.IOException - raised on errors performing I/O.protected void blockAllocated()
protected void blockReleased()
protected BlockUploadStatistics getStatistics()
public long getIndex()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.