jakarta-jcs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asm...@apache.org
Subject svn commit: r433657 - in /jakarta/jcs/trunk: src/java/org/apache/jcs/auxiliary/remote/ src/java/org/apache/jcs/auxiliary/remote/behavior/ src/java/org/apache/jcs/engine/behavior/ src/java/org/apache/jcs/utils/struct/ src/test/org/apache/jcs/auxiliary/d...
Date Tue, 22 Aug 2006 14:58:24 GMT
Author: asmuts
Date: Tue Aug 22 07:58:23 2006
New Revision: 433657

URL: http://svn.apache.org/viewvc?rev=433657&view=rev
Log:
Fix for JCS-10
http://issues.apache.org/jira/browse/JCS-10

I added a bounded queue to the Zombie and a new configuration option called ZombieQueueMaxSize. The configuration option has been added to the xdocs.

I added some unit tests for the event propagation from the zombie to the retored service.
Added some simple unit tests for the boudned queue.

Some formatting and javadoc improvements.

Added:
    jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/BoundedQueue.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/BoundedQueueUnitTest.java
Modified:
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheAttributes.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheRestore.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/ZombieRemoteCacheService.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheAttributes.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventQueue.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java
    jakarta/jcs/trunk/xdocs/RemoteCacheProperties.xml

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=433657&r1=433656&r2=433657&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 Tue Aug 22 07:58:23 2006
@@ -586,7 +586,7 @@
         if ( remote == null || !(remote instanceof ZombieRemoteCacheService) )
         {
             // TODO make configurable
-            remote = new ZombieRemoteCacheService( 1000 );
+            remote = new ZombieRemoteCacheService( irca.getZombieQueueMaxSize() );
         }
         // may want to flush if region specifies
         // Notify the cache monitor about the error, and kick off the recovery

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheAttributes.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheAttributes.java?rev=433657&r1=433656&r2=433657&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheAttributes.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheAttributes.java Tue Aug 22 07:58:23 2006
@@ -1,19 +1,12 @@
 package org.apache.jcs.auxiliary.remote;
 
 /*
- * 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;
@@ -22,8 +15,7 @@
 import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheConstants;
 
 /**
- * These objects are used to configure the remote cache client.  
- *  
+ * These objects are used to configure the remote cache client.
  */
 public class RemoteCacheAttributes
     extends AbstractAuxiliaryCacheAttributes
@@ -38,10 +30,9 @@
     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 failoverServers = "";
 
@@ -69,9 +60,11 @@
     private int getTimeoutMillis = -1;
 
     private int rmiSocketFactoryTimeoutMillis = DEFAULT_RMI_SOCKET_FACTORY_TIMEOUT_MILLIS;
-    
+
     private boolean receive = DEFAULT_RECEIVE;
-    
+
+    private int zombieQueueMaxSize = DEFAULT_ZOMBIE_QUEUE_MAX_SIZE;
+
     /** Default constructor for the RemoteCacheAttributes object */
     public RemoteCacheAttributes()
     {
@@ -79,8 +72,8 @@
     }
 
     /**
-     * Gets the remoteTypeName attribute of the RemoteCacheAttributes object
-     * 
+     * Gets the remoteTypeName attribute of the RemoteCacheAttributes object.
+     * <p>
      * @return The remoteTypeName value
      */
     public String getRemoteTypeName()
@@ -97,10 +90,9 @@
     }
 
     /**
-     * Sets the remoteTypeName attribute of the RemoteCacheAttributes object
-     * 
-     * @param s
-     *            The new remoteTypeName value
+     * Sets the remoteTypeName attribute of the RemoteCacheAttributes object.
+     * <p>
+     * @param s The new remoteTypeName value
      */
     public void setRemoteTypeName( String s )
     {
@@ -115,8 +107,8 @@
     }
 
     /**
-     * Gets the failoverIndex attribute of the RemoteCacheAttributes object
-     * 
+     * Gets the failoverIndex attribute of the RemoteCacheAttributes object.
+     * <p>
      * @return The failoverIndex value
      */
     public int getFailoverIndex()
@@ -125,10 +117,9 @@
     }
 
     /**
-     * Sets the failoverIndex attribute of the RemoteCacheAttributes object
-     * 
-     * @param p
-     *            The new failoverIndex value
+     * Sets the failoverIndex attribute of the RemoteCacheAttributes object.
+     * <p>
+     * @param p The new failoverIndex value
      */
     public void setFailoverIndex( int p )
     {
@@ -136,8 +127,8 @@
     }
 
     /**
-     * Gets the failovers attribute of the RemoteCacheAttributes object
-     * 
+     * Gets the failovers attribute of the RemoteCacheAttributes object.
+     * <p>
      * @return The failovers value
      */
     public String[] getFailovers()
@@ -146,10 +137,9 @@
     }
 
     /**
-     * Sets the failovers attribute of the RemoteCacheAttributes object
-     * 
-     * @param f
-     *            The new failovers value
+     * Sets the failovers attribute of the RemoteCacheAttributes object.
+     * <p>
+     * @param f The new failovers value
      */
     public void setFailovers( String[] f )
     {
@@ -157,8 +147,8 @@
     }
 
     /**
-     * Gets the remoteType attribute of the RemoteCacheAttributes object
-     * 
+     * Gets the remoteType attribute of the RemoteCacheAttributes object.
+     * <p>
      * @return The remoteType value
      */
     public int getRemoteType()
