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:17:55 UTC
cvs commit: jakarta-turbine-jcs/src/java/org/apache/jcs/access CacheAccess.java
asmuts 2005/01/05 17:17:55
Modified: src/java/org/apache/jcs/auxiliary/disk
AbstractDiskCache.java
src/java/org/apache/jcs/engine/memory
AbstractMemoryCache.java
src/experimental/org/apache/jcs/engine/memory/arc
ARCMemoryCache.java
src/java/org/apache/jcs/auxiliary AuxiliaryCache.java
src/conf cache.ccf cache2.ccf
src/test-conf cache2.ccf
src/java/org/apache/jcs/access CacheAccess.java
Removed: src/test cache.ccf
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.
#-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.23 +46 -8 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.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- AbstractDiskCache.java 16 Jul 2004 01:25:17 -0000 1.22
+++ AbstractDiskCache.java 6 Jan 2005 01:17:55 -0000 1.23
@@ -20,7 +20,10 @@
import java.io.IOException;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Hashtable;
+import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -32,6 +35,10 @@
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 org.apache.jcs.utils.locking.ReadWriteLock;
import org.apache.jcs.utils.locking.ReadWriteLockManager;
@@ -295,15 +302,46 @@
*/
public String getStats()
{
- StringBuffer buf = new StringBuffer();
- buf.append( "\n -------------------------" );
- buf.append( "\n Abstract Disk Cache:" );
- buf.append( "\n Purgatory Hits: " + purgHits );
- buf.append( "\n Purgatory Size: " + purgatory.size() );
- buf.append( this.cacheEventQueue.getStats() );
- return buf.toString();
+ return getStatistics().toString();
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatistics()
+ */
+ public IStats getStatistics()
+ {
+ IStats stats = new Stats();
+ stats.setTypeName( "Abstract Disk Cache" );
+
+ ArrayList elems = new ArrayList();
+
+ IStatElement se = null;
+
+ se = new StatElement();
+ se.setName( "Purgatory Hits" );
+ se.setData("" + purgHits);
+ elems.add(se);
+
+ se.setName( "Purgatory Size" );
+ se = new StatElement();
+ se.setData("" + purgatory.size());
+ elems.add(se);
+
+ // get the stats from the event queue too
+ // get as array, convert to list, add list to our outer list
+ IStats eqStats = this.cacheEventQueue.getStatistics();
+ IStatElement[] eqSEs = eqStats.getStatElements();
+ List eqL = Arrays.asList(eqSEs);
+ elems.addAll( eqL );
+
+ // get an array and put them in the Stats object
+ IStatElement[] ses = (IStatElement[])elems.toArray( new StatElement[0] );
+ stats.setStatElements( ses );
+
+ return stats;
+ }
+
/**
* @see ICache#getStatus
*/
1.10 +11 -8 jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java
Index: AbstractMemoryCache.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AbstractMemoryCache.java 10 Jul 2004 03:53:39 -0000 1.9
+++ AbstractMemoryCache.java 6 Jan 2005 01:17:55 -0000 1.10
@@ -27,6 +27,8 @@
import org.apache.jcs.engine.control.*;
import org.apache.jcs.engine.control.group.*;
import org.apache.jcs.engine.memory.shrinking.*;
+import org.apache.jcs.engine.stats.Stats;
+import org.apache.jcs.engine.stats.behavior.IStats;
/**
* Some common code for the LRU and MRU caches.
@@ -177,16 +179,17 @@
}
}
- /**
- * Returns the cache statistics.
- *
- * @return The stats value
+ /*
+ * (non-Javadoc)
+ * @see org.apache.jcs.engine.memory.MemoryCache#getStatistics()
*/
- public String getStats()
+ public IStats getStatistics()
{
- return "";
+ IStats stats = new Stats();
+ stats.setTypeName( "Abstract Memory Cache" );
+ return stats;
}
-
+
/**
* Returns the current cache size.
*
1.3 +76 -33 jakarta-turbine-jcs/src/experimental/org/apache/jcs/engine/memory/arc/ARCMemoryCache.java
Index: ARCMemoryCache.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-jcs/src/experimental/org/apache/jcs/engine/memory/arc/ARCMemoryCache.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ARCMemoryCache.java 13 Jul 2004 02:13:12 -0000 1.2
+++ ARCMemoryCache.java 6 Jan 2005 01:17:55 -0000 1.3
@@ -18,6 +18,7 @@
import java.io.IOException;
import java.io.Serializable;
+import java.util.ArrayList;
import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
@@ -30,6 +31,10 @@
import org.apache.jcs.engine.memory.AbstractMemoryCache;
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;
/**
* This is a rough implmentation of an adaptive replacement cache.
@@ -405,7 +410,7 @@
if (log.isDebugEnabled())
{
log.debug("replace -- T1 to B1");
- log.debug(getInfo());
+ log.debug(getStats());
}
temp = (ElementDescriptor) T1.removeLast(); // grab LRU from T1
// nullify object, temp is now just a dummy container to help
@@ -443,7 +448,7 @@
if (log.isDebugEnabled())
{
log.debug("replace -- T2 to B2");
- log.debug(getInfo());
+ log.debug(getStats());
}
temp = (ElementDescriptor) T2.removeLast(); // grab LRU page of T2
@@ -527,40 +532,78 @@
/////////////////////////////////////////////////////////////////////////
public String getStats()
{
- StringBuffer buf = new StringBuffer(0);
- buf.append(getInfo());
- buf.append(getCnts());
- return buf.toString();
+ return getStatistics().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();
- }
-
- public String getInfo()
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.jcs.engine.memory.MemoryCache#getStatistics()
+ */
+ public IStats getStatistics()
{
- StringBuffer buf = new StringBuffer();
- buf.append("\n T1.size() = " + T1.size());
- buf.append("\n T2.size() = " + T2.size());
- buf.append("\n B1.size() = " + B1.size());
- buf.append("\n B2.size() = " + B2.size());
- buf.append("\n target_T1 = " + target_T1);
- buf.append("\n map.size() = " + map.size());
- buf.append("\n -------------------------");
- return buf.toString();
- }
-
+ IStats stats = new Stats();
+ stats.setTypeName( "LRU Memory Cache" );
+
+ ArrayList elems = new ArrayList();
+
+ IStatElement se = null;
+
+ se = new StatElement();
+ se.setName( "T1 Size" );
+ se.setData("" + T1.size());
+ elems.add(se);
+
+ se = new StatElement();
+ se.setName( "T2 Size" );
+ se.setData("" + T2.size());
+ elems.add(se);
+
+ se = new StatElement();
+ se.setName( "B1 Size" );
+ se.setData("" + B1.size());
+ elems.add(se);
+
+ se = new StatElement();
+ se.setName( "B2 Size" );
+ se.setData("" + B2.size());
+ elems.add(se);
+
+ se = new StatElement();
+ se.setName( "Target T1 Size" );
+ se.setData("" + target_T1);
+ 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 class ElementDescriptor
extends MemoryElementDescriptor
1.8 +10 -2 jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/AuxiliaryCache.java
Index: AuxiliaryCache.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/AuxiliaryCache.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AuxiliaryCache.java 15 Apr 2004 19:22:53 -0000 1.7
+++ AuxiliaryCache.java 6 Jan 2005 01:17:55 -0000 1.8
@@ -24,6 +24,7 @@
import org.apache.jcs.engine.behavior.ICache;
import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.stats.behavior.IStats;
/**
* Tag interface for auxiliary caches. Currently this provides no additional
@@ -63,5 +64,12 @@
/**
* Gets the set of keys of objects currently in the group
*/
- public Set getGroupKeys(String group) throws IOException;;
+ public Set getGroupKeys(String group) throws IOException;
+
+ /**
+ * Returns the historical and statistical data for a region's auxiliary cache.
+ *
+ * @return
+ */
+ public IStats getStatistics();
}
1.10 +22 -14 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- cache.ccf 22 Jul 2004 13:16:21 -0000 1.9
+++ cache.ccf 6 Jan 2005 01:17:55 -0000 1.10
@@ -17,20 +17,6 @@
jcs.default.elementattributes.IsRemote=true
jcs.default.elementattributes.IsLateral=true
-# SYSTEM CACHE
-# should be defined for the storage of group attribute list
-jcs.system.groupIdCache=DC
-jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
-jcs.system.groupIdCache.cacheattributes.MaxObjects=1000
-jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
-jcs.system.groupIdCache.elementattributes=org.apache.jcs.engine.ElementAttributes
-jcs.system.groupIdCache.elementattributes.IsEternal=true
-jcs.system.groupIdCache.elementattributes.MaxLifeSeconds=3600
-jcs.system.groupIdCache.elementattributes.IdleTime=1800
-jcs.system.groupIdCache.elementattributes.IsSpool=true
-jcs.system.groupIdCache.elementattributes.IsRemote=true
-jcs.system.groupIdCache.elementattributes.IsLateral=true
-
##############################################################
################## CACHE REGIONS AVAILABLE ###################
@@ -131,6 +117,10 @@
#jcs.auxiliary.RC.attributes.LocalPort=1103
jcs.auxiliary.RC.attributes.RemoveUponRemotePut=false
#jcs.auxiliary.RC.attributes.RemoteServiceName=RemoteCache
+#-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
# unreliable
jcs.auxiliary.LUDP=org.apache.jcs.auxiliary.lateral.LateralCacheFactory
@@ -184,3 +174,21 @@
jcs.auxiliary.LCHTTP.attributes.httpReceiveServlet=/cache/LateralCacheReceiverServlet
jcs.auxiliary.LCHTTP.attributes.httpDeleteServlet=/cache/DeleteCacheServlet
+
+##############################################################
+################## 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
1.3 +29 -6 jakarta-turbine-jcs/src/conf/cache2.ccf
Index: cache2.ccf
===================================================================
RCS file: /home/cvs/jakarta-turbine-jcs/src/conf/cache2.ccf,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- cache2.ccf 11 May 2004 01:05:11 -0000 1.2
+++ cache2.ccf 6 Jan 2005 01:17:55 -0000 1.3
@@ -15,7 +15,7 @@
##############################################################
################## CACHE REGIONS AVAILABLE ###################
-jcs.region.testCache1=LJG
+jcs.region.testCache1=RC
jcs.region.testCache1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.testCache1.cacheattributes.MaxObjects=1000
jcs.region.testCache1.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
@@ -43,13 +43,19 @@
jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.DC.attributes.DiskPath=@project_home@/raf
-# connects to the server started by "startRemoteCacheServer 2"
+# need to make put or invalidate an option
+# just a remove lock to add
jcs.auxiliary.RC=org.apache.jcs.auxiliary.remote.RemoteCacheFactory
jcs.auxiliary.RC.attributes=org.apache.jcs.auxiliary.remote.RemoteCacheAttributes
-jcs.auxiliary.RC.attributes.RemoteHost=localhost
-jcs.auxiliary.RC.attributes.RemotePort=1103
-jcs.auxiliary.RFailover.attributes.FailoverServers=localhost:1103,localhost:1102
-jcs.auxiliary.RC.attributes.RemoveUponRemotePut=true
+jcs.auxiliary.RC.attributes.RemoteHost=10.21.209.150
+jcs.auxiliary.RC.attributes.RemotePort=1102
+#jcs.auxiliary.RC.attributes.LocalPort=1103
+jcs.auxiliary.RC.attributes.RemoveUponRemotePut=false
+#jcs.auxiliary.RC.attributes.RemoteServiceName=RemoteCache
+#-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
# unreliable
jcs.auxiliary.LUDP=org.apache.jcs.auxiliary.lateral.LateralCacheFactory
@@ -96,3 +102,20 @@
jcs.auxiliary.LCHTTP.attributes.httpReceiveServlet=/cache/LateralCacheReceiverServlet
jcs.auxiliary.LCHTTP.attributes.httpDeleteServlet=/cache/DeleteCacheServlet
+##############################################################
+################## 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
1.2 +22 -0 jakarta-turbine-jcs/src/test-conf/cache2.ccf
Index: cache2.ccf
===================================================================
RCS file: /home/cvs/jakarta-turbine-jcs/src/test-conf/cache2.ccf,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cache2.ccf 5 Jan 2005 00:28:25 -0000 1.1
+++ cache2.ccf 6 Jan 2005 01:17:55 -0000 1.2
@@ -131,6 +131,10 @@
#jcs.auxiliary.RC.attributes.LocalPort=1103
jcs.auxiliary.RC.attributes.RemoveUponRemotePut=false
#jcs.auxiliary.RC.attributes.RemoteServiceName=RemoteCache
+#-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
# unreliable
jcs.auxiliary.LUDP=org.apache.jcs.auxiliary.lateral.LateralCacheFactory
@@ -184,3 +188,21 @@
jcs.auxiliary.LCHTTP.attributes.httpReceiveServlet=/cache/LateralCacheReceiverServlet
jcs.auxiliary.LCHTTP.attributes.httpDeleteServlet=/cache/DeleteCacheServlet
+
+##############################################################
+################## 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
1.16 +1 -22 jakarta-turbine-jcs/src/java/org/apache/jcs/access/CacheAccess.java
Index: CacheAccess.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/access/CacheAccess.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- CacheAccess.java 16 Nov 2004 07:40:42 -0000 1.15
+++ CacheAccess.java 6 Jan 2005 01:17:55 -0000 1.16
@@ -330,27 +330,6 @@
cacheControl.remove( ( Serializable ) name );
}
-
- // TODO: rethink the point of these methods
-// /**
-// * Remove the entire region of elements from other caches specified in the
-// * cache.properties file as lateral caches.
-// */
-// public void removeLateralDirect()
-// {
-// cacheControl.removeLateralDirect( "ALL" );
-// }
-// /**
-// * Remove the specified element from other caches specified in in the
-// * cache.properties file as lateral caches.
-// *
-// * @param key Key identifying object to remove
-// */
-// public void removeLateralDirect( Serializable key )
-// {
-// cacheControl.removeLateralDirect( key );
-// }
-
/**
* If there are any auxiliary caches associated with this cache, save all
* objects to them.
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-dev-help@jakarta.apache.org