@NotThreadSafe public abstract class AbstractEvictor extends AbstractBlockStoreEventListener implements Evictor
Evictor.Factory, Evictor.Mode
Modifier and Type | Field and Description |
---|---|
protected Allocator |
mAllocator |
protected BlockMetadataEvictorView |
mMetadataView |
Constructor and Description |
---|
AbstractEvictor(BlockMetadataEvictorView view,
Allocator allocator)
Creates a new instance of
AbstractEvictor . |
Modifier and Type | Method and Description |
---|---|
protected StorageDirEvictorView |
cascadingEvict(long bytesToBeAvailable,
BlockStoreLocation location,
EvictionPlan plan,
Evictor.Mode mode)
A recursive implementation of cascading eviction.
|
EvictionPlan |
freeSpaceWithView(long bytesToBeAvailable,
BlockStoreLocation location,
BlockMetadataEvictorView view)
Frees space with the guaranteed mode.
|
EvictionPlan |
freeSpaceWithView(long bytesToBeAvailable,
BlockStoreLocation location,
BlockMetadataEvictorView view,
Evictor.Mode mode)
Frees space in the given block store location and with the given view.
|
protected abstract Iterator<Long> |
getBlockIterator()
Returns an iterator for evictor cache blocks.
|
protected void |
onRemoveBlockFromIterator(long blockId)
Performs additional cleanup when a block is removed from the iterator returned by
getBlockIterator() . |
protected BlockStoreLocation |
updateBlockStoreLocation(long bytesToBeAvailable,
BlockStoreLocation location)
Updates the block store location if the evictor wants to free space in a specific location.
|
onAbortBlock, onAccessBlock, onBlockLost, onCommitBlock, onMoveBlockByClient, onMoveBlockByWorker, onRemoveBlockByClient, onRemoveBlockByWorker, onStorageLost
protected final Allocator mAllocator
protected BlockMetadataEvictorView mMetadataView
public AbstractEvictor(BlockMetadataEvictorView view, Allocator allocator)
AbstractEvictor
.view
- a view of block metadata informationallocator
- an allocation policyprotected StorageDirEvictorView cascadingEvict(long bytesToBeAvailable, BlockStoreLocation location, EvictionPlan plan, Evictor.Mode mode)
StorageDir
in the location has
the specific amount of free space. It then uses an allocation strategy to allocate space in the
next tier to move each evicted blocks. If the next tier fails to allocate space for the evicted
blocks, the next tier will continue to evict its blocks to free space.
This method is only used in
freeSpaceWithView(long, BlockStoreLocation, BlockMetadataEvictorView)
.bytesToBeAvailable
- bytes to be available after evictionlocation
- target location to evict blocks fromplan
- the plan to be recursively updated, is empty when first called in
freeSpaceWithView(long, BlockStoreLocation, BlockMetadataEvictorView)
mode
- the eviction modeStorageDirEvictorView
in the range of location
to evict/move bytes from, or null if there is no planpublic EvictionPlan freeSpaceWithView(long bytesToBeAvailable, BlockStoreLocation location, BlockMetadataEvictorView view)
Evictor
freeSpaceWithView
in interface Evictor
bytesToBeAvailable
- the amount of free space in bytes to be ensured after evictionlocation
- the location in block storeview
- generated and passed by block storeEvictionPlan
(possibly with empty fields) to get the free space, or null
if no plan is feasiblepublic EvictionPlan freeSpaceWithView(long bytesToBeAvailable, BlockStoreLocation location, BlockMetadataEvictorView view, Evictor.Mode mode)
Evictor
StorageDir
in the location has the specific amount of free
space after eviction. The location can be a specific
StorageDir
, or BlockStoreLocation.anyTier()
or
BlockStoreLocation.anyDirInTier(String)
. The view is generated and passed by the
calling BlockStore
. This method returns null if Evictor
fails to propose a feasible plan to meet the requirement.
With the BEST_EFFORT mode, the evictor always returns an eviction plan with toMove and toEvict fields to indicate how to free space. Even if the tier does not have the amount of free space, the evictor returns the plan to free the max space.
If both toMove and toEvict of the plan are empty, it indicates that Evictor
has no
actions to take and the requirement is already met.
Throws an IllegalArgumentException
if the given block location is invalid.
freeSpaceWithView
in interface Evictor
bytesToBeAvailable
- the amount of free space in bytes to be ensured after evictionlocation
- the location in block storeview
- generated and passed by block storemode
- the eviction modeEvictionPlan
(possibly with empty fields) to get the free space, or null
if no plan is feasibleprotected abstract Iterator<Long> getBlockIterator()
LRUEvictor
returns an iterator
that iterates through the block ids in LRU order.protected void onRemoveBlockFromIterator(long blockId)
getBlockIterator()
.protected BlockStoreLocation updateBlockStoreLocation(long bytesToBeAvailable, BlockStoreLocation location)
PartialLRUEvictor
always evicts blocks from a dir with max free space.bytesToBeAvailable
- bytes to be available after evictionlocation
- the original block store locationCopyright © 2023. All Rights Reserved.