@NotThreadSafe public final class BlockMetadataManager extends Object
TieredBlockStore
, Allocator
and Evictor
.
All operations on block metadata such as StorageTier
, StorageDir
should go
through this class.
Modifier and Type | Method and Description |
---|---|
void |
abortTempBlockMeta(TempBlockMeta tempBlockMeta)
Aborts a temp block.
|
void |
addTempBlockMeta(TempBlockMeta tempBlockMeta)
Adds a temp block.
|
void |
cleanupSessionTempBlocks(long sessionId,
List<Long> tempBlockIds)
Deprecated.
As of version 0.8.
|
void |
commitTempBlockMeta(TempBlockMeta tempBlockMeta)
Commits a temp block.
|
static BlockMetadataManager |
createBlockMetadataManager()
Creates a new instance of
BlockMetadataManager . |
long |
getAvailableBytes(BlockStoreLocation location)
Gets the amount of available space of given location in bytes.
|
BlockIterator |
getBlockIterator() |
BlockMeta |
getBlockMeta(long blockId)
Gets the metadata of a block given its block id.
|
String |
getBlockPath(long blockId,
BlockStoreLocation location)
Returns the path of a block given its location, or null if the location is not a specific
StorageDir . |
BlockStoreMeta |
getBlockStoreMeta()
Gets a summary of the metadata.
|
BlockStoreMeta |
getBlockStoreMetaFull()
Gets a full summary of block store metadata.
|
StorageDir |
getDir(BlockStoreLocation location)
Gets the
StorageDir given its location in the store. |
List<TempBlockMeta> |
getSessionTempBlocks(long sessionId)
Gets all the temporary blocks associated with a session, empty list is returned if the session
has no temporary blocks.
|
StorageTierAssoc |
getStorageTierAssoc() |
TempBlockMeta |
getTempBlockMeta(long blockId)
Gets the metadata of a temp block.
|
TempBlockMeta |
getTempBlockMetaOrNull(long blockId)
Gets the metadata of a temp block.
|
StorageTier |
getTier(String tierAlias)
Gets the
StorageTier given its tierAlias. |
List<StorageTier> |
getTiers()
Gets the list of
StorageTier managed. |
List<StorageTier> |
getTiersBelow(String tierAlias)
Gets the list of
StorageTier below the tier with the given tierAlias. |
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.
|
BlockMeta |
moveBlockMeta(BlockMeta blockMeta,
BlockStoreLocation newLocation)
Deprecated.
As of version 0.8. Use
moveBlockMeta(BlockMeta, TempBlockMeta) instead. |
BlockMeta |
moveBlockMeta(BlockMeta blockMeta,
TempBlockMeta tempBlockMeta)
Moves an existing block to another location currently hold by a temp block.
|
void |
removeBlockMeta(BlockMeta block)
Removes the metadata of a specific block.
|
void |
resizeTempBlockMeta(TempBlockMeta tempBlockMeta,
long newSize)
Modifies the size of a temp block.
|
void |
swapBlocks(BlockMeta blockMeta1,
BlockMeta blockMeta2)
Swaps location of two blocks in metadata.
|
public BlockIterator getBlockIterator()
public static BlockMetadataManager createBlockMetadataManager()
BlockMetadataManager
.BlockMetadataManager
instancepublic void abortTempBlockMeta(TempBlockMeta tempBlockMeta) throws BlockDoesNotExistException
tempBlockMeta
- the metadata of the temp block to addBlockDoesNotExistException
- when block can not be foundpublic void addTempBlockMeta(TempBlockMeta tempBlockMeta) throws WorkerOutOfSpaceException, BlockAlreadyExistsException
tempBlockMeta
- the metadata of the temp block to addWorkerOutOfSpaceException
- when no more space left to hold the blockBlockAlreadyExistsException
- when the block already existspublic void commitTempBlockMeta(TempBlockMeta tempBlockMeta) throws WorkerOutOfSpaceException, BlockAlreadyExistsException, BlockDoesNotExistException
tempBlockMeta
- the metadata of the temp block to commitWorkerOutOfSpaceException
- when no more space left to hold the blockBlockAlreadyExistsException
- when the block already exists in committed blocksBlockDoesNotExistException
- when temp block can not be foundpublic void swapBlocks(BlockMeta blockMeta1, BlockMeta blockMeta2) throws BlockDoesNotExistException, BlockAlreadyExistsException, WorkerOutOfSpaceException
blockMeta1
- the first block metablockMeta2
- the second block metaBlockDoesNotExistException
BlockAlreadyExistsException
WorkerOutOfSpaceException
@Deprecated public void cleanupSessionTempBlocks(long sessionId, List<Long> tempBlockIds)
sessionId
- the id of the client associated with the temp blockstempBlockIds
- the list of temporary block ids to be cleaned up, non temporary block ids
will be ignored.public long getAvailableBytes(BlockStoreLocation location)
StorageDir
. Throws an IllegalArgumentException
when the location
does not belong to the tiered storage.location
- location the check available bytespublic BlockMeta getBlockMeta(long blockId) throws BlockDoesNotExistException
blockId
- the block idBlockDoesNotExistException
- if no BlockMeta for this block id is found@Nullable public String getBlockPath(long blockId, BlockStoreLocation location)
StorageDir
. Throws an IllegalArgumentException
if the location is not a
specific StorageDir
.blockId
- the id of the blocklocation
- location of a particular StorageDir
to store this blockpublic BlockStoreMeta getBlockStoreMeta()
public BlockStoreMeta getBlockStoreMetaFull()
public StorageDir getDir(BlockStoreLocation location)
StorageDir
given its location in the store. Throws an
IllegalArgumentException
if the location is not a specific dir or the location is
invalid.location
- Location of the dirStorageDir
objectpublic TempBlockMeta getTempBlockMeta(long blockId) throws BlockDoesNotExistException
blockId
- the id of the temp blockBlockDoesNotExistException
- when block id can not be found@Nullable public TempBlockMeta getTempBlockMetaOrNull(long blockId)
blockId
- the id of the temp blockpublic StorageTier getTier(String tierAlias)
StorageTier
given its tierAlias. Throws an IllegalArgumentException
if
the tierAlias is not found.tierAlias
- the alias of this tierStorageTier
object associated with the aliaspublic List<StorageTier> getTiers()
StorageTier
managed.StorageTier
spublic List<StorageTier> getTiersBelow(String tierAlias)
StorageTier
below the tier with the given tierAlias. Throws an
IllegalArgumentException
if the tierAlias is not found.tierAlias
- the alias of a tierStorageTier
public List<TempBlockMeta> getSessionTempBlocks(long sessionId)
sessionId
- the id of the sessionpublic boolean hasBlockMeta(long blockId)
blockId
- the block idpublic boolean hasTempBlockMeta(long blockId)
blockId
- the temp block idpublic BlockMeta moveBlockMeta(BlockMeta blockMeta, TempBlockMeta tempBlockMeta) throws BlockDoesNotExistException, WorkerOutOfSpaceException, BlockAlreadyExistsException
blockMeta
- the metadata of the block to movetempBlockMeta
- a placeholder in the destination directoryBlockDoesNotExistException
- when the block to move is not foundBlockAlreadyExistsException
- when the block to move already exists in the destinationWorkerOutOfSpaceException
- when destination have no extra space to hold the block to
move@Deprecated public BlockMeta moveBlockMeta(BlockMeta blockMeta, BlockStoreLocation newLocation) throws BlockDoesNotExistException, BlockAlreadyExistsException, WorkerOutOfSpaceException
moveBlockMeta(BlockMeta, TempBlockMeta)
instead.IllegalArgumentException
if the newLocation is not in the tiered storage.blockMeta
- the metadata of the block to movenewLocation
- new location of the blockBlockDoesNotExistException
- when the block to move is not foundBlockAlreadyExistsException
- when the block to move already exists in the destinationWorkerOutOfSpaceException
- when destination have no extra space to hold the block to
movepublic void removeBlockMeta(BlockMeta block) throws BlockDoesNotExistException
block
- the metadata of the block to removeBlockDoesNotExistException
- when block is not foundpublic void resizeTempBlockMeta(TempBlockMeta tempBlockMeta, long newSize) throws InvalidWorkerStateException
tempBlockMeta
- the temp block to modifynewSize
- new size in bytesInvalidWorkerStateException
- when newSize is smaller than current sizepublic StorageTierAssoc getStorageTierAssoc()
Copyright © 2023. All Rights Reserved.