@NotThreadSafe public class LRUEvictor extends AbstractEvictor
Evictor.Factory, Evictor.Mode
Modifier and Type | Field and Description |
---|---|
protected Map<Long,Boolean> |
mLRUCache
Access-ordered
LinkedHashMap from blockId to UNUSED_MAP_VALUE (just a
placeholder to occupy the value), acts as a LRU double linked list where most recently accessed
element is put at the tail while least recently accessed element is put at the head. |
mAllocator, mManagerView
Constructor and Description |
---|
LRUEvictor(BlockMetadataManagerView view,
Allocator allocator)
Creates a new instance of
LRUEvictor . |
Modifier and Type | Method and Description |
---|---|
protected Iterator<Long> |
getBlockIterator()
Returns an iterator for evictor cache blocks.
|
void |
onAccessBlock(long sessionId,
long blockId)
Actions when accessing a block.
|
void |
onCommitBlock(long sessionId,
long blockId,
BlockStoreLocation location)
Actions when committing a temporary block to a
BlockStoreLocation . |
void |
onRemoveBlockByClient(long sessionId,
long blockId)
Actions when removing an existing block.
|
void |
onRemoveBlockByWorker(long sessionId,
long blockId)
Actions when removing an existing block by worker.
|
protected void |
onRemoveBlockFromIterator(long blockId)
Performs additional cleanup when a block is removed from the iterator returned by
AbstractEvictor.getBlockIterator() . |
cascadingEvict, freeSpaceWithView, freeSpaceWithView, updateBlockStoreLocation
onAbortBlock, onMoveBlockByClient, onMoveBlockByWorker
protected Map<Long,Boolean> mLRUCache
LinkedHashMap
from blockId to UNUSED_MAP_VALUE
(just a
placeholder to occupy the value), acts as a LRU double linked list where most recently accessed
element is put at the tail while least recently accessed element is put at the head.public LRUEvictor(BlockMetadataManagerView view, Allocator allocator)
LRUEvictor
.view
- a view of block metadata informationallocator
- an allocation policyprotected Iterator<Long> getBlockIterator()
AbstractEvictor
LRUEvictor
returns an iterator
that iterates through the block ids in LRU order.getBlockIterator
in class AbstractEvictor
public void onAccessBlock(long sessionId, long blockId)
BlockStoreEventListener
onAccessBlock
in interface BlockStoreEventListener
onAccessBlock
in class AbstractBlockStoreEventListener
sessionId
- the id of the session to access this blockblockId
- the id of the block to accesspublic void onCommitBlock(long sessionId, long blockId, BlockStoreLocation location)
BlockStoreEventListener
BlockStoreLocation
.onCommitBlock
in interface BlockStoreEventListener
onCommitBlock
in class AbstractBlockStoreEventListener
sessionId
- the id of the session to commit to this blockblockId
- the id of the block to commitlocation
- the location of the block to be committedpublic void onRemoveBlockByClient(long sessionId, long blockId)
BlockStoreEventListener
onRemoveBlockByClient
in interface BlockStoreEventListener
onRemoveBlockByClient
in class AbstractBlockStoreEventListener
sessionId
- the id of the session to remove this blockblockId
- the id of the block to be removedpublic void onRemoveBlockByWorker(long sessionId, long blockId)
BlockStoreEventListener
onRemoveBlockByWorker
in interface BlockStoreEventListener
onRemoveBlockByWorker
in class AbstractBlockStoreEventListener
sessionId
- the id of the session to remove this blockblockId
- the id of the block to be removedprotected void onRemoveBlockFromIterator(long blockId)
AbstractEvictor
AbstractEvictor.getBlockIterator()
.onRemoveBlockFromIterator
in class AbstractEvictor
Copyright © 2023. All Rights Reserved.