[jboss-cvs] JBossCache/src/org/jboss/cache/eviction ...
Elias Ross
genman at noderunner.net
Mon Nov 27 14:59:11 EST 2006
User: genman
Date: 06/11/27 14:59:11
Modified: src/org/jboss/cache/eviction ExpirationAlgorithm.java
Log:
JBCACHE-880 - Fix update of expiration, better debug messages
Revision Changes Path
1.2 +299 -296 JBossCache/src/org/jboss/cache/eviction/ExpirationAlgorithm.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ExpirationAlgorithm.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/ExpirationAlgorithm.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ExpirationAlgorithm.java 27 Nov 2006 04:51:24 -0000 1.1
+++ ExpirationAlgorithm.java 27 Nov 2006 19:59:11 -0000 1.2
@@ -1,23 +1,14 @@
package org.jboss.cache.eviction;
-import java.util.Comparator;
-import java.util.HashMap;
import java.util.Iterator;
-import java.util.Map;
-import java.util.PriorityQueue;
-import java.util.Queue;
-import java.util.SortedMap;
import java.util.SortedSet;
-import java.util.TreeMap;
import java.util.TreeSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
-import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.optimistic.FqnComparator;
-import org.jgroups.ExitEvent;
/**
* Eviction algorithm that uses a key in the Node data that indicates the time the node should
@@ -56,15 +47,20 @@
private void addEvictionEntry(Fqn fqn)
{
Long l = getExpiration(fqn);
- if (l == null) {
+ if (l == null)
+ {
if (config.getWarnNoExpirationKey())
- log.warn("No expiration key '" + config.getExpirationKeyName() +
- "' for Node: " + fqn);
+ log.warn("No expiration key '" + config.getExpirationKeyName() + "' for Node: " + fqn);
else if (log.isDebugEnabled())
log.debug("No expiration key for Node: " + fqn);
return;
}
+ boolean found = set.remove(new ExpirationEntry(fqn));
+ if (found && log.isTraceEnabled())
+ log.trace("removed old expiration for " + fqn);
ExpirationEntry ee = new ExpirationEntry(fqn, l.longValue());
+ if (log.isTraceEnabled())
+ log.trace("adding eviction entry: " + ee);
set.add(ee);
}
@@ -83,10 +79,6 @@
int count = 0;
while ((node = region.takeLastEventNode()) != null)
{
- if (log.isTraceEnabled())
- {
- log.trace("process " + node);
- }
count++;
switch (node.getEventType())
{
@@ -146,7 +138,7 @@
@Override
public void resetEvictionQueue(Region region)
{
- for (ExpirationEntry ee: set)
+ for (ExpirationEntry ee : set)
{
addEvictionEntry(ee.getFqn());
}
@@ -219,8 +211,9 @@
return fqn;
}
- public boolean equals(ExpirationEntry ee)
+ public boolean equals(Object o)
{
+ ExpirationEntry ee = (ExpirationEntry) o;
return fqn.equals(ee.fqn);
}
@@ -231,11 +224,21 @@
public String toString()
{
- return "EE fqn=" + fqn;
+ long now = System.currentTimeMillis();
+ long ttl = expiration - now;
+ String sttl;
+ if (ttl > 1000 * 60)
+ sttl = (ttl / (1000 * 60)) + "min";
+ else if (ttl > 1000)
+ sttl = (ttl / 1000) + "s";
+ else
+ sttl = ttl + "ms";
+ return "EE fqn=" + fqn + " ttl=" + sttl;
}
}
- class DummyEvictionQueue implements EvictionQueue {
+ class DummyEvictionQueue implements EvictionQueue
+ {
public void addNodeEntry(NodeEntry entry)
{
More information about the jboss-cvs-commits
mailing list