|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.cache.eviction.BaseEvictionAlgorithm org.jboss.cache.eviction.ExpirationAlgorithm
public class ExpirationAlgorithm
Eviction algorithm that uses a key in the Node data that indicates the time
the node should be evicted. The key must be a java.lang.Long object, with
the time to expire as milliseconds past midnight January 1st, 1970 UTC (the
same relative time as provided by System.currentTimeMillis()
).
EvictionAlgorithmConfigBase.getMaxNodes()
, and will evict the soonest to
expire entires first to reduce the region size. If there are not enough
nodes with expiration keys set, a warning is logged.
If a node in the eviction region does not have an expiration value, then
ExpirationAlgorithmConfig.getTimeToLive()
(if set) will be used.
The expiration is updated when a node is added or updated.
If there is no time-to-live set, and a node in the eviction region does not
have an expiration value, then that node will never be evicted. As
forgetting to indicate an expiration value is likely a mistake, a warning
message is logged by this class. This warning, however, can be disabled
through ExpirationAlgorithmConfig.setWarnNoExpirationKey(boolean)
.
A node's expiration time can be changed by setting a new value in the node.
Example usage:
Cache cache; Fqn fqn1 = Fqn.fromString("/node/1"); Long future = new Long(System.currentTimeMillis() + 2000); cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future); cache.put(fqn1, "foo"); assertTrue(cache.get(fqn1) != null); Thread.sleep(5000); // 5 seconds assertTrue(cache.get(fqn1) == null);
Field Summary |
---|
Fields inherited from class org.jboss.cache.eviction.BaseEvictionAlgorithm |
---|
allowTombstones, cache, configuration, evictionActionPolicy, evictionAlgorithmConfig, evictionQueue, recycleQueue, regionFqn |
Constructor Summary | |
---|---|
ExpirationAlgorithm()
Constructs a new algorithm with a policy. |
Method Summary | |
---|---|
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. |
protected void |
processQueues(BlockingQueue<EvictionEvent> queue)
Event processing for Evict/Add/Visiting of nodes. |
protected void |
prune()
|
void |
resetEvictionQueue()
Reset the whole eviction queue. |
protected EvictionQueue |
setupEvictionQueue()
This method will create an EvictionQueue implementation and prepare it for use. |
protected boolean |
shouldEvictNode(NodeEntry ne)
This method will check whether the given node should be evicted or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ExpirationAlgorithm()
Method Detail |
---|
protected void processQueues(BlockingQueue<EvictionEvent> queue) throws EvictionException
BaseEvictionAlgorithm
processQueues
in class BaseEvictionAlgorithm
queue
- queue to inspect
EvictionException
- in the event of problemsprotected void prune() throws EvictionException
prune
in class BaseEvictionAlgorithm
EvictionException
public void resetEvictionQueue()
EvictionAlgorithm
resetEvictionQueue
in interface EvictionAlgorithm
resetEvictionQueue
in class BaseEvictionAlgorithm
protected EvictionQueue setupEvictionQueue() throws EvictionException
BaseEvictionAlgorithm
setupEvictionQueue
in class BaseEvictionAlgorithm
EvictionException
- if there are problemsEvictionQueue
protected boolean shouldEvictNode(NodeEntry ne)
BaseEvictionAlgorithm
shouldEvictNode
in class BaseEvictionAlgorithm
ne
- NodeEntry to test eviction for.
public boolean canIgnoreEvent(EvictionEvent.Type eventType)
EvictionAlgorithm
canIgnoreEvent
in interface EvictionAlgorithm
canIgnoreEvent
in class BaseEvictionAlgorithm
eventType
- event type to test for
public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
EvictionAlgorithm
EvictionAlgorithmConfig
implementation
class corresponding to this EvictionAlgorithm. E.g., the FIFOAlgorithm
would return FIFOAlgorithmConfig
.class.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |