public final class BufferData
extends java.lang.Object
CachingBlockManager.
This class is not meant to be of general use. It exists into its own file due to its size.
We use the term block and buffer interchangeably in this file because one buffer
holds exactly one block of data.
Holding all of the state associated with a block allows us to validate and control
state transitions in a synchronized fashion.| Modifier and Type | Class | Description |
|---|---|---|
static class |
BufferData.State |
| Constructor | Description |
|---|---|
BufferData(int blockNumber,
java.nio.ByteBuffer buffer) |
Constructs an instances of this class.
|
| Modifier and Type | Method | Description |
|---|---|---|
java.util.concurrent.Future<java.lang.Void> |
getActionFuture() |
|
int |
getBlockNumber() |
Gets the id of this block.
|
java.nio.ByteBuffer |
getBuffer() |
Gets the buffer associated with this block.
|
long |
getChecksum() |
Gets the checksum of data in this block.
|
static long |
getChecksum(java.nio.ByteBuffer buffer) |
Computes CRC32 checksum of the given buffer's contents.
|
BufferData.State |
getState() |
Gets the state of this block.
|
void |
setCaching(java.util.concurrent.Future<java.lang.Void> actionFuture) |
Indicates that a caching operation is in progress.
|
void |
setDone() |
Indicates that this block is no longer of use and can be reclaimed.
|
void |
setPrefetch(java.util.concurrent.Future<java.lang.Void> actionFuture) |
Indicates that a prefetch operation is in progress.
|
void |
setReady(BufferData.State... expectedCurrentState) |
Marks the completion of reading data into the buffer.
|
boolean |
stateEqualsOneOf(BufferData.State... states) |
|
void |
throwIfStateIncorrect(BufferData.State... states) |
Helper that asserts the current state is one of the expected values.
|
java.lang.String |
toString() |
|
void |
updateState(BufferData.State newState,
BufferData.State... expectedCurrentState) |
Updates the current state to the specified value.
|
public BufferData(int blockNumber,
java.nio.ByteBuffer buffer)
blockNumber - Number of the block associated with this buffer.buffer - The buffer associated with this block.java.lang.IllegalArgumentException - if blockNumber is negative.java.lang.IllegalArgumentException - if buffer is null.public int getBlockNumber()
public java.nio.ByteBuffer getBuffer()
public BufferData.State getState()
public long getChecksum()
public static long getChecksum(java.nio.ByteBuffer buffer)
buffer - the buffer whose content's checksum is to be computed.public java.util.concurrent.Future<java.lang.Void> getActionFuture()
public void setPrefetch(java.util.concurrent.Future<java.lang.Void> actionFuture)
actionFuture - the Future of a prefetch action.java.lang.IllegalArgumentException - if actionFuture is null.public void setCaching(java.util.concurrent.Future<java.lang.Void> actionFuture)
actionFuture - the Future of a caching action.java.lang.IllegalArgumentException - if actionFuture is null.public void setReady(BufferData.State... expectedCurrentState)
expectedCurrentState - the collection of states from which transition to READY is allowed.public void setDone()
public void updateState(BufferData.State newState, BufferData.State... expectedCurrentState)
newState - the state to transition to.expectedCurrentState - the collection of states from which
transition to newState is allowed.java.lang.IllegalArgumentException - if newState is null.java.lang.IllegalArgumentException - if expectedCurrentState is null.public void throwIfStateIncorrect(BufferData.State... states)
states - the collection of allowed states.java.lang.IllegalArgumentException - if states is null.public boolean stateEqualsOneOf(BufferData.State... states)
public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2008–2025 Apache Software Foundation. All rights reserved.