@ThreadSafe public class TieredBlockStore extends Object implements LocalBlockStore
This class is thread-safe, using the following lock hierarchy to ensure thread-safety:
mLockManager
. This block lock is a
read/write lock, guarding both the metadata operations and the following I/O on this block. It
coordinates different threads (clients) when accessing the same block concurrently.mMetaManager
and guarded by mMetadataLock
. This is also a read/write lock and
coordinates different threads (clients) when accessing the shared data structure for metadata.
createBlock(long, long, alluxio.worker.block.AllocateOptions)
does not acquire the block lock, because it only creates a
temp block which is only visible to its writer before committed (thus no concurrent access).abortBlock(long, long)
does not acquire the block lock, because only
temporary blocks can be aborted, and they are only visible to their writers (thus no concurrent
access).
freeSpace(long, long, long, alluxio.worker.block.BlockStoreLocation)
and it is on the basis of best effort. For
operations that may trigger this eviction (e.g., move, create, requestSpace), retry is usedConstructor and Description |
---|
TieredBlockStore()
Creates a new instance of
TieredBlockStore . |
TieredBlockStore(BlockMetadataManager metaManager,
BlockLockManager lockManager)
Creates a new instance of
TieredBlockStore . |
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 |
close() |
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
LocalBlockStore.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.
|
BlockWriter |
createBlockWriter(long sessionId,
long blockId)
Creates a writer to write data to a temp block.
|
void |
freeSpace(long sessionId,
long minContiguousBytes,
long minAvailableBytes,
BlockStoreLocation location)
Free space is the entry for immediate block deletion in order to open up space for
new or ongoing blocks.
|
BlockStoreMeta |
getBlockStoreMeta()
Gets the metadata of the entire store in a snapshot.
|
BlockStoreMeta |
getBlockStoreMetaFull()
Similar as
LocalBlockStore.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 |
removeDir(StorageDir dir)
Removes a storage directory.
|
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)
Updates the pinned blocks.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createBlockReader
public TieredBlockStore()
TieredBlockStore
.public TieredBlockStore(BlockMetadataManager metaManager, BlockLockManager lockManager)
TieredBlockStore
.metaManager
- the block metadata managerlockManager
- the lock managerpublic Optional<BlockLock> pinBlock(long sessionId, long blockId)
LocalBlockStore
pinBlock
in interface LocalBlockStore
sessionId
- the id of the session to lock this blockblockId
- the id of the block to lockpublic BlockWriter createBlockWriter(long sessionId, long blockId)
LocalBlockStore
createBlockWriter
in interface LocalBlockStore
sessionId
- the id of the session to get the writerblockId
- the id of the temp blockBlockWriter
instance on this blockpublic BlockReader createBlockReader(long sessionId, long blockId, long offset) throws IOException
LocalBlockStore
This operation requires the lock id returned by a previously acquired
LocalBlockStore.pinBlock(long, long)
.
createBlockReader
in interface LocalBlockStore
sessionId
- the id of the session to get the readerblockId
- the id of an existing blockoffset
- the offset within the blockBlockReader
instance on this blockIOException
public TempBlockMeta createBlock(long sessionId, long blockId, AllocateOptions options)
LocalBlockStore
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.
createBlock
in interface LocalBlockStore
sessionId
- the id of the sessionblockId
- the id of the block to createoptions
- allocation optionspublic Optional<BlockMeta> getVolatileBlockMeta(long blockId)
LocalBlockStore
getVolatileBlockMeta
in interface LocalBlockStore
blockId
- the block idpublic Optional<TempBlockMeta> getTempBlockMeta(long blockId)
LocalBlockStore
getTempBlockMeta
in interface LocalBlockStore
blockId
- the id of the blockpublic void commitBlock(long sessionId, long blockId, boolean pinOnCreate)
LocalBlockStore
commitBlock
in interface LocalBlockStore
sessionId
- the id of the sessionblockId
- the id of a temp blockpinOnCreate
- whether to pin block on createpublic BlockLock commitBlockLocked(long sessionId, long blockId, boolean pinOnCreate)
LocalBlockStore
LocalBlockStore.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 privatecommitBlockLocked
in interface LocalBlockStore
sessionId
- the id of the sessionblockId
- the id of a temp blockpinOnCreate
- whether to pin block on createpublic void abortBlock(long sessionId, long blockId)
LocalBlockStore
abortBlock
in interface LocalBlockStore
sessionId
- the id of the sessionblockId
- the id of a temp blockpublic void requestSpace(long sessionId, long blockId, long additionalBytes)
LocalBlockStore
requestSpace
in interface LocalBlockStore
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 void moveBlock(long sessionId, long blockId, AllocateOptions moveOptions) throws IOException
LocalBlockStore
moveBlock
in interface LocalBlockStore
sessionId
- the id of the session to move a blockblockId
- the id of an existing blockmoveOptions
- the options for move
blockIOException
public void removeBlock(long sessionId, long blockId) throws IOException
LocalBlockStore
removeBlock
in interface LocalBlockStore
sessionId
- the id of the session to remove a blockblockId
- the id of an existing blockIOException
public void accessBlock(long sessionId, long blockId)
LocalBlockStore
accessBlock
in interface LocalBlockStore
sessionId
- the id of the session to access a blockblockId
- the id of an accessed blockpublic void cleanupSession(long sessionId)
LocalBlockStore
cleanupSession
in interface LocalBlockStore
cleanupSession
in interface SessionCleanable
sessionId
- the session idpublic boolean hasBlockMeta(long blockId)
LocalBlockStore
hasBlockMeta
in interface LocalBlockStore
blockId
- the block idpublic boolean hasTempBlockMeta(long blockId)
LocalBlockStore
hasTempBlockMeta
in interface LocalBlockStore
blockId
- the temp block idpublic BlockStoreMeta getBlockStoreMeta()
LocalBlockStore
getBlockStoreMeta
in interface LocalBlockStore
public BlockStoreMeta getBlockStoreMetaFull()
LocalBlockStore
LocalBlockStore.getBlockStoreMeta()
except that this includes
more information about the block store (e.g. blockId list). This is an expensive operation.getBlockStoreMetaFull
in interface LocalBlockStore
public void registerBlockStoreEventListener(BlockStoreEventListener listener)
LocalBlockStore
BlockStoreEventListener
to this block store.registerBlockStoreEventListener
in interface LocalBlockStore
listener
- the listener to those eventspublic void freeSpace(long sessionId, long minContiguousBytes, long minAvailableBytes, BlockStoreLocation location)
sessionId
- the session idminContiguousBytes
- the minimum amount of contiguous free space in bytesminAvailableBytes
- the minimum amount of free space in byteslocation
- the location to free spacepublic void updatePinnedInodes(Set<Long> inodes)
updatePinnedInodes
in interface LocalBlockStore
inodes
- a set of ids inodes that are pinnedpublic void removeInaccessibleStorage()
LocalBlockStore
removeInaccessibleStorage
in interface LocalBlockStore
public void removeDir(StorageDir dir)
dir
- storage directory to be removedpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2023. All Rights Reserved.