You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by as...@apache.org on 2009/07/23 20:27:42 UTC

svn commit: r797178 [1/2] - in /jakarta/jcs/trunk/src: conf/ java/org/apache/jcs/auxiliary/lateral/ java/org/apache/jcs/auxiliary/lateral/behavior/ java/org/apache/jcs/auxiliary/lateral/socket/tcp/ java/org/apache/jcs/auxiliary/lateral/socket/tcp/behav...

Author: asmuts
Date: Thu Jul 23 18:27:41 2009
New Revision: 797178

URL: http://svn.apache.org/viewvc?rev=797178&view=rev
Log:
Made a reusable queuing zombie service from the one in the remote cache.  Made the lateral cache use it.  Finished, for now, the UDP discovery move into a reusable spot.  Lateral TCP is now fully functional with the new discovery service.

Added:
    jakarta/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheServiceNonLocal.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheServiceNonLocal.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/engine/MockCacheServiceNonLocal.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/engine/ZombieCacheServiceNonLocalUnitTest.java
Modified:
    jakarta/jcs/trunk/src/conf/log4j.properties
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheAttributes.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheRestore.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/ZombieLateralCacheService.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/behavior/ILateralCacheAttributes.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/behavior/ILateralCacheService.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerManager.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/behavior/ITCPLateralCacheAttributes.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/ZombieRemoteCacheService.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheService.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheService.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/DiscoveredService.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoverySenderThread.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoveryService.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/behavior/IDiscoveryListener.java
    jakarta/jcs/trunk/src/test-conf/TestTCPLateralRemoveFilter.ccf
    jakarta/jcs/trunk/src/test-conf/log4j.properties
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/utils/discovery/UDPDiscoveryServiceUnitTest.java

Modified: jakarta/jcs/trunk/src/conf/log4j.properties
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/conf/log4j.properties?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/conf/log4j.properties (original)
+++ jakarta/jcs/trunk/src/conf/log4j.properties Thu Jul 23 18:27:41 2009
@@ -54,15 +54,16 @@
 
 # log4j.category.org.apache.jcs.auxiliary=INFO
 # log4j.category.org.apache.jcs.auxiliary.disk=WARN,WF
-log4j.category.org.apache.jcs.auxiliary.lateral=INFO
-log4j.category.org.apache.jcs.auxiliary.lateral.javagroups=INFO
+# log4j.category.org.apache.jcs.auxiliary.lateral=INFO
+# log4j.category.org.apache.jcs.auxiliary.lateral.javagroups=INFO
 # log4j.category.org.apache.jcs.auxiliary.lateral.xmlrpc=INFO
-log4j.category.org.apache.jcs.auxiliary.remote=INFO
+# log4j.category.org.apache.jcs.auxiliary.remote=INFO
 # 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
+# log4j.category.org.apache.jcs.utils.discovery=DEBUG
 
 log4j.category.org.apache.jcs.utils=INFO

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCache.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCache.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCache.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCache.java Thu Jul 23 18:27:41 2009
@@ -53,13 +53,13 @@
     private final static Log log = LogFactory.getLog( LateralCache.class );
 
     /** generalize this, use another interface */
-    private ILateralCacheAttributes cattr;
+    private ILateralCacheAttributes lateralCacheAttribures;
 
     /** The region name */
     final String cacheName;
 
     /** either http, socket.udp, or socket.tcp can set in config */
-    private ILateralCacheService lateral;
+    private ILateralCacheService lateralCacheService;
 
     /** Monitors the connection. */
     private LateralCacheMonitor monitor;
@@ -74,8 +74,8 @@
     public LateralCache( ILateralCacheAttributes cattr, ILateralCacheService lateral, LateralCacheMonitor monitor )
     {
         this.cacheName = cattr.getCacheName();
-        this.cattr = cattr;
-        this.lateral = lateral;
+        this.lateralCacheAttribures = cattr;
+        this.lateralCacheService = lateral;
         this.monitor = monitor;
     }
 
@@ -84,10 +84,10 @@
      * <p>
      * @param cattr
      */
-    protected LateralCache( ILateralCacheAttributes cattr )
+    public LateralCache( ILateralCacheAttributes cattr )
     {
         this.cacheName = cattr.getCacheName();
-        this.cattr = cattr;
+        this.lateralCacheAttribures = cattr;
     }
 
     /**
@@ -103,20 +103,20 @@
         {
             if ( log.isDebugEnabled() )
             {
-                log.debug( "update: lateral = [" + lateral + "], " + "LateralCacheInfo.listenerId = "
+                log.debug( "update: lateral = [" + lateralCacheService + "], " + "LateralCacheInfo.listenerId = "
                     + LateralCacheInfo.listenerId );
             }
-            lateral.update( ce, LateralCacheInfo.listenerId );
+            lateralCacheService.update( ce, LateralCacheInfo.listenerId );
         }
         catch ( NullPointerException npe )
         {
-            log.error( "Failure updating lateral. lateral = " + lateral, npe );
-            handleException( npe, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName() + "@" + cattr );
+            log.error( "Failure updating lateral. lateral = " + lateralCacheService, npe );
+            handleException( npe, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName() + "@" + lateralCacheAttribures );
             return;
         }
         catch ( Exception ex )
         {
-            handleException( ex, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName() + "@" + cattr );
+            handleException( ex, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName() + "@" + lateralCacheAttribures );
         }
     }
 
@@ -132,18 +132,18 @@
     {
         ICacheElement obj = null;
 
-        if ( this.cattr.getPutOnlyMode() )
+        if ( this.lateralCacheAttribures.getPutOnlyMode() )
         {
             return null;
         }
         try
         {
-            obj = lateral.get( cacheName, key );
+            obj = lateralCacheService.get( cacheName, key );
         }
         catch ( Exception e )
         {
             log.error( e );
-            handleException( e, "Failed to get [" + key + "] from " + cattr.getCacheName() + "@" + cattr );
+            handleException( e, "Failed to get [" + key + "] from " + lateralCacheAttribures.getCacheName() + "@" + lateralCacheAttribures );
         }
         return obj;
     }
@@ -159,18 +159,18 @@
     {
         Map elements = new HashMap();
 
-        if ( this.cattr.getPutOnlyMode() )
+        if ( this.lateralCacheAttribures.getPutOnlyMode() )
         {
             return Collections.EMPTY_MAP;
         }
         try
         {
-            elements = lateral.getMatching( cacheName, pattern );
+            elements = lateralCacheService.getMatching( cacheName, pattern );
         }
         catch ( Exception e )
         {
             log.error( e );
-            handleException( e, "Failed to getMatching [" + pattern + "] from " + cattr.getCacheName() + "@" + cattr );
+            handleException( e, "Failed to getMatching [" + pattern + "] from " + lateralCacheAttribures.getCacheName() + "@" + lateralCacheAttribures );
         }
         return elements;
     }
@@ -211,10 +211,21 @@
     /**
      * @param groupName
      * @return A set of group keys.
+     * @throws IOException
      */
     public Set getGroupKeys( String groupName )
