public abstract class BaseEvictionAlgorithm extends Object implements EvictionAlgorithm
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
allowTombstones |
protected CacheSPI<?,?> |
cache |
protected Configuration |
configuration |
protected EvictionActionPolicy |
evictionActionPolicy |
protected EvictionAlgorithmConfig |
evictionAlgorithmConfig |
protected EvictionQueue |
evictionQueue
Contains NodeEntry instances.
|
protected BlockingQueue<Fqn> |
recycleQueue
Contains Fqn instances.
|
protected Fqn |
regionFqn |
| Modifier | Constructor and Description |
|---|---|
protected |
BaseEvictionAlgorithm() |
| Modifier and Type | Method and Description |
|---|---|
void |
assignToRegion(Fqn fqn,
CacheSPI<?,?> cache,
EvictionAlgorithmConfig evictionAlgorithmConfig,
Configuration configuration)
Assigns the algorithm instance to a specific region.
|
boolean |
canIgnoreEvent(EvictionEvent.Type eventType)
Tests whether the algorithm would ignore certain event types on certain Fqns.
|
protected void |
emptyRecycleQueue()
Empty the Recycle Queue.
|
protected void |
evict(NodeEntry ne) |
protected boolean |
evictCacheNode(Fqn fqn)
Evict a node from cache.
|
EvictionActionPolicy |
getEvictionActionPolicy() |
EvictionAlgorithmConfig |
getEvictionAlgorithmConfig() |
EvictionQueue |
getEvictionQueue()
Get the underlying EvictionQueue implementation.
|
protected EvictionEvent |
getNextInQueue(BlockingQueue<EvictionEvent> queue) |
void |
initialize()
Invoked by the region manager when the enclosing region is initialized.
|
protected boolean |
isNodeInUseAndNotTimedOut(NodeEntry ne) |
protected boolean |
isYoungerThanMinimumTimeToLive(NodeEntry entry)
Tests whether a node entry is younger than the minimum time to live - if one is configured.
|
void |
process(BlockingQueue<EvictionEvent> eventQueue)
Process the given eviction event queue.
|
protected void |
processAddedElement(EvictionEvent evictedEventNode) |
protected void |
processAddedNodes(EvictionEvent evictedEventNode)
Convenience method, which calls
processAddedNodes(EvictionEvent, int) using values in the
evictedEventNode for number of added elements and the resetElementCount flag. |
protected void |
processAddedNodes(EvictionEvent evictedEventNode,
int numAddedElements) |
protected void |
processMarkInUseNodes(Fqn fqn,
long inUseTimeout) |
protected void |
processQueues(BlockingQueue<EvictionEvent> queue)
Event processing for Evict/Add/Visiting of nodes.
|
protected void |
processRemovedElement(EvictionEvent evictedEventNode) |
protected void |
processRemovedNodes(EvictionEvent evictedEventNode)
Remove a node from cache.
|
protected void |
processUnmarkInUseNodes(Fqn fqn) |
protected void |
processVisitedNodes(EvictionEvent evictedEventNode)
Visit a node in cache.
|
protected void |
prune() |
void |
resetEvictionQueue()
Reset the whole eviction queue.
|
void |
setEvictionActionPolicy(EvictionActionPolicy evictionActionPolicy)
Sets the eviction action policy, so the algorithm knows what to do when a node is to be evicted.
|
protected abstract EvictionQueue |
setupEvictionQueue()
This method will create an EvictionQueue implementation and prepare it for use.
|
protected abstract boolean |
shouldEvictNode(NodeEntry ne)
This method will check whether the given node should be evicted or not.
|
String |
toString()
Returns debug information.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetConfigurationClassprotected EvictionActionPolicy evictionActionPolicy
protected EvictionAlgorithmConfig evictionAlgorithmConfig
protected BlockingQueue<Fqn> recycleQueue
protected EvictionQueue evictionQueue
protected boolean allowTombstones
protected Configuration configuration
protected Fqn regionFqn
protected CacheSPI<?,?> cache
protected abstract EvictionQueue setupEvictionQueue() throws EvictionException
EvictionException - if there are problemsEvictionQueueprotected abstract boolean shouldEvictNode(NodeEntry ne)
ne - NodeEntry to test eviction for.public void initialize()
EvictionAlgorithminitialize in interface EvictionAlgorithmpublic EvictionActionPolicy getEvictionActionPolicy()
public void setEvictionActionPolicy(EvictionActionPolicy evictionActionPolicy)
EvictionAlgorithmsetEvictionActionPolicy in interface EvictionAlgorithmevictionActionPolicy - to setpublic EvictionAlgorithmConfig getEvictionAlgorithmConfig()
public void assignToRegion(Fqn fqn, CacheSPI<?,?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration)
EvictionAlgorithmassignToRegion in interface EvictionAlgorithmfqn - of the region to be assigned tocache - cache referenceevictionAlgorithmConfig - configuration for the current algorithm instance.configuration - for the entire cache.public boolean canIgnoreEvent(EvictionEvent.Type eventType)
EvictionAlgorithmcanIgnoreEvent in interface EvictionAlgorithmeventType - event type to test forpublic void process(BlockingQueue<EvictionEvent> eventQueue) throws EvictionException
process in interface EvictionAlgorithmeventQueue - queue containing eviction eventsEvictionExceptionpublic void resetEvictionQueue()
EvictionAlgorithmresetEvictionQueue in interface EvictionAlgorithmpublic EvictionQueue getEvictionQueue()
getEvictionQueue in interface EvictionAlgorithmEvictionQueueprotected EvictionEvent getNextInQueue(BlockingQueue<EvictionEvent> queue)
protected void processQueues(BlockingQueue<EvictionEvent> queue) throws EvictionException
queue - queue to inspectEvictionException - in the event of problemsprotected void evict(NodeEntry ne)
protected boolean evictCacheNode(Fqn fqn)
fqn - node corresponds to this fqnprotected void processMarkInUseNodes(Fqn fqn, long inUseTimeout) throws EvictionException
EvictionExceptionprotected void processUnmarkInUseNodes(Fqn fqn) throws EvictionException
EvictionExceptionprotected void processAddedNodes(EvictionEvent evictedEventNode) throws EvictionException
processAddedNodes(EvictionEvent, int) using values in the
evictedEventNode for number of added elements and the resetElementCount flag.evictedEventNode - an evictedEventNode to processEvictionException - on problemsprotected void processAddedNodes(EvictionEvent evictedEventNode, int numAddedElements) throws EvictionException
EvictionExceptionprotected void processRemovedNodes(EvictionEvent evictedEventNode) throws EvictionException
EvictionExceptionprotected void processVisitedNodes(EvictionEvent evictedEventNode) throws EvictionException
EvictionExceptionprotected void processRemovedElement(EvictionEvent evictedEventNode) throws EvictionException
EvictionExceptionprotected void processAddedElement(EvictionEvent evictedEventNode) throws EvictionException
EvictionExceptionprotected void emptyRecycleQueue()
throws EvictionException
EvictionExceptionprotected boolean isNodeInUseAndNotTimedOut(NodeEntry ne)
protected void prune()
throws EvictionException
EvictionExceptionprotected boolean isYoungerThanMinimumTimeToLive(NodeEntry entry)
entry - the node entry being examinedCopyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.