no.feide.moria.store
Class TicketTTLEvictionPolicy

java.lang.Object
  extended by org.jboss.cache.eviction.BaseEvictionPolicy
      extended by org.jboss.cache.eviction.LRUPolicy
          extended by no.feide.moria.store.TicketTTLEvictionPolicy
All Implemented Interfaces:
org.jboss.cache.eviction.EvictionPolicy, org.jboss.cache.TreeCacheListener

public final class TicketTTLEvictionPolicy
extends org.jboss.cache.eviction.LRUPolicy

This eviction policy evicts tickets after a fixed period, aka Time To Live.

Version:
$Revision: 1.11 $
Author:
Bjørn Ola Smievoll <b.o.smievoll@conduct.no>

Nested Class Summary
(package private) static class TicketTTLEvictionPolicy.RegionValue
          Simple data container for region values.
 
Field Summary
private static java.lang.String ATTRIBUTE_NAME
          Constant representing the attribute name key.
private  org.jboss.cache.TreeCache cache
          The cache the evictions are done on.
private  java.util.Timer evictionTimer
          The timer responsible for scheduling the eviction threads.
private static int MAX_NODES_DEFAULT
          Default value for max nodes in each region.
private static java.lang.String MAX_NODES_NAME
          Constant representing the max nodes key.
private  int maxNodes
          Maximal number of nodes in a region.
private  no.feide.moria.log.MessageLogger messageLogger
          The logger used by this class.
private static java.lang.String NAME_ATTRIBUTE_NAME
          Constant representing the name attribute key.
private static java.lang.String OPERATION_FAILED_MESSAGE
          Constant holding default error message.
private static java.lang.String REGION_NAME
          Constant representing the region name key.
private  org.jboss.cache.eviction.RegionManager regionManager
          Manages the regions for each ticket type.
private  TicketTTLEvictionPolicy.RegionValue[] regionValues
          Contains the different regions registered for this policy.
private static org.jboss.cache.Fqn ROOT
          The root node.
private static java.lang.String TTL_ATTRIBUTE_NAME
          Constant representing the ttl attribute key.
private static int WAKEUP_INTERVAL_DEFAULT
          Default interval value for running the evictions.
private static java.lang.String WAKEUP_INTERVAL_NAME
          Constant representing the wakeup interval key.
private  int wakeUpIntervalSeconds
          The interval for the eviction threads to run.
 
Fields inherited from class org.jboss.cache.eviction.LRUPolicy
log_
 
Fields inherited from class org.jboss.cache.eviction.BaseEvictionPolicy
cache_, regionManager_
 
Constructor Summary
TicketTTLEvictionPolicy()
          Creates a new instance.
 
Method Summary
 void cacheStarted(org.jboss.cache.TreeCache cache)
           
 void cacheStopped(org.jboss.cache.TreeCache cache)
           
 void configure(org.jboss.cache.TreeCache cache)
           
 void evict(org.jboss.cache.Fqn fqn)
           
(package private)  java.lang.String getAttribute(org.w3c.dom.Element element, java.lang.String attributeName)
          Retrieves the value of the first occurance of the given attribute in the given element.
 java.lang.Object getCacheData(org.jboss.cache.Fqn fqn, java.lang.Object key)
           
 java.util.Set getChildrenNames(org.jboss.cache.Fqn fqn)
           
(package private)  java.lang.String getElementContent(org.w3c.dom.Element element, boolean trim)
          Retrieves the textual content of an xml element.
 org.jboss.cache.eviction.Region[] getRegions()
           
(package private)  TicketTTLEvictionPolicy.RegionValue getRegionValue(java.lang.String fqn)
          Gets a region value.
(package private)  TicketTTLEvictionPolicy.RegionValue[] getRegionValues()
          Gets the region values.
 int getWakeupIntervalSeconds()
           
 boolean hasChild(org.jboss.cache.Fqn fqn)
           
 void nodeCreated(org.jboss.cache.Fqn fqn)
           
 void nodeEvicted(org.jboss.cache.Fqn fqn)
           
 void nodeLoaded(org.jboss.cache.Fqn fqn)
           
 void nodeModified(org.jboss.cache.Fqn fqn)
           
 void nodeRemoved(org.jboss.cache.Fqn fqn)
           
 void nodeVisited(org.jboss.cache.Fqn fqn)
           
(package private)  void parseConfig(org.w3c.dom.Element config)
          Parses the config retrieved from TreeCache.getEvictionPolicyConfig().
 void viewChange(org.jgroups.View view)
           
 
Methods inherited from class org.jboss.cache.eviction.LRUPolicy
getEvictionAlgorithm, nodeAdded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messageLogger

