[infinispan-commits] Infinispan SVN: r2235 - trunk/core/src/main/java/org/infinispan/util/concurrent.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Tue Aug 17 04:46:42 EDT 2010
Author: vblagojevic at jboss.com
Date: 2010-08-17 04:46:41 -0400 (Tue, 17 Aug 2010)
New Revision: 2235
Modified:
trunk/core/src/main/java/org/infinispan/util/concurrent/BoundedConcurrentHashMap.java
Log:
[ISPN-598] - Fix LIRS with passivation
Modified: trunk/core/src/main/java/org/infinispan/util/concurrent/BoundedConcurrentHashMap.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/util/concurrent/BoundedConcurrentHashMap.java 2010-08-16 18:17:03 UTC (rev 2234)
+++ trunk/core/src/main/java/org/infinispan/util/concurrent/BoundedConcurrentHashMap.java 2010-08-17 08:46:41 UTC (rev 2235)
@@ -15,9 +15,8 @@
import java.util.*;
import java.io.Serializable;
import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+
/**
* A hash table supporting full concurrency of retrievals and
* adjustable expected concurrency for updates. This class obeys the
@@ -304,8 +303,10 @@
*
* @param e
* accessed entry in Segment
+ *
+ * @return non null set of evicted entries.
*/
- void onEntryMiss(HashEntry<K, V> e);
+ Set<HashEntry<K, V>> onEntryMiss(HashEntry<K, V> e);
/**
* Invoked to notify EvictionPolicy implementation that an entry in Segment has been
@@ -370,7 +371,8 @@
}
@Override
- public void onEntryMiss(HashEntry<K, V> e) {
+ public Set<HashEntry<K, V>> onEntryMiss(HashEntry<K, V> e) {
+ return Collections.emptySet();
}
@Override
@@ -433,8 +435,9 @@
}
@Override
- public void onEntryMiss(HashEntry<K, V> e) {
+ public Set<HashEntry<K, V>> onEntryMiss(HashEntry<K, V> e) {
lruQueue.addFirst(e);
+ return Collections.emptySet();
}
/*
@@ -560,8 +563,9 @@
}
@Override
- public void onEntryMiss(HashEntry<K, V> e) {
+ public Set<HashEntry<K, V>> onEntryMiss(HashEntry<K, V> e) {
// initialization
+ Set<HashEntry<K, V>> evicted = Collections.emptySet();
if (currentLIRSize + 1 < lirSizeLimit) {
currentLIRSize++;
e.transitionToLIRResident();
@@ -576,19 +580,19 @@
stack.put(e.hashCode(), e);
+ evicted = new HashSet<HashEntry<K, V>>();
if (inStack) {
- e.transitionToLIRResident();
- Set<HashEntry<K, V>> evicted = new HashSet<HashEntry<K, V>>();
- switchBottomostLIRtoHIRAndPrune(evicted);
- removeFromSegment(evicted);
+ e.transitionToLIRResident();
+ switchBottomostLIRtoHIRAndPrune(evicted);
} else {
queue.addLast(e);
- }
-
+ evicted.add(first);
+ }
// evict from segment
- segment.remove(first.key, first.hash, null);
+ removeFromSegment(evicted);
}
}
+ return evicted;
}
private void removeFromSegment(Set<HashEntry<K, V>> evicted) {
@@ -962,7 +966,13 @@
// add a new entry
tab[index] = new HashEntry<K, V>(key, hash, first, value);
// notify a miss
- eviction.onEntryMiss(tab[index]);
+ Set<HashEntry<K, V>> newlyEvicted = eviction.onEntryMiss(tab[index]);
+ if (!newlyEvicted.isEmpty()) {
+ if (evicted != null)
+ evicted.addAll(newlyEvicted);
+ else
+ evicted = newlyEvicted;
+ }
} else {
tab[index] = new HashEntry<K, V>(key, hash, first, value);
}
More information about the infinispan-commits
mailing list