org.jboss.cache.eviction
Class LRUQueue

java.lang.Object
  extended by org.jboss.cache.eviction.LRUQueue
All Implemented Interfaces:
EvictionQueue

public class LRUQueue
extends Object
implements EvictionQueue

LRU Eviction Queue implementation.

This eviction queue will iterate properly through two sorted lists. One sorted by maxAge and the other sorted by idleTime.

Version:
$Revision: 5979 $
Author:
Daniel Huang (dhuang@jboss.org)

Constructor Summary
protected LRUQueue()
           
 
Method Summary
 void addNodeEntry(NodeEntry entry)
          Add a NodeEntry to the queue.
 void clear()
          Clear the queue.
 boolean containsNodeEntry(NodeEntry entry)
          Check if queue contains the given NodeEntry.
 NodeEntry getFirstLRUNodeEntry()
           
 NodeEntry getFirstMaxAgeNodeEntry()
           
 NodeEntry getFirstNodeEntry()
          Get the first entry in the queue.
 NodeEntry getNodeEntry(Fqn fqn)
          Retrieve a node entry by Fqn.
 NodeEntry getNodeEntry(String fqn)
           
 int getNumberOfElements()
          Get the number of elements in the queue.
 int getNumberOfNodes()
          Get the number of nodes in the queue.
 Iterator<NodeEntry> iterate()
           
protected  Iterator<NodeEntry> iterateLRUQueue()
           
protected  Iterator<NodeEntry> iterateMaxAgeQueue()
           
 void modifyElementCount(int difference)
           
 void removeNodeEntry(NodeEntry entry)
          Remove a NodeEntry from queue.
protected  void removeNodeEntryFromLRU(NodeEntry entry)
           
protected  void removeNodeEntryFromMaxAge(NodeEntry entry)
           
protected  void reorderByLRU(Fqn fqn)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LRUQueue

protected LRUQueue()
Method Detail

reorderByLRU

protected void reorderByLRU(Fqn fqn)

getFirstNodeEntry

public NodeEntry getFirstNodeEntry()
Description copied from interface: EvictionQueue
Get the first entry in the queue.

If there are no entries in queue, this method will return null.

The first node returned is expected to be the first node to evict.

Specified by:
getFirstNodeEntry in interface EvictionQueue
Returns:
first NodeEntry in queue.

getFirstLRUNodeEntry

public NodeEntry getFirstLRUNodeEntry()

getFirstMaxAgeNodeEntry

public NodeEntry getFirstMaxAgeNodeEntry()

getNodeEntry

public NodeEntry getNodeEntry(Fqn fqn)
Description copied from interface: EvictionQueue
Retrieve a node entry by Fqn.

This will return null if the entry is not found.

Specified by:
getNodeEntry in interface EvictionQueue
Parameters:
fqn - Fqn of the node entry to retrieve.
Returns:
Node Entry object associated with given Fqn param.

getNodeEntry

public NodeEntry getNodeEntry(String fqn)
Specified by:
getNodeEntry in interface EvictionQueue

containsNodeEntry

public boolean containsNodeEntry(NodeEntry entry)
Description copied from interface: EvictionQueue
Check if queue contains the given NodeEntry.

Specified by:
containsNodeEntry in interface EvictionQueue
Parameters:
entry - NodeEntry to check for existence in queue.
Returns:
true/false if NodeEntry exists in queue.

removeNodeEntryFromLRU

protected void removeNodeEntryFromLRU(NodeEntry entry)

removeNodeEntryFromMaxAge

protected void removeNodeEntryFromMaxAge(NodeEntry entry)

removeNodeEntry

public void removeNodeEntry(NodeEntry entry)
Description copied from interface: EvictionQueue
Remove a NodeEntry from queue.

If the NodeEntry does not exist in the queue, this method will return normally.

Specified by:
removeNodeEntry in interface EvictionQueue
Parameters:
entry - The NodeEntry to remove from queue.

addNodeEntry

public void addNodeEntry(NodeEntry entry)
Description copied from interface: EvictionQueue
Add a NodeEntry to the queue.

Specified by:
addNodeEntry in interface EvictionQueue
Parameters:
entry - The NodeEntry to add to queue.

getNumberOfNodes

public int getNumberOfNodes()
Description copied from interface: EvictionQueue
Get the number of nodes in the queue.

Specified by:
getNumberOfNodes in interface EvictionQueue
Returns:
The number of nodes in the queue.

getNumberOfElements

public int getNumberOfElements()
Description copied from interface: EvictionQueue
Get the number of elements in the queue.

Specified by:
getNumberOfElements in interface EvictionQueue
Returns:
The number of elements in the queue.

clear

public void clear()
Description copied from interface: EvictionQueue
Clear the queue.

Specified by:
clear in interface EvictionQueue

modifyElementCount

public void modifyElementCount(int difference)
Specified by:
modifyElementCount in interface EvictionQueue

iterate

public Iterator<NodeEntry> iterate()
Specified by:
iterate in interface EvictionQueue

iterateMaxAgeQueue

protected final Iterator<NodeEntry> iterateMaxAgeQueue()

iterateLRUQueue

protected final Iterator<NodeEntry> iterateLRUQueue()


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