private no.feide.moria.log.MessageLogger messageLogger
The logger used by this class.


regionManager

private org.jboss.cache.eviction.RegionManager regionManager
Manages the regions for each ticket type.


ROOT

private static final org.jboss.cache.Fqn ROOT
The root node.


WAKEUP_INTERVAL_DEFAULT

private static final int WAKEUP_INTERVAL_DEFAULT
Default interval value for running the evictions.

See Also:
Constant Field Values

MAX_NODES_DEFAULT

private static final int MAX_NODES_DEFAULT
Default value for max nodes in each region.

See Also:
Constant Field Values

REGION_NAME

private static final java.lang.String REGION_NAME
Constant representing the region name key.

See Also:
Constant Field Values

ATTRIBUTE_NAME

private static final java.lang.String ATTRIBUTE_NAME
Constant representing the attribute name key.

See Also:
Constant Field Values

NAME_ATTRIBUTE_NAME

private static final java.lang.String NAME_ATTRIBUTE_NAME
Constant representing the name attribute key.

See Also:
Constant Field Values

WAKEUP_INTERVAL_NAME

private static final java.lang.String WAKEUP_INTERVAL_NAME
Constant representing the wakeup interval key.

See Also:
Constant Field Values

MAX_NODES_NAME

private static final java.lang.String MAX_NODES_NAME
Constant representing the max nodes key.

See Also:
Constant Field Values

TTL_ATTRIBUTE_NAME

private static final java.lang.String TTL_ATTRIBUTE_NAME
Constant representing the ttl attribute key.

See Also:
Constant Field Values

OPERATION_FAILED_MESSAGE

private static final java.lang.String OPERATION_FAILED_MESSAGE
Constant holding default error message.

See Also:
Constant Field Values

regionValues

private TicketTTLEvictionPolicy.RegionValue[] regionValues
Contains the different regions registered for this policy.


wakeUpIntervalSeconds

private int wakeUpIntervalSeconds
The interval for the eviction threads to run.


maxNodes

private int maxNodes
Maximal number of nodes in a region. Not really used, should be set high.


evictionTimer

private java.util.Timer evictionTimer
The timer responsible for scheduling the eviction threads.


cache

private org.jboss.cache.TreeCache cache
The cache the evictions are done on.

Constructor Detail

TicketTTLEvictionPolicy

public TicketTTLEvictionPolicy()
Creates a new instance.

Method Detail

configure

public void configure(org.jboss.cache.TreeCache cache)
Specified by:
configure in interface org.jboss.cache.eviction.EvictionPolicy
Overrides:
configure in class org.jboss.cache.eviction.LRUPolicy
See Also:
EvictionPolicy.configure(org.jboss.cache.TreeCache)

getRegions

public org.jboss.cache.eviction.Region[] getRegions()
Specified by:
getRegions in interface org.jboss.cache.eviction.EvictionPolicy
Overrides:
getRegions in class org.jboss.cache.eviction.BaseEvictionPolicy
See Also:
EvictionPolicy.getRegions()

evict

public void evict(org.jboss.cache.Fqn fqn)
           throws java.lang.Exception
Specified by:
evict in interface org.jboss.cache.eviction.EvictionPolicy
Overrides:
evict in class org.jboss.cache.eviction.BaseEvictionPolicy
Throws:
java.lang.Exception
See Also:
EvictionPolicy.evict(org.jboss.cache.Fqn)

getChildrenNames

public java.util.Set getChildrenNames(org.jboss.cache.Fqn fqn)
Specified by:
getChildrenNames in interface org.jboss.cache.eviction.EvictionPolicy
Overrides:
getChildrenNames in class org.jboss.cache.eviction.BaseEvictionPolicy
See Also:
EvictionPolicy.getChildrenNames(org.jboss.cache.Fqn)

hasChild

public boolean hasChild(org.jboss.cache.Fqn fqn)
Specified by:
hasChild in interface org.jboss.cache.eviction.EvictionPolicy
Overrides:
hasChild in class org.jboss.cache.eviction.BaseEvictionPolicy
See Also:
EvictionPolicy.hasChild(org.jboss.cache.Fqn)

getCacheData

public java.lang.Object getCacheData(org.jboss.cache.Fqn fqn,
                                     java.lang.Object key)
Specified by:
getCacheData in interface org.jboss.cache.eviction.EvictionPolicy
Overrides:
getCacheData in class org.jboss.cache.eviction.BaseEvictionPolicy
See Also:
EvictionPolicy.getCacheData(org.jboss.cache.Fqn, java.lang.Object)

getWakeupIntervalSeconds