@@ -167,10 +157,9 @@
     }
 
     /**
-     * Sets the remoteType attribute of the RemoteCacheAttributes object
-     * 
-     * @param p
-     *            The new remoteType value
+     * Sets the remoteType attribute of the RemoteCacheAttributes object.
+     * <p>
+     * @param p The new remoteType value
      */
     public void setRemoteType( int p )
     {
@@ -179,7 +168,6 @@
 
     /*
      * (non-Javadoc)
-     * 
      * @see org.apache.jcs.auxiliary.AuxiliaryCacheAttributes#copy()
      */
     public AuxiliaryCacheAttributes copy()
@@ -196,8 +184,8 @@
     }
 
     /**
-     * Gets the remoteServiceName attribute of the RemoteCacheAttributes object
-     * 
+     * Gets the remoteServiceName attribute of the RemoteCacheAttributes object.
+     * <p>
      * @return The remoteServiceName value
      */
     public String getRemoteServiceName()
@@ -206,10 +194,9 @@
     }
 
     /**
-     * Sets the remoteServiceName attribute of the RemoteCacheAttributes object
-     * 
-     * @param s
-     *            The new remoteServiceName value
+     * Sets the remoteServiceName attribute of the RemoteCacheAttributes object.
+     * <p>
+     * @param s The new remoteServiceName value
      */
     public void setRemoteServiceName( String s )
     {
@@ -217,8 +204,8 @@
     }
 
     /**
-     * Gets the remoteHost attribute of the RemoteCacheAttributes object
-     * 
+     * Gets the remoteHost attribute of the RemoteCacheAttributes object.
+     * <p>
      * @return The remoteHost value
      */
     public String getRemoteHost()
@@ -227,10 +214,9 @@
     }
 
     /**
-     * Sets the remoteHost attribute of the RemoteCacheAttributes object
-     * 
-     * @param s
-     *            The new remoteHost value
+     * Sets the remoteHost attribute of the RemoteCacheAttributes object.
+     * <p>
+     * @param s The new remoteHost value
      */
     public void setRemoteHost( String s )
     {
@@ -238,8 +224,8 @@
     }
 
     /**
-     * Gets the remotePort attribute of the RemoteCacheAttributes object
-     * 
+     * Gets the remotePort attribute of the RemoteCacheAttributes object.
+     * <p>
      * @return The remotePort value
      */
     public int getRemotePort()
@@ -248,10 +234,9 @@
     }
 
     /**
-     * Sets the remotePort attribute of the RemoteCacheAttributes object
-     * 
-     * @param p
-     *            The new remotePort value
+     * Sets the remotePort attribute of the RemoteCacheAttributes object.
+     * <p>
+     * @param p The new remotePort value
      */
     public void setRemotePort( int p )
     {
@@ -259,8 +244,8 @@
     }
 
     /**
-     * Gets the clusterServers attribute of the RemoteCacheAttributes object
-     * 
+     * Gets the clusterServers attribute of the RemoteCacheAttributes object.
+     * <p>
      * @return The clusterServers value
      */
     public String getClusterServers()
@@ -269,10 +254,9 @@
     }
 
     /**
-     * Sets the clusterServers attribute of the RemoteCacheAttributes object
-     * 
-     * @param s
-     *            The new clusterServers value
+     * Sets the clusterServers attribute of the RemoteCacheAttributes object.
+     * <p>
+     * @param s The new clusterServers value
      */
     public void setClusterServers( String s )
     {
@@ -280,8 +264,8 @@
     }
 
     /**
-     * Gets the failoverServers attribute of the RemoteCacheAttributes object
-     * 
+     * Gets the failoverServers attribute of the RemoteCacheAttributes object.
+     * <p>
      * @return The failoverServers value
      */
     public String getFailoverServers()
@@ -290,10 +274,9 @@
     }
 
     /**
-     * Sets the failoverServers attribute of the RemoteCacheAttributes object
-     * 
-     * @param s
-     *            The new failoverServers value
+     * Sets the failoverServers attribute of the RemoteCacheAttributes object.
+     * <p>
+     * @param s The new failoverServers value
      */
     public void setFailoverServers( String s )
     {
@@ -301,8 +284,8 @@
     }
 
     /**
-     * Gets the localPort attribute of the RemoteCacheAttributes object
-     * 
+     * Gets the localPort attribute of the RemoteCacheAttributes object.
+     * <p>
      * @return The localPort value
      */
     public int getLocalPort()
@@ -312,9 +295,7 @@
 
     /**
      * Sets the localPort attribute of the RemoteCacheAttributes object
-     * 
-     * @param p
-     *            The new localPort value
+     * @param p The new localPort value
      */
     public void setLocalPort( int p )
     {
@@ -322,9 +303,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()
@@ -333,11 +313,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 )
     {
@@ -345,8 +323,8 @@
     }
 
     /**
-     * Gets the getOnly attribute of the RemoteCacheAttributes object
-     * 
+     * Gets the getOnly attribute of the RemoteCacheAttributes object.
+     * <p>
      * @return The getOnly value
      */
     public boolean getGetOnly()
@@ -356,9 +334,7 @@
 
     /**
      * Sets the getOnly attribute of the RemoteCacheAttributes object
-     * 
-     * @param r
-     *            The new getOnly value
+     * @param r The new getOnly value
      */
     public void setGetOnly( boolean r )
     {
@@ -366,8 +342,8 @@
     }
 
     /**
-     * Should cluster updates be propogated to the locals
-     * 
+     * Should cluster updates be propogated to the locals.
+     * <p>
      * @return The localClusterConsistency value
      */
     public boolean getLocalClusterConsistency()
