jakarta-jcs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asm...@apache.org
Subject svn commit: r449025 - in /jakarta/jcs/trunk: src/java/org/apache/jcs/auxiliary/disk/indexed/ src/java/org/apache/jcs/auxiliary/lateral/ src/java/org/apache/jcs/auxiliary/remote/ xdocs/
Date Fri, 22 Sep 2006 18:06:22 GMT
Author: asmuts
Date: Fri Sep 22 11:06:22 2006
New Revision: 449025

URL: http://svn.apache.org/viewvc?view=rev&rev=449025
Log:
Added get, put, and remote counts to the lateral and remote stats. 
Added hit count to disk cache stats.

Modified:
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java
    jakarta/jcs/trunk/xdocs/changes.xml

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java?view=diff&rev=449025&r1=449024&r2=449025
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
(original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
Fri Sep 22 11:06:22 2006
@@ -101,6 +101,8 @@
     // the number of bytes free on disk.
     private long bytesFree = 0;
 
+    private int hitCount = 0;
+    
     /**
      * Use this lock to synchronize reads and writes to the underlying storage mechansism.
      */
@@ -520,12 +522,17 @@
             storageLock.readLock().acquire();
             try
             {
-                object = readElement( key );
+                object = readElement( key );               
             }
             finally
             {
                 storageLock.readLock().release();
             }
+            
+            if ( object != null )
+            {
+                incrementHitCount();
+            }
         }
         catch ( IOException ioe )
         {
@@ -1268,6 +1275,7 @@
 
     /**
      * For debugging.
+     * <p>
      * @param dumpValues A boolean indicating if values should be dumped.
      */
     public void dump( boolean dumpValues )
@@ -1299,6 +1307,15 @@
     }
     
     /**
+     * Increments the hit count in a thread safe manner.
+     *
+     */
+    private synchronized void incrementHitCount()
+    {
+        hitCount++;
+    }
+    
+    /**
      * Gets basic stats for the disk cache.
      * <p>
      * @return String
@@ -1358,6 +1375,11 @@
         {
             log.error( e );
         }
+
+        se = new StatElement();
+        se.setName( "Hit Count" );
+        se.setData( "" + this.hitCount );
+        elems.add( se );
 
         se = new StatElement();
         se.setName( "Bytes Free" );

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCache.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCache.java?view=diff&rev=449025&r1=449024&r2=449025
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCache.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCache.java Fri Sep
22 11:06:22 2006
@@ -51,7 +51,7 @@
     private ILateralCacheService lateral;
 
     private LateralCacheMonitor monitor;
-    
+        
     /**
      * Constructor for the LateralCache object
      * <p>

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java?view=diff&rev=449025&r1=449024&r2=449025
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java Fri
Sep 22 11:06:22 2006
@@ -1,19 +1,12 @@
 package org.apache.jcs.auxiliary.lateral;
 
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License")
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2001-2004 The Apache Software Foundation. Licensed under the Apache License,
Version
+ * 2.0 (the "License") you may not use this file except in compliance with the License. You
may
+ * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by
+ * applicable law or agreed to in writing, software distributed under the License is distributed
on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See
+ * the License for the specific language governing permissions and limitations under the
License.
  */
 
 import java.io.IOException;
@@ -26,7 +19,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.jcs.auxiliary.AuxiliaryCache;
 import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
 import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheService;
@@ -41,8 +33,8 @@
 import org.apache.jcs.engine.stats.behavior.IStats;
 
 /**
- * Used to queue up update requests to the underlying cache. These requests will
- * be processed in their order of arrival via the cache event queue processor.
+ * Used to queue up update requests to the underlying cache. These requests will be processed
in
+ * their order of arrival via the cache event queue processor.
  */
 public class LateralCacheNoWait
     implements AuxiliaryCache
@@ -55,10 +47,16 @@
 
     private ICacheEventQueue q;
 
