Author: asmuts
Date: Sun Aug 20 20:49:23 2006
New Revision: 433139
URL: http://svn.apache.org/viewvc?rev=433139&view=rev
Log:
On shutdown the cache will only send memory items to disk auxiliries and not
other types on shutdown. It no longer does this via an iterator, it does it
via the freeMemoryElements method on the memory cache itself. This has the
advantage of pushing the items to disk via the overflow chanel. The overflow
chanel has the disk update pattern logic. If the cache is running in disk mode
SWAP, then the items in memory will go to disk, otherwise they will not. This
makes disk shutdown faster.
I added unit tests for the composite cache manager shutdown that verify the
behavior.
Formatted several other classes.
Added:
jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/AuxiliaryCacheMockImpl.java
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java
Modified:
jakarta/jcs/trunk/src/conf/cacheRC.ccf
jakarta/jcs/trunk/src/conf/log4j.properties
jakarta/jcs/trunk/src/conf/remote.cache.ccf
jakarta/jcs/trunk/src/conf/remote.cache2.ccf
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteUtils.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerInfo.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java
jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MemoryCacheMockImpl.java
jakarta/jcs/trunk/xdocs/IndexedDiskAuxCache.xml
jakarta/jcs/trunk/xdocs/IndexedDiskCacheProperties.xml
jakarta/jcs/trunk/xdocs/RemoteAuxCache.xml
jakarta/jcs/trunk/xdocs/changes.xml
Modified: jakarta/jcs/trunk/src/conf/cacheRC.ccf
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/conf/cacheRC.ccf?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/conf/cacheRC.ccf (original)
+++ jakarta/jcs/trunk/src/conf/cacheRC.ccf Sun Aug 20 20:49:23 2006
@@ -131,8 +131,7 @@
# 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.FailoverServers=localhost:1101
-#,localhost:1102
+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
Modified: jakarta/jcs/trunk/src/conf/log4j.properties
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/conf/log4j.properties?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/conf/log4j.properties (original)
+++ jakarta/jcs/trunk/src/conf/log4j.properties Sun Aug 20 20:49:23 2006
@@ -8,7 +8,7 @@
# RF --file appender
log4j.appender.RF=org.apache.log4j.RollingFileAppender
-log4j.appender.RF.File=I:/dev/jakarta-turbine-jcs/src/scripts/primary.log
+log4j.appender.RF.File=server.log
log4j.appender.RF.layout=org.apache.log4j.PatternLayout
log4j.appender.RF.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
@@ -43,6 +43,7 @@
#log4j.category.org.apache.jcs.auxiliary.remote.RemoteCacheFailoverRunner=INFO
#log4j.category.org.apache.jcs.auxiliary.remote.RemoteCacheListener=DEBUG
#log4j.category.org.apache.jcs.auxiliary.remote.RemoteCacheManager=INFO
+log4j.category.org.apache.jcs.auxiliary.remote.server.RemoteCacheServer=DEBUG
#log4j.category.org.apache.jcs.auxiliary.remote.server=INFO
#log4j.category.org.apache.jcs.utils=WARN,WF
Modified: jakarta/jcs/trunk/src/conf/remote.cache.ccf
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/conf/remote.cache.ccf?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/conf/remote.cache.ccf (original)
+++ jakarta/jcs/trunk/src/conf/remote.cache.ccf Sun Aug 20 20:49:23 2006
@@ -42,7 +42,7 @@
jcs.auxiliary.RCluster.attributes=org.apache.jcs.auxiliary.remote.RemoteCacheAttributes
jcs.auxiliary.RCluster.attributes.RemoteTypeName=CLUSTER
jcs.auxiliary.RCluster.attributes.RemoveUponRemotePut=false
-#jcs.auxiliary.RCluster.attributes.ClusterServers=localhost:1102
+jcs.auxiliary.RCluster.attributes.ClusterServers=localhost:1102
jcs.auxiliary.RCluster.attributes.GetOnly=false
jcs.auxiliary.RCluster.attributes.LocalClusterConsistency=true
Modified: jakarta/jcs/trunk/src/conf/remote.cache2.ccf
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/conf/remote.cache2.ccf?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/conf/remote.cache2.ccf (original)
+++ jakarta/jcs/trunk/src/conf/remote.cache2.ccf Sun Aug 20 20:49:23 2006
@@ -49,6 +49,6 @@
# disk cache
jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
-jcs.auxiliary.DC.attributes.DiskPath=@project_home@/raf/remote
+jcs.auxiliary.DC.attributes.DiskPath=@project_home@/raf/remote-rc2
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteUtils.java
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteUtils.java?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteUtils.java
(original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteUtils.java
Sun Aug 20 20:49:23 2006
@@ -31,7 +31,6 @@
/**
* This class provides some basic utilities for doing things such as starting
* the registry properly.
- *
*/
public class RemoteUtils
{
@@ -45,9 +44,9 @@
/**
* Creates and exports a registry on the specified port of the local host.
- *
+ * <p>
* @param port
- * @return
+ * @return the port the registry was started on
* @throws RemoteException
*/
public static int createRegistry( int port )
@@ -78,9 +77,9 @@
/**
* Loads properties for the named props file.
- *
+ * <p>
* @param propFile
- * @return
+ * @return The properties object for the file
* @throws IOException
*/
public static Properties loadProps( String propFile )
@@ -119,7 +118,6 @@
catch ( Exception ex )
{
log.error( "Error loading remote properties, for file name [" +
propFile + "]", ex );
- // ignore;
}
finally
{
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
---
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
(original)
+++
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
Sun Aug 20 20:49:23 2006
@@ -49,17 +49,17 @@
* This class provides remote cache services. The remote cache server
propagates
* events from local caches to other local caches. It can also store cached
* data, making it available to new clients.
- *
+ * <p>
* Remote cache servers can be clustered. If the cache used by this remote
cache
* is configured to use a remote cache of type cluster, the two remote caches
* will communicate with each other. Remote and put requests can be sent from
* one remote to another. If they are configured to broadcast such event to
* their client, then remove an puts can be sent to all locals in the cluster.
- * However, get requests are not made between clustered servers. You can setup
+ * <p>
+ * Get requests are made between clustered servers if AllowClusterGet is true.
You can setup
* several clients to use one remote server and several to use another. The get
* locad will be distributed between the two servers. Since caches are usually
* high get and low put, this should allow you to scale.
- *
*/
class RemoteCacheServer
extends UnicastRemoteObject
@@ -97,7 +97,7 @@
/**
* Constructor for the RemoteCacheServer object. Thiks initializes the
* server with the values from the config file.
- *
+ * <p>
* @param rcsa
* @throws RemoteException
* @exception IOException
@@ -111,8 +111,8 @@
}
/**
- * Initialize the RMI Cache Server from a proeprties file.
- *
+ * Initialize the RMI Cache Server from a properties file.
+ * <p>
* @param prop
*/
private void init( String prop )
@@ -131,7 +131,7 @@
/**
* Subclass can override this method to create the specific cache manager.
- *
+ * <p>
* @param prop
* The anem of the configuration file.
* @return The cache hub configured with this configuration file.
@@ -154,7 +154,7 @@
/**
* Returns the cache lsitener for the specified cache. Creates the cache
and
* the cache descriptor if they do not already exist.
- *
+ * <p>
* @param cacheName
* @return The cacheListeners value
*/
@@ -178,7 +178,7 @@
/**
* Gets the clusterListeners attribute of the RemoteCacheServer object.
- *
+ * <p>
* @todo may be able to remove this
*
* @param cacheName
@@ -202,17 +202,14 @@
return cacheListeners;
}
- // ///////////////////// Implements the ICacheService interface.
- // //////////////////
/**
* Puts a cache bean to the remote cache and notifies all listeners which
* <br>
- *
* <ol>
* <li>have a different listener id than the originating host;
* <li>are currently subscribed to the related cache.
* </ol>
- *
+ * <p>
* @param item
* @throws IOException
*
@@ -258,7 +255,7 @@
* you can scale a bit with a cluster configuration. Puts and removes will
* be broadcasted to all clients, but the get load on a remote server can
be
* reduced.
- *
+ * <p>
* @param item
* @param requesterId
* @throws IOException
@@ -407,8 +404,7 @@
* Basically, this makes sure that a request from a particular local cache,
* identified by its listener id, does not result in a call to that same
* listener.
- *
- *
+ * <p>
* @param cacheListeners
* @param requesterId
* @return The eventQList value
@@ -456,7 +452,7 @@
/**
* Returns a cache value from the specified remote cache; or null if the
* cache or key does not exist.
- *
+ * <p>
* @param cacheName
* @param key
* @return ICacheElement
@@ -474,7 +470,7 @@
* <p>
* Adding the requestor id, allows the cache to determine the sournce of
the
* get.
- *
+ * <p>
* @param cacheName
* @param key
* @param requesterId
@@ -539,7 +535,7 @@
{
if ( log.isDebugEnabled() )
{
- log.debug( "Get NOT from cluster, NOT allowing a get from
other auxiliaries for the region." );
+ log.debug( "NonLocalGet. fromCluster [" + fromCluster + "]
AllowClusterGet [" + this.rcsa.getAllowClusterGet() + "]" );
}
element = c.get( key );
}
@@ -551,7 +547,7 @@
if ( log.isDebugEnabled() )
{
- log.debug( "Allowing a get from other auxiliaries for the
region." );
+ log.debug( "LocalGet. fromCluster [" + fromCluster + "]
AllowClusterGet [" + this.rcsa.getAllowClusterGet() + "]" );
}
element = c.localGet( key );
}
@@ -561,7 +557,7 @@
/**
* Gets the set of keys of objects currently in the group.
- *
+ * <p>
* @param cacheName
* @param group
* @return A Set of group keys
@@ -589,7 +585,7 @@
/**
* Removes the given key from the specified remote cache. Defaults the
* listener id to 0.
- *
+ * <p>
* @param cacheName
* @param key
* @throws IOException
@@ -603,7 +599,7 @@
/**
* Remove the key from the cache region and don't tell the source listener
* about it.
- *
+ * <p>
* @param cacheName
* @param key
* @param requesterId
@@ -678,7 +674,7 @@
/**
* Remove all keys from the sepcified remote cache.
- *
+ * <p>
* @param cacheName
* @throws IOException
*/
@@ -690,7 +686,7 @@
/**
* Remove all keys from the sepcified remote cache.
- *
+ * <p>
* @param cacheName
* @param requesterId
* @throws IOException
@@ -798,7 +794,7 @@
/**
* Frees all remote caches.
- *
+ * <p>
* @throws IOException
*/
public void release()
@@ -821,11 +817,9 @@
return;
}
- // ///////////////////// Implements the ICacheObserver interface.
- // //////////////////
/**
* Removes dead event queues. Should clean out deregistered listeners.
- *
+ * <p>
* @param eventQMap
*/
private static void cleanupEventQMap( Map eventQMap )
@@ -855,7 +849,7 @@
* <p>
* If the client id is 0, then the remote cache server will increment it's
* local count and assign an id to the client.
- *
+ * <p>
* @param cacheName
* the specified remote cache.
* @param listener
@@ -1050,9 +1044,6 @@
return;
}
- // ///////////////////// Implements the ICacheServiceAdmin interface.
- // //////////////////
-
/**
* Shuts down the remote server.
* <p>
@@ -1065,8 +1056,8 @@
}
/**
- * Shuts down a server at a particular host and port.
- *
+ * Shuts down a server at a particular host and port. Then it calls
shutdown on the cache itself.
+ * <p>
* @param host
* @param port
* @throws IOException
@@ -1079,11 +1070,9 @@
log.info( "Received shutdown request. Shutting down server." );
}
RemoteCacheServerFactory.shutdownImpl( host, port );
+ this.cacheManager.shutDown();
}
- // ///////////////////// Implements the Unreferenced interface.
- // //////////////////
-
/**
* Called by the RMI runtime sometime after the runtime determines that the
* reference list, the list of clients referencing the remote object,
@@ -1100,7 +1089,7 @@
/**
* Returns the next generated listener id [0,255].
- *
+ * <p>
* @return the listener id of a client. This should be unique for this
* server.
*/
@@ -1127,13 +1116,12 @@
id = ++listenerId[0];
}
}
- // ( long ) ( id & 0xff );
return id;
}
/**
- * Gets the stats attribute of the RemoteCacheServer object
- *
+ * Gets the stats attribute of the RemoteCacheServer object.
+ * <p>
* @return The stats value
* @throws IOException
*/
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
---
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java
(original)
+++
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java
Sun Aug 20 20:49:23 2006
@@ -1,36 +1,26 @@
package org.apache.jcs.auxiliary.remote.server;
/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed 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.
+ * Copyright 2001-2004 The Apache Software Foundation. Licensed 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.
*/
import org.apache.jcs.auxiliary.AbstractAuxiliaryCacheAttributes;
import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
-
-import
org.apache.jcs.auxiliary.remote.server.behavior.IRemoteCacheServerAttributes;
import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheConstants;
+import
org.apache.jcs.auxiliary.remote.server.behavior.IRemoteCacheServerAttributes;
/**
* These attributes are used to configure the remote cache server.
- *
*/
public class RemoteCacheServerAttributes
extends AbstractAuxiliaryCacheAttributes
implements IRemoteCacheServerAttributes
{
-
private static final long serialVersionUID = -2741662082869155365L;
private String remoteServiceName =
IRemoteCacheConstants.REMOTE_CACHE_SERVICE_VAL;
@@ -40,15 +30,12 @@
private int remotePort;
/**
- * Failover servers will be used by local caches one at a time. Listeners
- * will be registered with all cluster servers. If we add a get from
cluster
- * attribute we will have the ability to chain clusters and have them get
- * from each other.
+ * Failover servers will be used by local caches one at a time. Listeners
will be registered
+ * with all cluster servers. If we add a get from cluster attribute we
will have the ability to
+ * chain clusters and have them get from each other.
*/
private String clusterServers = "";
- //private boolean getFromCluster = true;
-
private int servicePort = 0;
private int remoteType = LOCAL;
@@ -59,7 +46,7 @@
private boolean localClusterConsistency = false;
- private boolean allowClusterGet = false;
+ private boolean allowClusterGet = true;
private String configFileName = "";
@@ -71,7 +58,7 @@
/**
* Gets the remoteTypeName attribute of the RemoteCacheAttributes object
- *
+ * <p>
* @return The remoteTypeName value
*/
public String getRemoteTypeName()
@@ -89,9 +76,8 @@
/**
* Sets the remoteTypeName attribute of the RemoteCacheAttributes object
- *
- * @param s
- * The new remoteTypeName value
+ * <p>
+ * @param s The new remoteTypeName value
*/
public void setRemoteTypeName( String s )
{
@@ -107,7 +93,7 @@
/**
* Gets the remoteType attribute of the RemoteCacheAttributes object
- *
+ * <p>
* @return The remoteType value
*/
public int getRemoteType()
@@ -117,17 +103,17 @@
/**
* Sets the remoteType attribute of the RemoteCacheAttributes object
- *
- * @param p
- * The new remoteType value
+ * <p>
+ * @param p The new remoteType value
*/
public void setRemoteType( int p )
{
this.remoteType = p;
}
- /**
+ /**
* clones
+ * <p>
* @return AuxiliaryCacheAttributes clone
*/
public AuxiliaryCacheAttributes copy()
@@ -145,7 +131,7 @@
/**
* Gets the remoteServiceName attribute of the RemoteCacheAttributes object
- *
+ * <p>
* @return The remoteServiceName value
*/
public String getRemoteServiceName()
@@ -155,9 +141,8 @@
/**
* Sets the remoteServiceName attribute of the RemoteCacheAttributes object
- *
- * @param s
- * The new remoteServiceName value
+ * <p>
+ * @param s The new remoteServiceName value
*/
public void setRemoteServiceName( String s )
{
@@ -166,7 +151,7 @@
/**
* Gets the remoteHost attribute of the RemoteCacheAttributes object
- *
+ * <p>
* @return The remoteHost value
*/
public String getRemoteHost()
@@ -176,9 +161,8 @@
/**
* Sets the remoteHost attribute of the RemoteCacheAttributes object
- *
- * @param s
- * The new remoteHost value
+ * <p>
+ * @param s The new remoteHost value
*/
public void setRemoteHost( String s )
{
@@ -187,7 +171,7 @@
/**
* Gets the remotePort attribute of the RemoteCacheAttributes object
- *
+ * <p>
* @return The remotePort value
*/
public int getRemotePort()
@@ -197,9 +181,8 @@
/**
* Sets the remotePort attribute of the RemoteCacheAttributes object
- *
- * @param p
- * The new remotePort value
+ * <p>
+ * @param p The new remotePort value
*/
public void setRemotePort( int p )
{
@@ -208,7 +191,7 @@
/**
* Gets the clusterServers attribute of the RemoteCacheAttributes object
- *
+ * <p>
* @return The clusterServers value
*/
public String getClusterServers()
@@ -218,9 +201,8 @@
/**
* Sets the clusterServers attribute of the RemoteCacheAttributes object
- *
- * @param s
- * The new clusterServers value
+ * <p>
+ * @param s The new clusterServers value
*/
public void setClusterServers( String s )
{
@@ -229,7 +211,7 @@
/**
* Gets the localPort attribute of the RemoteCacheAttributes object
- *
+ * <p>
* @return The localPort value
*/
public int getServicePort()
@@ -239,9 +221,8 @@
/**
* Sets the localPort attribute of the RemoteCacheAttributes object
- *
- * @param p
- * The new localPort value
+ * <p>
+ * @param p The new localPort value
*/
public void setServicePort( int p )
{
@@ -249,9 +230,8 @@
}
/**
- * Gets the removeUponRemotePut attribute of the RemoteCacheAttributes
- * object
- *
+ * Gets the removeUponRemotePut attribute of the RemoteCacheAttributes
object
+ * <p>
* @return The removeUponRemotePut value
*/
public boolean getRemoveUponRemotePut()
@@ -260,11 +240,9 @@
}
/**
- * Sets the removeUponRemotePut attribute of the RemoteCacheAttributes
- * object
- *
- * @param r
- * The new removeUponRemotePut value
+ * Sets the removeUponRemotePut attribute of the RemoteCacheAttributes
object
+ * <p>
+ * @param r The new removeUponRemotePut value
*/
public void setRemoveUponRemotePut( boolean r )
{
@@ -273,7 +251,7 @@
/**
* Gets the getOnly attribute of the RemoteCacheAttributes object
- *
+ * <p>
* @return The getOnly value
*/
public boolean getGetOnly()
@@ -283,9 +261,8 @@
/**
* Sets the getOnly attribute of the RemoteCacheAttributes object
- *
- * @param r
- * The new getOnly value
+ * <p>
+ * @param r The new getOnly value
*/
public void setGetOnly( boolean r )
{
@@ -294,7 +271,7 @@
/**
* Should cluster updates be propogated to the locals
- *
+ * <p>
* @return The localClusterConsistency value
*/
public boolean getLocalClusterConsistency()
@@ -304,9 +281,8 @@
/**
* Should cluster updates be propogated to the locals
- *
- * @param r
- * The new localClusterConsistency value
+ * <p>
+ * @param r The new localClusterConsistency value
*/
public void setLocalClusterConsistency( boolean r )
{
@@ -314,8 +290,8 @@
}
/**
- * Should cluster updates be propogated to the locals
- *
+ * Should gets from non-cluster clients be allowed to get from other
remote auxiliaries.
+ * <p>
* @return The localClusterConsistency value
*/
public boolean getAllowClusterGet()
@@ -324,10 +300,9 @@
}
/**
- * Should cluster updates be propogated to the locals
- *
- * @param r
- * The new localClusterConsistency value
+ * Should we try to get from other cluster servers if we don't find the
items locally.
+ * <p>
+ * @param r The new localClusterConsistency value
*/
public void setAllowClusterGet( boolean r )
{
@@ -336,7 +311,7 @@
/**
* Gets the ConfigFileName attribute of the IRemoteCacheAttributes object
- *
+ * <p>
* @return The clusterServers value
*/
public String getConfigFileName()
@@ -346,9 +321,8 @@
/**
* Sets the ConfigFileName attribute of the IRemoteCacheAttributes object
- *
- * @param s
- * The new clusterServers value
+ * <p>
+ * @param s The new clusterServers value
*/
public void setConfigFileName( String s )
{
@@ -356,18 +330,19 @@
}
/*
- * (non-Javadoc)
+ * (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
StringBuffer buf = new StringBuffer();
- buf.append( "\nremotePort = " + this.remoteHost );
- buf.append( "\nremotePort = " + this.remotePort );
- buf.append( "\ncacheName = " + this.cacheName );
- buf.append( "\nremoveUponRemotePut = " + this.removeUponRemotePut );
- buf.append( "\ngetOnly = " + getOnly );
+ buf.append( "\n remoteHost = " + this.remoteHost );
+ buf.append( "\n remotePort = " + this.remotePort );
+ buf.append( "\n cacheName = " + this.cacheName );
+ buf.append( "\n removeUponRemotePut = " + this.removeUponRemotePut );
+ buf.append( "\n getOnly = " + getOnly );
+ buf.append( "\n allowClusterGet = " + allowClusterGet );
+ buf.append( "\n localClusterConsistency = " + localClusterConsistency
);
return buf.toString();
}
-
}
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
---
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
(original)
+++
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
Sun Aug 20 20:49:23 2006
@@ -1,19 +1,12 @@
package org.apache.jcs.auxiliary.remote.server;
/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed 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.
+ * Copyright 2001-2004 The Apache Software Foundation. Licensed 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.
*/
import java.io.IOException;
@@ -33,8 +26,8 @@
import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheServiceAdmin;
/**
- * Provides remote cache services.
- *
+ * Provides remote cache services. This creates remote cache servers and can
proxy command line
+ * requests to a running server.
*/
public class RemoteCacheServerFactory
implements IRemoteCacheConstants
@@ -55,9 +48,9 @@
}
/**
- * This will allow you to get stats from the server, etc. Perhaps we should
- * provide methods on the factory to do this instead.
- *
+ * This will allow you to get stats from the server, etc. Perhaps we
should provide methods on
+ * the factory to do this instead.
+ * A remote cache is either a local cache or a cluster cache
* @return Returns the remoteCacheServer.
*/
public static RemoteCacheServer getRemoteCacheServer()
@@ -67,9 +60,9 @@
// ///////////////////// Statup/shutdown methods. //////////////////
/**
- * Starts up the remote cache server on this JVM, and binds it to the
- * registry on the given host and port.
- *
+ * Starts up the remote cache server on this JVM, and binds it to the
registry on the given host
+ * and port.
+ * A remote cache is either a local cache or a cluster cache
* @param host
* @param port
* @param propFile
@@ -187,8 +180,8 @@
}
/**
- * put your documentation comment here
- *
+ * Unbinds the remote server.
+ * <p>
* @param host
* @param port
* @exception IOException
@@ -237,11 +230,10 @@
}
/**
- * Creates an local RMI registry on the default port, starts up the remote
- * cache server, and binds it to the registry.
- *
- * @param args
- * The command line arguments
+ * Creates an local RMI registry on the default port, starts up the remote
cache server, and
+ * binds it to the registry.
+ * A remote cache is either a local cache or a cluster cache
+ * @param args The command line arguments
* @throws Exception
*/
public static void main( String[] args )
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerInfo.java
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerInfo.java?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
---
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerInfo.java
(original)
+++
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerInfo.java
Sun Aug 20 20:49:23 2006
@@ -19,28 +19,25 @@
import java.rmi.dgc.VMID;
/**
- * A shared static variable holder for the server
- *
+ * A shared static variable holder for the server.
*/
public class RemoteCacheServerInfo
{
-
- // shouldn't be instantiated
- /** Constructor for the RemoteCacheServerInfo object */
+ /** shouldn't be instantiated */
private RemoteCacheServerInfo()
{
super();
}
/**
- * Shouldn't be used till after reconneting, after setting = thread safe
+ * Shouldn't be used until after reconnecting, after setting = thread safe
* Used to identify a client, so we can run multiple clients off one host.
* Need since there is no way to identify a client other than by host in
* rmi.
*/
protected static VMID vmid = new VMID();
- /** Description of the Field */
+ /** By default it is the VMID. */
public static long listenerId = vmid.hashCode();
}
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
---
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java
(original)
+++
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java
Sun Aug 20 20:49:23 2006
@@ -60,7 +60,6 @@
* <p>
* Gets the port from a props file. Uses the local host name for the
rgistry
* host. Tries to start the registry, ignoreing failure. Starts the server.
- *
*/
public void init()
throws ServletException
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
---
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java
(original)
+++
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java
Sun Aug 20 20:49:23 2006
@@ -21,153 +21,148 @@
/**
* This defeines the minimal behavior for the objects that are used to
configure
* the remote cache server.
- *
*/
public interface IRemoteCacheServerAttributes
extends AuxiliaryCacheAttributes
{
-
- /*
- * A remote cache is either a local cache or a cluster cache.
- */
- /** Description of the Field */
+ /** A remote cache is either a local cache or a cluster cache */
public static int LOCAL = 0;
- /** Description of the Field */
+ /** A remote cache is either a local cache or a cluster cache */
public static int CLUSTER = 1;
/**
- * Gets the remoteTypeName attribute of the IRemoteCacheAttributes object
- *
+ * Gets the remoteTypeName attribute of the IRemoteCacheAttributes object.
+ * <p>
* @return The remoteTypeName value
*/
public String getRemoteTypeName();
/**
- * Sets the remoteTypeName attribute of the IRemoteCacheAttributes object
- *
+ * Sets the remoteTypeName attribute of the IRemoteCacheAttributes object.
+ * <p>
* @param s
* The new remoteTypeName value
*/
public void setRemoteTypeName( String s );
/**
- * Gets the remoteType attribute of the IRemoteCacheAttributes object
- *
+ * Gets the remoteType attribute of the IRemoteCacheAttributes object.
+ * <p>
* @return The remoteType value
*/
public int getRemoteType();
/**
- * Sets the remoteType attribute of the IRemoteCacheAttributes object
- *
+ * Sets the remoteType attribute of the IRemoteCacheAttributes object.
+ * <p>
* @param p
* The new remoteType value
*/
public void setRemoteType( int p );
/**
- * Gets the remoteHost attribute of the IRemoteCacheAttributes object
- *
+ * Gets the remoteHost attribute of the IRemoteCacheAttributes object.
+ * <p>
* @return The remoteHost value
*/
public String getRemoteHost();
/**
- * Sets the remoteHost attribute of the IRemoteCacheAttributes object
- *
+ * Sets the remoteHost attribute of the IRemoteCacheAttributes object.
+ * <p>
* @param s
* The new remoteHost value
*/
public void setRemoteHost( String s );
/**
- * Gets the remotePort attribute of the IRemoteCacheAttributes object
- *
+ * Gets the remotePort attribute of the IRemoteCacheAttributes object.
+ * <p>
* @return The remotePort value
*/
public int getRemotePort();
/**
- * Sets the remotePort attribute of the IRemoteCacheAttributes object
- *
+ * Sets the remotePort attribute of the IRemoteCacheAttributes object.
+ * <p>
* @param p
* The new remotePort value
*/
public void setRemotePort( int p );
/**
- * Gets the localPort attribute of the IRemoteCacheAttributes object
- *
+ * Gets the localPort attribute of the IRemoteCacheAttributes object.
+ * <p>
* @return The localPort value
*/
public int getServicePort();
/**
- * Sets the localPort attribute of the IRemoteCacheAttributes object
- *
+ * Sets the localPort attribute of the IRemoteCacheAttributes object.
+ * <p>
* @param p
* The new localPort value
*/
public void setServicePort( int p );
/**
- * Gets the clusterServers attribute of the IRemoteCacheAttributes object
- *
+ * Gets the clusterServers attribute of the IRemoteCacheAttributes object.
+ * <p>
* @return The clusterServers value
*/
public String getClusterServers();
/**
- * Sets the clusterServers attribute of the IRemoteCacheAttributes object
- *
+ * Sets the clusterServers attribute of the IRemoteCacheAttributes object.
+ * <p>
* @param s
* The new clusterServers value
*/
public void setClusterServers( String s );
/**
- * Gets the removeUponRemotePut attribute of the IRemoteCacheAttributes
- * object
- *
+ * Gets the removeUponRemotePut attribute of the IRemoteCacheAttributes.
+ * object.
+ * <p>
* @return The removeUponRemotePut value
*/
public boolean getRemoveUponRemotePut();
/**
- * Sets the removeUponRemotePut attribute of the IRemoteCacheAttributes
+ * Sets the removeUponRemotePut attribute of the IRemoteCacheAttributes.
* object
- *
+ * <p>
* @param r
* The new removeUponRemotePut value
*/
public void setRemoveUponRemotePut( boolean r );
/**
- * Gets the getOnly attribute of the IRemoteCacheAttributes object
- *
+ * Gets the getOnly attribute of the IRemoteCacheAttributes object.
+ * A remote cache is either a local cache or a cluster cache
* @return The getOnly value
*/
public boolean getGetOnly();
/**
- * Sets the getOnly attribute of the IRemoteCacheAttributes object
- *
+ * Sets the getOnly attribute of the IRemoteCacheAttributes object.
+ * <p>
* @param r
* The new getOnly value
*/
public void setGetOnly( boolean r );
/**
- * Should cluster updates be propogated to the locals
- *
+ * Should cluster updates be propogated to the locals.
+ * <p>
* @return The localClusterConsistency value
*/
public boolean getLocalClusterConsistency();
/**
- * Should cluster updates be propogated to the locals
- *
+ * Should cluster updates be propogated to the locals.
+ * <p>
* @param r
* The new localClusterConsistency value
*/
@@ -180,32 +175,31 @@
* remote update. The local update stays local. Normal updates, removes,
* etc, stay local when they come from a client. If this is set to true,
* then they can go remote.
- *
+ * <p>
* @return The localClusterConsistency value
*/
public boolean getAllowClusterGet();
/**
- * Should cluster updates be propogated to the locals
- *
+ * Should cluster updates be propogated to the locals.
+ * <p>
* @param r
* The new localClusterConsistency value
*/
public void setAllowClusterGet( boolean r );
/**
- * Gets the ConfigFileName attribute of the IRemoteCacheAttributes object
- *
+ * Gets the ConfigFileName attribute of the IRemoteCacheAttributes object.
+ * <p>
* @return The clusterServers value
*/
public String getConfigFileName();
/**
- * Sets the ConfigFileName attribute of the IRemoteCacheAttributes object
- *
+ * Sets the ConfigFileName attribute of the IRemoteCacheAttributes object.
+ * <p>
* @param s
* The new clusterServers value
*/
public void setConfigFileName( String s );
-
}
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
---
jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java
(original)
+++
jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java
Sun Aug 20 20:49:23 2006
@@ -860,7 +860,9 @@
}
/**
- * Invoked only by CacheManager.
+ * Invoked only by CacheManager. This method disposes of the auxiliaries
one by one. For the disk cache, the items in memory
+ * are freed, meaning that they will be sent through the overflow chanel
to disk. After the
+ * auxiliaries are disposed, the memory cache is dispposed.
* <p>
* @param fromRemote
*/
@@ -868,9 +870,9 @@
{
if ( log.isInfoEnabled() )
{
- log.info( "In DISPOSE, [" + this.cacheName + "] fromRemote [" +
fromRemote + "]" );
+ log.info( "In DISPOSE, [" + this.cacheName + "] fromRemote [" +
fromRemote + "] \n" + this.getStats() );
}
-
+
// If already disposed, return immediately
if ( !alive )
{
@@ -892,55 +894,38 @@
// - The auxilliary is not alive
// - The auxilliary is remote and the invocation was remote
- if ( aux == null || aux.getStatus() !=
CacheConstants.STATUS_ALIVE || ( fromRemote
- && aux.getCacheType() == REMOTE_CACHE ) )
+ if ( aux == null || aux.getStatus() !=
CacheConstants.STATUS_ALIVE
+ || ( fromRemote && aux.getCacheType() == REMOTE_CACHE ) )
{
if ( log.isInfoEnabled() )
{
- log.info( "In DISPOSE, [" + this.cacheName + "]
SKIPPING auxiliary [" + aux + "] fromRemote [" + fromRemote + "]" );
+ log.info( "In DISPOSE, [" + this.cacheName + "]
SKIPPING auxiliary [" + aux + "] fromRemote ["
+ + fromRemote + "]" );
}
continue;
}
- // If the auxilliary is not a lateral, or the cache attributes
- // have 'getUseLateral' set, all the elements currently in
- // memory are written to the lateral before disposing
-
- // TODO make sure disk gets a change to finish
- if ( aux.getCacheType() != ICacheType.LATERAL_CACHE ||
this.cacheAttr.getUseLateral() )
+ if ( log.isInfoEnabled() )
{
- Iterator itr = memCache.getIterator();
-
- if ( log.isInfoEnabled() )
- {
- log.info( "In DISPOSE, [" + this.cacheName + "]
memCache.size = " + memCache.getSize() + " auxiliary [" + aux + "]" );
- }
+ log.info( "In DISPOSE, [" + this.cacheName + "] auxiliary
[" + aux + "]" );
+ }
- int cnt = 0;
- while ( itr.hasNext() )
- {
- cnt++;
- Map.Entry entry = (Map.Entry) itr.next();
+ // IT USED TO BE THE CASE THAT (If the auxilliary is not a
lateral, or the cache
+ // attributes
+ // have 'getUseLateral' set, all the elements currently in
+ // memory are written to the lateral before disposing)
+ // I changed this. It was excessive. Only the disk cache needs
the items, since only
+ // the disk cache
+ // is in a situation to not get items on a put.
- ICacheElement ce = (ICacheElement) entry.getValue();
- try
- {
- if ( aux.getCacheType() == ICacheType.LATERAL_CACHE
- && !ce.getElementAttributes().getIsLateral() )
- {
- continue;
- }
- aux.update( ce );
- }
- catch ( Exception e )
- {
- log.error( e );
- }
- }
+ if ( aux.getCacheType() == ICacheType.DISK_CACHE )
+ {
+ int numToFree = memCache.getSize();
+ memCache.freeElements( numToFree );
if ( log.isInfoEnabled() )
{
- log.info( "In DISPOSE, [" + this.cacheName + "] put "
+ cnt + " into auxiliary " + aux );
+ log.info( "In DISPOSE, [" + this.cacheName + "] put "
+ numToFree + " into auxiliary " + aux );
}
}
@@ -965,8 +950,6 @@
{
log.error( "Failure disposing of memCache", ex );
}
-
- log.warn( "Called close for [" + cacheName + "]" );
}
/**
Added:
jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/AuxiliaryCacheMockImpl.java
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/AuxiliaryCacheMockImpl.java?rev=433139&view=auto
==============================================================================
---
jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/AuxiliaryCacheMockImpl.java
(added)
+++
jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/AuxiliaryCacheMockImpl.java
Sun Aug 20 20:49:23 2006
@@ -0,0 +1,153 @@
+package org.apache.jcs.auxiliary;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Set;
+
+import org.apache.jcs.engine.CacheConstants;
+import org.apache.jcs.engine.behavior.ICache;
+import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.stats.behavior.IStats;
+
+/**
+ * Mock auxiliary for unit tests.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class AuxiliaryCacheMockImpl
+ implements AuxiliaryCache
+{
+ private static final long serialVersionUID = 1L;
+
+ /** Can setup the cache type */
+ public int cacheType = ICache.DISK_CACHE;
+
+ /** Can setup status */
+ public int status = CacheConstants.STATUS_ALIVE;
+
+ /*
+ * (non-Javadoc)
+ * @see
org.apache.jcs.auxiliary.AuxiliaryCache#update(org.apache.jcs.engine.behavior.ICacheElement)
+ */
+ public void update( ICacheElement ce )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.jcs.auxiliary.AuxiliaryCache#get(java.io.Serializable)
+ */
+ public ICacheElement get( Serializable key )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.apache.jcs.auxiliary.AuxiliaryCache#remove(java.io.Serializable)
+ */
+ public boolean remove( Serializable key )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.jcs.auxiliary.AuxiliaryCache#removeAll()
+ */
+ public void removeAll()
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.jcs.auxiliary.AuxiliaryCache#dispose()
+ */
+ public void dispose()
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.jcs.auxiliary.AuxiliaryCache#getSize()
+ */
+ public int getSize()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatus()
+ */
+ public int getStatus()
+ {
+ // TODO Auto-generated method stub
+ return status;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.jcs.auxiliary.AuxiliaryCache#getCacheName()
+ */
+ public String getCacheName()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.apache.jcs.auxiliary.AuxiliaryCache#getGroupKeys(java.lang.String)
+ */
+ public Set getGroupKeys( String group )
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatistics()
+ */
+ public IStats getStatistics()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.jcs.engine.behavior.ICache#getStats()
+ */
+ public String getStats()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.jcs.engine.behavior.ICacheType#getCacheType()
+ */
+ public int getCacheType()
+ {
+ return cacheType;
+ }
+
+}
Added:
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java?rev=433139&view=auto
==============================================================================
---
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java
(added)
+++
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java
Sun Aug 20 20:49:23 2006
@@ -0,0 +1,103 @@
+package org.apache.jcs.engine.control;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.jcs.auxiliary.AuxiliaryCache;
+import org.apache.jcs.auxiliary.AuxiliaryCacheMockImpl;
+import org.apache.jcs.engine.CacheElement;
+import org.apache.jcs.engine.CompositeCacheAttributes;
+import org.apache.jcs.engine.ElementAttributes;
+import org.apache.jcs.engine.behavior.ICache;
+import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
+import org.apache.jcs.engine.behavior.IElementAttributes;
+import org.apache.jcs.engine.memory.MemoryCacheMockImpl;
+
+/**
+ * Tests that directly engage the composite cache.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class CompositeCacheUnitTest
+ extends TestCase
+{
+ /**
+ * Verify that the freeMemoryElements method on the memory cache is called
on shutdown if there
+ * is a disk cache.
+ * <p>
+ * @throws IOException
+ */
+ public void testShutdownMemoryFlush()
+ throws IOException
+ {
+ // SETUP
+ String cacheName = "testCacheName";
+ String mockMemoryCacheClassName =
"org.apache.jcs.engine.memory.MemoryCacheMockImpl";
+ ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
+ cattr.setMemoryCacheName( mockMemoryCacheClassName );
+
+ IElementAttributes attr = new ElementAttributes();
+
+ CompositeCache cache = new CompositeCache( cacheName, cattr, attr );
+
+ AuxiliaryCacheMockImpl diskMock = new AuxiliaryCacheMockImpl();
+ diskMock.cacheType = ICache.DISK_CACHE;
+ AuxiliaryCache[] aux = new AuxiliaryCache[] { diskMock };
+ cache.setAuxCaches( aux );
+
+ // DO WORK
+ int numToInsert = 10;
+ for ( int i = 0; i < numToInsert; i++ )
+ {
+ ICacheElement element = new CacheElement( cacheName,
String.valueOf( i ), new Integer( i ) );
+ cache.update( element, false );
+ }
+
+ cache.dispose();
+
+ // VERIFY
+ MemoryCacheMockImpl memoryCache = (MemoryCacheMockImpl)
cache.getMemoryCache();
+ assertEquals( "Wrong number freed.", numToInsert,
memoryCache.lastNumberOfFreedElements );
+ }
+
+ /**
+ * Verify that the freeMemoryElements method on the memory cache is NOT
called on shutdown if
+ * there is NOT a disk cache.
+ * <p>
+ * @throws IOException
+ */
+ public void testShutdownMemoryFlush_noDisk()
+ throws IOException
+ {
+ // SETUP
+ String cacheName = "testCacheName";
+ String mockMemoryCacheClassName =
"org.apache.jcs.engine.memory.MemoryCacheMockImpl";
+ ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
+ cattr.setMemoryCacheName( mockMemoryCacheClassName );
+
+ IElementAttributes attr = new ElementAttributes();
+
+ CompositeCache cache = new CompositeCache( cacheName, cattr, attr );
+
+ AuxiliaryCacheMockImpl diskMock = new AuxiliaryCacheMockImpl();
+ diskMock.cacheType = ICache.REMOTE_CACHE;
+ AuxiliaryCache[] aux = new AuxiliaryCache[] { diskMock };
+ cache.setAuxCaches( aux );
+
+ // DO WORK
+ int numToInsert = 10;
+ for ( int i = 0; i < numToInsert; i++ )
+ {
+ ICacheElement element = new CacheElement( cacheName,
String.valueOf( i ), new Integer( i ) );
+ cache.update( element, false );
+ }
+
+ cache.dispose();
+
+ // VERIFY
+ MemoryCacheMockImpl memoryCache = (MemoryCacheMockImpl)
cache.getMemoryCache();
+ assertEquals( "Wrong number freed.", 0,
memoryCache.lastNumberOfFreedElements );
+ }
+}
Modified:
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MemoryCacheMockImpl.java
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MemoryCacheMockImpl.java?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
---
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MemoryCacheMockImpl.java
(original)
+++
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MemoryCacheMockImpl.java
Sun Aug 20 20:49:23 2006
@@ -30,9 +30,8 @@
/**
* Mock implementation of a memory cache for testing things like the memory
* shrinker.
- *
+ * <p>
* @author Aaron Smuts
- *
*/
public class MemoryCacheMockImpl
implements MemoryCache
@@ -46,6 +45,11 @@
*/
public int waterfallCallCount = 0;
+ /**
+ * The number passed to the last call of free elements.
+ */
+ public int lastNumberOfFreedElements = 0;
+
public void initialize( CompositeCache cache )
{
// TODO Auto-generated method stub
@@ -157,7 +161,7 @@
public int freeElements( int numberToFree )
throws IOException
{
- // TODO Auto-generated method stub
+ lastNumberOfFreedElements = numberToFree;
return 0;
}
}
Modified: jakarta/jcs/trunk/xdocs/IndexedDiskAuxCache.xml
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/xdocs/IndexedDiskAuxCache.xml?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
--- jakarta/jcs/trunk/xdocs/IndexedDiskAuxCache.xml (original)
+++ jakarta/jcs/trunk/xdocs/IndexedDiskAuxCache.xml Sun Aug 20 20:49:23 2006
@@ -31,7 +31,7 @@
still requires memory, it is
insignificant given the
performance trade off. Depending on the
key size,
500,000 disk entries will probably only
require
- about 1 MB of memory. Locating the
position of an
+ about 3 MB of memory. Locating the
position of an
item is as fast as a map lookup and the
retrieval of
the item only requires 2 disk accesses.
</p>
@@ -135,6 +135,16 @@
MaxKeySize. If the MaxKeySize is less
than 0, the
recycle bin will default to 5000.
</p>
+ <p>
+ If all the items put on disk are the
same size, then
+ the recycle bin will always return
perfect matches.
+ However, if the items are of various
sizes, the disk
+ cache will use the free spot closest in
size but not
+ smaller than the item being written to
disk. Since
+ some recycled spots will be larger than
the items
+ written to disk, unusable gaps will
result.
+ Optimization is intended to remove
these gaps.
+ </p>
<source>
<![CDATA[
jcs.auxiliary.DC.attributes.MaxRecycleBinSize=10000
@@ -151,6 +161,11 @@
data file will occur until shutdown. By
default the
value is -1.
</p>
+ <p>
+ In version 1.2.7.9 of JCS, the
optimization routine
+ was significantly improved. It now
occurs in place,
+ without the aid of a temporary file.
+ </p>
<source>
<![CDATA[
jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=30000
@@ -192,6 +207,7 @@
jcs.auxiliary.DC.attributes.MaxPurgatorySize=10000
jcs.auxiliary.DC.attributes.MaxKeySize=10000
jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=300000
+jcs.auxiliary.DC.attributes.OptimizeOnShutdown=true
jcs.auxiliary.DC.attributes.MaxRecycleBinSize=7500
]]>
</source>
@@ -252,6 +268,7 @@
jcs.auxiliary.DC2.attributes.MaxKeySize=10000
jcs.auxiliary.DC2.attributes.MaxRecycleBinSize=5000
jcs.auxiliary.DC2.attributes.OptimizeAtRemoveCount=300000
+jcs.auxiliary.DC.attributes.OptimizeOnShutdown=true
jcs.auxiliary.DC2.attributes.EventQueueType=POOLED
jcs.auxiliary.DC2.attributes.EventQueuePoolName=disk_cache_event_queue
Modified: jakarta/jcs/trunk/xdocs/IndexedDiskCacheProperties.xml
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/xdocs/IndexedDiskCacheProperties.xml?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
--- jakarta/jcs/trunk/xdocs/IndexedDiskCacheProperties.xml (original)
+++ jakarta/jcs/trunk/xdocs/IndexedDiskCacheProperties.xml Sun Aug 20 20:49:23
2006
@@ -1,135 +1,168 @@
<?xml version="1.0"?>
<document>
- <properties>
- <title>Indexed Disk Cache Configuration</title>
- <author email="ASmuts@xxxxxxxxxx">Aaron Smuts</author>
- </properties>
-
- <body>
- <section name="Indexed Disk Auxiliary Cache Configuration">
-
- <p>
- The following properties apply to the Indexed Disk Cache plugin.
- </p>
-
- <subsection name="Indexed Disk Configuration Properties">
- <table>
- <tr>
- <th>Property</th>
- <th>Description</th>
- <th>Required</th>
- <th>Default Value</th>
- </tr>
- <tr>
- <td>DiskPath</td>
- <td>
- The directory where the disk cache should write its files.
- </td>
- <td>Y</td>
- <td>n/a</td>
- </tr>
- <tr>
- <td>MaxPurgatorySize</td>
- <td>
- The maximum number of items allowed in the queue of items to
- be written to disk.
- </td>
- <td>N</td>
- <td>5000</td>
- </tr>
- <tr>
- <td>MaxKeySize</td>
- <td>
- The maximum number of keys that the indexed disk cache can have.
- Since the keys are stored in memory, you may want to limit
- this number to something reasonable. The default is a bit small.
- </td>
- <td>N</td>
- <td>5000</td>
- </tr>
- <tr>
- <td>OptimizeAtRemoveCount</td>
- <td>
- At how many removes should the cache try to defragment the
- data file. Since we recycle empty spots, defragmentation
- is usually not needed. To prevent the cache from defragmenting
- the data file, you can set this to -1. This is the default
value.
- </td>
- <td>N</td>
- <td>-1</td>
- </tr>
- <tr>
- <td>MaxRecycleBinSize</td>
- <td>
- The maximum number of empty spots the cache will keep
- track of. The smallest are removed when the maximum size
- is reached. Keeping track of empty spots on disk allows us
- to reuse spots, thereby keeping the file from growing
unncessarily.
- </td>
- <td>N</td>
- <td>5000</td>
- </tr>
- </table>
- </subsection>
-
- <subsection name="Example Configuration">
- <source><![CDATA[
+ <properties>
+ <title>Indexed Disk Cache Configuration</title>
+ <author email="ASmuts@xxxxxxxxxx">Aaron Smuts</author>
+ </properties>
+
+ <body>
+ <section name="Indexed Disk Auxiliary Cache Configuration">
+
+ <p>
+ The following properties apply to the Indexed
Disk Cache
+ plugin.
+ </p>
+
+ <subsection name="Indexed Disk Configuration
Properties">
+ <table>
+ <tr>
+ <th>Property</th>
+ <th>Description</th>
+ <th>Required</th>
+ <th>Default Value</th>
+ </tr>
+ <tr>
+ <td>DiskPath</td>
+ <td>
+ The directory where the
disk cache should
+ write its files.
+ </td>
+ <td>Y</td>
+ <td>n/a</td>
+ </tr>
+ <tr>
+ <td>MaxPurgatorySize</td>
+ <td>
+ The maximum number of
items allowed in the
+ queue of items to be
written to disk.
+ </td>
+ <td>N</td>
+ <td>5000</td>
+ </tr>
+ <tr>
+ <td>MaxKeySize</td>
+ <td>
+ The maximum number of
keys that the indexed
+ disk cache can have.
Since the keys are
+ stored in memory, you
may want to limit this
+ number to something
reasonable. The default
+ is a bit small.
+ </td>
+ <td>N</td>
+ <td>5000</td>
+ </tr>
+ <tr>
+ <td>OptimizeAtRemoveCount</td>
+ <td>
+ At how many removes
should the cache try to
+ defragment the data
file. Since we recycle
+ empty spots,
defragmentation is usually not
+ needed. To prevent the
cache from
+ defragmenting the data
file, you can set
+ this to -1. This is the
default value.
+ </td>
+ <td>N</td>
+ <td>-1</td>
+ </tr>
+ <tr>
+ <td>OptimizeOnShutdown</td>
+ <td>
+ By default the Indexed
Disk Cache will
+ optimize on shutdown if
the free data size
+ is greater than 0. If
you want to prevent
+ this behavior, you can
set this parameter to
+ false.
+ </td>
+ <td>N</td>
+ <td>true</td>
+ </tr>
+ <tr>
+ <td>MaxRecycleBinSize</td>
+ <td>
+ The maximum number of
empty spots the cache
+ will keep track of. The
smallest are removed
+ when the maximum size
is reached. Keeping
+ track of empty spots on
disk allows us to
+ reuse spots, thereby
keeping the file from
+ growing unncessarily.
+ </td>
+ <td>N</td>
+ <td>5000</td>
+ </tr>
+ </table>
+ </subsection>
+
+ <subsection name="Example Configuration">
+ <source>
+ <![CDATA[
jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.DC.attributes.DiskPath=target/test-sandbox/indexed-disk-cache
jcs.auxiliary.DC.attributes.MaxPurgatorySize=10000
jcs.auxiliary.DC.attributes.MaxKeySize=10000
jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=300000
+jcs.auxiliary.DC.attributes.OptimizeOnShutdown=true
jcs.auxiliary.DC.attributes.MaxRecycleBinSize=7500
- ]]></source>
- </subsection>
-
- <subsection name="Indexed Disk Event Queue Configuration">
-
- <table>
- <tr>
- <th>Property</th>
- <th>Description</th>
- <th>Required</th>
- <th>Default Value</th>
- </tr>
- <tr>
- <td>EventQueueType</td>
- <td>
- This should be either SINGLE or POOLED. By default
the single
- style pool is used. The single style pool uses a
single thread
- per event queue. That thread is killed whenever the
queue is inactive
- for 30 seconds. Since the disk cache uses an event
queue for every region,
- if you have many regions and they are all active, you
will be using many threads.
- To limit the number of threads, you can configure the
disk cache to
- use the pooled event queue. Using more threads than
regions will not
- add any benefit for the indexed disk cache, since
only one thread can read or
- write at a time for a single region.
- </td>
- <td>N</td>
- <td>SINGLE</td>
- </tr>
- <tr>
- <td>EventQueuePoolName</td>
- <td>
- This is the name of the pool to use. It is required
if you
- choose the POOLED event queue type, otherwise it is
ignored.
- </td>
- <td>Y</td>
- <td>n/a</td>
- </tr>
- </table>
- </subsection>
-
- <subsection name="Example Configuration Using Thread Pool">
- <source><![CDATA[
+ ]]>
+ </source>
+ </subsection>
+
+ <subsection name="Indexed Disk Event Queue
Configuration">
+
+ <table>
+ <tr>
+ <th>Property</th>
+ <th>Description</th>
+ <th>Required</th>
+ <th>Default Value</th>
+ </tr>
+ <tr>
+ <td>EventQueueType</td>
+ <td>
+ This should be either
SINGLE or POOLED. By
+ default the single
style pool is used. The
+ single style pool uses
a single thread per
+ event queue. That
thread is killed whenever
+ the queue is inactive
for 30 seconds. Since
+ the disk cache uses an
event queue for every
+ region, if you have
many regions and they
+ are all active, you
will be using many
+ threads. To limit the
number of threads, you
+ can configure the disk
cache to use the
+ pooled event queue.
Using more threads than
+ regions will not add
any benefit for the
+ indexed disk cache,
since only one thread
+ can read or write at a
time for a single
+ region.
+ </td>
+ <td>N</td>
+ <td>SINGLE</td>
+ </tr>
+ <tr>
+ <td>EventQueuePoolName</td>
+ <td>
+ This is the name of the
pool to use. It is
+ required if you choose
the POOLED event
+ queue type, otherwise
it is ignored.
+ </td>
+ <td>Y</td>
+ <td>n/a</td>
+ </tr>
+ </table>
+ </subsection>
+
+ <subsection
+ name="Example Configuration Using Thread Pool">
+ <source>
+ <![CDATA[
jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.DC.attributes.DiskPath=target/test-sandbox/indexed-disk-cache
jcs.auxiliary.DC.attributes.MaxPurgatorySize=10000
jcs.auxiliary.DC.attributes.MaxKeySize=10000
jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=300000
+jcs.auxiliary.DC.attributes.OptimizeOnShutdown=true
jcs.auxiliary.DC.attributes.MaxRecycleBinSize=7500
jcs.auxiliary.DC.attributes.EventQueueType=POOLED
jcs.auxiliary.DC.attributes.EventQueuePoolName=disk_cache_event_queue
@@ -141,10 +174,11 @@
thread_pool.disk_cache_event_queue.minimumPoolSize=1
thread_pool.disk_cache_event_queue.keepAliveTime=3500
thread_pool.disk_cache_event_queue.startUpSize=1
- ]]></source>
- </subsection>
+ ]]>
+ </source>
+ </subsection>
+
-
- </section>
- </body>
-</document>
\ No newline at end of file
+ </section>
+ </body>
+</document>
\ No newline at end of file
Modified: jakarta/jcs/trunk/xdocs/RemoteAuxCache.xml
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/xdocs/RemoteAuxCache.xml?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
--- jakarta/jcs/trunk/xdocs/RemoteAuxCache.xml (original)
+++ jakarta/jcs/trunk/xdocs/RemoteAuxCache.xml Sun Aug 20 20:49:23 2006
@@ -175,14 +175,6 @@
<code>1102</code>
.
</p>
- <p>
- The tomcat configuration section is
evolving. If
- <code>remote.tomcat.on</code>
- is set to
- <code>true</code>
- an embedded tomcat server will run
within the remote
- cache, allowing the use of management
servlets.
- </p>
<source>
<![CDATA[
# Registry used to register and provide the
@@ -193,10 +185,11 @@
remote.cache.service.port=1102
# cluster setting
remote.cluster.LocalClusterConsistency=true
+remote.cluster.AllowClusterGet=true
]]>
</source>
<p>
- Remote servers can be chainied (or
clustered). This
+ Remote servers can be chained (or
clustered). This
allows gets from local caches to be
distributed
between multiple remote servers. Since
gets are the
most common operation for caches,
remote server
@@ -210,6 +203,20 @@
servers to registered local caches.
</p>
<p>
+ The
+ <code>AllowClusterGet</code>
+ setting tells the remote cache server
whether it
+ should allow the cache to look in
non-local
+ auxiliaries for items if they are not
present.
+ Basically, if the get request is not
from a cluster
+ server, the cache will treat it as if
it originated
+ locally. If the get request originated
from a
+ cluster client, then the get will be
restricted to
+ local (i.e. memory and disk)
auxiliaries. Hence,
+ cluster gets can only go one server
deep. They
+ cannot be chained. By default this
setting is true.
+ </p>
+ <p>
To use remote server clustering, the
remote cache
will have to be told what regions to
cluster. The
configuration below will cluster all
@@ -287,6 +294,43 @@
]]>
</source>
</subsection>
+ <subsection name="Server Startup / Shutdown">
+ <p>
+ It is highly recommended that you embed
the Remote
+ Cache Server in a Servlet container
such as Tomcat.
+ Running inside Tomcat allows you to use
the
+ JCSAdmin.jsp page. It also takes care
of the
+ complexity of creating working startup
and shutdown
+ scripts.
+ </p>
+ <p>
+ JCS provides a convenient startup
servlet for this
+ purpose. It will start the registery
and bind the
+ JCS server to the registry. To use the
startup
+ servlet, add the following to the
web.xml file add
+ make sure you have the remote.cache.ccf
file in the
+ WEB-INF/classes directly of your war
file.
+ </p>
+ <source>
+ <![CDATA[
+ <servlet>
+ <servlet-name>JCSRemoteCacheStartupServlet</servlet-name>
+ <servlet-class>
+ org.apache.jcs.auxiliary.remote.server.RemoteCacheStartupServlet
+ </servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+
+ <servlet-mapping>
+ <servlet-name>JCSRemoteCacheStartupServlet</servlet-name>
+ <url-pattern>/jcs</url-pattern>
+ </servlet-mapping>
+]]>
+ </source>
+
+ </subsection>
</section>
+
</body>
</document>
Modified: jakarta/jcs/trunk/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jakarta/jcs/trunk/xdocs/changes.xml?rev=433139&r1=433138&r2=433139&view=diff
==============================================================================
--- jakarta/jcs/trunk/xdocs/changes.xml (original)
+++ jakarta/jcs/trunk/xdocs/changes.xml Sun Aug 20 20:49:23 2006
@@ -6,13 +6,28 @@
<body>
<release version="1.2.7.9" date="in CVS">
- <action dev="asmuts" type="update" issue="JCS-5">
+ <action dev="asmuts" type="fix" issue="JCS-1">
+ Fixed last element too small recycle bin bug.
+ </action>
+ <action dev="asmuts" type="update" issue="JCS-2">
Added the ability to send all items to disk or
to use
the disk merely as a swap. This is done by
setting the
DiskUsagePattern on the cache attributes for a
region.
</action>
- <action dev="asmuts" type="fix" issue="JCS-1">
- Fixed last element too small recycle bin bug.
+ <action dev="asmuts" type="fix" issue="JCS-3"
+ due-to="Peter Schwarz">
+ Disk optimization now occurs in place, without
using
+ additional files. It is far more efficient.
+ </action>
+ <action dev="asmuts" type="fix" issue="JCS-4">
+ The disk cache will not optimize on shutdown if
the
+ freedata size is 0.
+ </action>
+ <action dev="asmuts" type="fix" issue="JCS-8">
+ Remote cache client will now shutdown properly.
+ </action>
+ <action dev="asmuts" type="fix" issue="JCS-9">
+ Only send memory items to disk auxiliaries on
shutdown.
</action>
</release>
|