public interface BlockStore extends Closeable, SessionCleanable
Modifier and Type | Method and Description |
---|---|
void |
abortBlock(long sessionId,
long blockId)
Aborts a temporary block.
|
void |
accessBlock(long sessionId,
long blockId)
Notifies the block store that a block was accessed so the block store could update accordingly
the registered listeners such as evictor and allocator on block access.
|
void |
commitBlock(long sessionId,
long blockId,
boolean pinOnCreate)
Commits a block to Alluxio managed space.
|
String |
createBlock(long sessionId,
long blockId,
int tier,
CreateBlockOptions createBlockOptions)
Creates a block in Alluxio managed space.
|
BlockReader |
createBlockReader(long sessionId,
long blockId,
long lockId)
Creates a reader of an existing block to read data from this block.
|
BlockReader |
createBlockReader(long sessionId,
long blockId,
long offset,
boolean positionShort,
Protocol.OpenUfsBlockOptions options)
Creates the block reader to read from Alluxio block or UFS block.
|
BlockWriter |
createBlockWriter(long sessionId,
long blockId)
Creates a
BlockWriter for an existing temporary block which is already created by
createBlock(long, long, int, alluxio.worker.block.CreateBlockOptions) . |
BlockReader |
createUfsBlockReader(long sessionId,
long blockId,
long offset,
boolean positionShort,
Protocol.OpenUfsBlockOptions options)
Creates a block reader to read a UFS block starting from given block offset.
|
BlockMeta |
getBlockMeta(long sessionId,
long blockId,
long lockId)
Gets the metadata of a specific block from local storage.
|
BlockStoreMeta |
getBlockStoreMeta()
Gets the metadata of the entire store in a snapshot.
|
BlockStoreMeta |
getBlockStoreMetaFull()
Similar as
getBlockStoreMeta() except that this includes
more information about the block store (e.g. |
BlockWriter |
getBlockWriter(long sessionId,
long blockId)
Creates a writer to write data to a temp block.
|
Optional<TempBlockMeta> |
getTempBlockMeta(long blockId)
Gets the temp metadata of a specific block from local storage.
|
Optional<BlockMeta> |
getVolatileBlockMeta(long blockId)
Gets the metadata of a block given its block id or empty if block does not exist.
|
boolean |
hasBlockMeta(long blockId)
Checks if the storage has a given block.
|
boolean |
hasTempBlockMeta(long blockId)
Checks if the storage has a given temp block.
|
default void |
initialize()
Initialize the block store.
|
CompletableFuture<List<BlockStatus>> |
load(List<Block> fileBlocks,
UfsReadOptions options)
Load blocks into alluxio.
|
long |
lockBlock(long sessionId,
long blockId)
Locks an existing block and guards subsequent reads on this block.
|
long |
lockBlockNoException(long sessionId,
long blockId)
Locks an existing block and guards subsequent reads on this block.
|
void |
moveBlock(long sessionId,
long blockId,
AllocateOptions moveOptions)
Moves an existing block to a new location.
|
Optional<BlockLock> |
pinBlock(long sessionId,
long blockId)
Pins the block indicating subsequent access.
|
void |
registerBlockStoreEventListener(BlockStoreEventListener listener)
Registers a
BlockStoreEventListener to this block store. |
void |
removeBlock(long sessionId,
long blockId)
Removes an existing block.
|
void |
removeInaccessibleStorage()
Remove Storage directories that are no longer accessible.
|
void |
requestSpace(long sessionId,
long blockId,
long additionalBytes)
Requests to increase the size of a temp block.
|
void |
unlockBlock(long lockId)
Releases an acquired block lock based on a lockId (returned by
lockBlock(long, long) . |
boolean |
unlockBlock(long sessionId,
long blockId)
Releases an acquired block lock based on a session id and block id.
|
void |
unpinBlock(BlockLock lock)
Unpins an accessed block based on the id (returned by
pinBlock(long, long) ). |
void |
updatePinnedInodes(Set<Long> inodes)
Update the pinned inodes.
|
cleanupSession
default void initialize()
void abortBlock(long sessionId, long blockId)
sessionId
- the id of the sessionblockId
- the id of a temp blockvoid accessBlock(long sessionId, long blockId)
sessionId
- the id of the session to access a blockblockId
- the id of an accessed blockvoid commitBlock(long sessionId, long blockId, boolean pinOnCreate)
sessionId
- the id of the clientblockId
- the id of the block to commitpinOnCreate
- whether to pin block on createString createBlock(long sessionId, long blockId, int tier, CreateBlockOptions createBlockOptions)
createBlockWriter(long, long)
to get a writer for writing to the block.
The block will be temporary until it is committed by commitBlock(long, long, boolean)
.
Throws an IllegalArgumentException
if the location does not belong to tiered storage.sessionId
- the id of the clientblockId
- the id of the block to createtier
- the tier to place the new block in
BlockStoreLocation.ANY_TIER
for any tiercreateBlockOptions
- the createBlockOptionsBlockReader createBlockReader(long sessionId, long blockId, long offset, boolean positionShort, Protocol.OpenUfsBlockOptions options) throws IOException
sessionId
- the client session IDblockId
- the ID of the UFS block to readoffset
- the offset within the blockpositionShort
- whether the operation is using positioned read to a small buffer sizeoptions
- the optionsIOException
- if it fails to get block readerBlockReader createBlockReader(long sessionId, long blockId, long lockId) throws BlockDoesNotExistException, IOException
This operation requires the lock id returned by a previously acquired
lockBlock(long, long)
.
sessionId
- the id of the session to get the readerblockId
- the id of an existing blocklockId
- the id of the lock returned by lockBlock(long, long)
BlockReader
instance on this blockBlockDoesNotExistException
- if lockId is not foundIOException
BlockReader createUfsBlockReader(long sessionId, long blockId, long offset, boolean positionShort, Protocol.OpenUfsBlockOptions options) throws IOException
sessionId
- the client session IDblockId
- the ID of the UFS block to readoffset
- the offset within the blockpositionShort
- whether the operation is using positioned read to a small buffer sizeoptions
- the optionsIOException
- if it fails to get block readerBlockWriter createBlockWriter(long sessionId, long blockId) throws IOException
BlockWriter
for an existing temporary block which is already created by
createBlock(long, long, int, alluxio.worker.block.CreateBlockOptions)
.sessionId
- the id of the clientblockId
- the id of the block to be opened for writingIOException
BlockStoreMeta getBlockStoreMeta()
BlockStoreMeta getBlockStoreMetaFull()
getBlockStoreMeta()
except that this includes
more information about the block store (e.g. blockId list). This is an expensive operation.Optional<TempBlockMeta> getTempBlockMeta(long blockId)
blockId
- the id of the blockboolean hasBlockMeta(long blockId)
blockId
- the block idboolean hasTempBlockMeta(long blockId)
blockId
- the temp block idOptional<BlockMeta> getVolatileBlockMeta(long blockId)
blockId
- the block idvoid moveBlock(long sessionId, long blockId, AllocateOptions moveOptions) throws IOException
sessionId
- the id of the session to move a blockblockId
- the id of an existing blockmoveOptions
- the options for moveIOException
Optional<BlockLock> pinBlock(long sessionId, long blockId)
sessionId
- the id of the session to lock this blockblockId
- the id of the block to lockvoid unpinBlock(BlockLock lock)
pinBlock(long, long)
).lock
- the lock returned by pinBlock(long, long)
void updatePinnedInodes(Set<Long> inodes)
inodes
- a set of inodes that are currently pinnedvoid registerBlockStoreEventListener(BlockStoreEventListener listener)
BlockStoreEventListener
to this block store.listener
- the listener to those eventsvoid removeBlock(long sessionId, long blockId) throws IOException
sessionId
- the id of the session to remove a blockblockId
- the id of an existing blockIOException
void removeInaccessibleStorage()
void requestSpace(long sessionId, long blockId, long additionalBytes)
sessionId
- the id of the session to request spaceblockId
- the id of the temp blockadditionalBytes
- the amount of more space to request in bytes, never be less than 0CompletableFuture<List<BlockStatus>> load(List<Block> fileBlocks, UfsReadOptions options)
fileBlocks
- list of fileBlocks, one file blocks contains blocks belong to one fileoptions
- read ufs optionsBlockMeta getBlockMeta(long sessionId, long blockId, long lockId) throws BlockDoesNotExistException, InvalidWorkerStateException
This method requires the lock id returned by a previously acquired
lockBlock(long, long)
.
sessionId
- the id of the session to get this fileblockId
- the id of the blocklockId
- the id of the lockBlockDoesNotExistException
- if the block id can not be found in committed blocks or
lockId can not be foundInvalidWorkerStateException
- if session id or block id is not the same as that in the
LockRecord of lockIdlong lockBlock(long sessionId, long blockId) throws BlockDoesNotExistException
sessionId
- the id of the session to lock this blockblockId
- the id of the block to lockBlockDoesNotExistException
- if block id can not be found, for example, evicted alreadylong lockBlockNoException(long sessionId, long blockId)
BlockLockManager#INVALID_LOCK_ID
.sessionId
- the id of the session to lock this blockblockId
- the id of the block to lockBlockLockManager#INVALID_LOCK_ID
if it failed to lockvoid unlockBlock(long lockId) throws BlockDoesNotExistException
lockBlock(long, long)
.lockId
- the id of the lock returned by lockBlock(long, long)
BlockDoesNotExistException
- if lockId can not be foundboolean unlockBlock(long sessionId, long blockId)
sessionId
- the id of the session to lock this blockblockId
- the id of the block to lockBlockWriter getBlockWriter(long sessionId, long blockId) throws BlockDoesNotExistException, BlockAlreadyExistsException, InvalidWorkerStateException, IOException
sessionId
- the id of the session to get the writerblockId
- the id of the temp blockBlockWriter
instance on this blockBlockDoesNotExistException
- if the block can not be foundBlockAlreadyExistsException
- if a committed block with the same ID existsInvalidWorkerStateException
- if the worker state is invalidIOException
Copyright © 2023. All Rights Reserved.