@@ -376,10 +352,9 @@
     }
 
     /**
-     * Should cluster updates be propogated to the locals
-     * 
-     * @param r
-     *            The new localClusterConsistency value
+     * Should cluster updates be propogated to the locals.
+     * <p>
+     * @param r The new localClusterConsistency value
      */
     public void setLocalClusterConsistency( boolean r )
     {
@@ -388,7 +363,6 @@
 
     /*
      * (non-Javadoc)
-     * 
      * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes#getThreadPoolName()
      */
     public String getThreadPoolName()
@@ -398,7 +372,6 @@
 
     /*
      * (non-Javadoc)
-     * 
      * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes#setThreadPoolName(java.lang.String)
      */
     public void setThreadPoolName( String name )
@@ -408,7 +381,6 @@
 
     /*
      * (non-Javadoc)
-     * 
      * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes#getGetTimeoutMillis()
      */
     public int getGetTimeoutMillis()
@@ -418,7 +390,6 @@
 
     /*
      * (non-Javadoc)
-     * 
      * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes#setGetTimeoutMillis(int)
      */
     public void setGetTimeoutMillis( int millis )
@@ -443,10 +414,10 @@
     }
 
     /**
-     * By default this option is true. If you set it to false, you will not
-     * receive updates or removes from the remote server.
-     * 
-     * @param receive 
+     * By default this option is true. If you set it to false, you will not receive updates or
+     * removes from the remote server.
+     * <p>
+     * @param receive
      */
     public void setReceive( boolean receive )
     {
@@ -454,24 +425,43 @@
     }
 
     /**
-     * If RECEIVE is false then the remote cache will not register a listener
-     * with the remote server. This allows you to configure a remote server as a
-     * repository from which you can get and to which you put, but from which
-     * you do not reveive any notifications. That is, you will not receive
-     * updates or removes.
+     * If RECEIVE is false then the remote cache will not register a listener with the remote
+     * server. This allows you to configure a remote server as a repository from which you can get
+     * and to which you put, but from which you do not reveive any notifications. That is, you will
+     * not receive updates or removes.
      * <p>
-     * If you set this option to false, you should set your locl memory size to
-     * 0.
+     * If you set this option to false, you should set your locl memory size to 0.
      * <p>
      * The remote cache manager uses this value to decide whether or not to register a listener.
-     * 
      * @return the receive value.
      */
     public boolean isReceive()
     {
         return this.receive;
     }
-    
+
+    /**
+     * The number of elements the zombie queue will hold. This queue is used to store events if we
+     * loose our conenction with the server.
+     * <p>
+     * @param zombieQueueMaxSize The zombieQueueMaxSize to set.
+     */
+    public void setZombieQueueMaxSize( int zombieQueueMaxSize )
+    {
+        this.zombieQueueMaxSize = zombieQueueMaxSize;
+    }
+
+    /**
+     * The number of elements the zombie queue will hold. This queue is used to store events if we
+     * loose our conenction with the server.
+     * <p>
+     * @return Returns the zombieQueueMaxSize.
+     */
+    public int getZombieQueueMaxSize()
+    {
+        return zombieQueueMaxSize;
+    }
+
     /**
      * @return String, all the important values that can be configured
      */
@@ -489,6 +479,7 @@
         buf.append( "\n threadPoolName = [" + getThreadPoolName() + "]" );
         buf.append( "\n remoteType = [" + remoteType + "]" );
         buf.append( "\n localClusterConsistency = [" + getLocalClusterConsistency() + "]" );
+        buf.append( "\n zombieQueueMaxSize = [" + getZombieQueueMaxSize() + "]" );
         return buf.toString();
     }
 

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java?rev=433657&r1=433656&r2=433657&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java Tue Aug 22 07:58:23 2006
@@ -1,19 +1,12 @@
 package org.apache.jcs.auxiliary.remote;
 
 /*
- * 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;
@@ -40,9 +33,21 @@
 import org.apache.jcs.engine.stats.behavior.IStats;
 
 /**
- * Used to queue up update requests to the underlying cache. These requests will
- * be processed in their order of arrival via the cache event queue processor.
- * 
+ * Used to queue up update requests to the underlying cache. These requests will be processed in
+ * their order of arrival via the cache event queue processor.
+ * <p>
+ * Typically errors will be handled down stream. We only need to kill the queue if an error makes it
+ * to this level from the queue. That can only happen if the queue is damaged, since the events are
+ * procesed asynchronously.
+ * <p>
+ * There is no reason to create a queue on startup if the remote is not healthy.
+ * <p>
+ * If the remote cache encounters an error it will zombie--create a blaking facade for the service.
+ * The Zombie will queue up items until the conenction is restored. An alternative way to accomplish
+ * the same thing would be to stop, not destroy the queue at this level. That way items would be
+ * added to the queue and then when the connection is restored, we could start the worker threads
+ * again. This is a better long term solution, but it requires some significnat changes to the
+ * complicated worker queues.
  */
 public class RemoteCacheNoWait
     implements AuxiliaryCache
@@ -56,9 +61,9 @@
     private ICacheEventQueue q;
 
     /**
-     * Constructs with the given remote cache, and fires up an event queue for
-     * aysnchronous processing.
-     * 
+     * Constructs with the given remote cache, and fires up an event queue for aysnchronous
+     * processing.
+     * <p>
      * @param cache
      */
     public RemoteCacheNoWait( RemoteCache cache )
@@ -75,9 +80,10 @@
         }
     }
 
-    /*
+    /**
+     * Adds a put event to the queue.
+     * <p>
      * (non-Javadoc)
-     * 
      * @see org.apache.jcs.engine.behavior.ICache#update(org.apache.jcs.engine.behavior.ICacheElement)
      */
     public void update( ICacheElement ce )
@@ -89,7 +95,7 @@
         }
         catch ( IOException ex )
         {
-            log.error( ex );
+            log.error( "Problem adding putEvent to queue.", ex );
             q.destroy();
             throw ex;
         }
