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

Elias Ross genman at noderunner.net
Fri Dec 8 13:49:17 EST 2006


  User: genman  
  Date: 06/12/08 13:49:17

  Modified:    src/org/jboss/cache/loader   FileCacheLoader.java
                        AsyncCacheLoader.java
  Log:
  JBCACHE-892 Use JDK1.5 concurrent classes
  
  Revision  Changes    Path
  1.27      +3 -3      JBossCache/src/org/jboss/cache/loader/FileCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FileCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/FileCacheLoader.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -b -r1.26 -r1.27
  --- FileCacheLoader.java	23 Nov 2006 16:07:38 -0000	1.26
  +++ FileCacheLoader.java	8 Dec 2006 18:49:17 -0000	1.27
  @@ -1,6 +1,5 @@
   package org.jboss.cache.loader;
   
  -import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.jboss.cache.Fqn;
  @@ -20,12 +19,13 @@
   import java.util.Set;
   import java.util.regex.Pattern;
   import java.util.regex.Matcher;
  +import java.util.concurrent.ConcurrentHashMap;
   
   /**
    * Simple file-based CacheLoader implementation. Nodes are directories, attributes of a node is a file in the directory
    *
    * @author Bela Ban
  - * @version $Id: FileCacheLoader.java,v 1.26 2006/11/23 16:07:38 gzamarreno Exp $
  + * @version $Id: FileCacheLoader.java,v 1.27 2006/12/08 18:49:17 genman Exp $
    */
   public class FileCacheLoader extends AbstractCacheLoader
   {
  @@ -372,7 +372,7 @@
         {
            if (config.isCheckCharacterPortability())
            {
  -            /* Check whether the entire file path (root + fqn + data file name), is lenght portable */
  +            /* Check whether the entire file path (root + fqn + data file name), is length portable */
               isLengthPortablePath(child.getAbsolutePath());
               /* Check whether the fqn tree we're trying to store could contain non portable characters */
               isCharacterPortableTree(fqn);            
  
  
  
  1.24      +12 -10    JBossCache/src/org/jboss/cache/loader/AsyncCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AsyncCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/AsyncCacheLoader.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -b -r1.23 -r1.24
  --- AsyncCacheLoader.java	20 Nov 2006 07:33:14 -0000	1.23
  +++ AsyncCacheLoader.java	8 Dec 2006 18:49:17 -0000	1.24
  @@ -3,9 +3,6 @@
    */
   package org.jboss.cache.loader;
   
  -import EDU.oswego.cs.dl.util.concurrent.BoundedLinkedQueue;
  -import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
  -import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.jboss.cache.CacheException;
  @@ -20,6 +17,11 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  +import java.util.concurrent.BlockingQueue;
  +import java.util.concurrent.LinkedBlockingQueue;
  +import java.util.concurrent.TimeUnit;
  +import java.util.concurrent.atomic.AtomicInteger;
  +import java.util.concurrent.atomic.AtomicBoolean;
   
   /**
    * The AsyncCacheLoader is a delegating cache loader that extends
  @@ -81,7 +83,7 @@
   
      private static final Log log = LogFactory.getLog(AsyncCacheLoader.class);
   
  -   private static SynchronizedInt threadId = new SynchronizedInt(0);
  +   private static AtomicInteger threadId = new AtomicInteger(0);
      
   
      /**
  @@ -91,8 +93,8 @@
   
      private AsynchCacheLoaderConfig config;
      private AsyncProcessor processor;
  -   private SynchronizedBoolean stopped = new SynchronizedBoolean(true);
  -   private BoundedLinkedQueue queue = new BoundedLinkedQueue(DEFAULT_QUEUE_SIZE);
  +   private AtomicBoolean stopped = new AtomicBoolean(true);
  +   private BlockingQueue<Modification> queue = new LinkedBlockingQueue(DEFAULT_QUEUE_SIZE);
   
   
      public AsyncCacheLoader()
  @@ -118,7 +120,7 @@
   
         if (config.getQueueSize() > 0)
         {
  -         queue = new BoundedLinkedQueue(config.getQueueSize());
  +         queue = new LinkedBlockingQueue(config.getQueueSize());
         }
   
         super.setConfig(base);
  @@ -270,7 +272,7 @@
         {
            if (t == null || !t.isAlive())
            {
  -            t = new Thread(this, "AsyncCacheLoader-" + threadId.increment());
  +            t = new Thread(this, "AsyncCacheLoader-" + threadId.getAndIncrement());
               //t.setDaemon(true);
               t.start();
            }
  @@ -332,7 +334,7 @@
            addTaken(o);
            while (mods.size() < config.getBatchSize())
            {
  -            o = queue.poll(config.getPollWait());
  +            o = queue.poll(config.getPollWait(), TimeUnit.MILLISECONDS);
               if (o == null)
               {
                  break;
  @@ -390,7 +392,7 @@
                " pollWait=" + config.getPollWait() +
                " returnOld=" + config.getReturnOld() +
                " asyncPut=" + config.getUseAsyncPut() +
  -             " queue.capacity()=" + queue.capacity() +
  +             " queue.remainingCapacity()=" + queue.remainingCapacity() +
                " queue.peek()=" + queue.peek();
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list