asmuts 2005/01/31 20:53:58
Modified: src/test/org/apache/jcs/access TestCacheAccess.java
src/java/org/apache/jcs/utils/struct
SortedPreferentialArray.java
src/conf cache.ccf
src/java/org/apache/jcs/auxiliary/disk
AbstractDiskCache.java
Added: tempbuild jcs-1.2.4-dev.jar
Log:
Changed read write lock in abstract disk cache to just simple
synchronization. It is a tad bit slower but I cannot cause any problems. I've
run millions of operations against the disk cache alone (memeory = 0) with no
memory increase.
Changed version to 1.2.4-dev
Revision Changes Path
1.15 +25 -16
jakarta-turbine-jcs/src/test/org/apache/jcs/access/TestCacheAccess.java
Index: TestCacheAccess.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/test/org/apache/jcs/access/TestCacheAccess.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- TestCacheAccess.java 1 Feb 2005 00:01:59 -0000 1.14
+++ TestCacheAccess.java 1 Feb 2005 04:53:58 -0000 1.15
@@ -34,9 +34,9 @@
/**
* Allows the user to run common cache commands from the command line for a
test
* cache.
- *
+ *
* This also provide basic methods for use in unit tests.
- *
+ *
*/
public class TestCacheAccess
{
@@ -49,22 +49,22 @@
/**
* Construct and initialize the cachecontrol based on the config file.
- *
+ *
*/
public TestCacheAccess()
{
- this( "testCache1" );
+ this( "testCache1" );
}
-
-
+
+
/**
* @param ccfFileName
*/
- public TestCacheAccess(String ccfFileName)
+ public TestCacheAccess(String regionName)
{
try
{
- cache_control = GroupCacheAccess.getGroupAccess( ccfFileName );
+ cache_control = GroupCacheAccess.getGroupAccess( regionName );
}
catch (Exception e)
{
@@ -103,6 +103,10 @@
{
help();
}
+ else if (message.startsWith( "gc" ))
+ {
+ System.gc();
+ }
else if (message.startsWith( "getAttributeNames" ))
{
long n_start = System.currentTimeMillis();
@@ -674,7 +678,7 @@
/**
* Test harness.
- *
+ *
* @param args
* The command line arguments
*/
@@ -682,7 +686,11 @@
{
isSysOut = true;
String ccfFileName = args[0];
- TestCacheAccess tca = new TestCacheAccess( ccfFileName );
+ if ( ccfFileName != null )
+ {
+ JCS.setConfigFilename( ccfFileName );
+ }
+ TestCacheAccess tca = new TestCacheAccess( "testCache1" );
tca.runLoop();
}
@@ -692,7 +700,7 @@
/**
* Gets multiple items from the cache with keys of the form key1, key2,
key3
* up to key[num].
- *
+ *
* @param num
* int
*/
@@ -730,7 +738,7 @@
/**
* Puts multiple items into the cache.
- *
+ *
* @param num
* int
*/
@@ -756,7 +764,7 @@
/**
* Removes multiple items from the cache.
- *
+ *
* @param num
* int
*/
@@ -783,7 +791,7 @@
* The random method performs numOps number of operations. The operations
* will be a mix of puts, gets, and removes. The key range will be from
0 to
* range.
- *
+ *
* @param range
* int The end of the key range.
* @param numOps
@@ -853,7 +861,7 @@
/**
* Sets the region to be used by test methods.
- *
+ *
* @param name
* String -- Name of region
*/
@@ -876,7 +884,7 @@
* The tester will print to the console if isSysOut is true, else it will
* log. It is false by default. When run via the main method, isSysOut
will
* be set to true
- *
+ *
* @param s
* String to print or log
*/
@@ -919,6 +927,7 @@
p( "type 'cloneattr num' to clone attr" );
p( "type 'random range numOps' to put, get, and remove randomly" );
p( "type 'switch number' to switch to testCache[number], 1 ==
testCache1" );
+ p( "type 'gc' to call System.gc()" );
p( "type 'help' for commands" );
}
1.3 +2 -2
jakarta-turbine-jcs/src/java/org/apache/jcs/utils/struct/SortedPreferentialArray.java
Index: SortedPreferentialArray.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/utils/struct/SortedPreferentialArray.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SortedPreferentialArray.java 16 Jul 2004 01:28:22 -0000 1.2
+++ SortedPreferentialArray.java 1 Feb 2005 04:53:58 -0000 1.3
@@ -236,9 +236,9 @@
insertCnt++;
if (insertCnt % 100 == 0)
{
- if (log.isInfoEnabled())
+ if (log.isDebugEnabled())
{
- log.info(this.dumpArray());
+ log.debug(this.dumpArray());
}
}
1.1 jakarta-turbine-jcs/tempbuild/jcs-1.2.4-dev.jar
<<Binary file>>
1.19 +3 -3 jakarta-turbine-jcs/src/conf/cache.ccf
Index: cache.ccf
===================================================================
RCS file: /home/cvs/jakarta-turbine-jcs/src/conf/cache.ccf,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- cache.ccf 1 Feb 2005 00:01:58 -0000 1.18
+++ cache.ccf 1 Feb 2005 04:53:58 -0000 1.19
@@ -3,7 +3,7 @@
# sets the default aux value for any non configured caches
jcs.default=DC
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
-jcs.default.cacheattributes.MaxObjects=1000
+jcs.default.cacheattributes.MaxObjects=12345
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
@@ -20,9 +20,9 @@
##############################################################
################## CACHE REGIONS AVAILABLE ###################
# Regions preconfirgured for caching
-jcs.region.testCache1=LTCP
+jcs.region.testCache1=DC
jcs.region.testCache1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
-jcs.region.testCache1.cacheattributes.MaxObjects=1000
+jcs.region.testCache1.cacheattributes.MaxObjects=0
jcs.region.testCache1.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.testCache1.cacheattributes.UseMemoryShrinker=true
jcs.region.testCache1.cacheattributes.ShrinkerIntervalSeconds=30
1.30 +29 -28
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
Index: AbstractDiskCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- AbstractDiskCache.java 1 Feb 2005 01:35:15 -0000 1.29
+++ AbstractDiskCache.java 1 Feb 2005 04:53:58 -0000 1.30
@@ -63,7 +63,7 @@
public abstract class AbstractDiskCache implements AuxiliaryCache,
Serializable
{
private static final Log log =
- LogFactory.getLog( AbstractDiskCache.class );
+ LogFactory.getLog( AbstractDiskCache.class );
/** Generic disk cache attributes */
private IDiskCacheAttributes dcattr = null;
@@ -84,8 +84,8 @@
* updating of the persistent storage.
*/
protected ICacheEventQueue cacheEventQueue;
-
-
+
+
/**
* Indicates whether the cache is 'alive', defined as having been
* initialized, but not yet disposed.
@@ -107,9 +107,9 @@
/**
* Construc the abstract disk cache, create event queues and purgatory.
- *
+ *
* @param attr
- */
+ */
public AbstractDiskCache( IDiskCacheAttributes attr )
{
this.dcattr = attr;
@@ -163,7 +163,7 @@
* An update results in a put event being created. The put event will
call the
* handlePut method defined here. The handlePut method calls the
implemented
* doPut on the child.
- *
+ *
* @param cacheElement
* @throws IOException
*
@@ -191,9 +191,10 @@
pe.setSpoolable( true );
// Add the element to purgatory
-
- purgatory.put( pe.getKey(), pe );
-
+ synchronized ( purgatory )
+ {
+ purgatory.put( pe.getKey(), pe );
+ }
// Queue element for serialization
cacheEventQueue.addPutEvent( pe );
@@ -209,10 +210,10 @@
/**
* Check to see if the item is in purgatory. If so, return it. If not,
* check to see if we have it on disk.
- *
+ *
* @param key
* @return ICacheElement or null
- *
+ *
* @see AuxiliaryCache#get
*/
public final ICacheElement get( Serializable key )
@@ -227,7 +228,7 @@
PurgatoryElement pe = null;
synchronized ( purgatory )
{
- pe = ( PurgatoryElement ) purgatory.get( key );
+ pe = ( PurgatoryElement ) purgatory.get( key );
}
@@ -255,7 +256,7 @@
// not put an item to memory from disk ifthe size is 0;
// Do not set spoolable to false. Just let it go to disk. This
// will allow the memory size = 0 setting to work well.
-
+
log.debug( "Found element in purgatory, cacheName: " + cacheName
+ ", key: " + key );
@@ -284,10 +285,10 @@
/**
* Removes are not queued. A call to remove is immediate.
- *
+ *
* @param key
* @return whether the item was present to be removed.
- *
+ *
* @see org.apache.jcs.engine.behavior.ICache#remove
*/
public final boolean remove( Serializable key )
@@ -300,7 +301,7 @@
// Remove element from purgatory if it is there
pe = ( PurgatoryElement )purgatory.remove( key );
}
-
+
if ( pe != null ) {
// no way to remove from queue, just make sure it doesn't get on
disk
@@ -310,7 +311,7 @@
// Remove from persistent store immediately
doRemove( key );
-
+
return false;
}
@@ -447,7 +448,7 @@
/**
* @param id
* @throws IOException
- *
+ *
* @see ICacheListener#setListenerId
*/
public void setListenerId( long id )
@@ -498,13 +499,13 @@
{
doUpdate( element );
}
-
+
// After the update has completed, it is safe to
remove
// the element from purgatory.
purgatory.remove( element.getKey() );
-
- }
+
+ }
}
else
@@ -513,21 +514,21 @@
doUpdate( element );
}
}
- else
+ else
{
// The cache is not alive, hence the element should be
removed from
// purgatory. All elements should be removed eventually.
// Perhaps, the alive check should have been done before it
went in the
// queue. This block handles the case where the disk cache
fails
// during normal opertations.
-
+
//String keyAsString = element.getKey().toString();
synchronized ( purgatory )
{
purgatory.remove( element.getKey() );
}
-
+
}
}
@@ -535,7 +536,7 @@
* @param cacheName
* @param key
* @throws IOException
- *
+ *
* @see ICacheListener#handleRemove
*/
public void handleRemove( String cacheName, Serializable key )
@@ -553,7 +554,7 @@
/**
* @param cacheName
* @throws IOException
- *
+ *
* @see ICacheListener#handleRemoveAll
*/
public void handleRemoveAll( String cacheName )
@@ -568,7 +569,7 @@
/**
* @param cacheName
* @throws IOException
- *
+ *
* @see ICacheListener#handleDispose
*/
public void handleDispose( String cacheName )
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]