@NotThreadSafe public class BlockMetadataEvictorView extends BlockMetadataView
BlockMetadataManager
to Evictors,
filtering out un-evictable blocks and un-allocatable space internally, so that evictors and
allocators can be developed with much simpler logic, without worrying about various constraints,
e.g. pinned files, locked blocks, etc.
TODO(cc): Filter un-allocatable space.mMetadataManager, mUseReservedSpace
Constructor and Description |
---|
BlockMetadataEvictorView(BlockMetadataManager manager,
Set<Long> pinnedInodes,
Set<Long> lockedBlocks)
Creates a new instance of
BlockMetadataEvictorView . |
Modifier and Type | Method and Description |
---|---|
void |
clearBlockMarks()
Clears all marks of blocks to move in/out in all dir views.
|
long |
getAvailableBytes(BlockStoreLocation location)
Gets available bytes given certain location
BlockMetadataManager.getAvailableBytes(BlockStoreLocation) . |
Optional<BlockMeta> |
getBlockMeta(long blockId)
Returns Optional.empty() if block is pinned or currently being locked, otherwise returns
BlockMetadataManager.getBlockMeta(long) . |
List<StorageDirView> |
getDirs(BlockStoreLocation location)
Gets all dir views that belongs to a given location.
|
protected void |
initializeView()
Used to initialize the view based on the current metadata status.
|
boolean |
isBlockEvictable(long blockId)
Tests if the block is evictable.
|
boolean |
isBlockLocked(long blockId)
Tests if the block is locked.
|
boolean |
isBlockMarked(long blockId)
Tests if the block is marked to move out of its current dir in this view.
|
boolean |
isBlockPinned(long blockId)
Tests if the block is pinned either explicitly or because it is scheduled for async persist.
|
getNextTier, getTierView, getTierViews, getTierViewsBelow, refreshView
public BlockMetadataEvictorView(BlockMetadataManager manager, Set<Long> pinnedInodes, Set<Long> lockedBlocks)
BlockMetadataEvictorView
. Now we always create a new view
before freespace.manager
- which the view should be constructed frompinnedInodes
- a set of pinned inodeslockedBlocks
- a set of locked blocksprotected void initializeView()
BlockMetadataView
initializeView
in class BlockMetadataView
public List<StorageDirView> getDirs(BlockStoreLocation location)
location
- the locationpublic void clearBlockMarks()
public boolean isBlockPinned(long blockId)
blockId
- to be testedpublic boolean isBlockLocked(long blockId)
blockId
- to be testedpublic boolean isBlockEvictable(long blockId)
blockId
- to be testedpublic boolean isBlockMarked(long blockId)
blockId
- the id of the blockpublic long getAvailableBytes(BlockStoreLocation location)
BlockMetadataManager.getAvailableBytes(BlockStoreLocation)
. Throws an
IllegalArgumentException
if the location does not belong to tiered storage.location
- location the check available bytespublic Optional<BlockMeta> getBlockMeta(long blockId)
BlockMetadataManager.getBlockMeta(long)
.blockId
- the block idCopyright © 2023. All Rights Reserved.