public int getWakeupIntervalSeconds()
Specified by:
getWakeupIntervalSeconds in interface org.jboss.cache.eviction.EvictionPolicy
Overrides:
getWakeupIntervalSeconds in class org.jboss.cache.eviction.LRUPolicy
See Also:
EvictionPolicy.getWakeupIntervalSeconds()

nodeCreated

public void nodeCreated(org.jboss.cache.Fqn fqn)
Specified by:
nodeCreated in interface org.jboss.cache.TreeCacheListener
Overrides:
nodeCreated in class org.jboss.cache.eviction.LRUPolicy
See Also:
org.jboss.cache.TreeCacheListener#nodeAdded(org.jboss.cache.Fqn)

nodeLoaded

public void nodeLoaded(org.jboss.cache.Fqn fqn)
Specified by:
nodeLoaded in interface org.jboss.cache.TreeCacheListener
Overrides:
nodeLoaded in class org.jboss.cache.eviction.LRUPolicy
See Also:
TreeCacheListener.nodeLoaded(org.jboss.cache.Fqn)

nodeRemoved

public void nodeRemoved(org.jboss.cache.Fqn fqn)
Specified by:
nodeRemoved in interface org.jboss.cache.TreeCacheListener
Overrides:
nodeRemoved in class org.jboss.cache.eviction.LRUPolicy
See Also:
TreeCacheListener.nodeRemoved(org.jboss.cache.Fqn)

nodeEvicted

public void nodeEvicted(org.jboss.cache.Fqn fqn)
Specified by:
nodeEvicted in interface org.jboss.cache.TreeCacheListener
Overrides:
nodeEvicted in class org.jboss.cache.eviction.LRUPolicy
See Also:
TreeCacheListener.nodeEvicted(org.jboss.cache.Fqn)

nodeModified

public void nodeModified(org.jboss.cache.Fqn fqn)
Specified by:
nodeModified in interface org.jboss.cache.TreeCacheListener
Overrides:
nodeModified in class org.jboss.cache.eviction.LRUPolicy
See Also:
TreeCacheListener.nodeModified(org.jboss.cache.Fqn)

nodeVisited

public void nodeVisited(org.jboss.cache.Fqn fqn)
Specified by:
nodeVisited in interface org.jboss.cache.TreeCacheListener
Overrides:
nodeVisited in class org.jboss.cache.eviction.LRUPolicy
See Also:
TreeCacheListener.nodeVisited(org.jboss.cache.Fqn)

cacheStarted

public void cacheStarted(org.jboss.cache.TreeCache cache)
Specified by:
cacheStarted in interface org.jboss.cache.TreeCacheListener
Overrides:
cacheStarted in class org.jboss.cache.eviction.LRUPolicy
See Also:
TreeCacheListener.cacheStarted(org.jboss.cache.TreeCache)

cacheStopped

public void cacheStopped(org.jboss.cache.TreeCache cache)
Specified by:
cacheStopped in interface org.jboss.cache.TreeCacheListener
Overrides:
cacheStopped in class org.jboss.cache.eviction.LRUPolicy
See Also:
TreeCacheListener.cacheStopped(org.jboss.cache.TreeCache)

viewChange

public void viewChange(org.jgroups.View view)
Specified by:
viewChange in interface org.jboss.cache.TreeCacheListener
Overrides:
viewChange in class org.jboss.cache.eviction.LRUPolicy
See Also:
TreeCacheListener.viewChange(org.jgroups.View)

parseConfig

void parseConfig(org.w3c.dom.Element config)
Parses the config retrieved from TreeCache.getEvictionPolicyConfig(). Populates the regionValues array.

Parameters:
config - configuration for this eviction policy

getAttribute

java.lang.String getAttribute(org.w3c.dom.Element element,
                              java.lang.String attributeName)
Retrieves the value of the first occurance of the given attribute in the given element.

Parameters:
element - the element containing an named attribute.
attributeName - the name of the requested attribute.
Returns:
the value of the requested attribute, null if no attribute exists in element.

getElementContent

java.lang.String getElementContent(org.w3c.dom.Element element,
                                   boolean trim)
Retrieves the textual content of an xml element.

Parameters:
element - The element containing the data to be retrieved.
trim - Whether or not to trim whitespace before returing.
Returns:
A concatenated string of the text of the child nodes of the element.

getRegionValues

TicketTTLEvictionPolicy.RegionValue[] getRegionValues()
Gets the region values.

Returns:
Array containing the region values.

getRegionValue

final TicketTTLEvictionPolicy.RegionValue getRegionValue(java.lang.String fqn)
Gets a region value.

Parameters:
fqn - Fully quailified name.
Returns:
A region value.


Copyright © 2001-2006 UNINETT FAS. All Rights Reserved.