@ThreadSafe public final class GreedyEvictor extends Object implements Evictor
Evictor.Factory, Evictor.Mode
Constructor and Description |
---|
GreedyEvictor(BlockMetadataEvictorView view,
Allocator allocator)
Creates a new instance of
GreedyEvictor . |
Modifier and Type | Method and Description |
---|---|
EvictionPlan |
freeSpaceWithView(long availableBytes,
BlockStoreLocation location,
BlockMetadataEvictorView view)
Frees space with the guaranteed mode.
|
EvictionPlan |
freeSpaceWithView(long availableBytes,
BlockStoreLocation location,
BlockMetadataEvictorView view,
Evictor.Mode mode)
Frees space in the given block store location and with the given view.
|
public GreedyEvictor(BlockMetadataEvictorView view, Allocator allocator)
GreedyEvictor
.view
- a view of block metadata informationallocator
- an allocation policypublic EvictionPlan freeSpaceWithView(long availableBytes, BlockStoreLocation location, BlockMetadataEvictorView view)
Evictor
freeSpaceWithView
in interface Evictor
availableBytes
- 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 availableBytes, 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
availableBytes
- 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 feasibleCopyright © 2023. All Rights Reserved.