public class PagedBlockStore extends Object implements BlockStore
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.
|
static PagedBlockStore |
create(UfsManager ufsManager)
Create an instance of PagedBlockStore.
|
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.
|
List<BlockStatus> |
load(List<Block> fileBlocks,
String tag,
OptionalLong bandwidth)
Load blocks into alluxio.
|
void |
moveBlock(long sessionId,
long blockId,
AllocateOptions moveOptions)
Moves an existing block to a new location.
|
OptionalLong |
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(long id)
Unpins an accessed block based on the id (returned by
BlockStore.pinBlock(long, long) ). |
void |
updatePinnedInodes(Set<Long> inodes)
Update the pinned inodes.
|
public static PagedBlockStore create(UfsManager ufsManager)
ufsManager
- public OptionalLong 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(long id)
BlockStore
BlockStore.pinBlock(long, long)
).unpinBlock
in interface BlockStore
id
- the id returned by BlockStore.pinBlock(long, long)
public void commitBlock(long sessionId, long blockId, boolean pinOnCreate) throws IOException
BlockStore
commitBlock
in interface BlockStore
sessionId
- the id of the clientblockId
- the id of the block to commitpinOnCreate
- whether to pin block on createIOException
public String createBlock(long sessionId, long blockId, int tier, CreateBlockOptions createBlockOptions) throws WorkerOutOfSpaceException, IOException
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 createBlockOptionsWorkerOutOfSpaceException
- if this Store has no more space than the initialBlockSizeIOException
public 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 void abortBlock(long sessionId, long blockId) throws IOException
BlockStore
abortBlock
in interface BlockStore
sessionId
- the id of the sessionblockId
- the id of a temp blockIOException
public void requestSpace(long sessionId, long blockId, long additionalBytes) throws WorkerOutOfSpaceException, IOException
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 0WorkerOutOfSpaceException
- if requested space can not be satisfiedIOException
public List<BlockStatus> load(List<Block> fileBlocks, String tag, OptionalLong bandwidth)
BlockStore
load
in interface BlockStore
fileBlocks
- list of fileBlocks, one file blocks contains blocks belong to one filetag
- the user/client name or specific identifierbandwidth
- limited bandwidth to ufspublic 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 void moveBlock(long sessionId, long blockId, AllocateOptions moveOptions) throws WorkerOutOfSpaceException, 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 moveWorkerOutOfSpaceException
- if newLocation does not have enough extra space to hold the
blockIOException
public 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 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 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 cleanupSession(long sessionId)
SessionCleanable
cleanupSession
in interface SessionCleanable
sessionId
- the session idpublic void registerBlockStoreEventListener(BlockStoreEventListener listener)
BlockStore
BlockStoreEventListener
to this block store.registerBlockStoreEventListener
in interface BlockStore
listener
- the listener to those eventspublic void updatePinnedInodes(Set<Long> inodes)
BlockStore
updatePinnedInodes
in interface BlockStore
inodes
- a set of inodes that are currently pinnedpublic void removeInaccessibleStorage()
BlockStore
removeInaccessibleStorage
in interface BlockStore
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2023. All Rights Reserved.