IBM WebSphere Extended Deployment (XD)TM
Release 6.0

com.ibm.websphere.objectgrid.plugins.builtins
LRUEvictor

java.lang.Object
  |
  +--com.ibm.websphere.objectgrid.plugins.builtins.LRUEvictor
All Implemented Interfaces
Evictor, RollbackEvictor, Runnable


This manages a BaseMap using a simple Least-Recently-Used (LRU) algorithm. It attempts to keep the BaseMap at less than a certain number of entries.

Field Summary
public  longDEFAULT_SLEEP_TIME
           Default sleep time for evictor thread if the #setSleepTime(int) method is not called.
public  intDEFAULT_NUMBER_OF_QUEUES
           Default number of LRU queues to create if the #setNumberOfLRUQueues(int) method is not called.

Constructor Summary
LRUEvictor()
           Construct a LRUEvictor object with default values for the maximum size per LRU queue, the number of queues, and sleep time between sweeps by the evictor thread.


Method Summary
public  voidinitialize(com.ibm.websphere.objectgrid.BackingMap, com.ibm.websphere.objectgrid.plugins.EvictionEventCallback)
          
public  voidapply(com.ibm.websphere.objectgrid.plugins.LogSequence)
           This maintains a bi-directional queue ordered on last accessed.
public  voidrollingBack(com.ibm.websphere.objectgrid.plugins.LogSequence)
          
public  intgetMaxSize()
           Get maximum size of each LRU queue.
public  voidsetMaxSize(int)
           Used to override the default maximum size for each LRU queue used to keep LRU data.
public  intgetSleepTime()
           Get sleep time being used in seconds.
public  voidsetSleepTime(int)
           Used to override the default sleep time of evictor thread in seconds. .
public  intgetNumberOfLRUQueues()
           Get number of LRU queues being used.
public  voidsetNumberOfLRUQueues(int)
           Used to override the default number of LRU queues created by the initiaze method.
public  voidrun()
           The evictor must manage it's size here and send eviction events to the Map..
public  voiddestroy()
          

Inherited Methods

Methods inherited from java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

DEFAULT_SLEEP_TIME

public 
  static DEFAULT_SLEEP_TIME
Default sleep time for evictor thread if the #setSleepTime(int) method is not called.

DEFAULT_NUMBER_OF_QUEUES

public 
  static DEFAULT_NUMBER_OF_QUEUES
Default number of LRU queues to create if the #setNumberOfLRUQueues(int) method is not called.

Constructor Detail

LRUEvictor

public LRUEvictor( )
Construct a LRUEvictor object with default values for the maximum size per LRU queue, the number of queues, and sleep time between sweeps by the evictor thread. The default values can be overridden by use of the #setMaxSize(int), #setNumberOfLRUQueues(int), and #setSleepTime(int) methods. If setMaxSize is never called, the size of BackingMap is unlimited and no LRU data is kept.


Method Detail

initialize

public void initialize(BackingMap map,EvictionEventCallback callback)

See Also:
    initialize(com.ibm.websphere.objectgrid.BackingMap, com.ibm.websphere.objectgrid.plugins.EvictionEventCallback)
Parameters:


apply

public void apply(LogSequence sequence)
This maintains a bi-directional queue ordered on last accessed.
See Also:
    apply(com.ibm.websphere.objectgrid.plugins.LogSequence)
Parameters:


rollingBack

public void rollingBack(LogSequence sequence)
Parameters:


getMaxSize

public int getMaxSize()
Get maximum size of each LRU queue.


Returns:
     same value that was passed to the #setMaxSize(int) method. If the set method is never called, then the default value is returned.


setMaxSize

public void setMaxSize(int maxSize)
Used to override the default maximum size for each LRU queue used to keep LRU data. The evictor thread will attempt to keep each LRU queue to be no larger than the maximum size. Must be called prior to the #initialize(BackingMap, EvictionEventCallback) method to avoid IllegalStateException being thrown.
Parameters:
    maxSize - is the maximum size per LRU queue. Any value <= 0 indicates to allow queue to be of unlimited size. In which case, no LRU data is kept. If this method is not called, no LRU data is kept and size is unlimited.


Throws:
    java.lang.IllegalStateException


getSleepTime

public int getSleepTime()
Get sleep time being used in seconds.


Returns:
     same value that is passed to #setSleepTime(int) or default value if set method was never called.


setSleepTime

public void setSleepTime(int seconds)
Used to override the default sleep time of evictor thread in seconds. Must be called prior to the #initialize(BackingMap, EvictionEventCallback) method to avoid IllegalStateException being thrown. If this method is not called, then the constant #DEFAULT_SLEEP_TIME is used as the sleep time.
Parameters:
    seconds - is the number of seconds evictor thread sleeps in between each sweep of the LRU queue.


Throws:
    java.lang.IllegalArgumentExceptionjava.lang.IllegalStateException


getNumberOfLRUQueues

public int getNumberOfLRUQueues()
Get number of LRU queues being used.


Returns:
     same value that was passed to the #setNumberOfLRUQueues(int) method. If the set method is never called, then the default value used is returned.


setNumberOfLRUQueues

public void setNumberOfLRUQueues(int numberOfQueues)
Used to override the default number of LRU queues created by the initiaze method. Must be called prior to the #initialize(BackingMap, EvictionEventCallback) method to avoid IllegalStateException being thrown. If this method is not called, then the constant #DEFAULT_NUMBER_OF_QUEUES is used as the number of LRU queues.
Parameters:
    numberOfQueues - is the number of LinkedList instances used to LRU data.


Throws:
    java.lang.IllegalArgumentExceptionjava.lang.IllegalStateException


run

public void run()
The evictor must manage it's size here and send eviction events to the Map. The thread is only spawned if the map size is limited rather than unlimited in size (e.g. maxSize > 0 ).


destroy

public void destroy()

See Also:
    destroy()


IBM WebSphere Extended Deployment (XD)TM
Release 6.0