org.jboss.cache.eviction
Interface EvictionAlgorithm

All Known Implementing Classes:
BaseEvictionAlgorithm, BaseSortedEvictionAlgorithm, ElementSizeAlgorithm, ExpirationAlgorithm, FIFOAlgorithm, LFUAlgorithm, LRUAlgorithm, MRUAlgorithm, NullEvictionAlgorithm

public interface EvictionAlgorithm

Interface for all eviction algorithms.

Note: None of the Eviction classes are thread safe. It is assumed that an individual instance of an EvictionPolicy/ EvictionAlgorithm/EvictionQueue/EvictionConfiguration are only operated on by one thread at any given time.

Version:
$Revision: 7168 $
Author:
Ben Wang 2-2004, Daniel Huang - dhuang@jboss.org - 10/2005

Method Summary
 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.
 Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
          This is a helper so that the XML parser will be able to select and use the correct EvictionAlgorithmConfig implementation class corresponding to this EvictionAlgorithm.
 EvictionQueue getEvictionQueue()
          Get the EvictionQueue implementation used by this algorithm.
 void initialize()
          Invoked by the region manager when the enclosing region is initialized.
 void process(BlockingQueue<EvictionEvent> queue)
          Entry point for eviction algorithm.
 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.
 

Method Detail

process

void process(BlockingQueue<EvictionEvent> queue)
             throws EvictionException
Entry point for eviction algorithm. Invoking this will cause the algorithm to process the queue of EvictionEvent passed in.

Parameters:
queue - to process
Throws:
EvictionException

resetEvictionQueue

void resetEvictionQueue()
Reset the whole eviction queue. The queue may need to be reset due to corrupted state, for example.


getEvictionQueue

EvictionQueue getEvictionQueue()
Get the EvictionQueue implementation used by this algorithm.

Returns:
the EvictionQueue implementation.

setEvictionActionPolicy

void setEvictionActionPolicy(EvictionActionPolicy evictionActionPolicy)
Sets the eviction action policy, so the algorithm knows what to do when a node is to be evicted.

Parameters:
evictionActionPolicy - to set

assignToRegion

void assignToRegion(Fqn fqn,
                    CacheSPI<?,?> cache,
                    EvictionAlgorithmConfig evictionAlgorithmConfig,
                    Configuration configuration)
Assigns the algorithm instance to a specific region.

Parameters:
fqn - of the region to be assigned to
cache - cache reference
evictionAlgorithmConfig - configuration for the current algorithm instance.
configuration - for the entire cache.

canIgnoreEvent

boolean canIgnoreEvent(EvictionEvent.Type eventType)
Tests whether the algorithm would ignore certain event types on certain Fqns.

Parameters:
eventType - event type to test for
Returns:
true if the event representing the parameters would be ignored by this algorithm or not.

initialize

void initialize()
Invoked by the region manager when the enclosing region is initialized.


getConfigurationClass

Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
This is a helper so that the XML parser will be able to select and use the correct EvictionAlgorithmConfig implementation class corresponding to this EvictionAlgorithm. E.g., the FIFOAlgorithm would return FIFOAlgorithmConfig.class.

Returns:
a class that is used to configure this EvictionAlgorithm.


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.