+        throws IOException
     {
-        return lateral.getGroupKeys( cacheName, groupName );
+        try
+        {
+            return lateralCacheService.getGroupKeys( cacheName, groupName );
+        }
+        catch ( Exception ex )
+        {
+            handleException( ex, "Failed to remove groupName [" + groupName + "] from " + lateralCacheAttribures.getCacheName() + "@"
+                + lateralCacheAttribures );
+        }
+        return Collections.EMPTY_SET;
     }
 
     /**
@@ -235,11 +246,11 @@
 
         try
         {
-            lateral.remove( cacheName, key, LateralCacheInfo.listenerId );
+            lateralCacheService.remove( cacheName, key, LateralCacheInfo.listenerId );
         }
         catch ( Exception ex )
         {
-            handleException( ex, "Failed to remove " + key + " from " + cattr.getCacheName() + "@" + cattr );
+            handleException( ex, "Failed to remove " + key + " from " + lateralCacheAttribures.getCacheName() + "@" + lateralCacheAttribures );
         }
         return false;
     }
@@ -255,11 +266,11 @@
     {
         try
         {
-            lateral.removeAll( cacheName, LateralCacheInfo.listenerId );
+            lateralCacheService.removeAll( cacheName, LateralCacheInfo.listenerId );
         }
         catch ( Exception ex )
         {
-            handleException( ex, "Failed to remove all from " + cattr.getCacheName() + "@" + cattr );
+            handleException( ex, "Failed to remove all from " + lateralCacheAttribures.getCacheName() + "@" + lateralCacheAttribures );
         }
     }
 
@@ -279,13 +290,13 @@
         // any.
         try
         {
-            lateral.dispose( this.cattr.getCacheName() );
+            lateralCacheService.dispose( this.lateralCacheAttribures.getCacheName() );
             // Should remove connection
         }
         catch ( Exception ex )
         {
             log.error( "Couldn't dispose", ex );
-            handleException( ex, "Failed to dispose " + cattr.getCacheName() );
+            handleException( ex, "Failed to dispose " + lateralCacheAttribures.getCacheName() );
         }
     }
 
@@ -296,7 +307,7 @@
      */
     public int getStatus()
     {
-        return this.lateral instanceof IZombie ? CacheConstants.STATUS_ERROR : CacheConstants.STATUS_ALIVE;
+        return this.lateralCacheService instanceof IZombie ? CacheConstants.STATUS_ERROR : CacheConstants.STATUS_ALIVE;
     }
 
     /**
@@ -341,7 +352,7 @@
     {
         log.error( "Disabling lateral cache due to error " + msg, ex );
 
-        lateral = new ZombieLateralCacheService();
+        lateralCacheService = new ZombieLateralCacheService( lateralCacheAttribures.getZombieQueueMaxSize() );
         // may want to flush if region specifies
         // Notify the cache monitor about the error, and kick off the recovery
         // process.
@@ -358,17 +369,33 @@
     /**
      * Replaces the current remote cache service handle with the given handle.
      * <p>
-     * @param lateral
+     * @param restoredLateral
      */
-    public void fixCache( ILateralCacheService lateral )
+    public void fixCache( ILateralCacheService restoredLateral )
     {
-        if ( lateral != null )
+        if ( this.lateralCacheService != null && this.lateralCacheService instanceof ZombieLateralCacheService )
         {
-            this.lateral = lateral;
+            ZombieLateralCacheService zombie = (ZombieLateralCacheService) this.lateralCacheService;
+            this.lateralCacheService = restoredLateral;
+            try
+            {
+                zombie.propagateEvents( restoredLateral );
+            }
+            catch ( Exception e )
+            {
+                try
+                {
+                    handleException( e, "Problem propagating events from Zombie Queue to new Lateral Service." );
+                }
+                catch ( IOException e1 )
+                {
+                    // swallow, since this is just expected kick back.  Handle always throws
+                }
+            }
         }
         else
         {
-            log.warn( "Fix cache called with null lateral." );
+            this.lateralCacheService = restoredLateral;
         }
         return;
     }
@@ -388,7 +415,7 @@
      */
     public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
     {
-        return cattr;
+        return lateralCacheAttribures;
     }
 
     /**
@@ -398,8 +425,8 @@
     {
         StringBuffer buf = new StringBuffer();
         buf.append( "\n LateralCache " );
-        buf.append( "\n Cache Name [" + cattr.getCacheName() + "]" );
-        buf.append( "\n cattr =  [" + cattr + "]" );
+        buf.append( "\n Cache Name [" + lateralCacheAttribures.getCacheName() + "]" );
+        buf.append( "\n cattr =  [" + lateralCacheAttribures + "]" );
         return buf.toString();
     }
 

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheAttributes.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheAttributes.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheAttributes.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheAttributes.java Thu Jul 23 18:27:41 2009
@@ -68,6 +68,9 @@
      */
     private boolean receive = DEFAULT_RECEIVE;
 
+    /** If the primary fails, we will queue items before reconnect.  This limits the number of items that can be queued. */
+    private int zombieQueueMaxSize = DEFAULT_ZOMBIE_QUEUE_MAX_SIZE;
+    
     /**
      * Sets the httpServer attribute of the LateralCacheAttributes object
      * <P>
@@ -280,6 +283,28 @@
     }
 
     /**
+     * The number of elements the zombie queue will hold. This queue is used to store events if we
+     * loose our connection 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 connection with the server.
+     * <p>
+     * @return Returns the zombieQueueMaxSize.
+     */
+    public int getZombieQueueMaxSize()
+    {
+        return zombieQueueMaxSize;
+    }
+    
+    /**
      * @return debug string.
      */
     public String toString()

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java Thu Jul 23 18:27:41 2009
@@ -234,7 +234,16 @@
      */
     public Set getGroupKeys( String groupName )
     {
-        return cache.getGroupKeys( groupName );
+        try
+        {
+            return cache.getGroupKeys( groupName );
+        }
+        catch ( IOException ex )
+        {
+            log.error( ex );
+            eventQueue.destroy();
+        }
+        return Collections.EMPTY_SET;
     }
 
     /**

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheRestore.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheRestore.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheRestore.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheRestore.java Thu Jul 23 18:27:41 2009
@@ -92,6 +92,5 @@
         lcm.fixCaches( (ILateralCacheService) lateralObj, (ILateralCacheObserver) lateralObj );
         String msg = "Lateral connection resumed.";
         log.info( msg );
-        log.debug( msg );
     }
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/ZombieLateralCacheService.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/ZombieLateralCacheService.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/ZombieLateralCacheService.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/ZombieLateralCacheService.java Thu Jul 23 18:27:41 2009
@@ -19,79 +19,29 @@
  * under the License.
  */
 
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheService;
-import org.apache.jcs.engine.ZombieCacheService;
-import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.ZombieCacheServiceNonLocal;
 
 /**
  * The ZombieLateralCacheService is used as a facade when the lateral is not available. It balks
  * when the lateral is in error. When lateral service is restored, this is replaced by a live
  * facade.
+ * <p>
+ * Extends a queing non-local service.
  */
 public class ZombieLateralCacheService
