jtaylor 02/02/24 17:52:28
Modified: . build-test.xml
src/java/org/apache/stratum/jcs/auxiliary/disk
AbstractDiskCache.java
src/java/org/apache/stratum/jcs/auxiliary/disk/indexed
IndexedDiskCache.java
src/java/org/apache/stratum/jcs/engine CacheEventQueue.java
src/java/org/apache/stratum/jcs/utils/locking
ReadWriteLock.java
src/test/org/apache/stratum/jcs TestDiskCache.java
src/test-conf TestDiskCache.ccf
Log:
- Cleaned / expanded some logging messages.
- Removed the JISP and HSQL caches from TestDiskCache since It could be a
little while before those are working, and I'd like to have a more
flexible way to apply the test to different disk implementations.
- Made TestDiskCache multithreaded using ActiveTestSuite. It spawns three
threads to run the test on different regions concurrently, which should
better simulate the behavior of a real cache (although under HIGH load).
- Fixed a problem in AbstractDiskCache.MyCacheListener.handlePut where
elements could be removed from purgatory long (relatively) before they
are written to disk, causing gets during that period to return null even
though the element should be available. This was exposed by the above
unit test.
Revision Changes Path
1.10 +1 -0 jakarta-turbine-stratum/build-test.xml
Index: build-test.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-stratum/build-test.xml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- build-test.xml 23 Feb 2002 20:39:11 -0000 1.9
+++ build-test.xml 25 Feb 2002 01:52:28 -0000 1.10
@@ -64,6 +64,7 @@
<include name="**/Test*.class"/>
<!-- None of these are JUnit tests -->
<exclude name="org/apache/stratum/jcs/access/TestCacheAccess.class"/>
+ <exclude name="org/apache/stratum/jcs/TestDiskCache$$*.class"/>
</fileset>
</batchtest>
</junit>
1.2 +25 -9
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/disk/AbstractDiskCache.java
Index: AbstractDiskCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/disk/AbstractDiskCache.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractDiskCache.java 24 Feb 2002 19:18:04 -0000 1.1
+++ AbstractDiskCache.java 25 Feb 2002 01:52:28 -0000 1.2
@@ -87,7 +87,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Aaron Smuts</a>
* @author <a href="mailto:[EMAIL PROTECTED]">James Taylor</a>
- * @version $Id: AbstractDiskCache.java,v 1.1 2002/02/24 19:18:04 jtaylor Exp $
+ * @version $Id: AbstractDiskCache.java,v 1.2 2002/02/25 01:52:28 jtaylor Exp $
*/
public abstract class AbstractDiskCache implements ICache, Serializable
{
@@ -179,6 +179,12 @@
public final void update( ICacheElement cacheElement )
throws IOException
{
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "Putting element in purgatory, cacheName: " + cacheName +
+ ", key: " + cacheElement.getKey() );
+ }
+
try
{
// Wrap the CacheElement in a PurgatoryElement
@@ -249,7 +255,8 @@
pe.setSpoolable( false );
- log.debug( "Found in purgatory" );
+ log.debug( "Found element in purgatory, cacheName: " + cacheName +
+ ", key: " + key );
if ( container )
{
@@ -420,6 +427,10 @@
/**
* @see ICacheListener#handlePut
+ *
+ * NOTE: This checks if the element is a puratory element and behaves
+ * differently depending. However since we have control over how
+ * elements are added to the cache event queue.
*/
public void handlePut( ICacheElement element )
throws IOException
@@ -435,17 +446,22 @@
element = pe.getCacheElement();
- purgatory.remove( element.getKey() );
+ // If the element is still eligable, spool it.
- if ( ! pe.isSpoolable() )
+ if ( pe.isSpoolable() )
{
- // It has returned to memory from puratory, so do not
- // spool it to disk.
- return;
+ doUpdate( element );
}
- }
- doUpdate( element );
+ // After the update has completed, it is safe to remove
+ // the element from purgatory.
+
+ purgatory.remove( element.getKey() );
+ }
+ else
+ {
+ doUpdate( element );
+ }
}
}
1.5 +8 -4
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
Index: IndexedDiskCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/disk/indexed/IndexedDiskCache.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- IndexedDiskCache.java 24 Feb 2002 19:18:05 -0000 1.4
+++ IndexedDiskCache.java 25 Feb 2002 01:52:28 -0000 1.5
@@ -74,7 +74,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Aaron Smuts</a>
* @author <a href="mailto:[EMAIL PROTECTED]">James Taylor</a>
- * @version $Id: IndexedDiskCache.java,v 1.4 2002/02/24 19:18:05 jtaylor Exp $
+ * @version $Id: IndexedDiskCache.java,v 1.5 2002/02/25 01:52:28 jtaylor Exp $
*/
public class IndexedDiskCache extends AbstractDiskCache
{
@@ -338,6 +338,9 @@
if ( !alive )
{
+ log.debug( "No longer alive so returning null, cacheName: " +
+ cacheName + ", key = " + key );
+
return null;
}
@@ -346,7 +349,8 @@
}
catch ( Exception e )
{
- log.error( "cacheName = " + cacheName + ", key = " + key, e );
+ log.error( "Failure getting from disk, cacheName: " + cacheName +
+ ", key = " + key, e );
}
finally
{
@@ -651,7 +655,7 @@
*/
public void dump()
{
- log.debug( "Number of keys: " + keyHash.size() );
+ log.debug( "[dump] Number of keys: " + keyHash.size() );
Iterator itr = keyHash.entrySet().iterator();
@@ -666,7 +670,7 @@
Serializable val = get( key );
- log.debug( "Disk element, key: " + key +
+ log.debug( "[dump] Disk element, key: " + key +
", val: " + val +
", pos: " + ded.pos );
}
1.9 +4 -0
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/CacheEventQueue.java
Index: CacheEventQueue.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/CacheEventQueue.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CacheEventQueue.java 18 Feb 2002 17:14:24 -0000 1.8
+++ CacheEventQueue.java 25 Feb 2002 01:52:28 -0000 1.9
@@ -20,6 +20,8 @@
{
private final static Log log = LogSource.getInstance( CacheEventQueue.class );
+ private static int processorInstanceCount = 0;
+
private LinkedQueue queue = new LinkedQueue();
private ICacheListener listener;
@@ -219,6 +221,8 @@
*/
QProcessor()
{
+ super( "CacheEventQueue.QProcessor-" + ( ++processorInstanceCount ) );
+
setDaemon( true );
}
1.4 +1 -1
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/utils/locking/ReadWriteLock.java
Index: ReadWriteLock.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/utils/locking/ReadWriteLock.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ReadWriteLock.java 24 Feb 2002 19:18:05 -0000 1.3
+++ ReadWriteLock.java 25 Feb 2002 01:52:28 -0000 1.4
@@ -24,7 +24,7 @@
public class ReadWriteLock
{
private final static Log log =
- LogSource.getInstance( ReadWriteLockManager.class );
+ LogSource.getInstance( ReadWriteLock.class );
/** Number of threads waiting to read. */
private int waitingForReadLock = 0;
1.4 +50 -26
jakarta-turbine-stratum/src/test/org/apache/stratum/jcs/TestDiskCache.java
Index: TestDiskCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-stratum/src/test/org/apache/stratum/jcs/TestDiskCache.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestDiskCache.java 24 Feb 2002 19:18:05 -0000 1.3
+++ TestDiskCache.java 25 Feb 2002 01:52:28 -0000 1.4
@@ -58,6 +58,7 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import junit.extensions.ActiveTestSuite;
import org.apache.stratum.jcs.JCS;
import org.apache.stratum.jcs.engine.behavior.ICompositeCacheAttributes;
@@ -66,7 +67,7 @@
* Test which excercises the disk caches (Indexed, JISP, and HSQL).
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Taylor</a>
- * @version $Id: TestDiskCache.java,v 1.3 2002/02/24 19:18:05 jtaylor Exp $
+ * @version $Id: TestDiskCache.java,v 1.4 2002/02/25 01:52:28 jtaylor Exp $
*/
public class TestDiskCache extends TestCase
{
@@ -82,8 +83,6 @@
public TestDiskCache( String testName )
{
super( testName );
-
- JCS.setConfigFilename( "/TestDiskCache.ccf" );
}
/**
@@ -102,35 +101,60 @@
*/
public static Test suite()
{
- return new TestSuite( TestDiskCache.class );
- }
+ ActiveTestSuite suite = new ActiveTestSuite();
+
+ suite.addTest( new TestDiskCache( "testIndexedDiskCache1" )
+ {
+ public void runTest() throws Exception
+ {
+ runTestForRegion( "indexedRegion1" );
+ }
+ });
+
+ suite.addTest( new TestDiskCache( "testIndexedDiskCache2" )
+ {
+ public void runTest() throws Exception
+ {
+ runTestForRegion( "indexedRegion2" );
+ }
+ });
+
+ suite.addTest( new TestDiskCache( "testIndexedDiskCache3" )
+ {
+ public void runTest() throws Exception
+ {
+ runTestForRegion( "indexedRegion3" );
+ }
+ });
- /**
- * Tests the region which uses the indexed disk cache
- */
- public void testIndexedDiskCache()
- throws Exception
- {
- runTestForRegion( "indexedRegion" );
+ return suite;
}
/**
- * Tests the region which uses the JISP disk cache
+ * Test setup
*/
- public void testJISPDiskCache()
- throws Exception
+ public void setUp()
{
- runTestForRegion( "jispRegion" );
+ JCS.setConfigFilename( "/TestDiskCache.ccf" );
}
- /**
- * Tests the region which uses the HSQL disk cache
- */
- public void testHSQLDiskCache()
- throws Exception
- {
- runTestForRegion( "hsqlRegion" );
- }
+// /**
+// * Tests the region which uses the indexed disk cache
+// */
+// public void testIndexedDiskCache()
+// throws Exception
+// {
+// runTestForRegion( "indexedRegion" );
+// }
+//
+// /**
+// * Tests the region which uses the indexed disk cache
+// */
+// public void testIndexedDiskCache2()
+// throws Exception
+// {
+// runTestForRegion( "indexedRegion2" );
+// }
/**
* Adds items to cache, gets them, and removes them. The item count is more
@@ -149,7 +173,7 @@
for ( int i = 0; i <= items; i++ )
{
- jcs.put( i + ":key", "data" + i );
+ jcs.put( i + ":key", region + " data " + i );
}
// Test that all items are in cache
@@ -158,7 +182,7 @@
{
String value = ( String ) jcs.get( i + ":key" );
- this.assertEquals( "data" + i, value );
+ this.assertEquals( region + " data " + i , value );
}
// Remove all the items
1.3 +15 -26 jakarta-turbine-stratum/src/test-conf/TestDiskCache.ccf
Index: TestDiskCache.ccf
===================================================================
RCS file: /home/cvs/jakarta-turbine-stratum/src/test-conf/TestDiskCache.ccf,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestDiskCache.ccf 23 Feb 2002 20:39:11 -0000 1.2
+++ TestDiskCache.ccf 25 Feb 2002 01:52:28 -0000 1.3
@@ -15,35 +15,24 @@
##### CACHE REGIONS FOR TEST
-jcs.region.indexedRegion=indexedDiskCache
-jcs.region.indexedRegion.cacheattributes=org.apache.stratum.jcs.engine.CompositeCacheAttributes
-jcs.region.indexedRegion.cacheattributes.MaxObjects=100
-jcs.region.indexedRegion.cacheattributes.MemoryCacheName=org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache
-
-jcs.region.hsqlRegion=hsqlDiskCache
-jcs.region.hsqlRegion.cacheattributes=org.apache.stratum.jcs.engine.CompositeCacheAttributes
-jcs.region.hsqlRegion.cacheattributes.MaxObjects=100
-jcs.region.hsqlRegion.cacheattributes.MemoryCacheName=org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache
-
-jcs.region.jispRegion=jispDiskCache
-jcs.region.jispRegion.cacheattributes=org.apache.stratum.jcs.engine.CompositeCacheAttributes
-jcs.region.jispRegion.cacheattributes.MaxObjects=100
-jcs.region.jispRegion.cacheattributes.MemoryCacheName=org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache
+jcs.region.indexedRegion1=indexedDiskCache
+jcs.region.indexedRegion1.cacheattributes=org.apache.stratum.jcs.engine.CompositeCacheAttributes
+jcs.region.indexedRegion1.cacheattributes.MaxObjects=100
+jcs.region.indexedRegion1.cacheattributes.MemoryCacheName=org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache
+
+jcs.region.indexedRegion2=indexedDiskCache
+jcs.region.indexedRegion2.cacheattributes=org.apache.stratum.jcs.engine.CompositeCacheAttributes
+jcs.region.indexedRegion2.cacheattributes.MaxObjects=100
+jcs.region.indexedRegion2.cacheattributes.MemoryCacheName=org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache
+
+jcs.region.indexedRegion3=indexedDiskCache
+jcs.region.indexedRegion3.cacheattributes=org.apache.stratum.jcs.engine.CompositeCacheAttributes
+jcs.region.indexedRegion3.cacheattributes.MaxObjects=100
+jcs.region.indexedRegion3.cacheattributes.MemoryCacheName=org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache
##### AUXILIARY CACHES
# Indexed Disk Cache
jcs.auxiliary.indexedDiskCache=org.apache.stratum.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.indexedDiskCache.attributes=org.apache.stratum.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
-jcs.auxiliary.indexedDiskCache.attributes.DiskPath=bin/test/indexed-disk-cache
-
-# HSQL Disk Cache
-jcs.auxiliary.hsqlDiskCache=org.apache.stratum.jcs.auxiliary.disk.hsql.HSQLCacheFactory
-jcs.auxiliary.hsqlDiskCache.attributes=org.apache.stratum.jcs.auxiliary.disk.hsql.HSQLCacheAttributes
-jcs.auxiliary.hsqlDiskCache.attributes.DiskPath=bin/test/hsql-disk-cache
-
-# JISP Disk Cache
-jcs.auxiliary.jispDiskCache=org.apache.stratum.jcs.auxiliary.disk.jisp.JISPCacheFactory
-jcs.auxiliary.jispDiskCache.attributes=org.apache.stratum.jcs.auxiliary.disk.jisp.JISPCacheAttributes
-jcs.auxiliary.jispDiskCache.attributes.DiskPath=bin/test/jisp-disk-cache
-jcs.auxiliary.jispDiskCache.attributes.ClearOnStart=false
\ No newline at end of file
+jcs.auxiliary.indexedDiskCache.attributes.DiskPath=bin/test/indexed-disk-cache
\ No newline at end of file
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>