You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by as...@apache.org on 2005/01/06 02:21:04 UTC

cvs commit: jakarta-turbine-jcs/src/experimental/org/apache/jcs/engine PooledCacheEventQueue.java

asmuts      2005/01/05 17:21:04

  Modified:    src/java/org/apache/jcs/auxiliary/lateral
                        LateralCacheNoWaitFacade.java
               src/conf log4j.properties
               src/test-conf log4j.properties
               src/java/org/apache/jcs/engine/memory/lru
                        LRUMemoryCache.java
               src/java/org/apache/jcs/engine/memory MemoryCache.java
               src/java/org/apache/jcs/engine/memory/mru
                        MRUMemoryCache.java
               src/experimental/org/apache/jcs/engine
                        PooledCacheEventQueue.java
  Added:       src/java/org/apache/jcs/utils/threadpool
                        PoolConfiguration.java
  Removed:     src/test log4j.properties
  Log:
  1.  Put in a solution for the RMI bug.  Now, gets can be done asynchronously with a configurable timeout.
  You can specify that your remote region should timeout gets.
  
  see the cache.ccf in the src/conf for details
  
  #-1 means no timeout, this is the default
  # if the timeout is -1, no threadpool will be used.
  jcs.auxiliary.RC.attributes.GetTimeoutMillis=5000
  jcs.auxiliary.RC.attributes.ThreadPoolName=remote_cache_client
  
  Here RC is my auxiliary name.  I tell it to time out at 5 seconds and to use the thread pool named remote_cache_client.
  
  You can define pools in the file.  Below I define defaults for a thread pool and the settings for the pool I want the remote cache
  client to use.
  
  If the timeout is less than 0, no threadpool will be used.
  
  ##############################################################
  ################## THREAD POOL CONFIGURATION ###################
  # default thread pool config
  thread_pool.default.boundarySize=75
  thread_pool.default.maximumPoolSize=150
  thread_pool.default.minimumPoolSize=4
  thread_pool.default.keepAliveTime=350000
  thread_pool.default.abortWhenBlocked=false
  thread_pool.default.startUpSize=4
  
  # remote cache client thread pool config
  thread_pool.remote_cache_client.boundarySize=75
  thread_pool.remote_cache_client.maximumPoolSize=150
  thread_pool.remote_cache_client.minimumPoolSize=4
  thread_pool.remote_cache_client.keepAliveTime=350000
  thread_pool.remote_cache_client.abortWhenBlocked=false
  thread_pool.remote_cache_client.startUpSize=4
  
  2.  Changed stats gathering mechanism.  I will update the admin jsp to make use of the
  more easily formattable data.
  
  Revision  Changes    Path
  1.10      +35 -1     jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWaitFacade.java
  
  Index: LateralCacheNoWaitFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWaitFacade.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- LateralCacheNoWaitFacade.java	16 Jul 2004 01:27:42 -0000	1.9
  +++ LateralCacheNoWaitFacade.java	6 Jan 2005 01:21:03 -0000	1.10
  @@ -20,6 +20,7 @@
   
   import java.io.IOException;
   import java.io.Serializable;
  +import java.util.ArrayList;
   import java.util.Set;
   import java.util.HashSet;
   
  @@ -28,6 +29,10 @@
   import org.apache.jcs.auxiliary.AuxiliaryCache;
   import org.apache.jcs.engine.behavior.ICacheElement;
   import org.apache.jcs.engine.behavior.ICacheType;
  +import org.apache.jcs.engine.stats.StatElement;
  +import org.apache.jcs.engine.stats.Stats;
  +import org.apache.jcs.engine.stats.behavior.IStatElement;
  +import org.apache.jcs.engine.stats.behavior.IStats;
   
   /**
    * Used to provide access to multiple services under nowait protection.
  @@ -236,6 +241,35 @@
      */
     public String getStats()
     {
  -    return "";
  +    return getStatistics().toString();
  +  }
  +  
  +  /*
  +   * (non-Javadoc)
  +   * 
  +   * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatistics()
  +   */
  +  public IStats getStatistics()
  +  {
  +    IStats stats = new Stats();
  +    stats.setTypeName( "Lateral Cache No Wait Facade" );
  +
  +    ArrayList elems = new ArrayList();
  +
  +    IStatElement se = null;
  +
  +    if ( noWaits != null )
  +    {
  +      se = new StatElement();
  +      se.setName( "Number of No Waits" );
  +      se.setData( "" + noWaits.length  );
  +      elems.add( se );      
  +    }
  +
  +    // get an array and put them in the Stats object
  +    IStatElement[] ses = (IStatElement[]) elems.toArray( new StatElement[0] );
  +    stats.setStatElements( ses );
  +
  +    return stats;
     }
   }
  
  
  
  1.5       +4 -4      jakarta-turbine-jcs/src/conf/log4j.properties
  
  Index: log4j.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/conf/log4j.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- log4j.properties	22 Jul 2004 13:16:21 -0000	1.4
  +++ log4j.properties	6 Jan 2005 01:21:04 -0000	1.5
  @@ -1,4 +1,4 @@
  -log4j.rootCategory=WARN, A1
  +log4j.rootCategory=INFO, A1
   
   # A1 -- console
   log4j.appender.A1=org.apache.log4j.ConsoleAppender
  @@ -24,7 +24,7 @@
   
   
   
  -#log4j.category.org.apache.jcs=ERROR,A1,WF
  +log4j.category.org.apache.jcs=INFO,A1,WF
   #log4j.category.org.apache.jcs.acess=WARN,WF
   #log4j.category.org.apache.jcs.engine.control=WARN,WF
   
  @@ -37,7 +37,7 @@
   #log4j.category.org.apache.jcs.auxiliary.disk=WARN,WF
   log4j.category.org.apache.jcs.auxiliary.lateral.javagroups=INFO
   #log4j.category.org.apache.jcs.auxiliary.lateral.xmlrpc=DEBUG,WF
  -#log4j.category.org.apache.jcs.auxiliary.remote=WARN,WF
  +log4j.category.org.apache.jcs.auxiliary.remote=DEBUG,WF
   #log4j.category.org.apache.jcs.utils=WARN,WF
   
  -#log4j.category.org.apache.jcs.utils.locking=DEBUG
  +log4j.category.org.apache.jcs.utils=DEBUG
  
  
  
  1.5       +4 -0      jakarta-turbine-jcs/src/test-conf/log4j.properties
  
  Index: log4j.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/test-conf/log4j.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- log4j.properties	8 Jul 2004 00:50:47 -0000	1.4
  +++ log4j.properties	6 Jan 2005 01:21:04 -0000	1.5
  @@ -1,5 +1,9 @@
   log4j.rootCategory=WARN, stdout, logfile
   
  +log4j.category.org.apache.jcs.=DEBUG, stdout, logfile
  +log4j.category.org.apache.jcs.auxiliary.remote=DEBUG, stdout, logfile
  +log4j.category.org.apache.jcs.utils.threadpool=DEBUG, stdout, logfile
  +
   log4j.appender.stdout=org.apache.log4j.ConsoleAppender
   log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
   log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
  
  
  
  1.28      +69 -32    jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/lru/LRUMemoryCache.java
  
  Index: LRUMemoryCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/lru/LRUMemoryCache.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- LRUMemoryCache.java	16 Nov 2004 07:33:11 -0000	1.27
  +++ LRUMemoryCache.java	6 Jan 2005 01:21:04 -0000	1.28
  @@ -18,6 +18,7 @@
   
   import java.io.IOException;
   import java.io.Serializable;
  +import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.Map;
   import java.util.NoSuchElementException;
  @@ -34,6 +35,10 @@
   
   import org.apache.jcs.engine.memory.util.DoubleLinkedList;
   import org.apache.jcs.engine.memory.util.MemoryElementDescriptor;
  +import org.apache.jcs.engine.stats.StatElement;
  +import org.apache.jcs.engine.stats.Stats;
  +import org.apache.jcs.engine.stats.behavior.IStatElement;
  +import org.apache.jcs.engine.stats.behavior.IStats;
   
   /**
    *  A fast reference management system. The least recently used items move to
  @@ -500,11 +505,21 @@
       }
     }
   
  +  /**
  +   * Returns the size of the list.
  +   * 
  +   * @return
  +   */
     private int dumpCacheSize()
     {
       return list.size();
     }
   
  +  /**
  +   * Checks to see if all the items that should be in the cache are.
  +   * Checks consistency between List and map.
  +   *
  +   */
     private void verifyCache()
     {
       if (!log.isDebugEnabled())
  @@ -599,6 +614,12 @@
       }
     }
   
  +  
  +  /**
  +   * Logs an error is an element that should be in the cache is not.
  +   * 
  +   * @param key
  +   */
     private void verifyCache(Serializable key)
     {
       if (!log.isDebugEnabled())
  @@ -626,37 +647,53 @@
       }
     }
   
  -  /////////////////////////////////////////////////////////////////////////
  -  public String getStats()
  -  {
  -    StringBuffer buf = new StringBuffer(0);
  -    buf.append(getInfo());
  -    buf.append(getCnts());
  -    return buf.toString();
  -  }
  -
  -  public String getCnts()
  -  {
  -    StringBuffer buf = new StringBuffer(0);
  -    buf.append("\n putCnt = " + putCnt);
  -    buf.append("\n hitCnt = " + hitCnt);
  -    buf.append("\n missCnt = " + missCnt);
  -    buf.append( "\n -------------------------" );
  -    if (hitCnt != 0)
  -    {
  -      // int rate = ((hitCnt + missCnt) * 100) / (hitCnt * 100) * 100;
  -      //buf.append("\n Hit Rate = " + rate + " %" );
  -    }
  -    return buf.toString();
  -  }
  +  /*
  +   *  (non-Javadoc)
  +   * @see org.apache.jcs.engine.memory.MemoryCache#getStatistics()
  +   */
  +  public IStats getStatistics()
  +  {
  +  	IStats stats = new Stats();
  +  	stats.setTypeName( "LRU Memory Cache" );
  +  	
  +  	ArrayList elems = new ArrayList();
  +  	
  +  	IStatElement se = null;
  +  	
  +  	se = new StatElement();
  +  	se.setName( "List Size" );
  +  	se.setData("" + list.size());
  +	elems.add(se);
  +  	
  +  	se = new StatElement();
  +  	se.setName( "Map Size" );
  +  	se.setData("" + map.size());
  +	elems.add(se);
  +  	
  +  	se = new StatElement();
  +  	se.setName( "Put Count" );
  +	se.setData("" + putCnt);  	
  +	elems.add(se);
  +  	
  +	se = new StatElement();
  +  	se.setName( "Hit Count" );
  +	se.setData("" + hitCnt);
  +	elems.add(se);
  +
  +  	se = new StatElement();
  +  	se.setName( "Miss Count" );
  +  	se.setData("" + missCnt);
  +	elems.add(se);
  +	
  +	// get an array and put them in the Stats object
  +	IStatElement[] ses = (IStatElement[])elems.toArray( new StatElement[0] );
  +	stats.setStatElements( ses );
  +
  +	// int rate = ((hitCnt + missCnt) * 100) / (hitCnt * 100) * 100;
  +    //buf.append("\n Hit Rate = " + rate + " %" );
  +	
  +  	return stats;
  +  }  
   
  -  public String getInfo()
  -  {
  -    StringBuffer buf = new StringBuffer();
  -    buf.append("\n list.size() = " + list.size());
  -    buf.append("\n map.size() = " + map.size());
  -    buf.append( "\n -------------------------" );
  -    return buf.toString();
  -  }
   
   }
  
  
  
  1.14      +8 -6      jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/MemoryCache.java
  
  Index: MemoryCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/MemoryCache.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- MemoryCache.java	13 Jul 2004 02:48:30 -0000	1.13
  +++ MemoryCache.java	6 Jan 2005 01:21:04 -0000	1.14
  @@ -26,6 +26,7 @@
   import org.apache.jcs.engine.behavior.ICacheElement;
   import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
   import org.apache.jcs.engine.control.CompositeCache;
  +import org.apache.jcs.engine.stats.behavior.IStats;
   
   /**
    *  For the framework. Insures methods a MemoryCache needs to access. Not sure
  @@ -57,12 +58,13 @@
       public int getSize();
   
       /**
  -     * Allows access to stats available in the memory plugin.
  -     *
  -     * @return String of stats
  +     * Returns the historical and statistical data for a region's memory cache.
  +     * 
  +     * @return 
        */
  -    public String getStats();
  -
  +    public IStats getStatistics();
  +    
  +    
       /**
        *  Get an iterator for all elements in the memory cache. This should be
        *  removed since it is fairly dangerous. Other classes should not be able
  
  
  
  1.15      +61 -6     jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java
  
  Index: MRUMemoryCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- MRUMemoryCache.java	12 Jun 2004 02:33:41 -0000	1.14
  +++ MRUMemoryCache.java	6 Jan 2005 01:21:04 -0000	1.15
  @@ -20,6 +20,7 @@
   
   import java.io.IOException;
   import java.io.Serializable;
  +import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.LinkedList;
   import java.util.ListIterator;
  @@ -31,6 +32,10 @@
   import org.apache.jcs.engine.behavior.ICacheElement;
   import org.apache.jcs.engine.control.CompositeCache;
   import org.apache.jcs.engine.memory.AbstractMemoryCache;
  +import org.apache.jcs.engine.stats.StatElement;
  +import org.apache.jcs.engine.stats.Stats;
  +import org.apache.jcs.engine.stats.behavior.IStatElement;
  +import org.apache.jcs.engine.stats.behavior.IStats;
   import org.apache.jcs.engine.control.group.GroupId;
   import org.apache.jcs.engine.control.group.GroupAttrName;
   
  @@ -47,8 +52,12 @@
       private final static Log log =
           LogFactory.getLog( MRUMemoryCache.class );
   
  +    int hitCnt = 0;
  +    int missCnt = 0;
  +    int putCnt = 0;    
  +    
       /**
  -     * Description of the Field
  +     * Object to lock on the Field
        */
       protected int[] lockMe = new int[ 0 ];
   
  @@ -78,6 +87,8 @@
       public void update( ICacheElement ce )
           throws IOException
       {
  +        putCnt++;
  +    	
           Serializable key = ce.getKey();
           ce.getElementAttributes().setLastAccessTimeNow();
   
  @@ -229,7 +240,7 @@
               {
                   found = true;
                   ce.getElementAttributes().setLastAccessTimeNow();
  -                //ramHit++;
  +                hitCnt++;
                   if ( log.isDebugEnabled() )
                   {
                       log.debug( cacheName + " -- RAM-HIT for " + key );
  @@ -247,14 +258,13 @@
   
               if ( !found )
               {
  -                // Item not found in all caches.
  -                //miss++;
  +                // Item not found in cache.
  +            	missCnt++;
                   if ( log.isDebugEnabled() )
                   {
                       log.debug( cacheName + " -- MISS for " + key );
                   }
                   return null;
  -                //throw new ObjectNotFoundException( key + " not found in cache" );
               }
           }
           catch ( Exception e )
  @@ -402,4 +412,49 @@
               log.debug( "dumpCacheEntries> key=" + key + ", val=" + ( ( ICacheElement ) map.get( key ) ).getVal() );
           }
       }
  +    
  +    /*
  +     *  (non-Javadoc)
  +     * @see org.apache.jcs.engine.memory.MemoryCache#getStatistics()
  +     */
  +    public IStats getStatistics()
  +    {
  +    	IStats stats = new Stats();
  +    	stats.setTypeName( "MRU Memory Cache" );
  +    	
  +    	ArrayList elems = new ArrayList();
  +    	
  +    	IStatElement se = null;
  +    	
  +    	se = new StatElement();
  +    	se.setName( "List Size" );
  +    	se.setData("" + mrulist.size());
  +    	elems.add(se);
  +    	
  +    	se = new StatElement();
  +    	se.setName( "Map Size" );
  +    	se.setData("" + map.size());
  +    	elems.add(se);
  +    	
  +    	se = new StatElement();
  +    	se.setName( "Put Count" );
  +    	se.setData("" + putCnt);  	
  +    	elems.add(se);
  +    	
  +    	se = new StatElement();
  +    	se.setName( "Hit Count" );
  +    	se.setData("" + hitCnt);
  +    	elems.add(se);
  +
  +    	se = new StatElement();
  +    	se.setName( "Miss Count" );
  +    	se.setData("" + missCnt);
  +	  	elems.add(se);
  +	  	
  +	  	// get an array and put them in the Stats object
  +	  	IStatElement[] ses = (IStatElement[])elems.toArray( new StatElement[0] );
  +	  	stats.setStatElements( ses );
  +  	
  +    	return stats;
  +    }    
   }
  
  
  
  1.1                  jakarta-turbine-jcs/src/java/org/apache/jcs/utils/threadpool/PoolConfiguration.java
  
  Index: PoolConfiguration.java
  ===================================================================
  package org.apache.jcs.utils.threadpool;
  
  /**
   * This object holds configuration data for a thread pool.
   * 
   * @author Aaron Smuts
   *  
   */
  public class PoolConfiguration implements Cloneable
  {
    private int     boundarySize     = 75;
  
    private int     maximumPoolSize  = 150;
  
    private int     minimumPoolSize  = 4;
  
    private int     keepAliveTime    = 1000 * 60 * 5;
  
    private boolean abortWhenBlocked = false;
  
    private int     startUpSize      = 4;
  
    /**
     * Default
     *  
     */
    public PoolConfiguration()
    {
      // nop
    }
  
    /**
     * 
     * @param boundarySize
     * @param maximumPoolSize
     * @param minimumPoolSize
     * @param keepAliveTime
     * @param abortWhenlocked
     * @param startUpSize
     */
    public PoolConfiguration(int boundarySize, int maximumPoolSize,
        int minimumPoolSize, int keepAliveTime, boolean abortWhenBlocked,
        int startUpSize)
    {
    }
  
    /**
     * @param boundarySize
     *          The boundarySize to set.
     */
    public void setBoundarySize( int boundarySize )
    {
      this.boundarySize = boundarySize;
    }
  
    /**
     * @return Returns the boundarySize.
     */
    public int getBoundarySize()
    {
      return boundarySize;
    }
  
    /**
     * @param maximumPoolSize
     *          The maximumPoolSize to set.
     */
    public void setMaximumPoolSize( int maximumPoolSize )
    {
      this.maximumPoolSize = maximumPoolSize;
    }
  
    /**
     * @return Returns the maximumPoolSize.
     */
    public int getMaximumPoolSize()
    {
      return maximumPoolSize;
    }
  
    /**
     * @param minimumPoolSize
     *          The minimumPoolSize to set.
     */
    public void setMinimumPoolSize( int minimumPoolSize )
    {
      this.minimumPoolSize = minimumPoolSize;
    }
  
    /**
     * @return Returns the minimumPoolSize.
     */
    public int getMinimumPoolSize()
    {
      return minimumPoolSize;
    }
  
    /**
     * @param keepAliveTime
     *          The keepAliveTime to set.
     */
    public void setKeepAliveTime( int keepAliveTime )
    {
      this.keepAliveTime = keepAliveTime;
    }
  
    /**
     * @return Returns the keepAliveTime.
     */
    public int getKeepAliveTime()
    {
      return keepAliveTime;
    }
  
    /**
     * @param abortWhenBlocked
     *          The abortWhenBlocked to set.
     */
    public void setAbortWhenBlocked( boolean abortWhenBlocked )
    {
      this.abortWhenBlocked = abortWhenBlocked;
    }
  
    /**
     * @return Returns the abortWhenBlocked.
     */
    public boolean isAbortWhenBlocked()
    {
      return abortWhenBlocked;
    }
  
    /**
     * @param startUpSize
     *          The startUpSize to set.
     */
    public void setStartUpSize( int startUpSize )
    {
      this.startUpSize = startUpSize;
    }
  
    /**
     * @return Returns the startUpSize.
     */
    public int getStartUpSize()
    {
      return startUpSize;
    }
  
    /**
     * To string for debugging purposes.
     */
    public String toString()
    {
      StringBuffer buf = new StringBuffer();
      buf.append( "boundarySize = [" + boundarySize + "]" );
      buf.append( "maximumPoolSize = [" + maximumPoolSize + "]" );
      buf.append( "minimumPoolSize = [" + minimumPoolSize + "]" );
      buf.append( "keepAliveTime = [" + keepAliveTime + "]" );
      buf.append( "abortWhenBlocked = [" + abortWhenBlocked + "]" );
      buf.append( "startUpSize = [" + startUpSize + "]" );
      return buf.toString();
    }
  
    /**
     * Copies the instance variables to another instance.
     */
    public Object clone()
    {
      return new PoolConfiguration( boundarySize, maximumPoolSize,
          minimumPoolSize, keepAliveTime, abortWhenBlocked, startUpSize );
    }
  }
  
  
  1.3       +64 -12    jakarta-turbine-jcs/src/experimental/org/apache/jcs/engine/PooledCacheEventQueue.java
  
  Index: PooledCacheEventQueue.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/experimental/org/apache/jcs/engine/PooledCacheEventQueue.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PooledCacheEventQueue.java	30 Jul 2004 07:44:17 -0000	1.2
  +++ PooledCacheEventQueue.java	6 Jan 2005 01:21:04 -0000	1.3
  @@ -18,12 +18,17 @@
   
   import java.io.IOException;
   import java.io.Serializable;
  +import java.util.ArrayList;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.jcs.engine.behavior.ICacheElement;
   import org.apache.jcs.engine.behavior.ICacheEventQueue;
   import org.apache.jcs.engine.behavior.ICacheListener;
  +import org.apache.jcs.engine.stats.StatElement;
  +import org.apache.jcs.engine.stats.Stats;
  +import org.apache.jcs.engine.stats.behavior.IStatElement;
  +import org.apache.jcs.engine.stats.behavior.IStats;
   
   import EDU.oswego.cs.dl.util.concurrent.BoundedBuffer;
   import EDU.oswego.cs.dl.util.concurrent.PooledExecutor;
  @@ -97,7 +102,7 @@
        * @param listenerId
        * @param cacheName
        */
  -    public CacheEventQueue(ICacheListener listener, long listenerId, String cacheName) {
  +    public PooledCacheEventQueue(ICacheListener listener, long listenerId, String cacheName) {
           this(listener, listenerId, cacheName, 10, 500);
       }
   
  @@ -110,7 +115,7 @@
        * @param maxFailure
        * @param waitBeforeRetry
        */
  -    public CacheEventQueue(ICacheListener listener, long listenerId, String cacheName, int maxFailure,
  +    public PooledCacheEventQueue(ICacheListener listener, long listenerId, String cacheName, int maxFailure,
               int waitBeforeRetry) {
           if (listener == null) {
               throw new IllegalArgumentException("listener must not be null");
  @@ -256,17 +261,64 @@
       }
   
       public String getStats() {
  -        StringBuffer buf = new StringBuffer();
  -        buf.append("\n -------------------------");
  -        buf.append("\n Cache Event Queue:");
  -        buf.append("\n working = " + this.working);
  -        buf.append("\n isAlive() = " + this.isAlive());
  -        buf.append("\n isEmpty() = " + this.isEmpty());
  -        buf.append("\n pool size = " + pool.getPoolSize() + "/" + pool.getMaximumPoolSize());
  -        buf.append("\n queue size = " + queue.size() + "/" + queue.capacity());
  -        return buf.toString();
  +        return getStatistics().toString();
       }
   
  +    /*
  +     *  (non-Javadoc)
  +     * @see org.apache.jcs.engine.behavior.ICacheEventQueue#getStatistics()
  +     */
  +    public IStats getStatistics()
  +    {
  +    	IStats stats = new Stats();
  +    	stats.setTypeName( "Pooled Cache Event Queue" );
  +    	
  +    	ArrayList elems = new ArrayList();
  +    	
  +    	IStatElement se = null;
  +    	
  +    	se = new StatElement();
  +    	se.setName( "Working" );
  +    	se.setData("" + this.working);
  +    	elems.add(se);
  +    	
  +    	se.setName( "Destroyed" );
  +    	se = new StatElement();
  +    	se.setData("" + this.isAlive());
  +    	elems.add(se);
  +
  +    	se.setName( "Empty" );
  +    	se = new StatElement();
  +    	se.setData("" + this.isEmpty());
  +    	elems.add(se);
  +
  +    	se.setName( "Queue Size" );
  +    	se = new StatElement();
  +    	se.setData("" + queue.size() );
  +    	elems.add(se);
  +
  +    	se.setName( "Queue Capacity" );
  +    	se = new StatElement();
  +    	se.setData("" + queue.capacity() );
  +    	elems.add(se);
  +
  +    	se.setName( "Pool Size" );
  +    	se = new StatElement();
  +    	se.setData("" + pool.getPoolSize() );
  +    	elems.add(se);   	
  +
  +    	se.setName( "Maximum Pool Size" );
  +    	se = new StatElement();
  +    	se.setData("" + pool.getMaximumPoolSize() );
  +    	elems.add(se);   	
  +
  +    	// get an array and put them in the Stats object
  +    	IStatElement[] ses = (IStatElement[])elems.toArray( new StatElement[0] );
  +    	stats.setStatElements( ses );
  +
  +    	return stats;
  +    }       
  +    
       ///////////////////////////// Inner classes /////////////////////////////
   
       /**
  @@ -468,6 +520,6 @@
   
       public boolean isEmpty() {
           return queue.size() == 0;
  -    }
  +    }      
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-dev-help@jakarta.apache.org