-    extends ZombieCacheService
+    extends ZombieCacheServiceNonLocal
     implements ILateralCacheService
 {
-    /**
-     * Balks
-     * <p>
-     * @param item
-     * @param listenerId
-     */
-    public void update( ICacheElement item, long listenerId )
-    {
-        // zombies have no inner life
-    }
-
-    /**
-     * Balks
-     * <p>
-     * @param cacheName
-     * @param key
-     * @param listenerId
-     */
-    public void remove( String cacheName, Serializable key, long listenerId )
-    {
-        // zombies have no inner life
-    }
-
-    /**
-     * Balks
-     * <p>
-     * @param cacheName
-     * @param listenerId
-     */
-    public void removeAll( String cacheName, long listenerId )
-    {
-        // zombies have no inner life
-    }
-
-    /**
-     * Balks
-     * <p>
-     * @param cacheName
-     * @param groupName
-     * @return empty set
-     */
-    public Set getGroupKeys( String cacheName, String groupName )
-    {
-        return Collections.EMPTY_SET;
-    }
+    // backwards compatibility
 
     /**
-     * The service does not get via this method, so this return empty.
+     * Sets the maximum number of items that will be allowed on the queue.
      * <p>
-     * @param cacheName
-     * @param pattern
-     * @return Collections.EMPTY_MAP.
+     * @param maxQueueSize
      */
-    public Map getMatching( String cacheName, String pattern )
+    public ZombieLateralCacheService( int maxQueueSize )
     {
-        return Collections.EMPTY_MAP;
+        super( maxQueueSize );
     }
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/behavior/ILateralCacheAttributes.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/behavior/ILateralCacheAttributes.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/behavior/ILateralCacheAttributes.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/behavior/ILateralCacheAttributes.java Thu Jul 23 18:27:41 2009
@@ -45,6 +45,12 @@
     final static int XMLRPC = 4;
 
     /**
+     * The number of elements the zombie queue will hold. This queue is used to store events if we
+     * loose our connection with the server.
+     */
+    public static final int DEFAULT_ZOMBIE_QUEUE_MAX_SIZE = 1000;
+    
+    /**
      * Sets the httpServer attribute of the ILateralCacheAttributes object
      * <p>
      * @param val The new httpServer value
@@ -171,7 +177,23 @@
      * not configured for the lateral but another is. And if cache B has region R1 configured for
      * lateral distribution, A will get messages for R1 but not send them.
      * <p>
-     * @return true if we should have a listener conenction
+     * @return true if we should have a listener connection
      */
     public boolean isReceive();
+    
+    /**
+     * The number of elements the zombie queue will hold. This queue is used to store events if we
+     * loose our connection 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 connection with the server.
+     * <p>
+     * @return Returns the zombieQueueMaxSize.
+     */
+    public int getZombieQueueMaxSize();      
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/behavior/ILateralCacheService.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/behavior/ILateralCacheService.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/behavior/ILateralCacheService.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/behavior/ILateralCacheService.java Thu Jul 23 18:27:41 2009
@@ -19,65 +19,11 @@
  * under the License.
  */
 
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.jcs.engine.behavior.ICacheElement;
-import org.apache.jcs.engine.behavior.ICacheService;
+import org.apache.jcs.engine.behavior.ICacheServiceNonLocal;
 
 /** Used to retrieve and update the lateral cache. */
 public interface ILateralCacheService
-    extends ICacheService
+    extends ICacheServiceNonLocal
 {
-    /**
-     * Puts a cache item to the cache.
-     * <p>
-     * @param item
-     * @param requesterId
-     * @throws IOException
-     */
-    void update( ICacheElement item, long requesterId )
-        throws IOException;
-
-    /**
-     * Removes the given key from the specified cache.
-     * <p>
-     * @param cacheName
-     * @param key
-     * @param requesterId
-     * @throws IOException
-     */
-    void remove( String cacheName, Serializable key, long requesterId )
-        throws IOException;
-
-    /**
-     * Remove all keys from the sepcified cache.
-     * <p>
-     * @param cacheName
-     * @param requesterId
-     * @throws IOException
-     */
-    void removeAll( String cacheName, long requesterId )
-        throws IOException;
-
-    /**
-     * @param cacheName
-     * @param groupName
-     * @return keys
-     */
-    Set getGroupKeys( String cacheName, String groupName );
-    
-    /**
-     * Gets multiple items from the cache matching the pattern.
-     * <p>
-     * @param cacheName
-     * @param pattern
-     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
-     *         data in cache matching the pattern.
-     * @throws IOException
-     */
-    Map getMatching( String cacheName, String pattern )
-        throws IOException;    
+    // backwards compatibility
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java Thu Jul 23 18:27:41 2009
@@ -70,7 +70,7 @@
     protected static Map instances = Collections.synchronizedMap( new HashMap() );
 
     /** ITCPLateralCacheAttributes */
-    protected ITCPLateralCacheAttributes lca;
+    protected ITCPLateralCacheAttributes lateralCacheAttribures;
 
     /** number of clients, we can remove this. */
     private int clients;
@@ -160,14 +160,14 @@
     private LateralTCPCacheManager( ITCPLateralCacheAttributes lcaA, ICompositeCacheManager cacheMgr,
                                     ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
     {
-        this.lca = lcaA;
+        this.lateralCacheAttribures = lcaA;
         this.cacheMgr = cacheMgr;
         this.cacheEventLogger = cacheEventLogger;
         this.elementSerializer = elementSerializer;
 
         if ( log.isDebugEnabled() )
         {
-            log.debug( "Creating lateral cache service, lca = " + this.lca );
+            log.debug( "Creating lateral cache service, lca = " + this.lateralCacheAttribures );
         }
 
         // Create the service
@@ -175,9 +175,9 @@
         {
             if ( log.isInfoEnabled() )
             {
-                log.info( "Creating TCP service, lca = " + this.lca );
+                log.info( "Creating TCP service, lca = " + this.lateralCacheAttribures );
             }
-            this.lateralService = new LateralTCPService( this.lca );
+            this.lateralService = new LateralTCPService( this.lateralCacheAttribures );
 
             if ( this.lateralService == null )
             {
@@ -195,7 +195,7 @@
             // "zombie" services.
             log.error( "Failure, lateral instance will use zombie service", ex );
 
-            this.lateralService = new ZombieLateralCacheService();
+            this.lateralService = new ZombieLateralCacheService( lateralCacheAttribures.getZombieQueueMaxSize() );
             this.lateralWatch = new LateralCacheWatchRepairable();
             this.lateralWatch.setCacheWatch( new ZombieLateralCacheWatch() );
 
@@ -242,7 +242,7 @@
             lateralNoWait = (LateralCacheNoWait) caches.get( cacheName );
             if ( lateralNoWait == null )
             {
-                LateralCacheAttributes attr = (LateralCacheAttributes) lca.copy();
+                LateralCacheAttributes attr = (LateralCacheAttributes) lateralCacheAttribures.copy();
                 attr.setCacheName( cacheName );
 
                 LateralCache cache = new LateralCache( attr, this.lateralService, monitor );
@@ -262,7 +262,7 @@
 
                 if ( log.isInfoEnabled() )
                 {
-                    log.info( "Created LateralCacheNoWait for [" + lca + "] LateralCacheNoWait = [" + lateralNoWait
+                    log.info( "Created LateralCacheNoWait for [" + lateralCacheAttribures + "] LateralCacheNoWait = [" + lateralNoWait
                         + "]" );
                 }
 
@@ -282,11 +282,11 @@
     private void addListenerIfNeeded( String cacheName )
     {
         // don't create a listener if we are not receiving.
-        if ( lca.isReceive() )
+        if ( lateralCacheAttribures.isReceive() )
         {
             try
             {
-                addLateralCacheListener( cacheName, LateralTCPListener.getInstance( lca, cacheMgr ) );
+                addLateralCacheListener( cacheName, LateralTCPListener.getInstance( lateralCacheAttribures, cacheMgr ) );
             }
             catch ( IOException ioe )
             {
@@ -324,7 +324,7 @@
         Object service = null;
         try
         {
-            service = new LateralTCPService( lca );
+            service = new LateralTCPService( lateralCacheAttribures );
         }
         catch ( Exception ex )
         {
@@ -335,7 +335,8 @@
     }
 
     /**
-     * Shutsdown the lateral.
+     * Shuts down the lateral sender. This does not shutdown the listener. This can be called if the
+     * end point is taken out of service.
      */
     public void shutdown()
     {

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java Thu Jul 23 18:27:41 2009
@@ -3,8 +3,10 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -20,7 +22,7 @@
 import org.apache.jcs.utils.discovery.behavior.IDiscoveryListener;
 
 /**
- * This knows how to add and remove discovered services.
+ * This knows how to add and remove discovered services. It observers UDP discovery events.
  * <p>
  * We can have one listener per region, or one shared by all regions.
  */
@@ -36,6 +38,12 @@
      */
     private Map facades = Collections.synchronizedMap( new HashMap() );
 
+    /**
+     * List of regions that are configured differently here than on another server. We keep track of
+     * this to limit the amount of info logging.
+     */
+    private Set knownDifferentlyConfiguredRegions = Collections.synchronizedSet( new HashSet() );
+
     /** The cache manager. */
     private ICompositeCacheManager cacheMgr;
 
@@ -66,21 +74,51 @@
      * This adds nowaits to a facade for the region name. If the region has no facade, then it is
      * not configured to use the lateral cache, and no facade will be created.
      * <p>
+     * @param cacheName - the region name
      * @param facade - facade (for region) => multiple lateral clients.
-     * @param cacheName
      * @return true if the facade was not already registered.
      */
     public synchronized boolean addNoWaitFacade( String cacheName, LateralCacheNoWaitFacade facade )
     {
-        boolean isNew = !facades.containsKey( cacheName );
+        boolean isNew = !containsNoWaitFacade( cacheName );
 
         // override or put anew, it doesn't matter
         facades.put( cacheName, facade );
+        knownDifferentlyConfiguredRegions.remove( cacheName );
 
         return isNew;
     }
 
     /**
+     * Allows us to see if the facade is present.
+     * <p>
+     * @param cacheName - facades are for a region
+     * @return do we contain the no wait. true if so
+     */
+    public boolean containsNoWaitFacade( String cacheName )
+    {
+        return facades.containsKey( cacheName );
+    }
+
+    /**
+     * Allows us to see if the facade is present and if it has the no wait.
+     * <p>
+     * @param cacheName - facades are for a region
+     * @param noWait - is this no wait in the facade
+     * @return do we contain the no wait. true if so
+     */
+    public boolean containsNoWait( String cacheName, LateralCacheNoWait noWait )
+    {
+        LateralCacheNoWaitFacade facade = (LateralCacheNoWaitFacade) facades.get( noWait.getCacheName() );
+        if ( facade == null )
+        {
+            return false;
+        }
+
+        return facade.containsNoWait( noWait );
+    }
+
+    /**
      * When a broadcast is received from the UDP Discovery receiver, for each cacheName in the
      * message, the add no wait will be called here. To add a no wait, the facade is looked up for
      * this cache name.
@@ -89,13 +127,15 @@
      * services.
      * <p>
      * @param noWait
+     * @return true if we found the no wait and added it. False if the no wait was not present or it
+     *         we already had it.
      */
-    protected void addNoWait( LateralCacheNoWait noWait )
+    protected boolean addNoWait( LateralCacheNoWait noWait )
     {
         LateralCacheNoWaitFacade facade = (LateralCacheNoWaitFacade) facades.get( noWait.getCacheName() );
         if ( log.isDebugEnabled() )
         {
-            log.debug( "Got facade for " + noWait.getCacheName() + " = " + facade );
+            log.debug( "addNoWait > Got facade for " + noWait.getCacheName() + " = " + facade );
         }
 
         if ( facade != null )
@@ -105,14 +145,20 @@
             {
                 log.debug( "Called addNoWait, isNew = " + isNew );
             }
+            return isNew;
         }
         else
         {
-            if ( log.isInfoEnabled() )
+            if ( !knownDifferentlyConfiguredRegions.contains( noWait.getCacheName() ) )
             {
-                log.info( "addNoWait > Different nodes are configured differently or region [" + noWait.getCacheName()
-                    + "] is not yet used on this side.  " );
+                if ( log.isInfoEnabled() )
+                {
+                    log.info( "addNoWait > Different nodes are configured differently or region ["
+                        + noWait.getCacheName() + "] is not yet used on this side.  " );
+                }
+                knownDifferentlyConfiguredRegions.add( noWait.getCacheName() );
             }
+            return false;
         }
     }
 
@@ -121,13 +167,14 @@
      * use with the lateral cache. If it is present, remove the item from the no wait list.
      * <p>
      * @param noWait
+     * @return true if we found the no wait and removed it. False if the no wait was not present.
      */
-    protected void removeNoWait( LateralCacheNoWait noWait )
+    protected boolean removeNoWait( LateralCacheNoWait noWait )
     {
         LateralCacheNoWaitFacade facade = (LateralCacheNoWaitFacade) facades.get( noWait.getCacheName() );
         if ( log.isDebugEnabled() )
         {
-            log.debug( "Got facade for " + noWait.getCacheName() + " = " + facade );
+            log.debug( "removeNoWait > Got facade for " + noWait.getCacheName() + " = " + facade );
         }
 
         if ( facade != null )
@@ -137,14 +184,20 @@
             {
                 log.debug( "Called removeNoWait, removed " + removed );
             }
+            return removed;
         }
         else
         {
-            if ( log.isInfoEnabled() )
+            if ( !knownDifferentlyConfiguredRegions.contains( noWait.getCacheName() ) )
             {
-                log.info( "removeNoWait > Different nodes are configured differently or region ["
-                    + noWait.getCacheName() + "] is not yet used on this side.  " );
+                if ( log.isInfoEnabled() )
+                {
+                    log.info( "removeNoWait > Different nodes are configured differently or region ["
+                        + noWait.getCacheName() + "] is not yet used on this side.  " );
+                }
+                knownDifferentlyConfiguredRegions.add( noWait.getCacheName() );
             }
+            return false;
         }
     }
 
@@ -155,7 +208,7 @@
      * force a full configuration of the region. One advantage of this would be that the creation of
      * the later would go through the factory, which would add the item to the no wait list. But we
      * don't want to do this. This would force this client to have all the regions as the other.
-     * This might not be desired. We don't want to send or recieve for a region here that is either
+     * This might not be desired. We don't want to send or receive for a region here that is either
      * not used or not configured to use the lateral.
      * <p>
      * Right now, I'm afraid that the region will get puts if another instance has the region

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerManager.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerManager.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerManager.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerManager.java Thu Jul 23 18:27:41 2009
@@ -57,11 +57,11 @@
         {
             ins = new LateralTCPDiscoveryListener( cacheMgr, cacheEventLogger, elementSerializer );
 
-            instances.put( String.valueOf( ilca.getTcpListenerPort() ), ins );
+            instances.put( key, ins );
 
-            if ( log.isDebugEnabled() )
+            if ( log.isInfoEnabled() )
             {
-                log.debug( "created new listener " + ilca.getTcpListenerPort() );
+                log.info( "Created new discovery listener for " + key + " cacheName for request " + ilca.getCacheName() );
             }
         }
 

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java Thu Jul 23 18:27:41 2009
@@ -176,7 +176,8 @@
     }
 
     /**
-     * Does nothing. <p.
+     * Does nothing.
+     * <p>
      * @throws IOException
      */
     public void release()
@@ -226,6 +227,21 @@
     public ICacheElement get( String cacheName, Serializable key )
         throws IOException
     {
+        return get( cacheName, key, getListenerId() );
+    }
+
+    /**
+     * If get is allowed, we will issues a get request.
+     * <p>
+     * @param cacheName
+     * @param key
+     * @param requesterId
+     * @return ICacheElement if found.
+     * @throws IOException
+     */
+    public ICacheElement get( String cacheName, Serializable key, long requesterId )
+        throws IOException
+    {
         // if get is not allowed return
         if ( this.getTcpLateralCacheAttributes().isAllowGet() )
         {
@@ -248,7 +264,7 @@
     }
 
     /**
-     * The service does not get via this method, so this return empty.
+     * If allow get is true, we will issue a getmatching query.
      * <p>
      * @param cacheName
      * @param pattern
@@ -259,6 +275,22 @@
     public Map getMatching( String cacheName, String pattern )
         throws IOException
     {
+        return getMatching( cacheName, pattern, getListenerId() );
+    }
+
+    /**
+     * If allow get is true, we will issue a getmatching query.
+     * <p>
+     * @param cacheName
+     * @param pattern
+     * @param requesterId - our identity
+     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+     *         data in cache matching the pattern.
+     * @throws IOException
+     */
+    public Map getMatching( String cacheName, String pattern, long requesterId )
+        throws IOException
+    {
         // if get is not allowed return
         if ( this.getTcpLateralCacheAttributes().isAllowGet() )
         {
@@ -266,7 +298,7 @@
             LateralElementDescriptor led = new LateralElementDescriptor( ce );
             // led.requesterId = requesterId; // later
             led.command = LateralElementDescriptor.GET_MATCHING;
-            
+
             Object response = sender.sendAndReceive( led );
             if ( response != null )
             {
@@ -280,7 +312,7 @@
             return null;
         }
     }
-    
+
     /**
      * Gets multiple items from the cache based on the given set of keys.
      * <p>
@@ -293,6 +325,24 @@
     public Map getMultiple( String cacheName, Set keys )
         throws IOException
     {
+        return getMultiple( cacheName, keys, getListenerId() );
+    }
+
+    /**
+     * This issues a separate get for each item.
+     * <p>
+     * TODO We should change this. It should issue one request.
+     * <p>
+     * @param cacheName
+     * @param keys
+     * @param requesterId
+     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+     *         data in cache for any of these keys
+     * @throws IOException
+     */
+    public Map getMultiple( String cacheName, Set keys, long requesterId )
+        throws IOException
+    {
         Map elements = new HashMap();
 
         if ( keys != null && !keys.isEmpty() )
@@ -311,7 +361,6 @@
                 }
             }
         }
-
         return elements;
     }
 
@@ -463,5 +512,4 @@
     {
         return tcpLateralCacheAttributes;
     }
-
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/behavior/ITCPLateralCacheAttributes.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/behavior/ITCPLateralCacheAttributes.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/behavior/ITCPLateralCacheAttributes.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/behavior/ITCPLateralCacheAttributes.java Thu Jul 23 18:27:41 2009
@@ -214,5 +214,5 @@
     /**
      * @return the openTimeOut
      */
-    public int getOpenTimeOut();  
+    public int getOpenTimeOut();       
 }

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=797178&r1=797177&r2=797178&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 Thu Jul 23 18:27:41 2009
@@ -19,20 +19,8 @@
  * under the License.
  */
 
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 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;
+import org.apache.jcs.engine.ZombieCacheServiceNonLocal;
 
 /**
  * Zombie adapter for the remote cache service. It just balks if there is no queue configured.
@@ -41,29 +29,20 @@
  * operation is restored, the remote cache will walk the queue. The queue must be bounded so it does
  * not eat memory.
  * <p>
- * Much of this is potentially reusable.
- * <p>
- * TODO figure out a way to get the propagate method into an interface for Zombies.
+ * Much of this was reusable, so I moved it to engine.
  */
 public class ZombieRemoteCacheService
-    extends ZombieCacheService
+    extends ZombieCacheServiceNonLocal
     implements IRemoteCacheService
 {
-    /** The logger */
-    private final static Log log = LogFactory.getLog( ZombieRemoteCacheService.class );
-
-    /** How big can the queue grow. */
-    private int maxQueueSize = 0;
-
-    /** The queue */
-    private BoundedQueue queue;
+    // backwards compatibility
 
     /**
-     * Default.
+     * We shouldn't be using this. It's only called on certain startup errors.
      */
     public ZombieRemoteCacheService()
     {
-        queue = new BoundedQueue( 0 );
+        super();
     }
 
     /**
@@ -73,238 +52,6 @@
      */
     public ZombieRemoteCacheService( int maxQueueSize )
     {
-        this.maxQueueSize = maxQueueSize;
-        queue = new BoundedQueue( maxQueueSize );
-    }
-
-    /**
-     * Gets the number of items on the queue.
-     * <p>
-     * @return size of the queue.
-     */
-    public int getQueueSize()
-    {
-        return queue.size();
-    }
-
-    /**
-     * Adds an update event to the queue if the maxSize is greater than 0;
-     * <p>
-     * (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService#update(org.apache.jcs.engine.behavior.ICacheElement,
-     *      long)
-     */
-    public void update( ICacheElement item, long listenerId )
-    {
-        if ( maxQueueSize > 0 )
-        {
-            PutEvent event = new PutEvent( item, listenerId );
-            queue.add( event );
-        }
-        // Zombies have no inner life
-        return;
-    }
-
-    /**
-     * Adds a removeAll event to the queue if the maxSize is greater than 0;
-     * <p>
-     * (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService#remove(java.lang.String,
-     *      java.io.Serializable, long)
-     */
-    public void remove( String cacheName, Serializable key, long listenerId )
-    {
-        if ( maxQueueSize > 0 )
-        {
-            RemoveEvent event = new RemoveEvent( cacheName, key, listenerId );
-            queue.add( event );
-        }
-        // Zombies have no inner life
-        return;
-    }
-
-    /**
-     * Adds a removeAll event to the queue if the maxSize is greater than 0;
-     * <p>
-     * (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService#removeAll(java.lang.String,
-     *      long)
-     */
-    public void removeAll( String cacheName, long listenerId )
-    {
-        if ( maxQueueSize > 0 )
-        {
-            RemoveAllEvent event = new RemoveAllEvent( cacheName, listenerId );
-            queue.add( event );
-        }
-        // Zombies have no inner life
-        return;
-    }
-
-    /**
-     * Does nothing. Gets are synchronous and cannot be added to a queue.
-     * <p>
-     * (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService#get(java.lang.String,
-     *      java.io.Serializable, long)
-     */
-    public ICacheElement get( String cacheName, Serializable key, long requesterId )
-        throws IOException
-    {
-        // Zombies have no inner life
-        return null;
-    }
-
-    /**
-     * @param cacheName 
-     * @param pattern 
-     * @param requesterId 
-     * @return empty map
-     * @throws IOException 
-     * 
-     */
-    public Map getMatching( String cacheName, String pattern, long requesterId )
-        throws IOException
-    {
-        return Collections.EMPTY_MAP;
-    }
-    
-    /**
-     * @param cacheName
-     * @param keys
-     * @param requesterId
-     * @return an empty map. zombies have no internal data
-     */
-    public Map getMultiple( String cacheName, Set keys, long requesterId )
-    {
-        return new HashMap();
-    }
-
-    /**
-     * Does nothing.
-     * <p>
-     * (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService#getGroupKeys(java.lang.String,
-     *      java.lang.String)
-     */
-    public Set getGroupKeys( String cacheName, String groupName )
-    {
-        return Collections.EMPTY_SET;
-    }
-
-    /**
-     * Walk the queue, calling the service for each queue operation.
-     * <p>
-     * @param service
-     * @throws Exception
-     */
-    protected void propagateEvents( IRemoteCacheService service )
-        throws Exception
-    {
-        int cnt = 0;
-        if ( log.isInfoEnabled() )
-        {
-            log.info( "Propagating events to the new RemoteService." );
-        }
-        ElapsedTimer timer = new ElapsedTimer();
-        while ( !queue.isEmpty() )
-        {
-            cnt++;
-
-            // for each item, call the appropriate service method
-            ZombieEvent event = (ZombieEvent) queue.take();
-
-            if ( event instanceof PutEvent )
-            {
-                PutEvent putEvent = (PutEvent) event;
-                service.update( putEvent.element, event.requesterId );
-            }
-            else if ( event instanceof RemoveEvent )
-            {
-                RemoveEvent removeEvent = (RemoveEvent) event;
-                service.remove( event.cacheName, removeEvent.key, event.requesterId );
-            }
-            else if ( event instanceof RemoveAllEvent )
-            {
-                service.removeAll( event.cacheName, event.requesterId );
-            }
-        }
-        if ( log.isInfoEnabled() )
-        {
-            log.info( "Propagated " + cnt + " events to the new RemoteService in " + timer.getElapsedTimeString() );
-        }
-    }
-
-    /**
-     * Base of the other events.
-     */
-    private abstract class ZombieEvent
-    {
-        /** The name of the region. */
-        String cacheName;
-
-        /** The id of the requester */
-        long requesterId;
-    }
-
-    /**
-     * A basic put event.
-     */
-    private class PutEvent
-        extends ZombieEvent
-    {
-        /** The element to put */
-        ICacheElement element;
-
-        /**
-         * Set the element
-         * @param element
-         * @param requesterId
-         */
-        public PutEvent( ICacheElement element, long requesterId )
-        {
-            this.requesterId = requesterId;
-            this.element = element;
-        }
-    }
-
-    /**
-     * A basic Remove event.
-     */
-    private class RemoveEvent
-        extends ZombieEvent
-    {
-        /** The key to remove */
-        Serializable key;
-
-        /**
-         * Set the element
-         * @param cacheName
-         * @param key
-         * @param requesterId
-         */
-        public RemoveEvent( String cacheName, Serializable key, long requesterId )
-        {
-            this.cacheName = cacheName;
-            this.requesterId = requesterId;
-            this.key = key;
-        }
-    }
-
-    /**
-     * A basic RemoveAll event.
-     */
-    private class RemoveAllEvent
-        extends ZombieEvent
-    {
-        /**
-         * @param cacheName
-         * @param requesterId
-         */
-        public RemoveAllEvent( String cacheName, long requesterId )
-        {
-            this.cacheName = cacheName;
-            this.requesterId = requesterId;
-        }
+        super( maxQueueSize );
     }
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheService.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheService.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheService.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheService.java Thu Jul 23 18:27:41 2009
@@ -19,101 +19,15 @@
  * under the License.
  */
 
-import java.io.IOException;
-import java.io.Serializable;
-import java.rmi.Remote;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.jcs.access.exception.ObjectExistsException;
-import org.apache.jcs.engine.behavior.ICacheElement;
-import org.apache.jcs.engine.behavior.ICacheService;
+import org.apache.jcs.engine.behavior.ICacheServiceNonLocal;
 
 /**
  * Used to retrieve and update the remote cache.
+ * <p>
+ * For convenience, ICacheServiceNonLocal extends Remote.
  */
 public interface IRemoteCacheService
-    extends Remote, ICacheService
+    extends ICacheServiceNonLocal
 {
-    /**
-     * Puts a cache item to the cache.
-     * <p>
-     * @param item
-     * @param requesterId
-     * @throws ObjectExistsException
-     * @throws IOException
-     */
-    void update( ICacheElement item, long requesterId )
-        throws ObjectExistsException, IOException;
-
-    /**
-     * Removes the given key from the specified cache.
-     * <p>
-     * @param cacheName
-     * @param key
-     * @param requesterId
-     * @throws IOException
-     */
-    void remove( String cacheName, Serializable key, long requesterId )
-        throws IOException;
-
-    /**
-     * Remove all keys from the specified cache.
-     * <p>
-     * @param cacheName
-     * @param requesterId
-     * @throws IOException
-     */
-    void removeAll( String cacheName, long requesterId )
-        throws IOException;
-
-    /**
-     * Returns a cache bean from the specified cache; or null if the key does not exist.
-     * <p>
-     * Adding the requestor id, allows the cache to determine the sournce of the get.
-     * <p>
-     * @param cacheName
-     * @param key
-     * @param requesterId
-     * @return ICacheElement
-     * @throws IOException
-     */
-    ICacheElement get( String cacheName, Serializable key, long requesterId )
-        throws IOException;
-
-    /**
-     * Gets multiple items from the cache based on the given set of keys.
-     * <p>
-     * @param cacheName
-     * @param keys
-     * @param requesterId
-     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
-     *         data in cache for any of these keys
-     * @throws IOException
-     */
-    Map getMultiple( String cacheName, Set keys, long requesterId )
-        throws IOException;
-
-    /**
-     * Gets multiple items from the cache matching the pattern.
-     * <p>
-     * @param cacheName
-     * @param pattern
-     * @param requesterId
-     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
-     *         data in cache matching the pattern.
-     * @throws IOException
-     */
-    Map getMatching( String cacheName, String pattern, long requesterId )
-        throws IOException;
-
-    /**
-     * @param cacheName
-     * @param groupName
-     * @return A Set of keys
-     * @throws java.rmi.RemoteException
-     * @throws IOException 
-     */
-    Set getGroupKeys( String cacheName, String groupName )
-        throws java.rmi.RemoteException, IOException;
+    // backwards compatibility
 }

Added: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheServiceNonLocal.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheServiceNonLocal.java?rev=797178&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheServiceNonLocal.java (added)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheServiceNonLocal.java Thu Jul 23 18:27:41 2009
@@ -0,0 +1,309 @@
+package org.apache.jcs.engine;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.behavior.ICacheServiceNonLocal;
+import org.apache.jcs.utils.struct.BoundedQueue;
+import org.apache.jcs.utils.timing.ElapsedTimer;
+
+/**
+ * Zombie adapter for the non local cache services. It just balks if there is no queue configured.
+ * <p>
+ * If a queue is configured, then events will be added to the queue. The idea is that when proper
+ * operation is restored, the non local cache will walk the queue. The queue must be bounded so it
+ * does not eat memory.
+ * <p>
+ * This originated in the remote cache.
+ */
+public class ZombieCacheServiceNonLocal
+    extends ZombieCacheService
+    implements ICacheServiceNonLocal
+{
+    /** The logger */
+    private final static Log log = LogFactory.getLog( ZombieCacheServiceNonLocal.class );
+
+    /** How big can the queue grow. */
+    private int maxQueueSize = 0;
+
+    /** The queue */
+    private BoundedQueue queue;
+
+    /**
+     * Default.
+     */
+    public ZombieCacheServiceNonLocal()
+    {
+        queue = new BoundedQueue( 0 );
+    }
+
+    /**
+     * Sets the maximum number of items that will be allowed on the queue.
+     * <p>
+     * @param maxQueueSize
+     */
+    public ZombieCacheServiceNonLocal( int maxQueueSize )
+    {
+        this.maxQueueSize = maxQueueSize;
+        queue = new BoundedQueue( maxQueueSize );
+    }
+
+    /**
+     * Gets the number of items on the queue.
+     * <p>
+     * @return size of the queue.
+     */
+    public int getQueueSize()
+    {
+        return queue.size();
+    }
+
+    /**
+     * Adds an update event to the queue if the maxSize is greater than 0;
+     * <p>
+     * @param item ICacheElement
+     * @param listenerId - identifies the caller.
+     */
+    public void update( ICacheElement item, long listenerId )
+    {
+        if ( maxQueueSize > 0 )
+        {
+            PutEvent event = new PutEvent( item, listenerId );
+            queue.add( event );
+        }
+        // Zombies have no inner life
+        return;
+    }
+
+    /**
+     * Adds a removeAll event to the queue if the maxSize is greater than 0;
+     * <p>
+     * @param cacheName - region name
+     * @param key - item key
+     * @param listenerId - identifies the caller.
+     */
+    public void remove( String cacheName, Serializable key, long listenerId )
+    {
+        if ( maxQueueSize > 0 )
+        {
+            RemoveEvent event = new RemoveEvent( cacheName, key, listenerId );
+            queue.add( event );
+        }
+        // Zombies have no inner life
+        return;
+    }
+
+    /**
+     * Adds a removeAll event to the queue if the maxSize is greater than 0;
+     * <p>
+     * @param cacheName - name of the region
+     * @param listenerId - identifies the caller.
+     */
+    public void removeAll( String cacheName, long listenerId )
+    {
+        if ( maxQueueSize > 0 )
+        {
+            RemoveAllEvent event = new RemoveAllEvent( cacheName, listenerId );
+            queue.add( event );
+        }
+        // Zombies have no inner life
+        return;
+    }
+
+    /**
+     * Does nothing. Gets are synchronous and cannot be added to a queue.
+     * <p>
+     * @param cacheName - region name
+     * @param key - item key
+     * @param requesterId - identifies the caller.
+     * @return null
+     * @throws IOException
+     */
+    public ICacheElement get( String cacheName, Serializable key, long requesterId )
+        throws IOException
+    {
+        // Zombies have no inner life
+        return null;
+    }
+
+    /**
+     * Does nothing.
+     * <p>
+     * @param cacheName
+     * @param pattern
+     * @param requesterId
+     * @return empty map
+     * @throws IOException
+     */
+    public Map getMatching( String cacheName, String pattern, long requesterId )
+        throws IOException
+    {
+        return Collections.EMPTY_MAP;
+    }
+
+    /**
+     * @param cacheName - region name
+     * @param keys - item key
+     * @param requesterId - identity of the caller
+     * @return an empty map. zombies have no internal data
+     */
+    public Map getMultiple( String cacheName, Set keys, long requesterId )
+    {
+        return new HashMap();
+    }
+
+    /**
+     * Does nothing.
+     * <p>
+     * @param cacheName - region name
+     * @param groupName - group name
+     * @return empty set
+     */
+    public Set getGroupKeys( String cacheName, String groupName )
+    {
+        return Collections.EMPTY_SET;
+    }
+
+    /**
+     * Walk the queue, calling the service for each queue operation.
+     * <p>
+     * @param service
+     * @throws Exception
+     */
+    public synchronized void propagateEvents( ICacheServiceNonLocal service )
+        throws Exception
+    {
+        int cnt = 0;
+        if ( log.isInfoEnabled() )
+        {
+            log.info( "Propagating events to the new ICacheServiceNonLocal." );
+        }
+        ElapsedTimer timer = new ElapsedTimer();
+        while ( !queue.isEmpty() )
+        {
+            cnt++;
+
+            // for each item, call the appropriate service method
+            ZombieEvent event = (ZombieEvent) queue.take();
+
+            if ( event instanceof PutEvent )
+            {
+                PutEvent putEvent = (PutEvent) event;
+                service.update( putEvent.element, event.requesterId );
+            }
+            else if ( event instanceof RemoveEvent )
+            {
+                RemoveEvent removeEvent = (RemoveEvent) event;
+                service.remove( event.cacheName, removeEvent.key, event.requesterId );
+            }
+            else if ( event instanceof RemoveAllEvent )
+            {
+                service.removeAll( event.cacheName, event.requesterId );
+            }
+        }
+        if ( log.isInfoEnabled() )
+        {
+            log.info( "Propagated " + cnt + " events to the new ICacheServiceNonLocal in "
+                + timer.getElapsedTimeString() );
+        }
+    }
+
+    /**
+     * Base of the other events.
+     */
+    private abstract class ZombieEvent
+    {
+        /** The name of the region. */
+        String cacheName;
+
+        /** The id of the requester */
+        long requesterId;
+    }
+
+    /**
+     * A basic put event.
+     */
+    private class PutEvent
+        extends ZombieEvent
+    {
+        /** The element to put */
+        ICacheElement element;
+
+        /**
+         * Set the element
+         * @param element
+         * @param requesterId
+         */
+        public PutEvent( ICacheElement element, long requesterId )
+        {
+            this.requesterId = requesterId;
+            this.element = element;
+        }
+    }
+
+    /**
+     * A basic Remove event.
+     */
+    private class RemoveEvent
+        extends ZombieEvent
+    {
+        /** The key to remove */
+        Serializable key;
+
+        /**
+         * Set the element
+         * @param cacheName
+         * @param key
+         * @param requesterId
+         */
+        public RemoveEvent( String cacheName, Serializable key, long requesterId )
+        {
+            this.cacheName = cacheName;
+            this.requesterId = requesterId;
+            this.key = key;
+        }
+    }
+
+    /**
+     * A basic RemoveAll event.
+     */
+    private class RemoveAllEvent
+        extends ZombieEvent
+    {
+        /**
+         * @param cacheName
+         * @param requesterId
+         */
+        public RemoveAllEvent( String cacheName, long requesterId )
+        {
+            this.cacheName = cacheName;
+            this.requesterId = requesterId;
+        }
+    }
+}

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheService.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheService.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheService.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheService.java Thu Jul 23 18:27:41 2009
@@ -28,8 +28,8 @@
 import org.apache.jcs.access.exception.ObjectNotFoundException;
 
 /**
- * Used to retrieve and update the cache. <br>
- * <br>
+ * Used to retrieve and update the cache.
+ * <p>
  * Note: server which implements this interface provides a local cache service, whereas server which
  * implements IRmiCacheService provides a remote cache service.
  */
@@ -60,11 +60,12 @@
     /**
      * Gets multiple items from the cache based on the given set of keys.
      * <p>
-     * @param cacheName 
+     * @param cacheName
      * @param keys
-     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no data in cache for any of these keys
-     * @throws ObjectNotFoundException 
-     * @throws IOException 
+     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+     *         data in cache for any of these keys
+     * @throws ObjectNotFoundException
+     * @throws IOException
      */
     Map getMultiple( String cacheName, Set keys )
         throws ObjectNotFoundException, IOException;
@@ -80,7 +81,7 @@
      */
     Map getMatching( String cacheName, String pattern )
         throws IOException;
-    
+
     /**
      * Removes the given key from the specified cache.
      * <p>

Added: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheServiceNonLocal.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheServiceNonLocal.java?rev=797178&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheServiceNonLocal.java (added)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheServiceNonLocal.java Thu Jul 23 18:27:41 2009
@@ -0,0 +1,119 @@
+package org.apache.jcs.engine.behavior;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.rmi.Remote;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Used to retrieve and update non local caches, such as the remote and lateral caches. Unlike
+ * ICacheService, the methods here have a requester id. This allows us to avoid propagating events
+ * to ourself.
+ * <p>
+ * TODO consider not extending ICacheService
+ */
+public interface ICacheServiceNonLocal
+    extends Remote, ICacheService
+{
+    /**
+     * Puts a cache item to the cache.
+     * <p>
+     * @param item
+     * @param requesterId
+     * @throws IOException
+     */
+    void update( ICacheElement item, long requesterId )
+        throws IOException;
+
+    /**
+     * Removes the given key from the specified cache.
+     * <p>
+     * @param cacheName
+     * @param key
+     * @param requesterId
+     * @throws IOException
+     */
+    void remove( String cacheName, Serializable key, long requesterId )
+        throws IOException;
+
+    /**
+     * Remove all keys from the specified cache.
+     * <p>
+     * @param cacheName
+     * @param requesterId
+     * @throws IOException
+     */
+    void removeAll( String cacheName, long requesterId )
+        throws IOException;
+
+    /**
+     * Returns a cache bean from the specified cache; or null if the key does not exist.
+     * <p>
+     * Adding the requestor id, allows the cache to determine the sournce of the get.
+     * <p>
+     * @param cacheName
+     * @param key
+     * @param requesterId
+     * @return ICacheElement
+     * @throws IOException
+     */
+    ICacheElement get( String cacheName, Serializable key, long requesterId )
+        throws IOException;
+
+    /**
+     * Gets multiple items from the cache based on the given set of keys.
+     * <p>
+     * @param cacheName
+     * @param keys
+     * @param requesterId
+     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+     *         data in cache for any of these keys
+     * @throws IOException
+     */
+    Map getMultiple( String cacheName, Set keys, long requesterId )
+        throws IOException;
+
+    /**
+     * Gets multiple items from the cache matching the pattern.
+     * <p>
+     * @param cacheName
+     * @param pattern
+     * @param requesterId
+     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+     *         data in cache matching the pattern.
+     * @throws IOException
+     */
+    Map getMatching( String cacheName, String pattern, long requesterId )
+        throws IOException;
+
+    /**
+     * Likely not implemented.  This probably should be deprecated.
+     * <p>
+     * @param cacheName
+     * @param groupName
+     * @return A Set of keys
+     * @throws IOException
+     */
+    Set getGroupKeys( String cacheName, String groupName )
+        throws IOException;
+}

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/DiscoveredService.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/DiscoveredService.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/DiscoveredService.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/DiscoveredService.java Thu Jul 23 18:27:41 2009
@@ -113,21 +113,25 @@
         return lastHearFromTime;
     }
 
-    /** @return hashcode based on address/port/name */
+    /** @return hashcode based on address/port */
     public int hashCode()
     {
         HashCodeBuilder builder = new HashCodeBuilder();
         builder.append( this.getServiceAddress() );
         builder.append( this.getServicePort() );
-        builder.append( this.getCacheNames() );
+        //builder.append( this.getCacheNames().toString() );
         return builder.toHashCode();
     }
 
     /**
      * NOTE - this object is often put into sets, so equals needs to be overridden.
      * <p>
+     * We can't use cache names as part of the equals unless we manually only use the address and
+     * port in a contains check. So that we can use normal set functionality, I've kept the cache
+     * names out.
+     * <p>
      * @param otherArg other
-     * @return equality based on the address/port/name
+     * @return equality based on the address/port
      */
     public boolean equals( Object otherArg )
     {
@@ -137,7 +141,7 @@
             EqualsBuilder builder = new EqualsBuilder();
             builder.append( this.getServiceAddress(), other.getServiceAddress() );
             builder.append( this.getServicePort(), other.getServicePort() );
-            builder.append( this.getCacheNames(), other.getCacheNames() );
+            //builder.append( this.getCacheNames().toString(), other.getCacheNames().toString() );
             return builder.isEquals();
         }
         return false;

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoverySenderThread.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoverySenderThread.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoverySenderThread.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoverySenderThread.java Thu Jul 23 18:27:41 2009
@@ -46,9 +46,9 @@
      */
     protected void setCacheNames( ArrayList cacheNames )
     {
-        if ( log.isDebugEnabled() )
+        if ( log.isInfoEnabled() )
         {
-            log.debug( "Resetting cacheNames = [" + cacheNames + "]" );
+            log.info( "Resetting cacheNames = [" + cacheNames + "]" );
         }
         this.cacheNames = cacheNames;
     }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoveryService.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoveryService.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoveryService.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoveryService.java Thu Jul 23 18:27:41 2009
@@ -124,7 +124,7 @@
 
         // create a sender thread
         sender = new UDPDiscoverySenderThread( getUdpDiscoveryAttributes(), getCacheNames() );
-        senderDaemon.executePeriodically( 15 * 1000, sender, true );        
+        senderDaemon.executePeriodically( 15 * 1000, sender, true );
 
         // add the cleanup daemon too
         cleanup = new UDPCleanupRunner( this );
@@ -206,7 +206,7 @@
     public void removeDiscoveredService( DiscoveredService service )
     {
         boolean contained = getDiscoveredServices().remove( service );
-        
+
         if ( contained )
         {
             if ( log.isInfoEnabled() )
@@ -214,7 +214,7 @@
                 log.info( "Removing " + service );
             }
         }
-        
+
         Iterator it = getDiscoveryListeners().iterator();
         while ( it.hasNext() )
         {
@@ -229,50 +229,73 @@
      */
     protected void addOrUpdateService( DiscoveredService discoveredService )
     {
-        // Since this is a set we can add it over an over.
-        // We want to replace the old one, since we may add info that is not part of the equals.
-        // The equals method on the object being added is intentionally restricted.
-        if ( !getDiscoveredServices().contains( discoveredService ) )
+        synchronized ( getDiscoveredServices() )
         {
-            if ( log.isInfoEnabled() )
+            // Since this is a set we can add it over an over.
+            // We want to replace the old one, since we may add info that is not part of the equals.
+            // The equals method on the object being added is intentionally restricted.
+            if ( !getDiscoveredServices().contains( discoveredService ) )
             {
-                log.info( "Set does not contain service. I discovered " + discoveredService );
+                if ( log.isInfoEnabled() )
+                {
+                    log.info( "Set does not contain service. I discovered " + discoveredService );
+                }
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "Adding service in the set " + discoveredService );
+                }
+                getDiscoveredServices().add( discoveredService );
             }
-            if ( log.isDebugEnabled() )
+            else
             {
-                log.debug( "Adding service in the set " + discoveredService );
-            }
-            getDiscoveredServices().add( discoveredService );
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "Set contains service." );
+                }
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "Updating service in the set " + discoveredService );
+                }
 
-            // todo update some list of cachenames
-            Iterator it = getDiscoveryListeners().iterator();
-            while ( it.hasNext() )
-            {
-                ( (IDiscoveryListener) it.next() ).addDiscoveredService( discoveredService );
-            }
-        }
-        else
-        {
-            if ( log.isDebugEnabled() )
-            {
-                log.debug( "Set contains service." );
-            }
-            if ( log.isDebugEnabled() )
-            {
-                log.debug( "Updating service in the set " + discoveredService );
-            }
-            Iterator it = getDiscoveredServices().iterator();
-            // need to update the time this sucks. add has no effect convert to a map
-            while ( it.hasNext() )
-            {
-                DiscoveredService service1 = (DiscoveredService) it.next();
-                if ( discoveredService.equals( service1 ) )
+                // Update the list of cache names if it has changed.
+                DiscoveredService theOldServiceInformation = null;
+                Iterator it = getDiscoveredServices().iterator();
+                // need to update the time this sucks. add has no effect convert to a map
+                while ( it.hasNext() )
                 {
-                    service1.setLastHearFromTime( discoveredService.getLastHearFromTime() );
-                    break;
+                    DiscoveredService service1 = (DiscoveredService) it.next();
+                    if ( discoveredService.equals( service1 ) )
+                    {
+                        theOldServiceInformation = service1;
+                        break;
+                    }
                 }
+                if ( theOldServiceInformation != null )
+                {
+                    if ( !theOldServiceInformation.getCacheNames().equals( discoveredService.getCacheNames() ) )
+                    {
+                        if ( log.isInfoEnabled() )
+                        {
+                            log.info( "List of cache names changed for service: " + discoveredService );
+                        }
+                    }
+                }
+
+                // replace it, we want to reset the payload and the last heard from time.
+                getDiscoveredServices().remove( discoveredService );
+                getDiscoveredServices().add( discoveredService );
             }
         }
+        // Always Notify the listeners
+        // If we don't do this, then if a region using the default config is initialized after notification, 
+        // it will never get the service in it's no wait list.
+        // Leave it to the listeners to decide what to do.
+        Iterator it = getDiscoveryListeners().iterator();
+        while ( it.hasNext() )
+        {
+            ( (IDiscoveryListener) it.next() ).addDiscoveredService( discoveredService );
+        }
+
     }
 
     /**

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/behavior/IDiscoveryListener.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/behavior/IDiscoveryListener.java?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/behavior/IDiscoveryListener.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/utils/discovery/behavior/IDiscoveryListener.java Thu Jul 23 18:27:41 2009
@@ -29,7 +29,7 @@
 {
     /**
      * Add the service if needed. This does not necessarily mean that the service is not already
-     * added. This can be called if there is a change.
+     * added. This can be called if there is a change in service information, such as the cacheNames.
      * <p>
      * @param service the service to add
      */

Modified: jakarta/jcs/trunk/src/test-conf/TestTCPLateralRemoveFilter.ccf
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test-conf/TestTCPLateralRemoveFilter.ccf?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test-conf/TestTCPLateralRemoveFilter.ccf (original)
+++ jakarta/jcs/trunk/src/test-conf/TestTCPLateralRemoveFilter.ccf Thu Jul 23 18:27:41 2009
@@ -37,36 +37,7 @@
 jcs.auxiliary.LTCP=org.apache.jcs.auxiliary.lateral.socket.tcp.LateralTCPCacheFactory
 jcs.auxiliary.LTCP.attributes=org.apache.jcs.auxiliary.lateral.socket.tcp.TCPLateralCacheAttributes
 jcs.auxiliary.LTCP.attributes.TcpServers=localhost:1117
-jcs.auxiliary.LTCP.attributes.TcpListenerPort=1118
+jcs.auxiliary.LTCP.attributes.TcpListenerPort=2001
 jcs.auxiliary.LTCP.attributes.AllowGet=false
 jcs.auxiliary.LTCP.attributes.IssueRemoveOnPut=true
-jcs.auxiliary.LTCP.attributes.FilterRemoveByHashCode=true
-
-# #############################################################
-# ################# THREAD POOL CONFIGURATION ###################
-# Default thread pool config
-thread_pool.default.boundarySize=2000
-thread_pool.default.maximumPoolSize=150
-thread_pool.default.minimumPoolSize=4
-thread_pool.default.keepAliveTime=350000
-# RUN ABORT WAIT BLOCK DISCARDOLDEST
-thread_pool.default.whenBlockedPolicy=RUN
-thread_pool.default.startUpSize=4
-
-# Default Cache Event Queue thread pool config, used by auxiliaries
-thread_pool.cache_event_queue.useBoundary=false
-# thread_pool.cache_event_queue.boundarySize=2000
-# thread_pool.cache_event_queue.maximumPoolSize=10
-thread_pool.cache_event_queue.minimumPoolSize=5
-thread_pool.cache_event_queue.keepAliveTime=3500
-# thread_pool.cache_event_queue.whenBlockedPolicy=RUN
-thread_pool.cache_event_queue.startUpSize=5
-
-# Remote cache client thread pool config
-thread_pool.remote_cache_client.boundarySize=75
-thread_pool.remote_cache_client.maximumPoolSize=150
-thread_pool.remote_cache_client.minimumPoolSize=4
-thread_pool.remote_cache_client.keepAliveTime=350000
-thread_pool.remote_cache_client.whenBlockedPolicy=RUN
-thread_pool.remote_cache_client.startUpSize=4
-
+jcs.auxiliary.LTCP.attributes.FilterRemoveByHashCode=true
\ No newline at end of file

Modified: jakarta/jcs/trunk/src/test-conf/log4j.properties
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test-conf/log4j.properties?rev=797178&r1=797177&r2=797178&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test-conf/log4j.properties (original)
+++ jakarta/jcs/trunk/src/test-conf/log4j.properties Thu Jul 23 18:27:41 2009
@@ -28,7 +28,7 @@
 log4j.category.org.apache.jcs.auxiliary.lateral=INFO
 log4j.category.org.apache.jcs.utils.struct=INFO
 log4j.category.org.apache.jcs.utils.threadpool=INFO
-log4j.category.org.apache.jcs.utils.discovery=DEBUG
+log4j.category.org.apache.jcs.utils.discovery=INFO
 
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout



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