+    private int getCount = 0;
+
+    private int removeCount = 0;
+
+    private int putCount = 0;
+
     /**
-     * Constructs with the given lateral cache, and fires up an event queue for
-     * aysnchronous processing.
-     * 
+     * Constructs with the given lateral cache, and fires up an event queue for aysnchronous
+     * processing.
+     * <p>
      * @param cache
      */
     public LateralCacheNoWait( LateralCache cache )
@@ -77,9 +75,9 @@
 
         // need each no wait to handle each of its real updates and removes,
         // since there may
-        // be more than one per cache? alternativve is to have the cache
+        // be more than one per cache? alternative is to have the cache
         // perform updates using a different method that spcifies the listener
-        //this.q = new CacheEventQueue(new CacheAdaptor(this),
+        // this.q = new CacheEventQueue(new CacheAdaptor(this),
         // LateralCacheInfo.listenerId, cache.getCacheName());
         if ( cache.getStatus() == CacheConstants.STATUS_ERROR )
         {
@@ -94,6 +92,7 @@
     public void update( ICacheElement ce )
         throws IOException
     {
+        putCount++;
         try
         {
             q.addPutEvent( ce );
@@ -113,6 +112,7 @@
      */
     public ICacheElement get( Serializable key )
     {
+        getCount++;
         if ( this.getStatus() != CacheConstants.STATUS_ERROR )
         {
             try
@@ -147,12 +147,13 @@
 
     /**
      * Adds a remove request to the lateral cache.
-     * 
+     * <p>
      * @param key
      * @return always false
      */
     public boolean remove( Serializable key )
     {
+        removeCount++;
         try
         {
             q.addRemoveEvent( key );
@@ -194,8 +195,8 @@
     }
 
     /**
-     * No lateral invokation.
-     * 
+     * No lateral invocation.
+     * <p>
      * @return The size value
      */
     public int getSize()
@@ -204,8 +205,8 @@
     }
 
     /**
-     * No lateral invokation.
-     * 
+     * No lateral invocation.
+     * <p>
      * @return The cacheType value
      */
     public int getCacheType()
@@ -214,10 +215,9 @@
     }
 
     /**
-     * Returns the asyn cache status. An error status indicates either the
-     * lateral connection is not available, or the asyn queue has been
-     * unexpectedly destroyed. No lateral invokation.
-     * 
+     * Returns the asyn cache status. An error status indicates either the lateral connection
is not
+     * available, or the asyn queue has been unexpectedly destroyed. No lateral invokation.
+     * <p>
      * @return The status value
      */
     public int getStatus()
@@ -227,7 +227,7 @@
 
     /**
      * Gets the cacheName attribute of the LateralCacheNoWait object
-     * 
+     * <p>
      * @return The cacheName value
      */
     public String getCacheName()
@@ -236,9 +236,9 @@
     }
 
     /**
-     * Replaces the lateral cache service handle with the given handle and reset
-     * the queue by starting up a new instance.
-     * 
+     * Replaces the lateral cache service handle with the given handle and reset the queue
by
+     * starting up a new instance.
+     * <p>
      * @param lateral
      */
     public void fixCache( ILateralCacheService lateral )
@@ -249,8 +249,7 @@
     }
 
     /**
-     * Resets the event q by first destroying the existing one and starting up
-     * new one.
+     * Resets the event q by first destroying the existing one and starting up new one.
      */
     public void resetEventQ()
     {
@@ -271,10 +270,9 @@
     {
         return cache.getAuxiliaryCacheAttributes();
     }
-    
+
     /**
      * getStats
-     * 
      * @return String
      */
     public String getStats()
@@ -284,7 +282,6 @@
 
     /*
      * (non-Javadoc)
-     * 
      * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatistics()
      */
     public IStats getStatistics()
@@ -294,18 +291,36 @@
 
         ArrayList elems = new ArrayList();
 
-        //IStatElement se = null;
+        // IStatElement se = null;
         // no data gathered here
 
         // get the stats from the event queue too
         // get as array, convert to list, add list to our outer list
         IStats eqStats = this.q.getStatistics();
+
         IStatElement[] eqSEs = eqStats.getStatElements();
         List eqL = Arrays.asList( eqSEs );
         elems.addAll( eqL );
 
+        IStatElement se = null;
+
+        se = new StatElement();
+        se.setName( "Get Count" );
+        se.setData( "" + this.getCount );
+        elems.add( se );
+
+        se = new StatElement();
+        se.setName( "Remove Count" );
+        se.setData( "" + this.removeCount );
+        elems.add( se );
+
+        se = new StatElement();
+        se.setName( "Put Count" );
+        se.setData( "" + this.putCount );
+        elems.add( se );
+
         // get an array and put them in the Stats object
-        IStatElement[] ses = (IStatElement[]) elems.toArray( new StatElement[0] );
+        IStatElement[] ses = (IStatElement[]) elems.toArray( new StatElement[elems.size()]
);
         stats.setStatElements( ses );
 
         return stats;
@@ -313,7 +328,6 @@
 
     /*
      * (non-Javadoc)
-     * 
      * @see java.lang.Object#toString()
      */
     public String toString()

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java?view=diff&rev=449025&r1=449024&r2=449025
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java Fri
Sep 22 11:06:22 2006
@@ -62,6 +62,12 @@
 
     private ICacheEventQueue cacheEventQueue;
 
+    private int getCount = 0;
+
+    private int removeCount = 0;
+
+    private int putCount = 0;
+    
     /**
      * Constructs with the given remote cache, and fires up an event queue for aysnchronous
      * processing.
@@ -91,6 +97,7 @@
     public void update( ICacheElement ce )
         throws IOException
     {
+        putCount++;
         try
         {
             cacheEventQueue.addPutEvent( ce );
@@ -113,6 +120,7 @@
     public ICacheElement get( Serializable key )
         throws IOException
     {
+        getCount++;
         try
         {
             return cache.get( key );
@@ -161,6 +169,7 @@
     public boolean remove( Serializable key )
         throws IOException
     {
+        removeCount++;
         try
         {
             cacheEventQueue.addRemoveEvent( key );
@@ -391,8 +400,23 @@
         List eqL = Arrays.asList( eqSEs );
         elems.addAll( eqL );
 
+        se = new StatElement();
+        se.setName( "Get Count" );
+        se.setData( "" + this.getCount );
+        elems.add( se );
+
+        se = new StatElement();
+        se.setName( "Remove Count" );
+        se.setData( "" + this.removeCount );
+        elems.add( se );
+
+        se = new StatElement();
+        se.setName( "Put Count" );
+        se.setData( "" + this.putCount );
+        elems.add( se );
+        
         // get an array and put them in the Stats object
-        IStatElement[] ses = (IStatElement[]) elems.toArray( new StatElement[0] );
+        IStatElement[] ses = (IStatElement[]) elems.toArray( new StatElement[elems.size()]
);
         stats.setStatElements( ses );
 
         return stats;

Modified: jakarta/jcs/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/xdocs/changes.xml?view=diff&rev=449025&r1=449024&r2=449025
==============================================================================
--- jakarta/jcs/trunk/xdocs/changes.xml (original)
+++ jakarta/jcs/trunk/xdocs/changes.xml Fri Sep 22 11:06:22 2006
@@ -10,6 +10,10 @@
 				Added a summary page to the JCSAdmin.jsp that just dumps
 				the stats for a region. It doesn't display all the keys.
 			</action>
+			<action dev="asmuts" type="update">
+				Added get, put, and remove counts to the lateral and
+				remote stats. Added hit count to disk cache stats.
+			</action>			
 		</release>
 
 		<release version="1.2.7.9" date="in CVS">



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


Mime
View raw message