|
IBM WebSphereTM eXtreme Scale, Release 8.6 API Specification |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.websphere.objectgrid.plugins.builtins.LRUEvictor
public final class LRUEvictor
This evictor manages a BackingMap using a simple Least Recently Used (LRU) algorithm. It attempts to keep the BackingMap at less than a certain number of entries.
Evictor
Field Summary | |
---|---|
static int |
DEFAULT_NUMBER_OF_QUEUES
Default number of LRU queues to create if the setNumberOfLRUQueues(int) method is not called. |
static long |
DEFAULT_SLEEP_TIME
Default sleep time for evictor thread if the setSleepTime(int) method is not called. |
Constructor Summary | |
---|---|
LRUEvictor()
Creates a new 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 | |
---|---|
void |
activate()
This method is called to activate the Evictor. |
void |
apply(LogSequence sequence)
Maintains a bi-directional queue ordered on last access. |
void |
deactivate()
This method is called to deactivate the Evictor. |
void |
destroy()
Called when the BackingMap associated with this evictor is
destroyed. |
int |
getMaxSize()
Gets the maximum size of each LRU queue. |
int |
getNumberOfLRUQueues()
Gets number of LRU queues being used. |
int |
getSleepTime()
Gets the sleep time being used in seconds. |
void |
initialize(BackingMap map,
EvictionEventCallback callback)
Called by a BackingMap instance during the evictor
initialization time. |
void |
rollingBack(LogSequence sequence)
Called after a transaction rollback to allow an evictor to track object usage in a backing map even when rollback occurs instead of commit. |
void |
run()
Manages the map's size and sends eviction events to the Map. |
void |
setMaxSize(int maxSize)
Sets the maximum size of each LRU queue. |
void |
setNumberOfLRUQueues(int numberOfQueues)
Sets the number of LRU queues to use. |
void |
setSleepTime(int seconds)
Sets the sleep time to use in seconds. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long DEFAULT_SLEEP_TIME
setSleepTime(int)
method is not called.
setSleepTime(int)
,
Constant Field Valuespublic static final int DEFAULT_NUMBER_OF_QUEUES
setNumberOfLRUQueues(int)
method is not called.
setNumberOfLRUQueues(int)
,
Constant Field ValuesConstructor Detail |
---|
public LRUEvictor()
The default values can be overridden by use of the setMaxSize(int)
,
setNumberOfLRUQueues(int)
, and setSleepTime(int)
methods. If the
setMaxSize
method is never called, the size of BackingMap is unlimited and no LRU data is kept.
Method Detail |
---|
public void initialize(BackingMap map, EvictionEventCallback callback)
Evictor
Called by a BackingMap
instance during the evictor
initialization time.
The BackingMap
calls this method so the Evictor
instance can have references to the BackingMap
and
EvictionEventCallback
instances. The evictor can signal
events to have specific entries evicted using the
EvictionEventCallback
.
initialize
in interface Evictor
map
- the BackingMap instancecallback
- the EvictionEventCallback instanceEvictor.initialize(BackingMap, EvictionEventCallback)
public void apply(LogSequence sequence)
apply
in interface Evictor
sequence
- the LogSequence
of changes committed to the mapEvictor.apply(LogSequence)
public void rollingBack(LogSequence sequence)
RollbackEvictor
Evictor.apply(LogSequence)
for other considerations when implementing this method. Many of the
considerations with the Evictor.apply
method also apply to
this method.
rollingBack
in interface RollbackEvictor
sequence
- LogSequence of changes to the mapRollbackEvictor.rollingBack(LogSequence)
public int getMaxSize()
setMaxSize(int)
method or the default value of zero if
the setMaxSize
method is never calledsetMaxSize(int)
public void setMaxSize(int maxSize)
This method is 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. This method must be called
prior to the initialize
method to avoid an IllegalStateException being thrown.
maxSize
- is the maximum size per LRU queue. Any value <= 0 indicates to allow each queue to be of unlimited
size. In which case, no LRU data is kept.
IllegalStateException
- if called after the initialize method.initialize(BackingMap, EvictionEventCallback)
public int getSleepTime()
setSleepTime(int)
method or the default value of
DEFAULT_SLEEP_TIME
if the setSleepTime
method is never calledsetSleepTime(int)
public void setSleepTime(int seconds)
This method is used to override the default sleep time of the evictor thread in seconds. This method must be
called prior to the initialize
method to avoid an IllegalStateException being thrown. If this method
is not called, the DEFAULT_SLEEP_TIME
constant is used as the sleep time.
seconds
- is the number of seconds the evictor thread sleeps in between each sweep of the LRU queue data
IllegalArgumentException
- if seconds < 1
IllegalStateException
- if called after the initialize method.DEFAULT_SLEEP_TIME
,
initialize(BackingMap, EvictionEventCallback)
public int getNumberOfLRUQueues()
setNumberOfLRUQueues(int)
method or the default value
of DEFAULT_NUMBER_OF_QUEUES
if the setNumberOfLRUQueues
method is never calledDEFAULT_NUMBER_OF_QUEUES
,
setNumberOfLRUQueues(int)
public void setNumberOfLRUQueues(int numberOfQueues)
This method is used to override the default number of LRU queues created by the initialize
method
for keeping the LRU data needed by the evictor thread. This method must be called prior to the
initialize
method to avoid an IllegalStateException being thrown. If this method is not called,the
DEFAULT_NUMBER_OF_QUEUES
constant is used as the number of heaps.
numberOfQueues
- is the number of LRU queue instances used to hold LRU data. The value must be greater than or equal to
1 and a prime number is recommended for best performance.
IllegalArgumentException
- if numberOfQueuess < 1
IllegalStateException
- if called after the initialize method.DEFAULT_NUMBER_OF_QUEUES
,
initialize(BackingMap, EvictionEventCallback)
public void run()
The thread is only spawned if the map size is limited rather than unlimited in size (e.g. maxSize > 0 ).
run
in interface Runnable
public void destroy()
Evictor
Called when the BackingMap
associated with this evictor is
destroyed.
This method is the opposite of the initialize
method. When
it is called, the Evictor can free up any resources it uses.
destroy
in interface Evictor
Evictor.destroy()
public void activate()
Evictor
activate
in interface Evictor
Evictor.activate()
public void deactivate()
Evictor
deactivate
in interface Evictor
Evictor.deactivate()
|
IBM WebSphereTM eXtreme Scale, Release 8.6 API Specification |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |