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/08/20 23:44:07 UTC
svn commit: r687478 [2/2] - in /jakarta/jcs/trunk: ./ src/conf/
src/java/org/apache/jcs/auxiliary/
src/java/org/apache/jcs/auxiliary/disk/jdbc/
src/java/org/apache/jcs/auxiliary/lateral/
src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/ src/java/or...
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryService.java Wed Aug 20 14:44:05 2008
@@ -33,24 +33,21 @@
import org.apache.jcs.auxiliary.lateral.LateralCacheNoWaitFacade;
import org.apache.jcs.auxiliary.lateral.socket.tcp.behavior.ITCPLateralCacheAttributes;
import org.apache.jcs.engine.behavior.ICompositeCacheManager;
+import org.apache.jcs.engine.behavior.IElementSerializer;
import org.apache.jcs.engine.behavior.IShutdownObservable;
import org.apache.jcs.engine.behavior.IShutdownObserver;
+import org.apache.jcs.engine.logging.behavior.ICacheEventLogger;
import EDU.oswego.cs.dl.util.concurrent.ClockDaemon;
import EDU.oswego.cs.dl.util.concurrent.ThreadFactory;
/**
- *
- * This service creates a listener that can create lateral caches and add them
- * to the no wait list.
+ * This service creates a listener that can create lateral caches and add them to the no wait list.
* <p>
* It also creates a sender that periodically broadcasts its availability.
* <p>
- * The sender also broadcasts a request for other caches to broadcast their
- * addresses.
- *
+ * The sender also broadcasts a request for other caches to broadcast their addresses.
* @author Aaron Smuts
- *
*/
public class UDPDiscoveryService
implements IShutdownObserver
@@ -83,19 +80,23 @@
private ITCPLateralCacheAttributes tcpLateralCacheAttributes;
+ /** The event logger. */
+ protected ICacheEventLogger cacheEventLogger;
+
+ /** The serializer. */
+ protected IElementSerializer elementSerializer;
+
/**
- *
- * @param discoveryAddress
- * address to multicast to
- * @param discoveryPort
- * port to multicast to
- * @param servicePort
- * the port this service runs on, the service we are telling
- * other about
+ * @param discoveryAddress address to multicast to
+ * @param discoveryPort port to multicast to
+ * @param servicePort the port this service runs on, the service we are telling other about
* @param cacheMgr
+ * @param cacheEventLogger
+ * @param elementSerializer
*/
public UDPDiscoveryService( String discoveryAddress, int discoveryPort, int servicePort,
- ICompositeCacheManager cacheMgr )
+ ICompositeCacheManager cacheMgr, ICacheEventLogger cacheEventLogger,
+ IElementSerializer elementSerializer )
{
// register for shutdown notification
( (IShutdownObservable) cacheMgr ).registerShutdownObserver( this );
@@ -103,6 +104,8 @@
this.setDiscoveryAddress( discoveryAddress );
this.setDiscoveryPort( discoveryPort );
this.setServicePort( servicePort );
+ this.cacheEventLogger = cacheEventLogger;
+ this.elementSerializer = elementSerializer;
try
{
@@ -121,7 +124,8 @@
try
{
// todo need some kind of recovery here.
- receiver = new UDPDiscoveryReceiver( this, getDiscoveryAddress(), getDiscoveryPort(), cacheMgr );
+ receiver = new UDPDiscoveryReceiver( this, getDiscoveryAddress(), getDiscoveryPort(), cacheMgr,
+ cacheEventLogger, elementSerializer );
udpReceiverThread = new Thread( receiver );
udpReceiverThread.setDaemon( true );
// udpReceiverThread.setName( t.getName() + "--UDPReceiver" );
@@ -129,8 +133,8 @@
}
catch ( Exception e )
{
- log.error( "Problem creating UDPDiscoveryReceiver, address [" + getDiscoveryAddress() + "] port [" + getDiscoveryPort()
- + "] we won't be able to find any other caches", e );
+ log.error( "Problem creating UDPDiscoveryReceiver, address [" + getDiscoveryAddress() + "] port ["
+ + getDiscoveryPort() + "] we won't be able to find any other caches", e );
}
// todo only do the passive if receive is inenabled, perhaps set the
@@ -149,13 +153,11 @@
}
/**
- * Adds a nowait facade under this cachename. If one already existed, it
- * will be overridden.
+ * Adds a nowait facade under this cachename. If one already existed, it will be overridden.
* <p>
- * When a broadcast is received from the UDP Discovery receiver, for each
- * cacheName in the message, the add no wait will be called here. To add a
- * no wait, the facade is looked up for this cache name.
- *
+ * When a broadcast is received from the UDP Discovery receiver, for each cacheName in the
+ * message, the add no wait will be called here. To add a no wait, the facade is looked up for
+ * this cache name.
* @param facade
* @param cacheName
* @return true if the facade was not already registered.
@@ -180,10 +182,8 @@
}
/**
- * This adds nowaits to a facde for the region name. If the region has no
- * facade, then it is not configured to use the lateral cache, and no facde
- * will be created.
- *
+ * This adds nowaits to a facde for the region name. If the region has no facade, then it is not
+ * configured to use the lateral cache, and no facde will be created.
* @param noWait
*/
protected void addNoWait( LateralCacheNoWait noWait )
@@ -213,11 +213,10 @@
}
/**
- * Send a passive broadcast in response to a request broadcast. Never send a
- * request for a request. We can respond to our own reques, since a request
- * broadcast is not intended as a connection request. We might want to only
- * send messages, so we would send a request, but never a passive broadcast.
- *
+ * Send a passive broadcast in response to a request broadcast. Never send a request for a
+ * request. We can respond to our own reques, since a request broadcast is not intended as a
+ * connection request. We might want to only send messages, so we would send a request, but
+ * never a passive broadcast.
*/
protected void serviceRequestBroadcast()
{
@@ -261,7 +260,6 @@
/**
* Get all the cache names we have facades for.
- *
* @return
*/
protected ArrayList getCacheNames()
@@ -279,9 +277,7 @@
/**
* Allows us to set the daemon status on the clockdaemon
- *
* @author aaronsm
- *
*/
class MyThreadFactory
implements ThreadFactory
@@ -300,10 +296,8 @@
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jcs.engine.behavior.ShutdownObserver#shutdown()
+ /**
+ * Shuts down the receiver.
*/
public void shutdown()
{
@@ -340,8 +334,7 @@
}
/**
- * @param discoveryAddress
- * The discoveryAddress to set.
+ * @param discoveryAddress The discoveryAddress to set.
*/
protected void setDiscoveryAddress( String discoveryAddress )
{
@@ -357,8 +350,7 @@
}
/**
- * @param discoveryPort
- * The discoveryPort to set.
+ * @param discoveryPort The discoveryPort to set.
*/
protected void setDiscoveryPort( int discoveryPort )
{
@@ -374,8 +366,7 @@
}
/**
- * @param servicePort
- * The servicePort to set.
+ * @param servicePort The servicePort to set.
*/
protected void setServicePort( int servicePort )
{
@@ -391,8 +382,7 @@
}
/**
- * @param tCPLateralCacheAttributes
- * The tCPLateralCacheAttributes to set.
+ * @param tCPLateralCacheAttributes The tCPLateralCacheAttributes to set.
*/
public void setTcpLateralCacheAttributes( ITCPLateralCacheAttributes tCPLateralCacheAttributes )
{
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=687478&r1=687477&r2=687478&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 Wed Aug 20 14:44:05 2008
@@ -33,7 +33,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.jcs.auxiliary.AbstractAuxiliaryCache;
+import org.apache.jcs.auxiliary.AbstractAuxiliaryCacheEventLogging;
import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes;
import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient;
@@ -45,7 +45,6 @@
import org.apache.jcs.engine.behavior.IElementAttributes;
import org.apache.jcs.engine.behavior.IElementSerializer;
import org.apache.jcs.engine.behavior.IZombie;
-import org.apache.jcs.engine.logging.behavior.ICacheEvent;
import org.apache.jcs.engine.logging.behavior.ICacheEventLogger;
import org.apache.jcs.engine.stats.StatElement;
import org.apache.jcs.engine.stats.Stats;
@@ -64,7 +63,7 @@
* failover recovery when an error is encountered.
*/
public class RemoteCache
- extends AbstractAuxiliaryCache
+ extends AbstractAuxiliaryCacheEventLogging
implements IRemoteCacheClient
{
/** Don't change. */
@@ -208,29 +207,7 @@
* @param ce
* @throws IOException
*/
- public void update( ICacheElement ce )
- throws IOException
- {
- ICacheEvent cacheEvent = createICacheEvent( ce, ICacheEventLogger.UPDATE_EVENT );
- try
- {
- processUpdate( ce );
- }
- finally
- {
- logICacheEvent( cacheEvent );
- }
- }
-
- /**
- * Serializes the object and then calls update on the remote server with the byte array. The
- * byte array is wrapped in a ICacheElementSerialized. This allows the remote server to operate
- * without any knowledge of caches classes.
- * <p>
- * @param ce
- * @throws IOException
- */
- private void processUpdate( ICacheElement ce )
+ protected void processUpdate( ICacheElement ce )
throws IOException
{
if ( !this.irca.getGetOnly() )
@@ -256,7 +233,8 @@
catch ( Exception ex )
{
// event queue will wait and retry
- handleException( ex, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName(), ICacheEventLogger.UPDATE_EVENT );
+ handleException( ex, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName(),
+ ICacheEventLogger.UPDATE_EVENT );
}
}
else
@@ -281,38 +259,10 @@
* @return ICacheElement, a wrapper around the key, value, and attributes
* @throws IOException
*/
- public ICacheElement get( Serializable key )
+ protected ICacheElement processGet( Serializable key )
throws IOException
{
ICacheElement retVal = null;
- ICacheEvent cacheEvent = createICacheEvent( cacheName, key, ICacheEventLogger.GET_EVENT );
- try
- {
- retVal = processGet( key, retVal );
- }
- finally
- {
- logICacheEvent( cacheEvent );
- }
- return retVal;
- }
-
- /**
- * Synchronously get from the remote cache; if failed, replace the remote handle with a zombie.
- * <p>
- * Use threadpool to timeout if a value is set for GetTimeoutMillis
- * <p>
- * If we are a cluster client, we need to leave the Element in its serialized form. Cluster
- * clients cannot deserialize objects. Cluster clients get ICacheElementSerialized objects from
- * other remote servers.
- * <p>
- * @param key
- * @return ICacheElement, a wrapper around the key, value, and attributes
- * @throws IOException
- */
- private ICacheElement processGet( Serializable key, ICacheElement retVal )
- throws IOException
- {
try
{
if ( usePoolForGet )
@@ -350,30 +300,8 @@
* @param keys
* @return a map of Serializable key to ICacheElement element, or an empty map if there is no
* data in cache for any of these keys
- * @throws IOException
*/
- public Map getMultiple( Set keys )
- throws IOException
- {
- ICacheEvent cacheEvent = createICacheEvent( cacheName, (Serializable) keys, ICacheEventLogger.GETMULTIPLE_EVENT );
- try
- {
- return processGetMultiple( keys );
- }
- finally
- {
- logICacheEvent( cacheEvent );
- }
- }
-
- /**
- * Gets multiple items from the cache based on the given set of keys.
- * <p>
- * @param keys
- * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
- * data in cache for any of these keys
- */
- private Map processGetMultiple( Set keys )
+ protected Map processGetMultiple( Set keys )
throws IOException
{
Map elements = new HashMap();
@@ -477,29 +405,7 @@
* @return boolean, whether or not the item was removed
* @throws IOException
*/
- public boolean remove( Serializable key )
- throws IOException
- {
- ICacheEvent cacheEvent = createICacheEvent( cacheName, key, ICacheEventLogger.REMOVE_EVENT );
- try
- {
- return processRemove( key );
- }
- finally
- {
- logICacheEvent( cacheEvent );
- }
- }
-
- /**
- * Synchronously remove from the remote cache; if failed, replace the remote handle with a
- * zombie.
- * <p>
- * @param key
- * @return boolean, whether or not the item was removed
- * @throws IOException
- */
- private boolean processRemove( Serializable key )
+ protected boolean processRemove( Serializable key )
throws IOException
{
if ( !this.irca.getGetOnly() )
@@ -527,27 +433,19 @@
* <p>
* @throws IOException
*/
- public void removeAll()
+ protected void processRemoveAll()
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( cacheName, "all", ICacheEventLogger.REMOVEALL_EVENT );
- try
+ if ( !this.irca.getGetOnly() )
{
- if ( !this.irca.getGetOnly() )
+ try
{
- try
- {
- remote.removeAll( cacheName, getListenerId() );
- }
- catch ( Exception ex )
- {
- handleException( ex, "Failed to remove all from " + cacheName, ICacheEventLogger.REMOVEALL_EVENT );
- }
+ remote.removeAll( cacheName, getListenerId() );
+ }
+ catch ( Exception ex )
+ {
+ handleException( ex, "Failed to remove all from " + cacheName, ICacheEventLogger.REMOVEALL_EVENT );
}
- }
- finally
- {
- logICacheEvent( cacheEvent );
}
}
@@ -556,29 +454,21 @@
* <p>
* @throws IOException
*/
- public void dispose()
+ protected void processDispose()
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( cacheName, "none", ICacheEventLogger.DISPOSE_EVENT );
+ if ( log.isInfoEnabled() )
+ {
+ log.info( "Disposing of remote cache" );
+ }
try
{
- if ( log.isInfoEnabled() )
- {
- log.info( "Disposing of remote cache" );
- }
- try
- {
- listener.dispose();
- }
- catch ( Exception ex )
- {
- log.error( "Couldn't dispose", ex );
- handleException( ex, "Failed to dispose [" + cacheName + "]", ICacheEventLogger.DISPOSE_EVENT );
- }
+ listener.dispose();
}
- finally
+ catch ( Exception ex )
{
- logICacheEvent( cacheEvent );
+ log.error( "Couldn't dispose", ex );
+ handleException( ex, "Failed to dispose [" + cacheName + "]", ICacheEventLogger.DISPOSE_EVENT );
}
}
@@ -712,7 +602,8 @@
{
try
{
- handleException( e, "Problem propagating events from Zombie Queue to new Remote Service.", "fixCache" );
+ handleException( e, "Problem propagating events from Zombie Queue to new Remote Service.",
+ "fixCache" );
}
catch ( IOException e1 )
{
@@ -740,7 +631,7 @@
throws IOException
{
String message = "Disabling remote cache due to error: " + msg;
-
+
logError( cacheName, "", message );
log.error( message, ex );
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=687478&r1=687477&r2=687478&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 Wed Aug 20 14:44:05 2008
@@ -91,7 +91,7 @@
* @param threadPoolName
*/
public PooledCacheEventQueue( ICacheListener listener, long listenerId, String cacheName, int maxFailure,
- int waitBeforeRetry, String threadPoolName )
+ int waitBeforeRetry, String threadPoolName )
{
if ( listener == null )
{
@@ -117,9 +117,8 @@
}
}
- /*
- * (non-Javadoc)
- * @see org.apache.jcs.engine.behavior.ICacheEventQueue#getQueueType()
+ /**
+ * @return the queue type
*/
public int getQueueType()
{
@@ -127,7 +126,7 @@
}
/**
- * Event Q is emtpy.
+ * Event Q is empty.
*/
public synchronized void stopProcessing()
{
@@ -309,9 +308,8 @@
return getStatistics().toString();
}
- /*
- * (non-Javadoc)
- * @see org.apache.jcs.engine.behavior.ICacheEventQueue#getStatistics()
+ /**
+ * @return IStats
*/
public IStats getStatistics()
{
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheService.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheService.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheService.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheService.java Wed Aug 20 14:44:05 2008
@@ -31,7 +31,7 @@
import org.apache.jcs.engine.behavior.IZombie;
/**
- * Zombie adapter for any cache service. Balks at every call.
+ * Zombie adapter for any cache service. Balks at every call.
*/
public class ZombieCacheService
implements ICacheService, IZombie
@@ -54,7 +54,7 @@
/**
* Does nothing.
* <p>
- * @param item
+ * @param item
*/
public void update( ICacheElement item )
{
@@ -101,28 +101,25 @@
return null;
}
- /*
- * (non-Javadoc)
- * @see org.apache.jcs.engine.behavior.ICacheService#remove(java.lang.String,
- * java.io.Serializable)
+ /**
+ * @param cacheName
+ * @param key
*/
public void remove( String cacheName, Serializable key )
{
// zombies have no inner life
}
- /*
- * (non-Javadoc)
- * @see org.apache.jcs.engine.behavior.ICacheService#removeAll(java.lang.String)
+ /**
+ * @param cacheName
*/
public void removeAll( String cacheName )
{
// zombies have no inner life
}
- /*
- * (non-Javadoc)
- * @see org.apache.jcs.engine.behavior.ICacheService#dispose(java.lang.String)
+ /**
+ * @param cacheName
*/
public void dispose( String cacheName )
{
@@ -130,14 +127,12 @@
return;
}
- /*
- * (non-Javadoc)
- * @see org.apache.jcs.engine.behavior.ICacheService#release()
+ /**
+ * Frees all caches.
*/
public void release()
{
// zombies have no inner life
return;
}
-
}
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheWatch.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheWatch.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheWatch.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheWatch.java Wed Aug 20 14:44:05 2008
@@ -25,20 +25,16 @@
import org.apache.jcs.engine.behavior.ICacheListener;
/**
- * Description of the Class
- *
+ * Zombie Observer.
*/
public class ZombieCacheWatch
implements ICacheObserver, IZombie
{
/**
- * Adds a feature to the CacheListener attribute of the ZombieCacheWatch
- * object
+ * Adds a feature to the CacheListener attribute of the ZombieCacheWatch object
* <p>
- * @param cacheName
- * The feature to be added to the CacheListener attribute
- * @param obj
- * The feature to be added to the CacheListener attribute
+ * @param cacheName The feature to be added to the CacheListener attribute
+ * @param obj The feature to be added to the CacheListener attribute
*/
public void addCacheListener( String cacheName, ICacheListener obj )
{
@@ -46,29 +42,26 @@
}
/**
- * Adds a feature to the CacheListener attribute of the ZombieCacheWatch
- * object
+ * Adds a feature to the CacheListener attribute of the ZombieCacheWatch object
* <p>
- * @param obj
- * The feature to be added to the CacheListener attribute
+ * @param obj The feature to be added to the CacheListener attribute
*/
public void addCacheListener( ICacheListener obj )
{
return;
}
- /*
- * (non-Javadoc)
- * @see org.apache.jcs.engine.behavior.ICacheObserver#removeCacheListener(java.lang.String, org.apache.jcs.engine.behavior.ICacheListener)
+ /**
+ * @param cacheName
+ * @param obj
*/
public void removeCacheListener( String cacheName, ICacheListener obj )
{
return;
}
- /*
- * (non-Javadoc)
- * @see org.apache.jcs.engine.behavior.ICacheObserver#removeCacheListener(org.apache.jcs.engine.behavior.ICacheListener)
+ /**
+ * @param obj
*/
public void removeCacheListener( ICacheListener obj )
{
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java Wed Aug 20 14:44:05 2008
@@ -67,6 +67,7 @@
final static String ELEMENT_ATTRIBUTE_PREFIX = ".elementattributes";
+ /** Can't operate on the interface. */
private CompositeCacheManager compositeCacheManager;
/**
@@ -550,17 +551,17 @@
String auxPrefix = AUXILIARY_PREFIX + auxName;
// CONFIGURE THE EVENT LOGGER
- ICacheEventLogger cacheEventLogger = AuxiliaryCacheConfigurator.parseCacheEventLogger( props, auxName );
+ ICacheEventLogger cacheEventLogger = AuxiliaryCacheConfigurator.parseCacheEventLogger( props, auxPrefix );
// CONFIGURE THE ELEMENT SERIALIZER
- IElementSerializer elementSerializer = AuxiliaryCacheConfigurator.parseElementSerializer( props, auxName );
+ IElementSerializer elementSerializer = AuxiliaryCacheConfigurator.parseElementSerializer( props, auxPrefix );
// Consider putting the compositeCache back in the factory interface
// since the manager may not know about it at this point.
// need to make sure the manager already has the cache
// before the auxiliary is created.
auxCache = auxFac.createCache( auxAttr, compositeCacheManager, cacheEventLogger, elementSerializer );
-
+
return auxCache;
}
}
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/logging/CacheEvent.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/logging/CacheEvent.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/logging/CacheEvent.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/logging/CacheEvent.java Wed Aug 20 14:44:05 2008
@@ -12,6 +12,9 @@
/** Don't change. */
private static final long serialVersionUID = -5913139566421714330L;
+ /** The time at which this object was created. */
+ private long createTime = System.currentTimeMillis();
+
/** The auxiliary or other source of the event. */
private String source;
@@ -107,6 +110,16 @@
return key;
}
+ /**
+ * The time at which this object was created.
+ * <p>
+ * @return the createTime
+ */
+ public long getCreateTime()
+ {
+ return createTime;
+ }
+
/**
* @return reflection toString
*/
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/memory/mru/MRUMemoryCache.java Wed Aug 20 14:44:05 2008
@@ -41,12 +41,11 @@
import org.apache.jcs.engine.stats.behavior.IStats;
/**
- * A SLOW reference management system. The most recently used items move to the
- * front of the list and get spooled to disk if the cache hub is configured to
- * use a disk cache.
+ * A SLOW reference management system. The most recently used items move to the front of the list
+ * and get spooled to disk if the cache hub is configured to use a disk cache.
* <p>
- * This class is mainly for testing the hub. It also shows that use of the
- * Collection LinkedList is far slower than JCS' own double linked list.
+ * This class is mainly for testing the hub. It also shows that use of the Collection LinkedList is
+ * far slower than JCS' own double linked list.
*/
public class MRUMemoryCache
extends AbstractMemoryCache
@@ -193,14 +192,13 @@
}
/**
- * This instructs the memory cache to remove the <i>numberToFree</i>
- * according to its eviction policy. For example, the LRUMemoryCache will
- * remove the <i>numberToFree</i> least recently used items. These will be
- * spooled to disk if a disk auxiliary is available.
+ * This instructs the memory cache to remove the <i>numberToFree</i> according to its eviction
+ * policy. For example, the LRUMemoryCache will remove the <i>numberToFree</i> least recently
+ * used items. These will be spooled to disk if a disk auxiliary is available.
* <p>
* @param numberToFree
- * @return the number that were removed. if you ask to free 5, but there are
- * only 3, you will get 3.
+ * @return the number that were removed. if you ask to free 5, but there are only 3, you will
+ * get 3.
* @throws IOException
*/
public int freeElements( int numberToFree )
@@ -219,11 +217,9 @@
}
/**
- * Get an item from the cache without affecting its last access time or
- * position.
+ * Get an item from the cache without affecting its last access time or position.
* @return Element matching key if found, or null
- * @param key
- * Identifies item to find
+ * @param key Identifies item to find
* @exception IOException
*/
public ICacheElement getQuiet( Serializable key )
@@ -255,9 +251,10 @@
}
/**
- * Gets an item out of the map. If it finds an item, it is removed from the
- * list and then added to the first position in the linked list.
- * @return
+ * Gets an item out of the map. If it finds an item, it is removed from the list and then added
+ * to the first position in the linked list.
+ * <p>
+ * @return ICacheElement or null if none is found.
* @param key
* @exception IOException
*/
@@ -335,7 +332,8 @@
/**
* Removes an item from the cache.
- * @return
+ * <p>
+ * @return true if present
* @param key
* @exception IOException
*/
@@ -448,9 +446,8 @@
}
}
- /*
- * (non-Javadoc)
- * @see org.apache.jcs.engine.memory.MemoryCache#getStatistics()
+ /**
+ * @return IStats
*/
public IStats getStatistics()
{
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/LRUMap.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/LRUMap.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/LRUMap.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/LRUMap.java Wed Aug 20 14:44:05 2008
@@ -153,18 +153,16 @@
return map.containsValue( value );
}
- /*
- * (non-Javadoc)
- * @see java.util.Map#values()
+ /**
+ * @return map.values();
*/
public Collection values()
{
return map.values();
}
- /*
- * (non-Javadoc)
- * @see java.util.Map#putAll(java.util.Map)
+ /**
+ * @param source
*/
public void putAll( Map source )
{
@@ -180,9 +178,9 @@
}
}
- /*
- * (non-Javadoc)
- * @see java.util.Map#get(java.lang.Object)
+ /**
+ * @param key
+ * @return Object
*/
public Object get( Object key )
{
@@ -247,9 +245,9 @@
return ce;
}
- /*
- * (non-Javadoc)
- * @see java.util.Map#remove(java.lang.Object)
+ /**
+ * @param key
+ * @return Object removed
*/
public Object remove( Object key )
{
@@ -271,9 +269,10 @@
return null;
}
- /*
- * (non-Javadoc)
- * @see java.util.Map#put(java.lang.Object, java.lang.Object)
+ /**
+ * @param key
+ * @param value
+ * @return Object
*/
public Object put( Object key, Object value )
{
@@ -653,9 +652,8 @@
return unWrapped;
}
- /*
- * (non-Javadoc)
- * @see java.util.Map#keySet()
+ /**
+ * @return map.keySet();
*/
public Set keySet()
{
Added: jakarta/jcs/trunk/src/test-conf/TestRemoteCacheEventLogging.ccf
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test-conf/TestRemoteCacheEventLogging.ccf?rev=687478&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test-conf/TestRemoteCacheEventLogging.ccf (added)
+++ jakarta/jcs/trunk/src/test-conf/TestRemoteCacheEventLogging.ccf Wed Aug 20 14:44:05 2008
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# #############################################################
+# ################# DEFAULT CACHE REGION #####################
+# sets the default aux value for any non configured caches
+jcs.default=RC
+jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes.MaxObjects=200001
+jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
+jcs.default.cacheattributes.UseMemoryShrinker=true
+jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
+jcs.default.elementattributes.IsEternal=false
+jcs.default.elementattributes.MaxLifeSeconds=700
+jcs.default.elementattributes.IdleTime=1800
+jcs.default.elementattributes.IsSpool=true
+jcs.default.elementattributes.IsRemote=true
+jcs.default.elementattributes.IsLateral=true
+
+
+jcs.auxiliary.RC=org.apache.jcs.auxiliary.remote.RemoteCacheFactory
+jcs.auxiliary.RC.attributes=org.apache.jcs.auxiliary.remote.RemoteCacheAttributes
+jcs.auxiliary.RC.attributes.FailoverServers=localhost:1101
+jcs.auxiliary.RC.attributes.LocalPort=1201
+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=-1
+# jcs.auxiliary.RC.attributes.ThreadPoolName=remote_cache_client
+# jcs.auxiliary.RC.attributes.GetOnly=false
+jcs.auxiliary.RC.cacheeventlogger=org.apache.jcs.engine.logging.MockCacheEventLogger
\ No newline at end of file
Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/AuxiliaryCacheConfiguratorUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/AuxiliaryCacheConfiguratorUnitTest.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/AuxiliaryCacheConfiguratorUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/AuxiliaryCacheConfiguratorUnitTest.java Wed Aug 20 14:44:05 2008
@@ -4,8 +4,8 @@
import junit.framework.TestCase;
-import org.apache.jcs.engine.control.MockCacheEventLogger;
import org.apache.jcs.engine.control.MockElementSerializer;
+import org.apache.jcs.engine.logging.MockCacheEventLogger;
/** Unit tests for the auxiliary cache configurator. */
public class AuxiliaryCacheConfiguratorUnitTest
Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCache.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCache.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCache.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCache.java Wed Aug 20 14:44:05 2008
@@ -40,6 +40,7 @@
public class MockAuxiliaryCache
implements AuxiliaryCache
{
+ /** Don't change */
private static final long serialVersionUID = 1L;
/** Can setup the cache type */
@@ -48,6 +49,12 @@
/** Can setup status */
public int status = CacheConstants.STATUS_ALIVE;
+ /** The event logger */
+ public ICacheEventLogger cacheEventLogger;
+
+ /** IElementSerializer elementSerializer */
+ public IElementSerializer elementSerializer;
+
/**
* @param ce
* @throws IOException
@@ -192,15 +199,19 @@
return null;
}
+ /**
+ * @param cacheEventLogger
+ */
public void setCacheEventLogger( ICacheEventLogger cacheEventLogger )
{
- // TODO Auto-generated method stub
-
+ this.cacheEventLogger = cacheEventLogger;
}
+ /**
+ * @param elementSerializer
+ */
public void setElementSerializer( IElementSerializer elementSerializer )
{
- // TODO Auto-generated method stub
-
+ this.elementSerializer = elementSerializer;
}
}
Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCacheAttributes.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCacheAttributes.java?rev=687478&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCacheAttributes.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCacheAttributes.java Wed Aug 20 14:44:05 2008
@@ -0,0 +1,20 @@
+package org.apache.jcs.auxiliary;
+
+/** For testing. */
+public class MockAuxiliaryCacheAttributes
+ extends AbstractAuxiliaryCacheAttributes
+{
+ /** Don't change. */
+ private static final long serialVersionUID = 1091238902450504108L;
+
+ /**
+ * Doesn't really copy
+ * <p>
+ * @return this
+ */
+ public AuxiliaryCacheAttributes copy()
+ {
+ return this;
+ }
+
+}
Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCacheFactory.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCacheFactory.java?rev=687478&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCacheFactory.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCacheFactory.java Wed Aug 20 14:44:05 2008
@@ -0,0 +1,47 @@
+package org.apache.jcs.auxiliary;
+
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
+import org.apache.jcs.engine.behavior.IElementSerializer;
+import org.apache.jcs.engine.logging.behavior.ICacheEventLogger;
+
+/** For testing */
+public class MockAuxiliaryCacheFactory
+ implements AuxiliaryCacheFactory
+{
+ /** the name of the aux */
+ public String name = "MockAuxiliaryCacheFactory";
+
+ /**
+ * Creates a mock aux.
+ * <p>
+ * @param attr
+ * @param cacheMgr
+ * @param cacheEventLogger
+ * @param elementSerializer
+ * @return AuxiliaryCache
+ */
+ public AuxiliaryCache createCache( AuxiliaryCacheAttributes attr, ICompositeCacheManager cacheMgr,
+ ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
+ {
+ MockAuxiliaryCache auxCache = new MockAuxiliaryCache();
+ auxCache.setCacheEventLogger( cacheEventLogger );
+ auxCache.setElementSerializer( elementSerializer );
+ return auxCache;
+ }
+
+ /**
+ * @return String
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * @param s
+ */
+ public void setName( String s )
+ {
+ this.name = s;
+ }
+}
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=687478&r1=687477&r2=687478&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 Wed Aug 20 14:44:05 2008
@@ -26,12 +26,14 @@
import junit.framework.TestCase;
+import org.apache.jcs.auxiliary.MockCacheEventLogger;
import org.apache.jcs.engine.CacheElement;
import org.apache.jcs.engine.ElementAttributes;
import org.apache.jcs.engine.behavior.ICacheElement;
import org.apache.jcs.engine.behavior.IElementAttributes;
import org.apache.jcs.engine.control.group.GroupAttrName;
import org.apache.jcs.engine.control.group.GroupId;
+import org.apache.jcs.utils.timing.SleepUtil;
/**
* Tests for common functionality.
@@ -558,4 +560,147 @@
GroupId gid = new GroupId( cacheName, group );
return new GroupAttrName( gid, name );
}
+
+
+ /**
+ * Verify event log calls.
+ * <p>
+ * @throws Exception
+ */
+ public void testUpdate_EventLogging_simple()
+ throws Exception
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes();
+ cattr.setCacheName( "testUpdate_EventLogging_simple" );
+ cattr.setMaxKeySize( 100 );
+ cattr.setDiskPath( "target/test-sandbox/IndexDiskCacheUnitTestCEL" );
+ IndexedDiskCache diskCache = new IndexedDiskCache( cattr );
+ diskCache.doRemoveAll();
+
+ MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+ diskCache.setCacheEventLogger( cacheEventLogger );
+
+ ICacheElement item = new CacheElement( "region", "key", "value" );
+
+ // DO WORK
+ 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 );
+ }
+
+ /**
+ * Verify event log calls.
+ * <p>
+ * @throws Exception
+ */
+ public void testGet_EventLogging_simple()
+ throws Exception
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes();
+ cattr.setCacheName( "testGet_EventLogging_simple" );
+ cattr.setMaxKeySize( 100 );
+ cattr.setDiskPath( "target/test-sandbox/IndexDiskCacheUnitTestCEL" );
+ IndexedDiskCache diskCache = new IndexedDiskCache( cattr );
+ diskCache.doRemoveAll();
+
+ MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+ diskCache.setCacheEventLogger( cacheEventLogger );
+
+ // DO WORK
+ diskCache.get( "key" );
+
+ // VERIFY
+ assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls );
+ assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls );
+ }
+
+ /**
+ * Verify event log calls.
+ * <p>
+ * @throws Exception
+ */
+ public void testGetMultiple_EventLogging_simple()
+ throws Exception
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes();
+ cattr.setCacheName( "testGetMultiple_EventLogging_simple" );
+ cattr.setMaxKeySize( 100 );
+ cattr.setDiskPath( "target/test-sandbox/IndexDiskCacheUnitTestCEL" );
+ IndexedDiskCache diskCache = new IndexedDiskCache( cattr );
+ diskCache.doRemoveAll();
+
+ MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+ diskCache.setCacheEventLogger( cacheEventLogger );
+
+ Set keys = new HashSet();
+ keys.add( "junk" );
+
+ // DO WORK
+ diskCache.getMultiple( keys );
+
+ // VERIFY
+ assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls );
+ assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls );
+ }
+
+ /**
+ * Verify event log calls.
+ * <p>
+ * @throws Exception
+ */
+ public void testRemove_EventLogging_simple()
+ throws Exception
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes();
+ cattr.setCacheName( "testRemoveAll_EventLogging_simple" );
+ cattr.setMaxKeySize( 100 );
+ cattr.setDiskPath( "target/test-sandbox/IndexDiskCacheUnitTestCEL" );
+ IndexedDiskCache diskCache = new IndexedDiskCache( cattr );
+ diskCache.doRemoveAll();
+
+ MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+ diskCache.setCacheEventLogger( cacheEventLogger );
+
+ // DO WORK
+ diskCache.remove( "key" );
+
+ // VERIFY
+ assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls );
+ assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls );
+ }
+
+ /**
+ * Verify event log calls.
+ * <p>
+ * @throws Exception
+ */
+ public void testRemoveAll_EventLogging_simple()
+ throws Exception
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes();
+ cattr.setCacheName( "testRemoveAll_EventLogging_simple" );
+ cattr.setMaxKeySize( 100 );
+ cattr.setDiskPath( "target/test-sandbox/IndexDiskCacheUnitTestCEL" );
+ IndexedDiskCache diskCache = new IndexedDiskCache( cattr );
+ diskCache.doRemoveAll();
+
+ MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+ diskCache.setCacheEventLogger( cacheEventLogger );
+
+ // DO WORK
+ diskCache.remove( "key" );
+
+ // VERIFY
+ assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls );
+ assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls );
+ }
}
Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java Wed Aug 20 14:44:05 2008
@@ -35,17 +35,13 @@
/**
* Runs basic tests for the JDBC disk cache.
- *
+ *<p>
* @author Aaron Smuts
- *
*/
public class JDBCDiskCacheUnitTest
extends TestCase
{
-
- /**
- * Test setup
- */
+ /** Test setup */
public void setUp()
{
JCS.setConfigFilename( "/TestJDBCDiskCache.ccf" );
@@ -53,7 +49,6 @@
/**
* Test the basic JDBC disk cache functionality with a hsql backing.
- *
* @throws Exception
*/
public void testSimpleJDBCPutGetWithHSQL()
@@ -79,15 +74,12 @@
}
/**
- * Adds items to cache, gets them, and removes them. The item count is more
- * than the size of the memory cache, so items should spool to disk.
- *
- * @param region
- * Name of the region to access
+ * Adds items to cache, gets them, and removes them. The item count is more than the size of the
+ * memory cache, so items should spool to disk.
+ * <p>
+ * @param region Name of the region to access
* @param items
- *
- * @exception Exception
- * If an error occurs
+ * @exception Exception If an error occurs
*/
public void runTestForRegion( String region, int items )
throws Exception
@@ -148,7 +140,6 @@
/**
* SETUP TABLE FOR CACHE
- *
* @param cConn
*/
void setupTABLE( Connection cConn )
Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/MockLateralCache.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/MockLateralCache.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/MockLateralCache.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/MockLateralCache.java Wed Aug 20 14:44:05 2008
@@ -29,14 +29,12 @@
/**
* For testing things that need a lateral cache
- *
- * @author Aaron Smuts
- *
*/
public class MockLateralCache
extends LateralCache
implements ICache
{
+ /** junk */
private static final long serialVersionUID = 1L;
/**
@@ -47,12 +45,10 @@
super( cattr );
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jcs.engine.behavior.ICache#update(org.apache.jcs.engine.behavior.ICacheElement)
+ /**
+ * Nothing.
*/
- public void update( ICacheElement ce )
+ protected void processUpdate( ICacheElement ce )
throws IOException
{
// TODO Auto-generated method stub
@@ -64,7 +60,7 @@
*
* @see org.apache.jcs.engine.behavior.ICache#get(java.io.Serializable)
*/
- public ICacheElement get( Serializable key )
+ protected ICacheElement processGet( Serializable key )
throws IOException
{
// TODO Auto-generated method stub
@@ -76,7 +72,7 @@
*
* @see org.apache.jcs.engine.behavior.ICache#remove(java.io.Serializable)
*/
- public boolean remove( Serializable key )
+ protected boolean processRemove( Serializable key )
throws IOException
{
// TODO Auto-generated method stub
@@ -88,7 +84,7 @@
*
* @see org.apache.jcs.engine.behavior.ICache#removeAll()
*/
- public void removeAll()
+ public void processRemoveAll()
throws IOException
{
// TODO Auto-generated method stub
@@ -100,7 +96,7 @@
*
* @see org.apache.jcs.engine.behavior.ICache#dispose()
*/
- public void dispose()
+ public void processDispose()
throws IOException
{
// TODO Auto-generated method stub
Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryUnitTest.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/UDPDiscoveryUnitTest.java Wed Aug 20 14:44:05 2008
@@ -24,6 +24,7 @@
import junit.framework.TestCase;
import org.apache.jcs.JCS;
+import org.apache.jcs.auxiliary.MockCacheEventLogger;
import org.apache.jcs.auxiliary.lateral.LateralCache;
import org.apache.jcs.auxiliary.lateral.LateralCacheAttributes;
import org.apache.jcs.auxiliary.lateral.LateralCacheNoWait;
@@ -32,6 +33,7 @@
import org.apache.jcs.auxiliary.lateral.socket.tcp.TCPLateralCacheAttributes;
import org.apache.jcs.engine.behavior.ICompositeCacheManager;
import org.apache.jcs.engine.control.CompositeCacheManager;
+import org.apache.jcs.utils.serialization.StandardSerializer;
/**
*
@@ -85,7 +87,7 @@
ICompositeCacheManager cacheMgr = CompositeCacheManager.getInstance();
// create the service
- UDPDiscoveryService service = new UDPDiscoveryService( lac.getUdpDiscoveryAddr(), lac.getUdpDiscoveryPort(), lac.getTcpListenerPort(), cacheMgr );
+ UDPDiscoveryService service = new UDPDiscoveryService( lac.getUdpDiscoveryAddr(), lac.getUdpDiscoveryPort(), lac.getTcpListenerPort(), cacheMgr, new MockCacheEventLogger(), new StandardSerializer() );
service.setTcpLateralCacheAttributes( lac );
// create a no wait facade for the service
@@ -100,7 +102,7 @@
service.addNoWaitFacade( lcnwf, "testCache1" );
// create a receiver with the service
- UDPDiscoveryReceiver receiver = new UDPDiscoveryReceiver( service, "228.5.6.7", 6789, cacheMgr );
+ UDPDiscoveryReceiver receiver = new UDPDiscoveryReceiver( service, "228.5.6.7", 6789, cacheMgr, new MockCacheEventLogger(), new StandardSerializer() );
Thread t = new Thread( receiver );
t.start();
Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheConfiguratorUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheConfiguratorUnitTest.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheConfiguratorUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheConfiguratorUnitTest.java Wed Aug 20 14:44:05 2008
@@ -4,25 +4,51 @@
import junit.framework.TestCase;
+import org.apache.jcs.auxiliary.AuxiliaryCacheConfigurator;
+import org.apache.jcs.auxiliary.MockAuxiliaryCache;
+import org.apache.jcs.auxiliary.MockAuxiliaryCacheAttributes;
+import org.apache.jcs.auxiliary.MockAuxiliaryCacheFactory;
+import org.apache.jcs.engine.CompositeCacheAttributes;
+import org.apache.jcs.engine.ElementAttributes;
+import org.apache.jcs.engine.logging.MockCacheEventLogger;
+
/** Unit tests for the configurator. */
public class CompositeCacheConfiguratorUnitTest
extends TestCase
{
/**
- * Verify that we can parse the ElementSerializer.
+ * Verify that we can parse the event logger correctly
*/
- public void testParseElementSerializer_Null()
+ public void testParseAuxiliary_CacheEventLogger_Normal()
{
// SETUP
+ String regionName = "MyRegion";
+
+ String auxName = "MockAux";
+ String auxPrefix = "jcs.auxiliary." + auxName;
+ String auxiliaryClassName = MockAuxiliaryCacheFactory.class.getCanonicalName();
+ String eventLoggerClassName = MockCacheEventLogger.class.getCanonicalName();
+ String auxiliaryAttributeClassName = MockAuxiliaryCacheAttributes.class.getCanonicalName();
+
Properties props = new Properties();
+ props.put( auxPrefix, auxiliaryClassName );
+ props.put( auxPrefix + CompositeCacheConfigurator.ATTRIBUTE_PREFIX, auxiliaryAttributeClassName );
+ props.put( auxPrefix + AuxiliaryCacheConfigurator.CACHE_EVENT_LOGGER_PREFIX, eventLoggerClassName );
+
+ System.out.print( props );
+
+ CompositeCacheManager manager = CompositeCacheManager.getUnconfiguredInstance();
+
+ CompositeCacheConfigurator configurator = new CompositeCacheConfigurator( manager );
- CompositeCacheConfigurator configurator = new CompositeCacheConfigurator( CompositeCacheManager
- .getUnconfiguredInstance() );
+ CompositeCache cache = new CompositeCache( regionName, new CompositeCacheAttributes(), new ElementAttributes() );
// DO WORK
- //MockElementSerializer result = (MockElementSerializer) configurator.parseElementSerializer( props, "junk" );
+ MockAuxiliaryCache result = (MockAuxiliaryCache) configurator
+ .parseAuxiliary( cache, props, auxName, regionName );
// VERIFY
- //assertNull( "Should not have a logger.", result );
+ assertNotNull( "Should have an auxcache.", result );
+ assertNotNull( "Should have an event logger.", result.cacheEventLogger );
}
}
Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCompositeCacheManager.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCompositeCacheManager.java?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCompositeCacheManager.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCompositeCacheManager.java Wed Aug 20 14:44:05 2008
@@ -23,23 +23,24 @@
import org.apache.jcs.engine.ElementAttributes;
import org.apache.jcs.engine.behavior.ICompositeCacheManager;
-/**
- */
+/** For testing. */
public class MockCompositeCacheManager
implements ICompositeCacheManager
{
-
+ /** The cache that was returned. */
private CompositeCache cache;
- /* (non-Javadoc)
- * @see org.apache.jcs.engine.behavior.ICompositeCacheManager#getCache(java.lang.String)
+ /**
+ * @param cacheName
+ * @return Returns a CompositeCache
*/
public CompositeCache getCache( String cacheName )
{
if ( cache == null )
{
System.out.println( "Creating mock cache" );
- CompositeCache newCache = new CompositeCache( cacheName, new CompositeCacheAttributes(), new ElementAttributes() );
+ CompositeCache newCache = new CompositeCache( cacheName, new CompositeCacheAttributes(),
+ new ElementAttributes() );
this.setCache( newCache );
}
return cache;
@@ -60,5 +61,4 @@
{
return cache;
}
-
}
Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/logging/MockCacheEventLogger.java (from r686881, jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCacheEventLogger.java)
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/logging/MockCacheEventLogger.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/engine/logging/MockCacheEventLogger.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCacheEventLogger.java&r1=686881&r2=687478&rev=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/MockCacheEventLogger.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/logging/MockCacheEventLogger.java Wed Aug 20 14:44:05 2008
@@ -1,4 +1,4 @@
-package org.apache.jcs.engine.control;
+package org.apache.jcs.engine.logging;
import java.io.Serializable;
Propchange: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/logging/MockCacheEventLogger.java
------------------------------------------------------------------------------
svn:mergeinfo =
Added: jakarta/jcs/trunk/xdocs/CacheEventLogging.xml
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/xdocs/CacheEventLogging.xml?rev=687478&view=auto
==============================================================================
--- jakarta/jcs/trunk/xdocs/CacheEventLogging.xml (added)
+++ jakarta/jcs/trunk/xdocs/CacheEventLogging.xml Wed Aug 20 14:44:05 2008
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ -->
+<document>
+ <properties>
+ <title>Cache Event Logging</title>
+ <author email="ASmuts@apache.com">Aaron Smuts</author>
+ </properties>
+ <body>
+ <section name="Cache Event Logging">
+ <p> JCS allows you to implement custom event loggers. Most of the
+ auxiliaries will log ICacheEvents (eg. update, get, getMultiple, remove,
+ removeAll, and dispose) to an injected event logger. By default the
+ log calls balk. But if you inject a logger, you can add monitoring
+ to any auxiliary. Most auxiliaries also log key application events
+ and critical errors to the same logger.</p>
+ <p>
+ To inject a custom event logger, you simply need to implement the
+ <code>org.apache.jcs.engine.logging.behavior.ICacheEventLogger
+ </code>
+ interface and add a couple of lines to the cache.ccf file.
+ </p>
+ <p> During configuration, JCS will look for event loggers configured
+ for each auxiliary. JCS will set any custom properties. For
+ instance, to add debug event logging to a remote cache client, you
+ could do the following:</p>
+ <source><![CDATA[
+ . . .
+ jcs.auxiliary.RC=org.apache.jcs.auxiliary.remote.RemoteCacheFactory
+jcs.auxiliary.RC.attributes=org.apache.jcs.auxiliary.remote.RemoteCacheAttributes
+jcs.auxiliary.RC.attributes.FailoverServers=localhost:1101,localhost:1102
+jcs.auxiliary.RC.attributes.LocalPort=1201
+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=500
+jcs.auxiliary.RC.attributes.ThreadPoolName=remote_cache_client
+jcs.auxiliary.RC.attributes.GetOnly=false
+jcs.auxiliary.RC.cacheeventlogger=org.apache.jcs.engine.logging.CacheEventLoggerDebugLoggerImpl
+jcs.auxiliary.RC.cacheeventlogger.attributes.logCategoryName=test.RCCEventLogCategory
+ . . .
+ ]]></source>
+ <p> The attribute "logCateoryName" is a property of this
+ implementation. You can configure any properties on your
+ implementation in the same way.</p>
+ </section>
+ </body>
+</document>
\ No newline at end of file
Modified: jakarta/jcs/trunk/xdocs/RegionProperties.xml
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/xdocs/RegionProperties.xml?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/xdocs/RegionProperties.xml (original)
+++ jakarta/jcs/trunk/xdocs/RegionProperties.xml Wed Aug 20 14:44:05 2008
@@ -136,7 +136,7 @@
<td>60</td>
</tr>
<tr>
- <td>DiskUsagePattern</td>
+ <td>DiskUsagePatternName</td>
<td>
SWAP is the default. Under the swap pattern,
data is only put to disk when the max memory
@@ -153,7 +153,7 @@
disk. If you are using the JDBC disk cache
for instance, you can put all the items on
disk while using the memory cache for
- performance, and not worry about lossing
+ performance, and not worry about losing
data from a system crash or improper
shutdown. Also, since all items are on disk,
there is no need to swap to disk. This
@@ -189,7 +189,7 @@
If you specify that elements within a region
are not eternal, then you can set the max
life seconds. If this is exceeded the
- elmenets will be removed passively when a
+ elements will be removed passively when a
client tries to retrieve them. If you are
using a memory shrinker, then the items can
be removed actively.
Modified: jakarta/jcs/trunk/xdocs/navigation.xml
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/xdocs/navigation.xml?rev=687478&r1=687477&r2=687478&view=diff
==============================================================================
--- jakarta/jcs/trunk/xdocs/navigation.xml (original)
+++ jakarta/jcs/trunk/xdocs/navigation.xml Wed Aug 20 14:44:05 2008
@@ -59,6 +59,8 @@
</item>
<item name="Auxiliary" href="/Plugins.html"
collapse="true">
+ <item name="Cache Event Logging"
+ href="/CacheEventLogging.html" />
<item name="Indexed Disk Cache"
href="/IndexedDiskAuxCache.html" />
<item name="Indexed Disk Properties"
---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org