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 2008/10/31 22:04:33 UTC

svn commit: r709566 - in /jakarta/jcs/trunk/src: java/org/apache/jcs/auxiliary/disk/ java/org/apache/jcs/auxiliary/disk/block/ java/org/apache/jcs/auxiliary/disk/indexed/ java/org/apache/jcs/auxiliary/remote/ java/org/apache/jcs/auxiliary/remote/server...

Author: asmuts
Date: Fri Oct 31 14:04:32 2008
New Revision: 709566

URL: http://svn.apache.org/viewvc?rev=709566&view=rev
Log:
Implemented getMatching for the Block Disk Cache and the Indexed Disk Cache.  Started on a remote cache implementation.  The matching utility needs to be abstracted and made pluggable.

Added:
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheUnitTest.java
Modified:
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/engine/PooledCacheEventQueue.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheConcurrentUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexDiskCacheUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheDefragPerformanceTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java?rev=709566&r1=709565&r2=709566&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java Fri Oct 31 14:04:32 2008
@@ -317,8 +317,6 @@
     public Map getMatching( String pattern )
         throws IOException
     {
-        // TODO finish.
-
         // Get the keys from purgatory
         Object[] keyArray = null;
 

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java?rev=709566&r1=709565&r2=709566&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java Fri Oct 31 14:04:32 2008
@@ -43,6 +43,7 @@
 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.utils.match.KeyMatcherUtil;
 
 import EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock;
 
@@ -230,9 +231,36 @@
     public Map processGetMatching( String pattern )
     {
         Map elements = new HashMap();
-
-        // implement
-
+        try
+        {
+            Object[] keyArray = null;
+            storageLock.readLock().acquire();
+            try
+            {
+                keyArray = this.keyStore.keySet().toArray();
+            }
+            finally
+            {
+                storageLock.readLock().release();
+            }
+            
+            Set matchingKeys = KeyMatcherUtil.getMatchingKeysFromArray( pattern, keyArray );
+            
+            Iterator keyIterator = matchingKeys.iterator();
+            while ( keyIterator.hasNext() )
+            {
+                String key = (String)keyIterator.next();
+                ICacheElement element = processGet( key );
+                if ( element != null )
+                {
+                    elements.put( key, element );
+                }
+            }
+        }
+        catch ( Exception e )
+        {
+            log.error( logCacheName + "Failure getting matching from disk, pattern = " + pattern, e );
+        }
         return elements;
     }
     

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?rev=709566&r1=709565&r2=709566&view=diff
==============================================================================
--- 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 Oct 31 14:04:32 2008
@@ -49,6 +49,7 @@
 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.utils.match.KeyMatcherUtil;
 import org.apache.jcs.utils.struct.SortedPreferentialArray;
 import org.apache.jcs.utils.timing.ElapsedTimer;
 
@@ -586,12 +587,39 @@
     public Map processGetMatching( String pattern )
     {
         Map elements = new HashMap();
-
-        // implement
-
+        try
+        {
+            Object[] keyArray = null;
+            storageLock.readLock().acquire();
+            try
+            {
+                keyArray = keyHash.keySet().toArray();
+            }
+            finally
+            {
+                storageLock.readLock().release();
+            }
+            
+            Set matchingKeys = KeyMatcherUtil.getMatchingKeysFromArray( pattern, keyArray );
+            
+            Iterator keyIterator = matchingKeys.iterator();
+            while ( keyIterator.hasNext() )
+            {
+                String key = (String)keyIterator.next();
+                ICacheElement element = processGet( key );
+                if ( element != null )
+                {
+                    elements.put( key, element );
+                }
+            }
+        }
+        catch ( Exception e )
+        {
+            log.error( logCacheName + "Failure getting matching from disk, pattern = " + pattern, e );
+        }
         return elements;
     }
-    
+
     /**
      * Reads the item from disk.
      * <p>

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java?rev=709566&r1=709565&r2=709566&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java Fri Oct 31 14:04:32 2008
@@ -252,14 +252,58 @@
         return retVal;
     }
 
-    /** TODO finish */
+    /**
+     * Calls get matching on the server. Each entry in the result is unwrapped.
+     * <p>
+     * @param pattern
+     * @return Map
+     * @throws IOException
+     */
     public Map processGetMatching( String pattern )
         throws IOException
     {
-        // TODO Auto-generated method stub
-        return null;
+        Map results = new HashMap();
+        try
+        {
+            Map rawResults = remote.getMatching( cacheName, pattern, getListenerId() );
+
+            // Eventually the instance of will not be necessary.
+            if ( rawResults != null )
+            {
+                Set entrySet = rawResults.entrySet();
+                Iterator it = entrySet.iterator();
+                while ( it.hasNext() )
+                {
+                    Map.Entry entry = (Map.Entry) it.next();
+                    ICacheElement unwrappedResult = null;
+                    if ( entry.getValue() instanceof ICacheElementSerialized )
+                    {
+                        // Never try to deserialize if you are a cluster client. Cluster
+                        // clients are merely intra-remote cache communicators. Remote caches are assumed
+                        // to have no ability to deserialze the objects.
+                        if ( this.irca.getRemoteType() != IRemoteCacheAttributes.CLUSTER )
+                        {
+                            unwrappedResult = SerializationConversionUtil
+                                .getDeSerializedCacheElement( (ICacheElementSerialized) entry.getValue(),
+                                                              this.elementSerializer );
+                        }
+                    }
+                    else
+                    {
+                        unwrappedResult = (ICacheElement) entry.getValue();
+                    }
+                    results.put( entry.getKey(), unwrappedResult );
+                }
+            }
+        }
+        catch ( Exception ex )
+        {
+            handleException( ex, "Failed to getMatching [" + pattern + "] from [" + cacheName + "]",
+                             ICacheEventLogger.GET_EVENT );
+        }
+        return results;
     }
-    
+
     /**
      * Gets multiple items from the cache based on the given set of keys.
      * <p>

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java?rev=709566&r1=709565&r2=709566&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java Fri Oct 31 14:04:32 2008
@@ -494,14 +494,6 @@
         element = getFromCacheListeners( key, fromCluster, cacheDesc, element );
         return element;
     }
-
-    /** TODO finish */
-    public Map getMatching( String cacheName, String pattern, long requesterId )
-        throws IOException
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
         
     /**
      * Gets the item from the associated cache listeners.
@@ -559,6 +551,95 @@
         return element;
     }
 
+    /** TODO finish 
+     * <p>
+     * @param cacheName 
+     * @param pattern 
+     * @param requesterId 
+     * @return Map of keys and wrapped objects
+     * @throws IOException 
+     */
+    public Map getMatching( String cacheName, String pattern, long requesterId )
+        throws IOException
+    {
+        Integer remoteTypeL = (Integer) idTypeMap.get( new Long( requesterId ) );
+
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "getMatching [" + pattern + "] from cache [" + cacheName + "] requesterId = [" + requesterId
+                + "] remoteType = " + remoteTypeL );
+        }
+        
+        boolean fromCluster = false;
+        if ( remoteTypeL != null && remoteTypeL.intValue() == IRemoteCacheAttributes.CLUSTER )
+        {
+            fromCluster = true;
+        }
+
+        CacheListeners cacheDesc = null;
+        try
+        {
+            cacheDesc = getCacheListeners( cacheName );
+        }
+        catch ( Exception e )
+        {
+            log.error( "Problem getting listeners.", e );
+
+            if ( cacheEventLogger != null )
+            {
+                cacheEventLogger.logError( "RemoteCacheServer", ICacheEventLogger.GET_EVENT, e.getMessage() + cacheName
+                    + " pattern: " + pattern );
+            }
+        }
+        
+        return getMatchingFromCacheListeners( pattern, fromCluster, cacheDesc );
+    }
+    
+    /**
+     * Gets the item from the associated cache listeners.
+     * <p>
+     * @param pattern
+     * @param fromCluster
+     * @param cacheDesc
+     * @return Map of keys to results
+     */
+    private Map getMatchingFromCacheListeners( String pattern, boolean fromCluster, CacheListeners cacheDesc )
+    {
+        Map elements = null;
+        if ( cacheDesc != null )
+        {
+            CompositeCache c = (CompositeCache) cacheDesc.cache;
+
+            // We always want to go remote and then merge the items.  But this can lead to inconsistencies after 
+            // failover recovery.  Removed items may show up.  There is no good way to prevent this.
+            // We should make it configurable.
+
+            if ( !fromCluster && this.remoteCacheServerAttributes.getAllowClusterGet() )
+            {
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "NonLocalGet. fromCluster [" + fromCluster + "] AllowClusterGet ["
+                        + this.remoteCacheServerAttributes.getAllowClusterGet() + "]" );
+                }
+                elements = c.getMatching( pattern );
+            }
+            else
+            {
+                // Gets from cluster type remote will end up here.
+                // Gets from all clients will end up here if allow cluster get is
+                // false.
+
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "LocalGet.  fromCluster [" + fromCluster + "] AllowClusterGet ["
+                        + this.remoteCacheServerAttributes.getAllowClusterGet() + "]" );
+                }
+                elements = c.localGetMatching( pattern );
+            }
+        }
+        return elements;
+    }
+    
     /**
      * Gets multiple items from the cache based on the given set of keys.
      * <p>

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/PooledCacheEventQueue.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/PooledCacheEventQueue.java?rev=709566&r1=709565&r2=709566&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/PooledCacheEventQueue.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/PooledCacheEventQueue.java Fri Oct 31 14:04:32 2008
@@ -46,9 +46,6 @@
  * The PooledExecutor is static, because presumably these processes will be IO bound, so throwing
  * more than a few threads at them will serve no purpose other than to saturate the IO interface. In
  * light of this, having one thread per region seems unnecessary. This may prove to be false.
- * <p>
- * @author Aaron Smuts
- * @author Travis Savo <ts...@ifilm.com>
  */
 public class PooledCacheEventQueue
     implements ICacheEventQueue

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheConcurrentUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheConcurrentUnitTest.java?rev=709566&r1=709565&r2=709566&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheConcurrentUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheConcurrentUnitTest.java Fri Oct 31 14:04:32 2008
@@ -32,7 +32,7 @@
 
 /**
  * Test which exercises the block disk cache. This one uses three different
- * regions for thre threads.
+ * regions for three threads.
  */
 public class BlockDiskCacheConcurrentUnitTest
     extends TestCase

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheUnitTest.java?rev=709566&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheUnitTest.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheUnitTest.java Fri Oct 31 14:04:32 2008
@@ -0,0 +1,77 @@
+package org.apache.jcs.auxiliary.disk.block;
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.jcs.engine.CacheElement;
+
+/** Unit tests for the Block Disk Cache */
+public class BlockDiskCacheUnitTest
+    extends TestCase
+{
+    /**
+     * Test the basic get matching.
+     * <p>
+     * @throws Exception
+     */
+    public void testPutGetMatching_SmallWait()
+        throws Exception
+    {
+        // SETUP
+        int items = 200;
+
+        String cacheName = "testPutGetMatching_SmallWait";
+        BlockDiskCacheAttributes cattr = new BlockDiskCacheAttributes();
+        cattr.setCacheName( cacheName );
+        cattr.setMaxKeySize( 100 );
+        cattr.setDiskPath( "target/test-sandbox/BlockDiskCacheUnitTest" );
+        BlockDiskCache diskCache = new BlockDiskCache( cattr );
+
+        // DO WORK
+        for ( int i = 0; i <= items; i++ )
+        {
+            diskCache.update( new CacheElement( cacheName, i + ":key", cacheName + " data " + i ) );
+        }
+        Thread.sleep( 500 );
+
+        Map matchingResults = diskCache.getMatching( "1.8.+" );
+
+        // VERIFY
+        assertEquals( "Wrong number returned", 10, matchingResults.size() );
+        System.out.println( "matchingResults.keySet() " + matchingResults.keySet() );
+        System.out.println( "\nAFTER TEST \n" + diskCache.getStats() );
+    }
+
+    /**
+     * Test the basic get matching. With no wait this will all come from purgatory.
+     * <p>
+     * @throws Exception
+     */
+    public void testPutGetMatching_NoWait()
+        throws Exception
+    {
+        // SETUP
+        int items = 200;
+
+        String cacheName = "testPutGetMatching_NoWait";
+        BlockDiskCacheAttributes cattr = new BlockDiskCacheAttributes();
+        cattr.setCacheName( cacheName );
+        cattr.setMaxKeySize( 100 );
+        cattr.setDiskPath( "target/test-sandbox/BlockDiskCacheUnitTest" );
+        BlockDiskCache diskCache = new BlockDiskCache( cattr );
+
+        // DO WORK
+        for ( int i = 0; i <= items; i++ )
+        {
+            diskCache.update( new CacheElement( cacheName, i + ":key", cacheName + " data " + i ) );
+        }
+
+        Map matchingResults = diskCache.getMatching( "1.8.+" );
+
+        // VERIFY
+        assertEquals( "Wrong number returned", 10, matchingResults.size() );
+        System.out.println( "matchingResults.keySet() " + matchingResults.keySet() );
+        System.out.println( "\nAFTER TEST \n" + diskCache.getStats() );
+    }
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexDiskCacheUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexDiskCacheUnitTest.java?rev=709566&r1=709565&r2=709566&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexDiskCacheUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexDiskCacheUnitTest.java Fri Oct 31 14:04:32 2008
@@ -45,9 +45,10 @@
 {
     /**
      * Simply verify that we can put items in the disk cache and retrieve them.
-     * @throws IOException 
+     * @throws IOException
      */
-    public void testSimplePutAndGet() throws IOException
+    public void testSimplePutAndGet()
+        throws IOException
     {
         IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes();
         cattr.setCacheName( "testSimplePutAndGet" );
@@ -94,9 +95,10 @@
 
     /**
      * Add some items to the disk cache and then remove them one by one.
-     * @throws IOException 
+     * @throws IOException
      */
-    public void testRemoveItems() throws IOException
+    public void testRemoveItems()
+        throws IOException
     {
         IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes();
         cattr.setCacheName( "testRemoveItems" );
@@ -127,9 +129,10 @@
 
     /**
      * Verify that we don't override the largest item.
-     * @throws IOException 
+     * @throws IOException
      */
-    public void testRecycleBin() throws IOException
+    public void testRecycleBin()
+        throws IOException
     {
         IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes();
         cattr.setCacheName( "testRemoveItems" );
@@ -458,9 +461,10 @@
 
     /**
      * Add some items to the disk cache and then remove them one by one.
-     * @throws IOException 
+     * @throws IOException
      */
-    public void testRemove_PartialKey() throws IOException
+    public void testRemove_PartialKey()
+        throws IOException
     {
         IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes();
         cattr.setCacheName( "testRemove_PartialKey" );
@@ -498,9 +502,10 @@
 
     /**
      * Verify that group members are removed if we call remove with a group.
-     * @throws IOException 
+     * @throws IOException
      */
-    public void testRemove_Group() throws IOException
+    public void testRemove_Group()
+        throws IOException
     {
         // SETUP
         IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes();
@@ -565,8 +570,7 @@
         GroupId gid = new GroupId( cacheName, group );
         return new GroupAttrName( gid, name );
     }
-    
-    
+
     /**
      * Verify event log calls.
      * <p>
@@ -592,7 +596,7 @@
         diskCache.update( item );
 
         SleepUtil.sleepAtLeast( 200 );
-        
+
         // VERIFY
         assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls );
         assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls );
@@ -646,7 +650,7 @@
 
         Set keys = new HashSet();
         keys.add( "junk" );
-        
+
         // DO WORK
         diskCache.getMultiple( keys );
 
@@ -709,4 +713,69 @@
         assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls );
         assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls );
     }
+
+    /**
+     * Test the basic get matching.
+     * <p>
+     * @throws Exception
+     */
+    public void testPutGetMatching_SmallWait()
+        throws Exception
+    {
+        // SETUP
+        int items = 200;
+
+        String cacheName = "testPutGetMatching_SmallWait";
+        IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes();
+        cattr.setCacheName( cacheName );
+        cattr.setMaxKeySize( 100 );
+        cattr.setDiskPath( "target/test-sandbox/IndexDiskCacheUnitTest" );
+        IndexedDiskCache diskCache = new IndexedDiskCache( cattr );
+
+        // DO WORK
+        for ( int i = 0; i <= items; i++ )
+        {
+            diskCache.update( new CacheElement( cacheName, i + ":key", cacheName + " data " + i ) );
+        }
+        Thread.sleep( 500 );
+
+        Map matchingResults = diskCache.getMatching( "1.8.+" );
+
+        // VERIFY
+        assertEquals( "Wrong number returned", 10, matchingResults.size() );
+        System.out.println( "matchingResults.keySet() " + matchingResults.keySet() );
+        System.out.println( "\nAFTER TEST \n" + diskCache.getStats() );
+    }
+    
+    /**
+     * Test the basic get matching. With no wait this will all come from purgatory.
+     * <p>
+     * @throws Exception
+     */
+    public void testPutGetMatching_NoWait()
+        throws Exception
+    {
+        // SETUP
+        int items = 200;
+
+        String cacheName = "testPutGetMatching_NoWait";
+        IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes();
+        cattr.setCacheName( cacheName );
+        cattr.setMaxKeySize( 100 );
+        cattr.setDiskPath( "target/test-sandbox/IndexDiskCacheUnitTest" );
+        IndexedDiskCache diskCache = new IndexedDiskCache( cattr );
+
+        // DO WORK
+        for ( int i = 0; i <= items; i++ )
+        {
+            diskCache.update( new CacheElement( cacheName, i + ":key", cacheName + " data " + i ) );
+        }
+
+        Map matchingResults = diskCache.getMatching( "1.8.+" );
+
+        // VERIFY
+        assertEquals( "Wrong number returned", 10, matchingResults.size() );
+        System.out.println( "matchingResults.keySet() " + matchingResults.keySet() );
+        System.out.println( "\nAFTER TEST \n" + diskCache.getStats() );
+    }    
 }

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheDefragPerformanceTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheDefragPerformanceTest.java?rev=709566&r1=709565&r2=709566&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheDefragPerformanceTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheDefragPerformanceTest.java Fri Oct 31 14:04:32 2008
@@ -33,6 +33,7 @@
 public class IndexedDiskCacheDefragPerformanceTest
     extends TestCase
 {
+    /** For readability */
     private static final String LOG_DIVIDER = "---------------------------";
 
     private static final int TOTAL_ELEMENTS = 30000;
@@ -132,6 +133,7 @@
     private static class Tile
         implements Serializable
     {
+        /** Don't change */
         private static final long serialVersionUID = 1L;
 
         /**

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java?rev=709566&r1=709565&r2=709566&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java Fri Oct 31 14:04:32 2008
@@ -30,30 +30,31 @@
 import org.apache.jcs.engine.behavior.ICacheListener;
 
 /**
- * This test case is designed to makes sure there are no deadlocks in the event
- * queue. The time to live should be set to a very short interval to make a
- * deadlock more likely.
- *
+ * This test case is designed to makes sure there are no deadlocks in the event queue. The time to
+ * live should be set to a very short interval to make a deadlock more likely.
+ * <p>
  * @author Aaron Smuts
  */
 public class EventQueueConcurrentLoadTest
     extends TestCase
 {
-
+    /** The queue implementation */
     private static CacheEventQueue queue = null;
 
+    /** The mock listener */
     private static CacheListenerImpl listen = null;
 
+    /** max failure setting */
     private int maxFailure = 3;
 
+    /** time to wait before rtrying on failure. */
     private int waitBeforeRetry = 100;
 
-    // very small idle time
+    /** very small idle time */
     private int idleTime = 2;
 
     /**
      * Constructor for the TestDiskCache object.
-     *
      * @param testName
      */
     public EventQueueConcurrentLoadTest( String testName )
@@ -63,7 +64,6 @@
 
     /**
      * Main method passes this test to the text test runner.
-     *
      * @param args
      */
     public static void main( String args[] )
@@ -74,12 +74,10 @@
 
     /**
      * A unit test suite for JUnit
-     *
      * @return The test suite
      */
     public static Test suite()
     {
-
         ActiveTestSuite suite = new ActiveTestSuite();
 
         suite.addTest( new EventQueueConcurrentLoadTest( "testRunPutTest1" )
@@ -170,7 +168,6 @@
 
     /**
      * Adds put events to the queue.
-     *
      * @param end
      * @param expectedPutCount
      * @throws Exception
@@ -203,7 +200,6 @@
 
     /**
      * Add remove events to the event queue.
-     *
      * @param end
      * @throws Exception
      */
@@ -219,7 +215,6 @@
 
     /**
      * Add remove events to the event queue.
-     *
      * @throws Exception
      */
     public void runStopProcessingTest()
@@ -230,7 +225,6 @@
 
     /**
      * Test putting and a delay. Waits until queue is empty to start.
-     *
      * @param end
      * @param expectedPutCount
      * @throws Exception
@@ -284,7 +278,7 @@
         // this becomes less accurate with each test. It should never fail. If
         // it does things are very off.
         assertTrue( "The put count [" + listen.putCount + "] is below the expected minimum threshold ["
-                    + expectedPutCount + "]", listen.putCount >= ( expectedPutCount - 1 ) );
+            + expectedPutCount + "]", listen.putCount >= ( expectedPutCount - 1 ) );
 
     }
 
@@ -294,7 +288,6 @@
     private class CacheListenerImpl
         implements ICacheListener
     {
-
         /**
          * <code>putCount</code>
          */
@@ -305,10 +298,9 @@
          */
         protected int removeCount = 0;
 
-        /*
-         * (non-Javadoc)
-         *
-         * @see org.apache.jcs.engine.behavior.ICacheListener#handlePut(org.apache.jcs.engine.behavior.ICacheElement)
+        /**
+         * @param item
+         * @throws IOException
          */
         public void handlePut( ICacheElement item )
             throws IOException
@@ -319,11 +311,10 @@
             }
         }
 
-        /*
-         * (non-Javadoc)
-         *
-         * @see org.apache.jcs.engine.behavior.ICacheListener#handleRemove(java.lang.String,
-         *      java.io.Serializable)
+        /**
+         * @param cacheName
+         * @param key
+         * @throws IOException
          */
         public void handleRemove( String cacheName, Serializable key )
             throws IOException
@@ -335,10 +326,9 @@
 
         }
 
-        /*
-         * (non-Javadoc)
-         *
-         * @see org.apache.jcs.engine.behavior.ICacheListener#handleRemoveAll(java.lang.String)
+        /**
+         * @param cacheName
+         * @throws IOException
          */
         public void handleRemoveAll( String cacheName )
             throws IOException
@@ -347,10 +337,9 @@
 
         }
 
-        /*
-         * (non-Javadoc)
-         *
-         * @see org.apache.jcs.engine.behavior.ICacheListener#handleDispose(java.lang.String)
+        /**
+         * @param cacheName
+         * @throws IOException
          */
         public void handleDispose( String cacheName )
             throws IOException
@@ -359,10 +348,9 @@
 
         }
 
-        /*
-         * (non-Javadoc)
-         *
-         * @see org.apache.jcs.engine.behavior.ICacheListener#setListenerId(long)
+        /**
+         * @param id
+         * @throws IOException
          */
         public void setListenerId( long id )
             throws IOException
@@ -371,10 +359,9 @@
 
         }
 
-        /*
-         * (non-Javadoc)
-         *
-         * @see org.apache.jcs.engine.behavior.ICacheListener#getListenerId()
+        /**
+         * @return 0
+         * @throws IOException
          */
         public long getListenerId()
             throws IOException



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