@@ -97,7 +103,7 @@
 
     /**
      * Synchronously reads from the remote cache.
-     * 
+     * <p>
      * @param key
      * @return
      * @throws IOException
@@ -111,20 +117,27 @@
         }
         catch ( UnmarshalException ue )
         {
-            log.debug( "Retrying the get owing to UnmarshalException..." );
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "Retrying the get owing to UnmarshalException..." );
+            }
             try
             {
                 return cache.get( key );
             }
             catch ( IOException ex )
             {
-                log.debug( "Failed in retrying the get for the second time." );
-                q.destroy();
+                if ( log.isInfoEnabled() )
+                {
+                    log.info( "Failed in retrying the get for the second time. " + ex.getMessage() );
+                }
             }
         }
         catch ( IOException ex )
         {
-            q.destroy();
+            // We don't want to destroy the queue on a get failure.
+            // The RemoteCache will Zombie and queue.
+            // Since get does not use the queue, I dont want to killing the queue.
             throw ex;
         }
         return null;
@@ -138,7 +151,7 @@
 
     /**
      * Adds a remove request to the remote cache.
-     * 
+     * <p>
      * @param key
      * @return
      * @throws IOException
@@ -152,7 +165,7 @@
         }
         catch ( IOException ex )
         {
-            log.error( ex );
+            log.error( "Problem adding RemoveEvent to queue.", ex );
             q.destroy();
             throw ex;
         }
@@ -161,7 +174,6 @@
 
     /**
      * Adds a removeAll request to the remote cache.
-     * 
      * @throws IOException
      */
     public void removeAll()
@@ -173,7 +185,7 @@
         }
         catch ( IOException ex )
         {
-            log.error( ex );
+            log.error( "Problem adding RemoveAllEvent to queue.", ex );
             q.destroy();
             throw ex;
         }
@@ -188,15 +200,14 @@
         }
         catch ( IOException ex )
         {
-            log.error( ex );
-            // not clear that we should destroy the q here.
+            log.error( "Problem adding DisposeEvent to queue.", ex );
             q.destroy();
         }
     }
 
     /**
-     * No remote invokation.
-     * 
+     * No remote invocation.
+     * <p>
      * @return The size value
      */
     public int getSize()
@@ -206,7 +217,7 @@
 
     /**
      * No remote invokation.
-     * 
+     * <p>
      * @return The cacheType value
      */
     public int getCacheType()
@@ -215,9 +226,8 @@
     }
 
     /**
-     * Returns the asyn cache status. An error status indicates either the
-     * remote connection is not available, or the asyn queue has been
-     * unexpectedly destroyed. No remote invocation.
+     * Returns the asyn cache status. An error status indicates either the remote connection is not
+     * available, or the asyn queue has been unexpectedly destroyed. No remote invocation.
      * <p>
      * @return The status value
      */
@@ -237,8 +247,8 @@
     }
 
     /**
-     * Replaces the remote cache service handle with the given handle and reset
-     * the event queue by starting up a new instance.
+     * Replaces the remote cache service handle with the given handle and reset the event queue by
+     * starting up a new instance.
      * <p>
      * @param remote
      */
@@ -250,8 +260,9 @@
     }
 
     /**
-     * Resets the event q by first destroying the existing one and starting up
-     * new one.
+     * Resets the event q by first destroying the existing one and starting up new one.
+     * <p>
+     * TODO rethink this.  There may be no good reason to kill the existing queue.
      */
     public void resetEventQ()
     {
@@ -266,8 +277,8 @@
     }
 
     /**
-     * This is temporary. It allows the amanger to get the lister.
-     * 
+     * This is temporary. It allows the manager to get the lister.
+     * <p>
      * @return
      */
     protected RemoteCache getRemoteCache()
@@ -277,7 +288,6 @@
 
     /*
      * (non-Javadoc)
-     * 
      * @see java.lang.Object#toString()
      */
     public String toString()
@@ -287,7 +297,6 @@
 
     /**
      * getStats
-     * 
      * @return String
      */
     public String getStats()
@@ -297,7 +306,6 @@
 
     /*
      * (non-Javadoc)
-     * 
      * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatistics()
      */
     public IStats getStatistics()

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheRestore.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheRestore.java?rev=433657&r1=433656&r2=433657&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheRestore.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheRestore.java Tue Aug 22 07:58:23 2006
@@ -1,19 +1,12 @@
 package org.apache.jcs.auxiliary.remote;
 
 /*
- * 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.rmi.Naming;
@@ -27,14 +20,13 @@
 import org.apache.commons.logging.LogFactory;
 
 /**
- * Used to repair the remote caches managed by the associated instance of
- * RemoteCacheManager. When there is an error the monitor kicks off. The
- * Failover runner starts looks for a manager with a connection to a remote
- * cache that is not in error. If a manager's connection to a remote cache is
- * found to be in error, the restorer kicks off and tries to reconnect. When it
- * is succesful, the status of the manager changes. When the failover runner
- * finds that the primary is in good shape, it will switch back.
- *  
+ * Used to repair the remote caches managed by the associated instance of RemoteCacheManager.
+ * <p>
+ * When there is an error the monitor kicks off. The Failover runner starts looks for a manager with
+ * a connection to a remote cache that is not in error. If a manager's connection to a remote cache
+ * is found to be in error, the restorer kicks off and tries to reconnect. When it is succesful, the
+ * status of the manager changes. When the failover runner finds that the primary is in good shape,
+ * it will switch back.
  */
 public class RemoteCacheRestore
     implements ICacheRestore
@@ -43,26 +35,26 @@
 
     private final RemoteCacheManager rcm;
 
