[jboss-cvs] JBossCache/src/org/jboss/cache/eviction ...

Manik Surtani msurtani at jboss.com
Sat Dec 30 14:48:48 EST 2006


  User: msurtani
  Date: 06/12/30 14:48:48

  Modified:    src/org/jboss/cache/eviction  ExpirationAlgorithm.java
  Log:
  Genericised, autoboxed
  
  Revision  Changes    Path
  1.4       +36 -36    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.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- ExpirationAlgorithm.java	8 Dec 2006 19:19:05 -0000	1.3
  +++ ExpirationAlgorithm.java	30 Dec 2006 19:48:48 -0000	1.4
  @@ -1,15 +1,15 @@
   package org.jboss.cache.eviction;
   
  -import java.util.Iterator;
  -import java.util.SortedSet;
  -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.optimistic.FqnComparator;
   
  +import java.util.Iterator;
  +import java.util.SortedSet;
  +import java.util.TreeSet;
  +
   /**
    * Eviction algorithm that uses a key in the Node data that indicates the time
    * the node should be evicted.  The key must be a java.lang.Long object, with
  @@ -41,23 +41,23 @@
    * A node's expiration time can be changed by setting a new value in the node.
    * <p/>
    * Example usage:
  - <pre>
  - Cache cache;
  - Fqn fqn1 = Fqn.fromString("/node/1");
  - Long future = Long.valueOf(System.currentTimeMillis() + 2000);
  - cache.put(fqn1, ExpirationConfiguration.DEFAULT_EXPIRATION_KEY, future);
  - cache.put(fqn1, "foo");
  - assertTrue(cache.get(fqn1) != null);
  - 
  - Thread.sleep(5000); // 5 seconds
  - assertTrue(cache.get(fqn1) == null);
  -
  - // Alternatively, this expires a node in one second
  - cache.put(fqn1, "foo");
  - cache.getRegion(fqn1, false).markNodeCurrentlyInUse(fqn1, 1000);
  - Thread.sleep(2000); // 5 seconds
  - assertTrue(cache.get(fqn1) == null);
  - </pre>
  + * <pre>
  + * Cache cache;
  + * Fqn fqn1 = Fqn.fromString("/node/1");
  + * Long future = Long.valueOf(System.currentTimeMillis() + 2000);
  + * cache.put(fqn1, ExpirationConfiguration.DEFAULT_EXPIRATION_KEY, future);
  + * cache.put(fqn1, "foo");
  + * assertTrue(cache.get(fqn1) != null);
  + * <p/>
  + * Thread.sleep(5000); // 5 seconds
  + * assertTrue(cache.get(fqn1) == null);
  + * <p/>
  + * // Alternatively, this expires a node in one second
  + * cache.put(fqn1, "foo");
  + * cache.getRegion(fqn1, false).markNodeCurrentlyInUse(fqn1, 1000);
  + * Thread.sleep(2000); // 5 seconds
  + * assertTrue(cache.get(fqn1) == null);
  + * </pre>
    */
   public class ExpirationAlgorithm extends BaseEvictionAlgorithm
   {
  @@ -106,7 +106,7 @@
         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());
  +      ExpirationEntry ee = new ExpirationEntry(fqn, l);
         if (log.isTraceEnabled())
            log.trace("adding eviction entry: " + ee);
         set.add(ee);
  @@ -130,22 +130,22 @@
            count++;
            switch (node.getEventType())
            {
  -            case ADD_NODE_EVENT :
  -            case ADD_ELEMENT_EVENT :
  +            case ADD_NODE_EVENT:
  +            case ADD_ELEMENT_EVENT:
                  addEvictionEntry(node);
                  break;
  -            case REMOVE_ELEMENT_EVENT :
  -            case REMOVE_NODE_EVENT :
  -            case UNMARK_USE_EVENT :
  +            case REMOVE_ELEMENT_EVENT:
  +            case REMOVE_NODE_EVENT:
  +            case UNMARK_USE_EVENT:
                  removeEvictionEntry(node);
                  break;
  -            case VISIT_NODE_EVENT :
  +            case VISIT_NODE_EVENT:
                  // unused
                  break;
  -            case MARK_IN_USE_EVENT :
  +            case MARK_IN_USE_EVENT:
                  markInUse(node);
                  break;
  -            default :
  +            default:
                  throw new RuntimeException("Illegal Eviction Event type " + node.getEventType());
            }
         }
  @@ -159,7 +159,7 @@
      private void markInUse(EvictedEventNode node)
      {
         long expiration = node.getInUseTimeout() + System.currentTimeMillis();
  -      setExpiration(node.getFqn(), new Long(expiration));
  +      setExpiration(node.getFqn(), expiration);
      }
   
      @Override
  
  
  



More information about the jboss-cvs-commits mailing list