You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by as...@apache.org on 2002/02/13 05:45:05 UTC
cvs commit: jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control Cache.java
asmuts 02/02/12 20:45:05
Modified: src/java/org/apache/stratum/jcs/engine/memory/lru
LRUMemoryCache.java
src/java/org/apache/stratum/jcs/engine/group GroupCache.java
src/java/org/apache/stratum/jcs/engine/control Cache.java
Log:
testing log4j migration. since the api changed it is much more difficult to migrate, but well worth the effort
Revision Changes Path
1.5 +22 -21 jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/memory/lru/LRUMemoryCache.java
Index: LRUMemoryCache.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/memory/lru/LRUMemoryCache.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LRUMemoryCache.java 29 Jan 2002 06:12:57 -0000 1.4
+++ LRUMemoryCache.java 13 Feb 2002 04:45:05 -0000 1.5
@@ -23,22 +23,22 @@
import org.apache.stratum.jcs.engine.memory.MemoryElementDescriptor;
import org.apache.stratum.jcs.engine.memory.behavior.IMemoryCache;
-import org.apache.stratum.jcs.utils.log.Logger;
-import org.apache.stratum.jcs.utils.log.LoggerManager;
+import org.apache.log4j.Category;
+
+//import org.apache.stratum.jcs.utils.log.Logger;
+//import org.apache.stratum.jcs.utils.log.LoggerManager;
/////////////////////////////////////////////////////
/**
* A fast reference management system. The least recently used items move tot
* he end of the list and get spooled to disk if the cache hub is configured to
- * use a disk cache.
- *
- * Most of the cache bottelnecks ar ein IO. There are no io bottlenecks here,
- * it's all about processing power. Even though there are only a few adjustments
- * necessary to maintain the double linked list, we might want to find a more
- * efficient memory manager for large cache regions. The LRUMemoryCache is most
- * efficeint when the first element is selected. The smaller teh region, the
- * better the chance that this will be the case. < .04 ms per put, p3 866,
- * 1/10 of that per get
+ * use a disk cache. Most of the cache bottelnecks ar ein IO. There are no io
+ * bottlenecks here, it's all about processing power. Even though there are
+ * only a few adjustments necessary to maintain the double linked list, we
+ * might want to find a more efficient memory manager for large cache regions.
+ * The LRUMemoryCache is most efficeint when the first element is selected. The
+ * smaller teh region, the better the chance that this will be the case. < .04
+ * ms per put, p3 866, 1/10 of that per get
*
*@author asmuts
*@created January 15, 2002
@@ -81,7 +81,7 @@
/**
* Description of the Field
*/
- protected final static Logger log = LoggerManager.getLogger( LRUMemoryCache.class );
+ protected final static Category log = Category.getInstance( LRUMemoryCache.class );
// The HUB
ICacheHub hub;
@@ -134,6 +134,7 @@
this.max = cattr.getMaxObjects();
this.hub = hub;
status = this.STATUS_ALIVE;
+ log.info( "initialized LRUMemoryCache for " + cacheName );
}
@@ -224,7 +225,7 @@
{
p( "update: After spool, put " + last.ce.getKey() + " on disk cache, map.size() = " + size + ", this.cattr.getMaxObjects() = " + this.cattr.getMaxObjects() + ", chunkSizeCorrected = " + chunkSizeCorrected );
}
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( "update: After spool, put " + last.ce.getKey() + " on disk cache, map.size() = " + size + ", this.cattr.getMaxObjects() = " + this.cattr.getMaxObjects() + ", chunkSizeCorrected = " + chunkSizeCorrected );
}
@@ -306,14 +307,14 @@
try
{
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( "get> key=" + key );
log.debug( "get> key=" + key.toString() );
}
me = ( MemoryElementDescriptor ) map.get( key );
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( "me =" + me );
}
@@ -327,7 +328,7 @@
found = true;
ce = me.ce;
//ramHit++;
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( cacheName + " -- RAM-HIT for " + key );
}
@@ -346,7 +347,7 @@
{
// Item not found in all caches.
//miss++;
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( cacheName + " -- MISS for " + key );
}
@@ -356,7 +357,7 @@
}
catch ( Exception e )
{
- log.error( e, "Error handling miss" );
+ log.error( "Error handling miss", e );
return null;
}
@@ -366,7 +367,7 @@
}
catch ( Exception e )
{
- log.error( e, "Error making first" );
+ log.error( "Error making first", e );
return null;
}
@@ -393,7 +394,7 @@
throws IOException
{
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( "remove> key=" + key );
//+, nonLocal="+nonLocal);
@@ -700,7 +701,7 @@
}
catch ( Exception e )
{
- log.error( e, "Couldn't make first" );
+ log.error( "Couldn't make first", e );
}
return;
}
1.8 +1 -1 jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/group/GroupCache.java
Index: GroupCache.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/group/GroupCache.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- GroupCache.java 17 Jan 2002 22:28:56 -0000 1.7
+++ GroupCache.java 13 Feb 2002 04:45:05 -0000 1.8
@@ -1156,7 +1156,7 @@
*
*@param s Description of the Parameter
*/
- public static void p( String s )
+ public void p( String s )
{
System.out.println( "GroupCache: " + s );
}
1.11 +28 -28 jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control/Cache.java
Index: Cache.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control/Cache.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Cache.java 29 Jan 2002 06:12:58 -0000 1.10
+++ Cache.java 13 Feb 2002 04:45:05 -0000 1.11
@@ -77,8 +77,8 @@
import org.apache.stratum.jcs.engine.memory.behavior.IMemoryCache;
import org.apache.stratum.jcs.engine.memory.lru.LRUMemoryCache;
-import org.apache.stratum.jcs.utils.log.Logger;
-import org.apache.stratum.jcs.utils.log.LoggerManager;
+import org.apache.log4j.Category;
+import org.apache.log4j.Priority;
//////////////////////////////////////////////////////
/**
@@ -126,9 +126,9 @@
private String source_id = "org.apache.stratum.jcs.engine.control.Cache";
/**
- * need to convert to log4j
+ * log4j
*/
- protected final Logger log;
+ protected final Category log;
// statistics
private static int numInstances;
@@ -180,17 +180,16 @@
this.attr = attr;
this.cacheAttr = cattr;
- log = LoggerManager.getLogger( this );
+ log = Category.getInstance( Cache.class );
if ( debugcmd )
{
- log.setLogLevel( log.DEBUG );
- log.setSystemOut( true );
+ log.setPriority( Priority.DEBUG );
}
createMemoryCache( cattr );
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( "******************* Constructing cache " + cacheName );
}
@@ -369,7 +368,7 @@
"key must not end with " + NAME_COMPONENT_DELIMITER + " for a put operation" );
}
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
StringBuffer params = new StringBuffer();
params.append( "Cache.updateExclude(ce,updateRemoteCache) > updateRemoteCache = " + updateRemoteCache + " key=" + ce.getKey() + ", val=" + ce.getVal() + ", " + ce.getAttributes().toString() );
@@ -414,7 +413,7 @@
// SEND TO REMOTE STORE
if ( aux != null && aux.getCacheType() == ICache.REMOTE_CACHE )
{
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( "ce.getAttributes().IS_REMOTE = " + ce.getAttributes().IS_REMOTE );
}
@@ -426,7 +425,7 @@
// need to make sure the group cache understands that the
// key is a group attribute on update
aux.update( ce );
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( "Updated remote store for " + ce.getKey() + ce );
}
@@ -457,7 +456,7 @@
// Currently always multicast even if the value is unchanged,
// just to cause the cache item to move to the front.
aux.update( ce );
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( "updated lateral cache for " + ce.getKey() );
}
@@ -509,7 +508,7 @@
catch ( Exception oee )
{
}
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( "moveToMemory -- request to put " + ce.getKey() + " on disk cache[" + i + "]" );
}
@@ -582,7 +581,7 @@
try
{
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( "get> key=" + key );
log.debug( "get> key=" + key.toString() );
@@ -636,7 +635,7 @@
p( "ce.getKey() = " + ce.getKey() );
p( "ce.getVal() = " + ce.getVal() );
}
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( cacheName + " -- AUX[" + i + "]-HIT for " + key );
log.debug( "ce.getKey() = " + ce.getKey() );
@@ -657,7 +656,7 @@
{
found = true;
ramHit++;
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( cacheName + " -- RAM-HIT for " + key );
}
@@ -676,7 +675,7 @@
{
// Item not found in all caches.
miss++;
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( cacheName + " -- MISS for " + key );
}
@@ -686,7 +685,7 @@
}
catch ( Exception e )
{
- log.error( e, "Error handling miss" );
+ log.error( "Error handling miss", e );
return null;
}
@@ -700,10 +699,10 @@
if ( !ce.getAttributes().IS_ETERNAL && ( ( System.currentTimeMillis() - ce.getAttributes().createTime ) > ( ce.getAttributes().ttl * 1000 ) ) )
{
// Item expired.
- if ( log.logLevel >= log.INFO )
- {
- log.info( ce.getKey() + " expired" );
- }
+ //if ( log.logLevel >= log.INFO )
+ //{
+ log.info( ce.getKey() + " expired" );
+ //}
if ( debugcmd )
{
p( ce.getKey() + " expired" );
@@ -715,7 +714,7 @@
}
catch ( Exception e )
{
- log.error( e, "Error determining expiration period" );
+ log.error( "Error determining expiration period", e );
return null;
}
@@ -781,7 +780,7 @@
public synchronized boolean remove( Serializable key, boolean nonLocal )
{
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( "remove> key=" + key + ", nonLocal=" + nonLocal );
}
@@ -914,7 +913,7 @@
if ( aux.getStatus() == ICache.STATUS_ALIVE )
{
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( "size = " + memCache.getSize() );
}
@@ -1013,7 +1012,7 @@
}
}
}
- if ( log.logLevel >= log.DEBUG )
+ if ( log.isDebugEnabled() )
{
log.debug( "Called save for " + cacheName );
}
@@ -1185,9 +1184,10 @@
*
*@param s Description of the Parameter
*/
- public static void p( String s )
+ public void p( String s )
{
- System.out.println( "Cache: " + s );
+ //System.out.println( "Cache: " + s );
+ log.debug( "Cache: " + s );
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>