-    //private final AuxiliaryCacheManager rcm;
+    // private final AuxiliaryCacheManager rcm;
     private boolean canFix = true;
 
     private Object remoteObj;
 
     /**
      * Constructs with the given instance of RemoteCacheManager.
-     * 
      * @param rcm
      */
     public RemoteCacheRestore( RemoteCacheManager rcm )
     {
-        //public RemoteCacheRestore(AuxiliaryCacheManager rcm) {
+        // public RemoteCacheRestore(AuxiliaryCacheManager rcm) {
         this.rcm = rcm;
     }
 
     /**
-     * Returns true if the connection to the remote host for the corresponding
-     * cache manager can be successfully re-established.
-     * @return
+     * Returns true if the connection to the remote host for the corresponding cache manager can be
+     * successfully re-established.
+     * <p>
+     * @return true if we found a failover server
      */
     public boolean canFix()
     {
@@ -71,16 +63,20 @@
             return canFix;
         }
         String registry = "//" + rcm.host + ":" + rcm.port + "/" + rcm.service;
-        log.info( "looking up server " + registry );
+        if ( log.isInfoEnabled() )
+        {
+            log.info( "looking up server " + registry );
+        }
         try
         {
             remoteObj = Naming.lookup( registry );
-            log.info( "looking up server " + registry );
+            if ( log.isInfoEnabled() )
+            {
+                log.info( "looking up server " + registry );
+            }
         }
         catch ( Exception ex )
         {
-            //log.error(ex, "host=" + rcm.host + "; port" + rcm.port + ";
-            // service=" + rcm.service );
             log.error( "host=" + rcm.host + "; port" + rcm.port + "; service=" + rcm.service );
             canFix = false;
         }
@@ -97,7 +93,11 @@
             return;
         }
         rcm.fixCaches( (IRemoteCacheService) remoteObj, (IRemoteCacheObserver) remoteObj );
-        String msg = "Remote connection to " + "//" + rcm.host + ":" + rcm.port + "/" + rcm.service + " resumed.";
-        log.info( msg );
+
+        if ( log.isInfoEnabled() )
+        {
+            String msg = "Remote connection to " + "//" + rcm.host + ":" + rcm.port + "/" + rcm.service + " resumed.";
+            log.info( msg );
+        }
     }
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/ZombieRemoteCacheService.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/ZombieRemoteCacheService.java?rev=433657&r1=433656&r2=433657&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/ZombieRemoteCacheService.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/ZombieRemoteCacheService.java Tue Aug 22 07:58:23 2006
@@ -12,7 +12,6 @@
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.Collections;
-import java.util.LinkedList;
 import java.util.Set;
 
 import org.apache.commons.logging.Log;
@@ -20,6 +19,7 @@
 import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService;
 import org.apache.jcs.engine.ZombieCacheService;
 import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.utils.struct.BoundedQueue;
 import org.apache.jcs.utils.timing.ElapsedTimer;
 
 /**
@@ -40,15 +40,14 @@
 
     private int maxQueueSize = 0;
 
-    // substitute the BoundedQueue tomorrow.
-    private LinkedList queue = new LinkedList();
+    private BoundedQueue queue;
 
     /**
      * Default.
      */
     public ZombieRemoteCacheService()
     {
-        // nothing
+        queue = new BoundedQueue( 0 );
     }
 
     /**
@@ -59,6 +58,7 @@
     public ZombieRemoteCacheService( int maxQueueSize )
     {
         this.maxQueueSize = maxQueueSize;
+        queue = new BoundedQueue( maxQueueSize );
     }
 
     /**
@@ -70,7 +70,7 @@
     {
         return queue.size();
     }
-    
+
     /**
      * Adds an update event to the queue if the maxSize is greater than 0;
      * <p>
@@ -83,7 +83,7 @@
         if ( maxQueueSize > 0 )
         {
             PutEvent event = new PutEvent( item, listenerId );
-            queue.addLast( event );
+            queue.add( event );
         }
         // Zombies have no inner life
         return;
@@ -101,7 +101,7 @@
         if ( maxQueueSize > 0 )
         {
             RemoveEvent event = new RemoveEvent( cacheName, key, listenerId );
-            queue.addLast( event );
+            queue.add( event );
         }
         // Zombies have no inner life
         return;
@@ -119,7 +119,7 @@
         if ( maxQueueSize > 0 )
         {
             RemoveAllEvent event = new RemoveAllEvent( cacheName, listenerId );
-            queue.addLast( event );
+            queue.add( event );
         }
         // Zombies have no inner life
         return;
@@ -155,6 +155,7 @@
      * Walk the queue, calling the service for each queue operation.
      * <p>
      * @param service
+     * @throws Exception
      */
     protected void propagateEvents( IRemoteCacheService service )
         throws Exception
