public class MonoBlockStore extends Object implements BlockStore
Constructor and Description |
---|
MonoBlockStore(LocalBlockStore localBlockStore,
BlockMasterClientPool blockMasterClientPool,
UfsManager ufsManager,
AtomicReference<Long> workerId)
Constructor of MonoBlockStore.
|
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 session.
|
void |
close() |
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 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
BlockStore.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.
|
BlockStoreMeta |
getBlockStoreMeta()
Gets the metadata of the entire store in a snapshot.
|
BlockStoreMeta |
getBlockStoreMetaFull()
Similar as
BlockStore.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.
|
CompletableFuture<List<BlockStatus>> |
load(List<Block> blocks,
UfsReadOptions options)
Load blocks into alluxio.
|
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 |
unpinBlock(BlockLock lock)
Unpins an accessed block based on the id (returned by
BlockStore.pinBlock(long, long) ). |
void |
updatePinnedInodes(Set<Long> inodes)
Update the pinned inodes.
|
public MonoBlockStore(LocalBlockStore localBlockStore, BlockMasterClientPool blockMasterClientPool, UfsManager ufsManager, AtomicReference<Long> workerId)
localBlockStore
- the local block storeblockMasterClientPool
- a client pool for talking to the block masterufsManager
- the UFS managerworkerId
- the worker idpublic void abortBlock(long sessionId, long blockId)
BlockStore
abortBlock
in interface BlockStore
sessionId
- the id of the sessionblockId
- the id of a temp blockpublic void accessBlock(long sessionId, long blockId)
BlockStore
accessBlock
in interface BlockStore
sessionId
- the id of the session to access a blockblockId
- the id of an accessed blockpublic void cleanupSession(long sessionId)
SessionCleanable
cleanupSession
in interface SessionCleanable
sessionId
- the session idpublic void commitBlock(long sessionId, long blockId, boolean pinOnCreate)
BlockStore
commitBlock
in interface BlockStore
sessionId
- the id of the clientblockId
- the id of the block to commitpinOnCreate
- whether to pin block on createpublic String createBlock(long sessionId, long blockId, int tier, CreateBlockOptions createBlockOptions)
BlockStore
BlockStore.createBlockWriter(long, long)
to get a writer for writing to the block.
The block will be temporary until it is committed by BlockStore.commitBlock(long, long, boolean)
.
Throws an IllegalArgumentException
if the location does not belong to tiered storage.createBlock
in interface BlockStore
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 createBlockOptionspublic BlockReader createBlockReader(long sessionId, long blockId, long offset, boolean positionShort, Protocol.OpenUfsBlockOptions options) throws IOException
BlockStore
createBlockReader
in interface BlockStore
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 readerpublic BlockReader createUfsBlockReader(long sessionId, long blockId, long offset, boolean positionShort, Protocol.OpenUfsBlockOptions options) throws IOException
BlockStore
createUfsBlockReader
in interface BlockStore
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 readerpublic BlockWriter createBlockWriter(long sessionId, long blockId) throws IOException
BlockStore
BlockWriter
for an existing temporary block which is already created by
BlockStore.createBlock(long, long, int, alluxio.worker.block.CreateBlockOptions)
.createBlockWriter
in interface BlockStore
sessionId
- the id of the clientblockId
- the id of the block to be opened for writingIOException
public BlockStoreMeta getBlockStoreMeta()
BlockStore
getBlockStoreMeta
in interface BlockStore
public BlockStoreMeta getBlockStoreMetaFull()
BlockStore
BlockStore.getBlockStoreMeta()
except that this includes
more information about the block store (e.g. blockId list). This is an expensive operation.getBlockStoreMetaFull
in interface BlockStore
public Optional<TempBlockMeta> getTempBlockMeta(long blockId)
BlockStore
getTempBlockMeta
in interface BlockStore
blockId
- the id of the blockpublic boolean hasBlockMeta(long blockId)
BlockStore
hasBlockMeta
in interface BlockStore
blockId
- the block idpublic boolean hasTempBlockMeta(long blockId)
BlockStore
hasTempBlockMeta
in interface BlockStore
blockId
- the temp block idpublic Optional<BlockMeta> getVolatileBlockMeta(long blockId)
BlockStore
getVolatileBlockMeta
in interface BlockStore
blockId
- the block idpublic void moveBlock(long sessionId, long blockId, AllocateOptions moveOptions) throws IOException
BlockStore
moveBlock
in interface BlockStore
sessionId
- the id of the session to move a blockblockId
- the id of an existing blockmoveOptions
- the options for moveIOException
public Optional<BlockLock> pinBlock(long sessionId, long blockId)
BlockStore
pinBlock
in interface BlockStore
sessionId
- the id of the session to lock this blockblockId
- the id of the block to lockpublic void unpinBlock(BlockLock lock)
BlockStore
BlockStore.pinBlock(long, long)
).unpinBlock
in interface BlockStore
lock
- the lock returned by BlockStore.pinBlock(long, long)
public void updatePinnedInodes(Set<Long> inodes)
BlockStore
updatePinnedInodes
in interface BlockStore
inodes
- a set of inodes that are currently pinnedpublic void registerBlockStoreEventListener(BlockStoreEventListener listener)
BlockStore
BlockStoreEventListener
to this block store.registerBlockStoreEventListener
in interface BlockStore
listener
- the listener to those eventspublic void removeBlock(long sessionId, long blockId) throws IOException
BlockStore
removeBlock
in interface BlockStore
sessionId
- the id of the session to remove a blockblockId
- the id of an existing blockIOException
public void removeInaccessibleStorage()
BlockStore
removeInaccessibleStorage
in interface BlockStore
public void requestSpace(long sessionId, long blockId, long additionalBytes)
BlockStore
requestSpace
in interface BlockStore
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 0public CompletableFuture<List<BlockStatus>> load(List<Block> blocks, UfsReadOptions options)
BlockStore
load
in interface BlockStore
blocks
- list of fileBlocks, one file blocks contains blocks belong to one fileoptions
- read ufs optionspublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2023. All Rights Reserved.