public interface LocalBlockStore extends SessionCleanable, Closeable
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 |
cleanupSession(long sessionId)
Cleans up the data associated with a specific session (typically a dead session).
|
void |
commitBlock(long sessionId,
long blockId,
boolean pinOnCreate)
Commits a temporary block to the local store.
|
BlockLock |
commitBlockLocked(long sessionId,
long blockId,
boolean pinOnCreate)
Similar to
commitBlock(long, long, boolean) . |
TempBlockMeta |
createBlock(long sessionId,
long blockId,
AllocateOptions options)
Creates the metadata of a new block and assigns a temporary path (e.g., a subdir of the final
location named after session id) to store its data.
|
BlockReader |
createBlockReader(long sessionId,
long blockId,
long offset)
Creates a reader of an existing block to read data from this block.
|
default BlockReader |
createBlockReader(long sessionId,
long blockId,
Protocol.OpenUfsBlockOptions options)
Creates a reader of an existing block to read data from this block.
|
BlockWriter |
createBlockWriter(long sessionId,
long blockId)
Creates a writer to write data to a temp block.
|
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. |
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.
|
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 |
updatePinnedInodes(Set<Long> inodes)
Update the pinned inodes.
|
Optional<BlockLock> pinBlock(long sessionId, long blockId)
sessionId
- the id of the session to lock this blockblockId
- the id of the block to lockTempBlockMeta createBlock(long sessionId, long blockId, AllocateOptions options)
BlockStoreLocation.anyTier()
, or
BlockStoreLocation.anyDirInTier(String)
.
Before commit, all the data written to this block will be stored in the temp path and the block is only "visible" to its writer client.
sessionId
- the id of the sessionblockId
- the id of the block to createoptions
- allocation optionsOptional<BlockMeta> getVolatileBlockMeta(long blockId)
blockId
- the block idOptional<TempBlockMeta> getTempBlockMeta(long blockId)
blockId
- the id of the blockvoid commitBlock(long sessionId, long blockId, boolean pinOnCreate)
sessionId
- the id of the sessionblockId
- the id of a temp blockpinOnCreate
- whether to pin block on createBlockLock commitBlockLocked(long sessionId, long blockId, boolean pinOnCreate)
commitBlock(long, long, boolean)
. It returns the block locked,
so the caller is required to explicitly unlock the block.
//TODO(Beinan): make this method to be privatesessionId
- the id of the sessionblockId
- the id of a temp blockpinOnCreate
- whether to pin block on createvoid abortBlock(long sessionId, long blockId)
sessionId
- the id of the sessionblockId
- the id of a temp blockvoid 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 0BlockWriter createBlockWriter(long sessionId, long blockId)
sessionId
- the id of the session to get the writerblockId
- the id of the temp blockBlockWriter
instance on this blockBlockReader createBlockReader(long sessionId, long blockId, long offset) throws IOException
This operation requires the lock id returned by a previously acquired
pinBlock(long, long)
.
sessionId
- the id of the session to get the readerblockId
- the id of an existing blockoffset
- the offset within the blockBlockReader
instance on this blockBlockDoesNotExistRuntimeException
- if lockId is not foundIOException
default BlockReader createBlockReader(long sessionId, long blockId, Protocol.OpenUfsBlockOptions options)
The block reader will fetch the data from UFS when the data is not cached by the worker
sessionId
- the id of the session to get the readerblockId
- the id of an existing blockoptions
- the options for UFS fall-backBlockReader
instance on this blockvoid 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 move
blockIOException
void removeBlock(long sessionId, long blockId) throws IOException
sessionId
- the id of the session to remove a blockblockId
- the id of an existing blockIOException
void accessBlock(long sessionId, long blockId)
sessionId
- the id of the session to access a blockblockId
- the id of an accessed blockBlockStoreMeta getBlockStoreMeta()
BlockStoreMeta getBlockStoreMetaFull()
getBlockStoreMeta()
except that this includes
more information about the block store (e.g. blockId list). This is an expensive operation.boolean hasBlockMeta(long blockId)
blockId
- the block idboolean hasTempBlockMeta(long blockId)
blockId
- the temp block idvoid cleanupSession(long sessionId)
cleanupSession
in interface SessionCleanable
sessionId
- the session idvoid registerBlockStoreEventListener(BlockStoreEventListener listener)
BlockStoreEventListener
to this block store.listener
- the listener to those eventsvoid updatePinnedInodes(Set<Long> inodes)
inodes
- a set of inodes that are currently pinnedvoid removeInaccessibleStorage()
Copyright © 2023. All Rights Reserved.