@NotThreadSafe public class BlockMetadataManagerView extends Object
BlockMetadataManager
to Evictors and Allocators,
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.Constructor and Description |
---|
BlockMetadataManagerView(BlockMetadataManager manager,
Set<Long> pinnedInodes,
Set<Long> lockedBlocks)
Creates a new instance of
BlockMetadataManagerView . |
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) . |
BlockMeta |
getBlockMeta(long blockId)
Returns null if block is pinned or currently being locked, otherwise returns
BlockMetadataManager.getBlockMeta(long) . |
StorageTierView |
getNextTier(StorageTierView tierView)
Gets the next storage tier view.
|
StorageTierView |
getTierView(String tierAlias)
Provides
StorageTierView given tierAlias. |
List<StorageTierView> |
getTierViews()
Gets all tierViews under this managerView.
|
List<StorageTierView> |
getTierViewsBelow(String tierAlias)
Gets all tierViews before certain tierView.
|
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.
|
public BlockMetadataManagerView(BlockMetadataManager manager, Set<Long> pinnedInodes, Set<Long> lockedBlocks)
BlockMetadataManagerView
. 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 blockspublic 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 StorageTierView getTierView(String tierAlias)
StorageTierView
given tierAlias. Throws an IllegalArgumentException
if
the tierAlias is not found.tierAlias
- the alias of this tierViewStorageTierView
object associated with the aliaspublic List<StorageTierView> getTierViews()
StorageTierView
spublic List<StorageTierView> getTierViewsBelow(String tierAlias)
IllegalArgumentException
if the
tierAlias is not found.tierAlias
- the alias of a tierViewStorageTierView
@Nullable public StorageTierView getNextTier(StorageTierView tierView)
tierView
- the storage tier viewpublic long getAvailableBytes(BlockStoreLocation location)
BlockMetadataManager.getAvailableBytes(BlockStoreLocation)
. Throws an
IllegalArgumentException
if the location does not belong to tiered storage.location
- location the check available bytes@Nullable public BlockMeta getBlockMeta(long blockId) throws BlockDoesNotExistException
BlockMetadataManager.getBlockMeta(long)
.blockId
- the block idBlockDoesNotExistException
- if no BlockMeta
for this block id is foundCopyright © 2023. All Rights Reserved.