Author: manik.surtani(a)jboss.com
Date: 2008-06-12 11:03:39 -0400 (Thu, 12 Jun 2008)
New Revision: 5979
Modified:
core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java
core/trunk/src/main/java/org/jboss/cache/eviction/FIFOQueue.java
core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java
core/trunk/src/main/java/org/jboss/cache/eviction/LRUQueue.java
core/trunk/src/main/java/org/jboss/cache/eviction/MRUQueue.java
core/trunk/src/test/java/org/jboss/cache/CallbackTest.java
Log:
JBCACHE-1169
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java 2008-06-12
12:03:09 UTC (rev 5978)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java 2008-06-12
15:03:39 UTC (rev 5979)
@@ -23,7 +23,7 @@
private Set<NodeEntry> removalQueue;
private int numElements = 0;
- ElementSizeQueue()
+ protected ElementSizeQueue()
{
nodeMap = new HashMap<Fqn, NodeEntry>();
evictionList = new LinkedList<NodeEntry>();
@@ -132,17 +132,17 @@
this.numElements = 0;
}
- final List<NodeEntry> getEvictionList()
+ protected final List<NodeEntry> getEvictionList()
{
return evictionList;
}
- final Set<NodeEntry> getRemovalQueue()
+ protected final Set<NodeEntry> getRemovalQueue()
{
return removalQueue;
}
- final void prune()
+ protected final void prune()
{
Iterator<NodeEntry> it = evictionList.iterator();
while (it.hasNext() && removalQueue.size() > 0)
@@ -170,7 +170,7 @@
* Note: this class has a natural ordering that is inconsistent with equals as defined
by the java.lang.Comparator
* contract.
*/
- static class MaxElementComparator implements Comparator<NodeEntry>
+ protected static class MaxElementComparator implements Comparator<NodeEntry>
{
public int compare(NodeEntry ne1, NodeEntry ne2)
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOQueue.java 2008-06-12 12:03:09
UTC (rev 5978)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOQueue.java 2008-06-12 15:03:39
UTC (rev 5979)
@@ -23,7 +23,7 @@
private Map<Fqn, NodeEntry> nodeMap;
private int numElements = 0;
- FIFOQueue()
+ protected FIFOQueue()
{
nodeMap = new LinkedHashMap<Fqn, NodeEntry>();
// We use a LinkedHashMap here because we want to maintain FIFO ordering and still
get the benefits of
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java 2008-06-12 12:03:09
UTC (rev 5978)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java 2008-06-12 15:03:39
UTC (rev 5979)
@@ -27,7 +27,7 @@
private Set<NodeEntry> removalQueue;
private int numElements = 0;
- LFUQueue()
+ protected LFUQueue()
{
nodeMap = new HashMap<Fqn, NodeEntry>();
comparator = new LFUComparator();
@@ -141,7 +141,7 @@
this.numElements += difference;
}
- void prune()
+ protected void prune()
{
Iterator<NodeEntry> it = this.iterate();
while (it.hasNext() && removalQueue.size() > 0)
@@ -153,14 +153,12 @@
}
}
- // provided as friend access for unit testing only.
- final List<NodeEntry> getEvictionList()
+ protected final List<NodeEntry> getEvictionList()
{
return this.evictionList;
}
- // provided as friend access for unit testing only.
- final Set<NodeEntry> getRemovalQueue()
+ protected final Set<NodeEntry> getRemovalQueue()
{
return this.removalQueue;
}
@@ -181,7 +179,7 @@
* Note: this class has a natural ordering that is inconsistent with equals as defined
by the java.lang.Comparator
* contract.
*/
- static class LFUComparator implements Comparator<NodeEntry>
+ protected static class LFUComparator implements Comparator<NodeEntry>
{
public int compare(NodeEntry ne1, NodeEntry ne2)
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LRUQueue.java 2008-06-12 12:03:09
UTC (rev 5978)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUQueue.java 2008-06-12 15:03:39
UTC (rev 5979)
@@ -28,13 +28,13 @@
private long alternatingCount = 0;
private int numElements = 0;
- LRUQueue()
+ protected LRUQueue()
{
maxAgeQueue = new LinkedHashMap<Fqn, NodeEntry>();
lruQueue = new LinkedHashMap<Fqn, NodeEntry>(16, 0.75f, true);
}
- void reorderByLRU(Fqn fqn)
+ protected void reorderByLRU(Fqn fqn)
{
// leave the max age queue alone - it is like a fifo.
@@ -105,13 +105,13 @@
return this.maxAgeQueue.containsKey(entry.getFqn());
}
- void removeNodeEntryFromLRU(NodeEntry entry)
+ protected void removeNodeEntryFromLRU(NodeEntry entry)
{
Fqn fqn = entry.getFqn();
lruQueue.remove(fqn);
}
- void removeNodeEntryFromMaxAge(NodeEntry entry)
+ protected void removeNodeEntryFromMaxAge(NodeEntry entry)
{
Fqn fqn = entry.getFqn();
maxAgeQueue.remove(fqn);
@@ -175,12 +175,12 @@
return lruQueue.values().iterator();
}
- final Iterator<NodeEntry> iterateMaxAgeQueue()
+ protected final Iterator<NodeEntry> iterateMaxAgeQueue()
{
return maxAgeQueue.values().iterator();
}
- final Iterator<NodeEntry> iterateLRUQueue()
+ protected final Iterator<NodeEntry> iterateLRUQueue()
{
return lruQueue.values().iterator();
}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/MRUQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/MRUQueue.java 2008-06-12 12:03:09
UTC (rev 5978)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/MRUQueue.java 2008-06-12 15:03:39
UTC (rev 5979)
@@ -33,7 +33,7 @@
EvictionQueueList list;
private int numElements = 0;
- MRUQueue()
+ protected MRUQueue()
{
nodeMap = new HashMap<Fqn, EvictionListEntry>();
list = new EvictionQueueList();
@@ -46,7 +46,7 @@
*
* @param fqn Fqn of the nodeEntry to move to the top of the stack.
*/
- void moveToTopOfStack(Fqn fqn)
+ protected void moveToTopOfStack(Fqn fqn)
{
EvictionListEntry le = nodeMap.remove(fqn);
if (le != null)
Modified: core/trunk/src/test/java/org/jboss/cache/CallbackTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/CallbackTest.java 2008-06-12 12:03:09 UTC
(rev 5978)
+++ core/trunk/src/test/java/org/jboss/cache/CallbackTest.java 2008-06-12 15:03:39 UTC
(rev 5979)
@@ -18,6 +18,7 @@
* @author Bela Ban
* @version $Id$
*/
+@Test(groups = "functional")
public class CallbackTest
{
CacheSPI<Object, Object> cache = null, cache2;
@@ -37,7 +38,6 @@
}
}
- @Test(groups = {"functional"})
public void testLocalPutCallbackWithoutTransaction() throws Exception
{
cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
@@ -46,12 +46,10 @@
cache.put(FQN_A, null);
assertTrue(cache.exists(FQN_A));
assertTrue(cache.exists(FQN_B));//created by callback
- //assertEquals(cache.getLockTable().size(), 0);
System.out.println("cache locks:\n" +
CachePrinter.printCacheLockingInfo(cache));
assertEquals(0, cache.getNumberOfLocksHeld());
}
- @Test(groups = {"functional"})
public void testLocalGetCallbackSameFqnWithoutTransaction() throws Exception
{
cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
@@ -59,12 +57,10 @@
cache.put(FQN_A, null);
assertTrue(cache.exists(FQN_A));
-// assertEquals(cache.getLockTable().size(), 0);
System.out.println("cache locks:\n" +
CachePrinter.printCacheLockingInfo(cache));
assertEquals(0, cache.getNumberOfLocksHeld());
}
- @Test(groups = {"functional"})
public void testLocalGetCallbackDifferentFqnWithoutTransaction() throws Exception
{
cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
@@ -74,12 +70,10 @@
cache.put("/a", null);
assertTrue(cache.exists(FQN_A));
assertTrue(cache.exists(FQN_B));
-// assertEquals(cache.getLockTable().size(), 0);
System.out.println("cache locks:\n" +
CachePrinter.printCacheLockingInfo(cache));
assertEquals(0, cache.getNumberOfLocksHeld());
}
- @Test(groups = {"functional"})
public void testLocalCallbackWithTransaction() throws Exception
{
cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
@@ -92,7 +86,6 @@
assertEquals(0, cache.getNumberOfLocksHeld());
}
- @Test(groups = {"functional"})
public void testLocalCallbackWithException() throws Exception
{
cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);