org.jboss.cache.eviction
Interface EvictionPolicy

All Known Implementing Classes:
BaseEvictionPolicy, ElementSizePolicy, ExpirationPolicy, FIFOPolicy, LFUPolicy, LRUPolicy, MRUPolicy, NullEvictionPolicy

public interface EvictionPolicy

Generic eviction policy interface.

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.

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

Method Summary
 boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType)
          This method will be invoked prior to an event being processed for a node with the specified Fqn.
 void evict(Fqn fqn)
          Evict a node form the underlying cache.
 CacheSPI getCache()
           
 EvictionAlgorithm getEvictionAlgorithm()
          Get the associated EvictionAlgorithm used by the EvictionPolicy.
 Class<? extends EvictionPolicyConfig> getEvictionConfigurationClass()
          The EvictionPolicyConfig implementation class used by this EvictionPolicy.
 void setCache(CacheSPI cache)
          Method called to set the cache in this implementation.
 

Method Detail

evict

void evict(Fqn fqn)
           throws Exception
Evict a node form the underlying cache.

Parameters:
fqn - DataNode corresponds to this fqn.
Throws:
Exception

getCache

CacheSPI getCache()
Returns:
the CacheSPI instance this eviction policy is configured to work on.

setCache

void setCache(CacheSPI cache)
Method called to set the cache in this implementation.

Parameters:
cache - the cache to set

getEvictionAlgorithm

EvictionAlgorithm getEvictionAlgorithm()
Get the associated EvictionAlgorithm used by the EvictionPolicy.

This relationship should be 1-1.

Returns:
An EvictionAlgorithm implementation.

getEvictionConfigurationClass

Class<? extends EvictionPolicyConfig> getEvictionConfigurationClass()
The EvictionPolicyConfig implementation class used by this EvictionPolicy.

Returns:
EvictionPolicyConfig implementation class.

canIgnoreEvent

boolean canIgnoreEvent(Fqn fqn,
                       NodeEventType eventType)
This method will be invoked prior to an event being processed for a node with the specified Fqn.

This method provides a way to optimize the performance of eviction by signalling that the node associated with the specified Fqn should not be subject to normal eviction processing. It can also be used to filter out certain event types in which the particular eviction algorithm has no interest.

If this method returns false then the event is processed normally and eviction processing for the node continues. As a result, the event will be added to the eviction region's event queue where at some later point the particular algorithm of the eviction policy can use it to decide whether to call evict(Fqn).

If this method returns true, then the event is ignored and will not factor in any subsequent eviction processing.

Parameters:
fqn - The Fqn of the node associated with the event.
eventType - the type of the event
Returns:
true to ignore events of this type for this Fqn, false to process events normally.


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