@@ -168,9 +169,9 @@
         while ( !queue.isEmpty() )
         {
             cnt++;
-            
+
             // for each item, call the appropriate service method
-            ZombieEvent event = (ZombieEvent) queue.removeFirst();
+            ZombieEvent event = (ZombieEvent) queue.take();
 
             if ( event instanceof PutEvent )
             {

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheAttributes.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheAttributes.java?rev=433657&r1=433656&r2=433657&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheAttributes.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheAttributes.java Tue Aug 22 07:58:23 2006
@@ -1,31 +1,22 @@
 package org.apache.jcs.auxiliary.remote.behavior;
 
 /*
- * 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.AuxiliaryCacheAttributes;
 
 /**
  * This specifies what a remote cache configuration object should look like.
- * 
  */
 public interface IRemoteCacheAttributes
     extends AuxiliaryCacheAttributes
 {
-
     /**
      * A remote cache is either a local cache or a cluster cache.
      */
@@ -40,300 +31,297 @@
     public static final int DEFAULT_RMI_SOCKET_FACTORY_TIMEOUT_MILLIS = 10000;
 
     /**
-     * If RECEIVE is false then the remote cache will not register a listener
-     * with the remote server. This allows you to configure a remote server as a
-     * repository from which you can get and to which you put, but from which
-     * you do not reveive any notifications. That is, you will not receive
-     * updates or removes.
+     * If RECEIVE is false then the remote cache will not register a listener with the remote
+     * server. This allows you to configure a remote server as a repository from which you can get
+     * and to which you put, but from which you do not reveive any notifications. That is, you will
+     * not receive updates or removes.
      * <p>
-     * If you set this option to false, you should set your locl memory size to
-     * 0.
+     * If you set this option to false, you should set your locl memory size to 0.
      */
     public static final boolean DEFAULT_RECEIVE = true;
 
     /**
+     * The number of elements the zombie queue will hold. This queue is used to store events if we
+     * loose our conenction with the server.
+     */
+    public static final int DEFAULT_ZOMBIE_QUEUE_MAX_SIZE = 1000;
+        
+    /**
      * Gets the remoteTypeName attribute of the IRemoteCacheAttributes object
-     * 
+     * <p>
      * @return The remoteTypeName value
      */
     public String getRemoteTypeName();
 
     /**
      * Sets the remoteTypeName attribute of the IRemoteCacheAttributes object
-     * 
-     * @param s
-     *            The new remoteTypeName value
+     * <p>
+     * @param s The new remoteTypeName value
      */
     public void setRemoteTypeName( String s );
 
     /**
      * Gets the remoteType attribute of the IRemoteCacheAttributes object
-     * 
+     * <p>
      * @return The remoteType value
      */
     public int getRemoteType();
 
     /**
      * Sets the remoteType attribute of the IRemoteCacheAttributes object
-     * 
-     * @param p
-     *            The new remoteType value
+     * <p>
+     * @param p The new remoteType value
      */
     public void setRemoteType( int p );
 
     /**
      * Gets the failoverIndex attribute of the IRemoteCacheAttributes object.
      * <p>
-     * This specifies which server in the list we are listening to if the number
-     * is greater than 0 we will try to move to 0 position the primary is added
-     * as position 1 if it is present
-     * 
+     * This specifies which server in the list we are listening to if the number is greater than 0
+     * we will try to move to 0 position the primary is added as position 1 if it is present
+     * <p>
      * @return The failoverIndex value
      */
     public int getFailoverIndex();
 
     /**
      * Sets the failoverIndex attribute of the IRemoteCacheAttributes object
-     * 
-     * @param p
-     *            The new failoverIndex value
+     * <p>
+     * @param p The new failoverIndex value
      */
     public void setFailoverIndex( int p );
 
     /**
      * Gets the failovers attribute of the IRemoteCacheAttributes object
-     * 
+     * <p>
      * @return The failovers value
      */
     public String[] getFailovers();
 
     /**
      * Sets the failovers attribute of the IRemoteCacheAttributes object
-     * 
-     * @param f
-     *            The new failovers value
+     * <p>
+     * @param f The new failovers value
      */
     public void setFailovers( String[] f );
 
     /**
      * Gets the remoteServiceName attribute of the IRemoteCacheAttributes object
-     * 
+     * <p>
      * @return The remoteServiceName value
      */
     public String getRemoteServiceName();
 
     /**
      * Sets the remoteServiceName attribute of the IRemoteCacheAttributes object
-     * 
-     * @param s
-     *            The new remoteServiceName value
+     * <p>
+     * @param s The new remoteServiceName value
      */
     public void setRemoteServiceName( String s );
 
     /**
      * Gets the remoteHost attribute of the IRemoteCacheAttributes object
-     * 
+     * <p>
      * @return The remoteHost value
      */
     public String getRemoteHost();
 
     /**
      * Sets the remoteHost attribute of the IRemoteCacheAttributes object
-     * 
-     * @param s
-     *            The new remoteHost value
+     * <p>
+     * @param s The new remoteHost value
      */
     public void setRemoteHost( String s );
 
     /**
      * Gets the remotePort attribute of the IRemoteCacheAttributes object
-     * 
+     * <p>
      * @return The remotePort value
      */
     public int getRemotePort();
 
     /**
      * Sets the remotePort attribute of the IRemoteCacheAttributes object
-     * 
-     * @param p
-     *            The new remotePort value
+     * <p>
+     * @param p The new remotePort value
      */
     public void setRemotePort( int p );
 
     /**
      * Gets the localPort attribute of the IRemoteCacheAttributes object
-     * 
+     * <p>
      * @return The localPort value
      */
     public int getLocalPort();
 
     /**
      * Sets the localPort attribute of the IRemoteCacheAttributes object
-     * 
-     * @param p
-     *            The new localPort value
+     * <p>
+     * @param p The new localPort value
      */
     public void setLocalPort( int p );
 
     /**
      * Gets the clusterServers attribute of the IRemoteCacheAttributes object
-     * 
+     * <p>
      * @return The clusterServers value
      */
     public String getClusterServers();
 
     /**
      * Sets the clusterServers attribute of the IRemoteCacheAttributes object
-     * 
-     * @param s
-     *            The new clusterServers value
+     * <p>
+     * @param s The new clusterServers value
      */
     public void setClusterServers( String s );
 
     /**
      * Gets the failoverServers attribute of the IRemoteCacheAttributes object
-     * 
+     * <p>
      * @return The failoverServers value
      */
     public String getFailoverServers();
 
     /**
      * Sets the failoverServers attribute of the IRemoteCacheAttributes object
-     * 
-     * @param s
-     *            The new failoverServers value
+     * <p>
+     * @param s The new failoverServers value
      */
     public void setFailoverServers( 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
-     * object
-     * 
-     * @param r
-     *            The new removeUponRemotePut value
+     * 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
-     * 
+     * <p>
      * @return The getOnly value
      */
     public boolean getGetOnly();
 
     /**
      * Sets the getOnly attribute of the IRemoteCacheAttributes object
-     * 
-     * @param r
-     *            The new getOnly value
+     * <p>
+     * @param r The new getOnly value
      */
     public void setGetOnly( boolean r );
 
     /**
      * Should cluster updates be propogated to the locals
-     * 
+     * <p>
      * @return The localClusterConsistency value
      */
     public boolean getLocalClusterConsistency();
 
     /**
      * 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 );
 
     /**
-     * The thread pool the remote cache should use. At first this will only be
-     * for gets.
+     * The thread pool the remote cache should use. At first this will only be for gets.
      * <p>
      * The default name is "remote_cache_client"
-     * 
+     * <p>
      * @return
      */
     public abstract String getThreadPoolName();
 
     /**
-     * Set the anme of the pool to use. Pools should be defined in the
-     * cache.ccf.
-     * 
+     * Set the anme of the pool to use. Pools should be defined in the cache.ccf.
+     * <p>
      * @param name
      */
     public abstract void setThreadPoolName( String name );
 
     /**
-     * -1 and 0 mean no timeout, this is the default if the timeout is -1 or 0,
-     * no threadpool will be used.
-     * 
+     * -1 and 0 mean no timeout, this is the default if the timeout is -1 or 0, no threadpool will
+     * be used.
+     * <p>
      * @return
      */
     public abstract int getGetTimeoutMillis();
 
     /**
-     * -1 means no timeout, this is the default if the timeout is -1 or 0, no
-     * threadpool will be used. If the timeout is greater than 0 a threadpool
-     * will be used for get requests.
-     * 
+     * -1 means no timeout, this is the default if the timeout is -1 or 0, no threadpool will be
+     * used. If the timeout is greater than 0 a threadpool will be used for get requests.
+     * <p>
      * @param millis
      */
     public abstract void setGetTimeoutMillis( int millis );
 
     /**
-     * This sets a general timeout on the rmi socket factory. By default the
-     * socket factory will block forever.
+     * This sets a general timeout on the rmi socket factory. By default the socket factory will
+     * block forever.
      * <p>
      * We have a default setting. The default rmi behavior should never be used.
-     * 
+     * <p>
      * @return int milliseconds
      */
     public abstract int getRmiSocketFactoryTimeoutMillis();
 
     /**
-     * This sets a general timeout on the rmi socket factory. By default the
-     * socket factory will block forever.
-     * 
+     * This sets a general timeout on the rmi socket factory. By default the socket factory will
+     * block forever.
+     * <p>
      * @param rmiSocketFactoryTimeoutMillis
      */
     public abstract void setRmiSocketFactoryTimeoutMillis( int rmiSocketFactoryTimeoutMillis );
 
     /**
-     * By default this option is true. If you set it to false, you will not
-     * receive updates or removes from the remote server.
-     * 
+     * By default this option is true. If you set it to false, you will not receive updates or
+     * removes from the remote server.
+     * <p>
      * @param receive
      */
     public void setReceive( boolean receive );
 
     /**
-     * If RECEIVE is false then the remote cache will not register a listener
-     * with the remote server. This allows you to configure a remote server as a
-     * repository from which you can get and to which you put, but from which
-     * you do not reveive any notifications. That is, you will not receive
-     * updates or removes.
+     * If RECEIVE is false then the remote cache will not register a listener with the remote
+     * server. This allows you to configure a remote server as a repository from which you can get
+     * and to which you put, but from which you do not reveive any notifications. That is, you will
+     * not receive updates or removes.
      * <p>
-     * If you set this option to false, you should set your locl memory size to
-     * 0.
+     * If you set this option to false, you should set your locl memory size to 0.
      * <p>
-     * The remote cache manager uses this value to decide whether or not to
-     * register a listener.
+     * The remote cache manager uses this value to decide whether or not to register a listener.
      * <p>
      * It makes no sense to configure a cluster remote cache to no receive.
      * <p>
-     * Since a non-receiving remote cache client will not register a listener,
-     * it will not have a listener id assigned from the server. As such the
-     * remote server cannot determine if it is a cluster or a normal client. It
-     * will assume that it is a normal client.
-     * 
+     * Since a non-receiving remote cache client will not register a listener, it will not have a
+     * listener id assigned from the server. As such the remote server cannot determine if it is a
+     * cluster or a normal client. It will assume that it is a normal client.
+     * <p>
      * @return the receive value.
      */
     public boolean isReceive();
+    
+    /**
+     * The number of elements the zombie queue will hold. This queue is used to store events if we
+     * loose our conenction with the server.
+     * <p>
+     * @param zombieQueueMaxSize The zombieQueueMaxSize to set.
+     */
+    public void setZombieQueueMaxSize( int zombieQueueMaxSize );
+
+    /**
+     * The number of elements the zombie queue will hold. This queue is used to store events if we
+     * loose our conenction with the server.
+     * <p>
+     * @return Returns the zombieQueueMaxSize.
+     */
+    public int getZombieQueueMaxSize();   
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventQueue.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventQueue.java?rev=433657&r1=433656&r2=433657&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventQueue.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventQueue.java Tue Aug 22 07:58:23 2006
@@ -28,7 +28,6 @@
  */
 public interface ICacheEventQueue
 {
-
     /**
      * Does not use a thread pool.
      */

Added: jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/BoundedQueue.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/BoundedQueue.java?rev=433657&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/BoundedQueue.java (added)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/BoundedQueue.java Tue Aug 22 07:58:23 2006
@@ -0,0 +1,72 @@
+package org.apache.jcs.utils.struct;
+
+/**
+ * This is a bounded queue. It only allows maxSize items.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class BoundedQueue
+{
+    private int maxSize;
+
+    private DoubleLinkedList list = new DoubleLinkedList();
+
+    /**
+     * Initialize the bounded queue.
+     * <p>
+     * @param maxSize
+     */
+    public BoundedQueue( int maxSize )
+    {
+        this.maxSize = maxSize;
+    }
+
+    /**
+     * Adds an item to the end of the queue, which is the front of the list.
+     * <p>
+     * @param object
+     */
+    public void add( Object object )
+    {
+        if ( list.size() >= maxSize )
+        {
+            list.removeLast();
+        }
+        list.addFirst( new DoubleLinkedListNode( object ) );
+    }
+
+    /**
+     * Takes the last of the underlying double linked list.
+     * <p>
+     * @return null if it is epmpty.
+     */
+    public Object take()
+    {
+        DoubleLinkedListNode node = list.removeLast();
+        if ( node != null )
+        {
+            return node.getPayload();
+        }
+        return null;
+    }
+    
+    /**
+     * Return the number of items in the queue.
+     * <p>
+     * @return size
+     */
+    public int size()
+    {
+        return list.size();
+    }
+    
+    /**
+     * Return true if the size is <= 0;
+     * <p>
+     * @return true is size <= 0;
+     */
+    public boolean isEmpty()
+    {
+        return list.size() <= 0;
+    }
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java?rev=433657&r1=433656&r2=433657&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java Tue Aug 22 07:58:23 2006
@@ -50,9 +50,9 @@
             disk.doRemove( new Integer( i ) );
         }
 
-        Thread.sleep( 100 );
+        Thread.sleep( 500 );
         Thread.yield();
-        Thread.sleep( 100 );
+        Thread.sleep( 500 );
         long sizeAfterRemove = disk.getDataFileSize();
         System.out.println( "file sizeAfterRemove " + sizeAfterRemove );
         long expectedSizeAfterRemove = DiskTestObjectUtil.totalSize( elements, removeCount, elements.length );

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/BoundedQueueUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/BoundedQueueUnitTest.java?rev=433657&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/BoundedQueueUnitTest.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/BoundedQueueUnitTest.java Tue Aug 22 07:58:23 2006
@@ -0,0 +1,74 @@
+package org.apache.jcs.utils.struct;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the bounded queue.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class BoundedQueueUnitTest
+    extends TestCase
+{
+    /**
+     * Verify null returned for empty.
+     */
+    public void testTakeLastEmpty()
+    {
+        // SETUP
+        int maxSize = 10;
+        BoundedQueue queue = new BoundedQueue( maxSize );
+
+        // DO WORK
+        Object result = queue.take();
+
+        // VERIFY
+        assertNull( "Result should be null", result );
+    }
+
+    /**
+     * Verify that the queue returns the number of elements and the it does not exceed the max.
+     */
+    public void testSize()
+    {
+        // SETUP
+        int maxSize = 10;
+        BoundedQueue queue = new BoundedQueue( maxSize );
+
+        // DO WORK
+        for ( int i = 0; i < maxSize * 2; i++ )
+        {
+            queue.add( "adfadsf sad " + i );
+        }
+
+        int result = queue.size();
+
+        // VERIFY
+        assertEquals( "Result size not as expected", maxSize, result );
+    }
+
+    /**
+     * Verify that the items come back in the order put in.
+     */
+    public void testFIFOOrderedTake()
+    {
+        // SETUP
+        int maxSize = 10;
+        BoundedQueue queue = new BoundedQueue( maxSize );
+
+        // DO WORK
+        for ( int i = 0; i < maxSize; i++ )
+        {
+            queue.add( String.valueOf( i ) );
+        }
+
+
+        // VERIFY
+        
+        for ( int i = 0; i < maxSize; i++ )
+        {
+            String result = (String)queue.take();
+            assertEquals( "Result not as expected",  String.valueOf( i ) ,  result  );
+        }        
+    }
+}

Modified: jakarta/jcs/trunk/xdocs/RemoteCacheProperties.xml
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/xdocs/RemoteCacheProperties.xml?rev=433657&r1=433656&r2=433657&view=diff
==============================================================================
--- jakarta/jcs/trunk/xdocs/RemoteCacheProperties.xml (original)
+++ jakarta/jcs/trunk/xdocs/RemoteCacheProperties.xml Tue Aug 22 07:58:23 2006
@@ -61,11 +61,12 @@
 							will remove any local copy it has of the
 							object rather than storing the new version.
 							If you have sticky load balancing across
-							your client servers, then it would make sense
-							to set RemoveUponRemotePut to true if the
-							data is mostly client specific. If the data
-							is re-usable, the you should most likely set
-							this option to false, which is the default.
+							your client servers, then it would make
+							sense to set RemoveUponRemotePut to true if
+							the data is mostly client specific. If the
+							data is re-usable, the you should most
+							likely set this option to false, which is
+							the default.
 						</td>
 						<td>N</td>
 						<td>false</td>
@@ -113,6 +114,16 @@
 						</td>
 						<td>N</td>
 						<td>true</td>
+					</tr>
+					<tr>
+						<td>ZombieQueueMaxSize</td>
+						<td>
+							The number of elements the zombie queue will
+							hold. This queue is used to store events if
+							we * loose our conenction with the server.
+						</td>
+						<td>N</td>
+						<td>1000</td>
 					</tr>
 				</table>
 			</subsection>



---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org


Mime
View raw message