jakarta-jcs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asm...@apache.org
Subject svn commit: r698720 - in /jakarta/jcs/trunk/src: conf/ java/org/apache/jcs/auxiliary/remote/ java/org/apache/jcs/auxiliary/remote/behavior/ java/org/apache/jcs/auxiliary/remote/server/ java/org/apache/jcs/utils/config/ test/org/apache/jcs/auxiliary/rem...
Date Wed, 24 Sep 2008 20:35:45 GMT
Author: asmuts
Date: Wed Sep 24 13:35:45 2008
New Revision: 698720

URL: http://svn.apache.org/viewvc?rev=698720&view=rev
Log:
Adding the ability to configure a custom socket factory for just the rmi cache server.  

Added:
    jakarta/jcs/trunk/src/conf/remote.cacheCEL_CSF.ccf
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/MockRMISocketFactory.java
Modified:
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheManager.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheMonitor.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheRestore.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteUtils.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheConstants.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/utils/config/OptionConverter.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheListener.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheService.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java

Added: jakarta/jcs/trunk/src/conf/remote.cacheCEL_CSF.ccf
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/conf/remote.cacheCEL_CSF.ccf?rev=698720&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/conf/remote.cacheCEL_CSF.ccf (added)
+++ jakarta/jcs/trunk/src/conf/remote.cacheCEL_CSF.ccf Wed Sep 24 13:35:45 2008
@@ -0,0 +1,69 @@
+# 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.
+# #############################################################
+# ################# REMOTE SERVER CONFIG  #####################
+# Registry used to register and provide the IRmiCacheService service.
+registry.host=localhost
+registry.port=1101
+jcs.remotecache.serverattributes.servicePort=1301
+jcs.remotecache.serverattributes.localClusterConsistency=true
+jcs.remotecache.customrmisocketfactory=org.apache.jcs.auxiliary.remote.server.MockRMISocketFactory
+jcs.remotecache.cacheeventlogger=org.apache.jcs.engine.logging.CacheEventLoggerDebugLogger
+jcs.remotecache.cacheeventlogger.attributes.logCategoryName=test.RCSEventLogCategory
+
+# #############################################################
+# ################# DEFAULT CACHE REGION  #####################
+# sets the default aux value for any non configured caches
+jcs.default=DC,RCluster
+jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes.MaxObjects=200000
+jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
+jcs.default.cacheattributes.UseMemoryShrinker=true
+jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
+jcs.default.elementattributes.IsEternal=false
+jcs.default.elementattributes.MaxLifeSeconds=7000
+jcs.default.elementattributes.IdleTime=1800
+jcs.default.elementattributes.IsSpool=true
+jcs.default.elementattributes.IsRemote=true
+jcs.default.elementattributes.IsLateral=true
+
+
+# #############################################################
+# ################# CACHE REGIONS AVAILABLE ###################
+jcs.region.testCache1=DC,RCluster
+jcs.region.testCache1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
+jcs.region.testCache1.cacheattributes.MaxObjects=200002
+
+
+# #############################################################
+# ################# AUXILIARY CACHES AVAILABLE ################
+# server to update for clustering -- remote.cache2.ccf(1102)  and remote.cache3.ccf(1103)
+jcs.auxiliary.RCluster=org.apache.jcs.auxiliary.remote.RemoteCacheFactory
+jcs.auxiliary.RCluster.attributes=org.apache.jcs.auxiliary.remote.RemoteCacheAttributes
+jcs.auxiliary.RCluster.attributes.RemoteTypeName=CLUSTER
+jcs.auxiliary.RCluster.attributes.RemoveUponRemotePut=false
+jcs.auxiliary.RCluster.attributes.ClusterServers=localhost:1102
+jcs.auxiliary.RCluster.attributes.GetOnly=false
+jcs.auxiliary.RCluster.attributes.LocalClusterConsistency=true
+
+
+jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
+jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
+jcs.auxiliary.DC.attributes.DiskPath=@project_home@/raf/remote
+

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=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java Wed Sep 24 13:35:45 2008
@@ -134,7 +134,7 @@
             }
         }
 
-        RemoteUtils.configureCustomSocketFactory( irca.getRmiSocketFactoryTimeoutMillis() );
+        RemoteUtils.configureGlobalCustomSocketFactory( irca.getRmiSocketFactoryTimeoutMillis() );
     }
 
     /**
@@ -545,17 +545,17 @@
      * Replaces the current remote cache service handle with the given handle. If the current remote
      * is a Zombie, the propagate teh events that may be queued to the restored service.
      * <p>
-     * @param remote IRemoteCacheService -- the remote server or proxy to the remote server
+     * @param restoredRemote IRemoteCacheService -- the remote server or proxy to the remote server
      */
-    public void fixCache( IRemoteCacheService remote )
+    public void fixCache( IRemoteCacheService restoredRemote )
     {
         if ( this.remote != null && this.remote instanceof ZombieRemoteCacheService )
         {
             ZombieRemoteCacheService zombie = (ZombieRemoteCacheService) this.remote;
-            this.remote = remote;
+            this.remote = restoredRemote;
             try
             {
-                zombie.propagateEvents( remote );
+                zombie.propagateEvents( restoredRemote );
             }
             catch ( Exception e )
             {
@@ -572,7 +572,7 @@
         }
         else
         {
-            this.remote = remote;
+            this.remote = restoredRemote;
         }
         return;
     }
@@ -670,17 +670,20 @@
      */
     public long getListenerId()
     {
-        try
+        if ( listener != null )
         {
-            if ( log.isDebugEnabled() )
+            try
             {
-                log.debug( "get listenerId = " + listener.getListenerId() );
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "get listenerId = " + listener.getListenerId() );
+                }
+                return listener.getListenerId();
+            }
+            catch ( Exception e )
+            {
+                log.error( "Problem getting listenerId", e );
             }
-            return listener.getListenerId();
-        }
-        catch ( Exception e )
-        {
-            log.error( "Problem setting listenerId", e );
         }
         return -1;
     }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheManager.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheManager.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheManager.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheManager.java Wed Sep 24 13:35:45 2008
@@ -604,4 +604,18 @@
         release();
     }
 
+    /**
+     * Logs an event if an event logger is configured.
+     * <p>
+     * @param source
+     * @param eventName
+     * @param optionalDetails
+     */
+    protected void logApplicationEvent( String source, String eventName, String optionalDetails )
+    {
+        if ( cacheEventLogger != null )
+        {
+            cacheEventLogger.logApplicationEvent( source, eventName, optionalDetails );
+        }
+    }
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheMonitor.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheMonitor.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheMonitor.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheMonitor.java Wed Sep 24 13:35:45 2008
@@ -21,20 +21,17 @@
 
 import java.util.Iterator;
 
-import org.apache.jcs.engine.CacheConstants;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.engine.CacheConstants;
 
 /**
- * Used to monitor and repair any failed connection for the remote cache
- * service. By default the monitor operates in a failure driven mode. That is,
- * it goes into a wait state until there is an error. TODO consider moving this
- * into an active monitoring mode. Upon the notification of a connection error,
- * the monitor changes to operate in a time driven mode. That is, it attempts to
- * recover the connections on a periodic basis. When all failed connections are
- * restored, it changes back to the failure driven mode.
- *
+ * Used to monitor and repair any failed connection for the remote cache service. By default the
+ * monitor operates in a failure driven mode. That is, it goes into a wait state until there is an
+ * error. TODO consider moving this into an active monitoring mode. Upon the notification of a
+ * connection error, the monitor changes to operate in a time driven mode. That is, it attempts to
+ * recover the connections on a periodic basis. When all failed connections are restored, it changes
+ * back to the failure driven mode.
  */
 public class RemoteCacheMonitor
     implements Runnable
@@ -51,8 +48,9 @@
     // minimum 30 seconds.
     //private static long idlePeriod = 3*1000; // for debugging.
 
-    /** Must make sure RemoteCacheMonitor is started before any remote error can
-    * be detected! */
+    /**
+     * Must make sure RemoteCacheMonitor is started before any remote error can be detected!
+     */
     private boolean alright = true;
 
     /** Time driven mode */
@@ -66,9 +64,7 @@
 
     /**
      * Configures the idle period between repairs.
-     *
-     * @param idlePeriod
-     *            The new idlePeriod value
+     * @param idlePeriod The new idlePeriod value
      */
     public static void setIdlePeriod( long idlePeriod )
     {
@@ -86,7 +82,6 @@
 
     /**
      * Returns the singleton instance;
-     *
      * @return The instance value
      */
     static RemoteCacheMonitor getInstance()
@@ -102,8 +97,7 @@
     }
 
     /**
-     * Notifies the cache monitor that an error occurred, and kicks off the
-     * error recovery process.
+     * Notifies the cache monitor that an error occurred, and kicks off the error recovery process.
      */
     public void notifyError()
     {

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=698720&r1=698719&r2=698720&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 Wed Sep 24 13:35:45 2008
@@ -110,6 +110,7 @@
         if ( log.isInfoEnabled() )
         {
             String msg = "Remote connection to " + "//" + remoteCacheManager.host + ":" + remoteCacheManager.port + "/" + remoteCacheManager.service + " resumed.";
+            remoteCacheManager.logApplicationEvent( "RemoteCacheRestore", "fix", msg );
             log.info( msg );
         }
     }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteUtils.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteUtils.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteUtils.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteUtils.java Wed Sep 24 13:35:45 2008
@@ -36,8 +36,7 @@
 import org.apache.commons.logging.LogFactory;
 
 /**
- * This class provides some basic utilities for doing things such as starting
- * the registry properly.
+ * This class provides some basic utilities for doing things such as starting the registry properly.
  */
 public class RemoteUtils
 {
@@ -136,13 +135,14 @@
         }
         return props;
     }
-    
+
     /**
-     * Configure a custom socket factory to set the timeout value.
+     * Configure a custom socket factory to set the timeout value. This sets the global socket
+     * factory. It's used only if a custom factory is not configured for the specific object.
      * <p>
      * @param timeoutMillis
      */
-    public static void configureCustomSocketFactory( final int timeoutMillis )
+    public static void configureGlobalCustomSocketFactory( final int timeoutMillis )
     {
         try
         {

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheConstants.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheConstants.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheConstants.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheConstants.java Wed Sep 24 13:35:45 2008
@@ -27,14 +27,22 @@
     /** Mapping to props file value */
     public final static String REMOTE_CACHE_SERVICE_VAL = IRemoteCacheService.class.getName();
 
+    /** The prefix for cache server config. */
+    public final static String CACHE_SERVER_PREFIX = "jcs.remotecache";
+
     /**
      * I'm trying to migrate everything to use this prefix. All those below will be replaced. Any of
      * the RemoteCacheServerAttributes can be configured this way.
      */
-    public final static String CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX = "jcs.remotecache.serverattributes";
+    public final static String CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX = CACHE_SERVER_PREFIX + ".serverattributes";
+
+    /**
+     * This is the name of the class that will be used for an object specific socket factory.
+     */
+    public final static String CUSTOM_RMI_SOCKET_FACTORY_PROPERTY_PREFIX = CACHE_SERVER_PREFIX + ".customrmisocketfactory";
 
     /** Property prefix, should be jcs.remote but this would break existing config. */
-    public final static String PROPERTY_PREFIX = "remote";
+    public final static String PROPERTY_PREFIX = "remote";    
 
     /** Mapping to props file value */
     public final static String SOCKET_TIMEOUT_MILLIS = PROPERTY_PREFIX + ".cache.rmiSocketFactoryTimeoutMillis";

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java Wed Sep 24 13:35:45 2008
@@ -19,6 +19,7 @@
 import java.io.Serializable;
 import java.rmi.RemoteException;
 import java.rmi.registry.Registry;
+import java.rmi.server.RMISocketFactory;
 import java.rmi.server.UnicastRemoteObject;
 import java.rmi.server.Unreferenced;
 import java.util.Collections;
@@ -103,7 +104,7 @@
     private int logInterval = 100;
 
     /** An optional event logger */
-    private ICacheEventLogger cacheEventLogger;
+    private transient ICacheEventLogger cacheEventLogger;
 
     /** If there is no event logger, we will return this event for all create calls. */
     private static final ICacheEvent EMPTY_ICACHE_EVENT = new CacheEvent();
@@ -122,6 +123,22 @@
         this.remoteCacheServerAttributes = rcsa;
         init( rcsa.getConfigFileName() );
     }
+    
+    /**
+     * Constructor for the RemoteCacheServer object. This initializes the server with the values
+     * from the config file.
+     * <p>
+     * @param rcsa
+     * @param customRMISocketFactory 
+     * @throws RemoteException
+     */
+    RemoteCacheServer( IRemoteCacheServerAttributes rcsa,  RMISocketFactory customRMISocketFactory )
+        throws RemoteException
+    {
+        super( rcsa.getServicePort(), customRMISocketFactory, customRMISocketFactory );
+        this.remoteCacheServerAttributes = rcsa;
+        init( rcsa.getConfigFileName() );
+    }
 
     /**
      * Initialize the RMI Cache Server from a properties file.
@@ -1193,18 +1210,22 @@
                     id = listenerIdB;
 
                     // in case it needs synchronization
+                    String message = "adding vm listener under new id = [" + listenerIdB + "], listenerAddress ["
+                    + listenerAddress + "]";
+                    logApplicationEvent( "RemoteCacheServer", "addCacheListener", message );
                     if ( log.isInfoEnabled() )
                     {
-                        log.info( "adding vm listener under new id = [" + listenerIdB + "], listenerAddress ["
-                            + listenerAddress + "]" );
+                        log.info( message );
                     }
                 }
                 else
                 {
+                    String message = "adding listener under existing id = [" + id + "], listenerAddress ["
+                    + listenerAddress + "]";
+                    logApplicationEvent( "RemoteCacheServer", "addCacheListener", message );
                     if ( log.isInfoEnabled() )
                     {
-                        log.info( "adding listener under existing id = [" + id + "], listenerAddress ["
-                            + listenerAddress + "]" );
+                        log.info( message );
                     }
                     // should confirm the the host is the same as we have on
                     // record, just in case a client has made a mistake.
@@ -1286,9 +1307,11 @@
      */
     public void removeCacheListener( String cacheName, long listenerId )
     {
+        String message = "Removing listener for cache region = [" + cacheName + "] and listenerId [" + listenerId + "]";
+        logApplicationEvent( "RemoteCacheServer", "removeCacheListener", message );
         if ( log.isInfoEnabled() )
         {
-            log.info( "Removing listener for cache region = [" + cacheName + "] and listenerId [" + listenerId + "]" );
+            log.info( message );
         }
 
         Integer remoteTypeL = (Integer) idTypeMap.get( new Long( listenerId ) );
@@ -1486,6 +1509,21 @@
         String ipAddress = getIPAddressForRequesterId( requesterId );
         return cacheEventLogger.createICacheEvent( "RemoteCacheServer", cacheName, eventName, ipAddress, key );
     }
+    
+    /**
+     * Logs an event if an event logger is configured.
+     * <p>
+     * @param source
+     * @param eventName
+     * @param optionalDetails
+     */
+    protected void logApplicationEvent( String source, String eventName, String optionalDetails )
+    {
+        if ( cacheEventLogger != null )
+        {
+            cacheEventLogger.logApplicationEvent( source, eventName, optionalDetails );
+        }
+    }
 
     /**
      * Logs an event if an event logger is configured.

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java Wed Sep 24 13:35:45 2008
@@ -36,7 +36,7 @@
     /** The remote host. */
     private String remoteHost;
 
-    /** The remote port. */
+    /** The registry remote port. */
     private int remotePort;
 
     /**
@@ -46,7 +46,7 @@
      */
     private String clusterServers = "";
 
-    /** port the rmi server will listen to */
+    /** port the server will listen to */
     private int servicePort = 0;
 
     /** Cluster or local */

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java Wed Sep 24 13:35:45 2008
@@ -26,6 +26,8 @@
 import java.rmi.RemoteException;
 import java.rmi.registry.LocateRegistry;
 import java.rmi.registry.Registry;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMISocketFactory;
 import java.util.Properties;
 
 import org.apache.commons.logging.Log;
@@ -35,6 +37,7 @@
 import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheConstants;
 import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheServiceAdmin;
 import org.apache.jcs.engine.logging.behavior.ICacheEventLogger;
+import org.apache.jcs.utils.config.OptionConverter;
 import org.apache.jcs.utils.config.PropertySetter;
 
 import EDU.oswego.cs.dl.util.concurrent.ClockDaemon;
@@ -123,14 +126,24 @@
 
             setServiceName( rcsa.getRemoteServiceName() );
 
-            RemoteUtils.configureCustomSocketFactory( rcsa.getRmiSocketFactoryTimeoutMillis() );
+            RMISocketFactory customRMISocketFactory = configureObjectSpecificCustomFactory( props );
+
+            RemoteUtils.configureGlobalCustomSocketFactory( rcsa.getRmiSocketFactoryTimeoutMillis() );
 
             // CONFIGURE THE EVENT LOGGER
-            ICacheEventLogger cacheEventLogger = AuxiliaryCacheConfigurator
-                .parseCacheEventLogger( props, IRemoteCacheConstants.PROPERTY_PREFIX );
+            ICacheEventLogger cacheEventLogger;
+
+            cacheEventLogger = configureCacheEventLogger( props );
 
             // CREATE SERVER
-            remoteCacheServer = new RemoteCacheServer( rcsa );
+            if ( customRMISocketFactory != null )
+            {
+                remoteCacheServer = new RemoteCacheServer( rcsa, customRMISocketFactory );
+            }
+            else
+            {
+                remoteCacheServer = new RemoteCacheServer( rcsa );
+            }
             remoteCacheServer.setCacheEventLogger( cacheEventLogger );
 
             // START THE REGISTRY
@@ -155,6 +168,57 @@
     }
 
     /**
+     * Tries to get the event logger by new and old config styles.
+     * <p>
+     * @param props
+     * @return ICacheEventLogger
+     */
+    protected static ICacheEventLogger configureCacheEventLogger( Properties props )
+    {
+        ICacheEventLogger cacheEventLogger = AuxiliaryCacheConfigurator
+            .parseCacheEventLogger( props, IRemoteCacheConstants.CACHE_SERVER_PREFIX );
+
+        // try the old way
+        if ( cacheEventLogger == null )
+        {
+            cacheEventLogger = AuxiliaryCacheConfigurator.parseCacheEventLogger( props,
+                                                                                 IRemoteCacheConstants.PROPERTY_PREFIX );
+        }
+        return cacheEventLogger;
+    }
+
+    /**
+     * This configures an object specific custom factory. This will be configured for just this
+     * object in the registry. This can be null.
+     * <p>
+     * @param props
+     * @return RMISocketFactory
+     */
+    protected static RMISocketFactory configureObjectSpecificCustomFactory( Properties props )
+    {
+        RMISocketFactory customRMISocketFactory = (RMISocketFactory) OptionConverter
+            .instantiateByKey( props, CUSTOM_RMI_SOCKET_FACTORY_PROPERTY_PREFIX, RMIClientSocketFactory.class, null );
+
+        if ( customRMISocketFactory != null )
+        {
+            PropertySetter.setProperties( customRMISocketFactory, props, CUSTOM_RMI_SOCKET_FACTORY_PROPERTY_PREFIX
+                + "." );
+            if ( log.isInfoEnabled() )
+            {
+                log.info( "Will use server specific custom socket factory. " + customRMISocketFactory );
+            }
+        }
+        else
+        {
+            if ( log.isInfoEnabled() )
+            {
+                log.info( "No server specific custom socket factory defined." );
+            }
+        }
+        return customRMISocketFactory;
+    }
+
+    /**
      * Starts the registry if needed
      * <p>
      * @param registryPort
@@ -252,8 +316,8 @@
         return rcsa;
     }
 
-    /** 
-     * This looks for the old config values.  
+    /**
+     * This looks for the old config values.
      * <p>
      * @param prop
      * @param rcsa

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/utils/config/OptionConverter.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/utils/config/OptionConverter.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/utils/config/OptionConverter.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/utils/config/OptionConverter.java Wed Sep 24 13:35:45 2008
@@ -155,6 +155,7 @@
 
     /**
      * Creates an object for the className value of the key.
+     * <p>
      * @param props
      * @param key
      * @param superClass

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheListener.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheListener.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheListener.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheListener.java Wed Sep 24 13:35:45 2008
@@ -57,6 +57,9 @@
     /** The type of remote listener */
     public int remoteType = IRemoteCacheAttributes.LOCAL;
 
+    /**
+     * @throws IOException
+     */
     public void dispose()
         throws IOException
     {
@@ -65,8 +68,8 @@
 
     /**
      * returns the listener id, which can be setup.
-     * @return 
-     * @throws IOException 
+     * @return listenerId
+     * @throws IOException
      */
     public long getListenerId()
         throws IOException
@@ -74,6 +77,10 @@
         return listenerId;
     }
 
+    /**
+     * @return localAddress
+     * @throws IOException
+     */
     public String getLocalHostAddress()
         throws IOException
     {
@@ -82,8 +89,8 @@
 
     /**
      * Return the setup remoteType.
-     * @return 
-     * @throws IOException 
+     * @return remoteType
+     * @throws IOException
      */
     public int getRemoteType()
         throws IOException
@@ -93,6 +100,9 @@
 
     /**
      * Allows you to setup the listener id.
+     * <p>
+     * @param id
+     * @throws IOException
      */
     public void setListenerId( long id )
         throws IOException
@@ -100,6 +110,10 @@
         listenerId = id;
     }
 
+    /**
+     * @param cacheName
+     * @throws IOException
+     */
     public void handleDispose( String cacheName )
         throws IOException
     {
@@ -109,6 +123,9 @@
 
     /**
      * This increments the put count and adds the item to the putItem list.
+     * <p>
+     * @param item
+     * @throws IOException
      */
     public void handlePut( ICacheElement item )
         throws IOException
@@ -119,6 +136,10 @@
 
     /**
      * Increments the remove count and adds the key to the removedKeys list.
+     * <p>
+     * @param cacheName
+     * @param key
+     * @throws IOException
      */
     public void handleRemove( String cacheName, Serializable key )
         throws IOException
@@ -127,11 +148,13 @@
         removedKeys.add( key );
     }
 
+    /**
+     * @param cacheName
+     * @throws IOException
+     */
     public void handleRemoveAll( String cacheName )
         throws IOException
     {
         // TODO Auto-generated method stub
-
     }
-
 }

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheService.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheService.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheService.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheService.java Wed Sep 24 13:35:45 2008
@@ -21,8 +21,10 @@
 
 import java.io.IOException;
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -31,8 +33,6 @@
 
 /**
  * This is a mock impl of the remote cache service.
- * <p>
- * @author admin
  */
 public class MockRemoteCacheService
     implements IRemoteCacheService
@@ -40,6 +40,12 @@
     /** The object that was last passed to update. */
     public Object lastUpdate;
 
+    /** List of updates. */
+    public List updateRequestList = new ArrayList();
+
+    /** List of request ids. */
+    public List updateRequestIdList = new ArrayList();
+
     /** The key that was last passed to remove. */
     public Object lastRemoveKey;
 
@@ -47,9 +53,9 @@
     public String lastRemoveAllCacheName;
 
     /**
-     * @param cacheName 
-     * @param key 
-     * @param requesterId 
+     * @param cacheName
+     * @param key
+     * @param requesterId
      * @return null
      */
     public ICacheElement get( String cacheName, Serializable key, long requesterId )
@@ -58,9 +64,9 @@
     }
 
     /**
-     * @param cacheName 
-     * @param groupName 
-     * @return empty set 
+     * @param cacheName
+     * @param groupName
+     * @return empty set
      */
     public Set getGroupKeys( String cacheName, String groupName )
     {
@@ -70,9 +76,9 @@
     /**
      * Set the last remove key.
      * <p>
-     * @param cacheName 
-     * @param key 
-     * @param requesterId 
+     * @param cacheName
+     * @param key
+     * @param requesterId
      */
     public void remove( String cacheName, Serializable key, long requesterId )
     {
@@ -95,18 +101,20 @@
     /**
      * Set the last update item.
      * <p>
-     * @param item 
-     * @param requesterId 
+     * @param item
+     * @param requesterId
      */
     public void update( ICacheElement item, long requesterId )
     {
         lastUpdate = item;
+        updateRequestList.add( item );
+        updateRequestIdList.add( new Long( requesterId ) );
     }
 
     /**
      * Do nothing.
      * <p>
-     * @param cacheName 
+     * @param cacheName
      */
     public void dispose( String cacheName )
     {
@@ -114,8 +122,8 @@
     }
 
     /**
-     * @param cacheName 
-     * @param key 
+     * @param cacheName
+     * @param key
      * @return null
      */
     public ICacheElement get( String cacheName, Serializable key )
@@ -134,8 +142,8 @@
     /**
      * Set the last remove key.
      * <p>
-     * @param cacheName 
-     * @param key 
+     * @param cacheName
+     * @param key
      */
     public void remove( String cacheName, Serializable key )
     {
@@ -145,7 +153,7 @@
     /**
      * Set the last remove all cache name.
      * <p>
-     * @param cacheName 
+     * @param cacheName
      */
     public void removeAll( String cacheName )
     {
@@ -155,7 +163,7 @@
     /**
      * Set the last update item.
      * <p>
-     * @param item 
+     * @param item
      */
     public void update( ICacheElement item )
     {
@@ -163,9 +171,9 @@
     }
 
     /**
-     * @param cacheName 
-     * @param keys 
-     * @param requesterId 
+     * @param cacheName
+     * @param keys
+     * @param requesterId
      * @return empty map
      */
     public Map getMultiple( String cacheName, Set keys, long requesterId )
@@ -174,13 +182,12 @@
     }
 
     /**
-     * @param cacheName 
-     * @param keys 
+     * @param cacheName
+     * @param keys
      * @return empty map
      */
     public Map getMultiple( String cacheName, Set keys )
     {
         return new HashMap();
     }
-
 }

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java Wed Sep 24 13:35:45 2008
@@ -36,7 +36,6 @@
  * Tests for the remote cache listener.
  * <p>
  * @author Aaron Smuts
- *
  */
 public class RemoteCacheListenerUnitTest
     extends TestCase
@@ -45,12 +44,13 @@
      * Create a RemoteCacheListener with a mock cache manager.  Set remove on put to false.
      * Create a serialized element.  Call put on the listener.
      * Verify that the deserialized element is in the cache.
-     *
+     * <p>
      * @throws Exception
      */
-    public void testUpdate()
+    public void testUpdate_PutOnPut()
         throws Exception
     {
+        // SETUP
         IRemoteCacheAttributes irca = new RemoteCacheAttributes();
         irca.setRemoveUponRemotePut( false );
         ICompositeCacheManager cacheMgr = new MockCompositeCacheManager();
@@ -66,8 +66,11 @@
 
         ICacheElementSerialized element = new CacheElementSerialized( cacheName, key, elementSerializer
             .serialize( value ), attr );
+        
+        // DO WORK
         listener.handlePut( element );
 
+        // VERIFY
         ICacheElement after = cacheMgr.getCache( cacheName ).get( key );
 
         assertNotNull( "Should have a deserialized object.", after );
@@ -79,15 +82,16 @@
     }
 
     /**
-     * Create a RemoteCacheListener with a mock cache manager.  Set remove on put to false.
+     * Create a RemoteCacheListener with a mock cache manager.  Set remove on put to true.
      * Create a serialized element.  Call put on the listener.
-     * Verify that the deserialized element is in the cache.
-     *
+     * Verify that the deserialized element is not in the cache.
+     * <p>
      * @throws Exception
      */
     public void testUpdate_RemoveOnPut()
         throws Exception
     {
+        // SETUP
         IRemoteCacheAttributes irca = new RemoteCacheAttributes();
         irca.setRemoveUponRemotePut( true );
         ICompositeCacheManager cacheMgr = new MockCompositeCacheManager();
@@ -103,11 +107,13 @@
 
         ICacheElementSerialized element = new CacheElementSerialized( cacheName, key, elementSerializer
             .serialize( value ), attr );
+        
+        // DO WORK
         listener.handlePut( element );
 
+        // VERIFY
         ICacheElement after = cacheMgr.getCache( cacheName ).get( key );
 
         assertNull( "Should not have a deserialized object since remove on put is true.", after );
     }
-
 }

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitUnitTest.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitUnitTest.java Wed Sep 24 13:35:45 2008
@@ -57,9 +57,9 @@
         // DO WORK
         noWait.update( element );
 
+        // VERIFY
         SleepUtil.sleepAtLeast( 10 );
 
-        // VERIFY
         assertEquals( "Wrong number updated.", 1, client.updateList.size() );
         assertEquals( "Wrong element", element, client.updateList.get( 0 ) );
     }

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheUnitTest.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheUnitTest.java Wed Sep 24 13:35:45 2008
@@ -46,9 +46,11 @@
         throws Exception
     {
         // SETUP
+        long listenerId = 123;
         IRemoteCacheAttributes cattr = new RemoteCacheAttributes();
         MockRemoteCacheService service = new MockRemoteCacheService();
         MockRemoteCacheListener listener = new MockRemoteCacheListener();
+        listener.setListenerId( listenerId );
 
         RemoteCache remoteCache = new RemoteCache( cattr, service, listener );
 
@@ -65,6 +67,7 @@
             .getDeSerializedCacheElement( (ICacheElementSerialized) service.lastUpdate, remoteCache
                 .getElementSerializer() );
         assertEquals( "Wrong element updated.", element.getVal(), result.getVal() );
+        assertEquals( "Wrong listener id.", new Long( listenerId ), service.updateRequestIdList.get( 0 ) );
     }
 
     /**

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java Wed Sep 24 13:35:45 2008
@@ -116,7 +116,9 @@
         attributes.setLocalPort( 1202 );
         attributes.setRemotePort( remotePort );
 
-        RemoteCacheManager remoteCacheManager = RemoteCacheManager.getInstance( attributes, compositeCacheManager, new MockCacheEventLogger(), null );
+        MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+        
+        RemoteCacheManager remoteCacheManager = RemoteCacheManager.getInstance( attributes, compositeCacheManager, cacheEventLogger, null );
         String regionName = "testPutRemove";
         AuxiliaryCache cache = remoteCacheManager.getCache( regionName );
 

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/MockRMISocketFactory.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/MockRMISocketFactory.java?rev=698720&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/MockRMISocketFactory.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/MockRMISocketFactory.java Wed Sep 24 13:35:45 2008
@@ -0,0 +1,67 @@
+package org.apache.jcs.auxiliary.remote.server;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.rmi.server.RMISocketFactory;
+
+/** For testing the custom socket factory configuration */
+public class MockRMISocketFactory
+    extends RMISocketFactory
+    implements Serializable
+{
+    /** Don't change */
+    private static final long serialVersionUID = 1056199478581218676L;
+
+    /** for testing automatic property configuration. */
+    private String testStringProperty;
+
+    /**
+     * @param host
+     * @param port
+     * @return Socket
+     * @throws IOException
+     */
+    public Socket createSocket( String host, int port )
+        throws IOException
+    {
+        System.out.println( "Creating socket" );
+        
+        Socket socket = new Socket();
+        socket.setSoTimeout( 1000 );
+        socket.setSoLinger( false, 0 );
+        socket.connect( new InetSocketAddress( host, port ), 1000 );
+        return socket;
+    }
+
+    /**
+     * @param port
+     * @return ServerSocket
+     * @throws IOException
+     */
+    public ServerSocket createServerSocket( int port )
+        throws IOException
+    {
+        System.out.println( "Creating server socket" );
+
+        return new ServerSocket( port );
+    }
+
+    /**
+     * @param testStringProperty the testStringProperty to set
+     */
+    public void setTestStringProperty( String testStringProperty )
+    {
+        this.testStringProperty = testStringProperty;
+    }
+
+    /**
+     * @return the testStringProperty
+     */
+    public String getTestStringProperty()
+    {
+        return testStringProperty;
+    }
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java Wed Sep 24 13:35:45 2008
@@ -1,5 +1,6 @@
 package org.apache.jcs.auxiliary.remote.server;
 
+import java.rmi.server.RMISocketFactory;
 import java.util.Properties;
 
 import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheConstants;
@@ -127,4 +128,21 @@
         // VERIFY
         assertEquals( "Wrong localClusterConsistency", localClusterConsistency, result.isLocalClusterConsistency() );
     }
+    
+    /** verify that we get the timeout value */
+    public void testConfigureObjectSpecificCustomFactory_withProperty()
+    {
+        // SETUP
+        String testValue = "123245";
+        Properties props = new Properties();
+        props.put( IRemoteCacheConstants.CUSTOM_RMI_SOCKET_FACTORY_PROPERTY_PREFIX, MockRMISocketFactory.class.getName() );        
+        props.put( IRemoteCacheConstants.CUSTOM_RMI_SOCKET_FACTORY_PROPERTY_PREFIX + ".testStringProperty", testValue );        
+                
+        // DO WORK
+        RMISocketFactory result = RemoteCacheServerFactory.configureObjectSpecificCustomFactory( props );
+        
+        // VERIFY
+        assertNotNull( "Should have a custom socket factory.", result );
+        assertEquals( "Wrong testValue", testValue, ((MockRMISocketFactory)result).getTestStringProperty() );
+    }
 }

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java?rev=698720&r1=698719&r2=698720&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java Wed Sep 24 13:35:45 2008
@@ -47,7 +47,7 @@
      * <p>
      * @throws Exception
      */
-    public void testAddListenerToCache()
+    public void testAddListenerToCache_LOCALtype()
         throws Exception
     {
         // SETUP
@@ -59,8 +59,10 @@
         RemoteCacheServer server = new RemoteCacheServer( rcsa );
 
         MockRemoteCacheListener mockListener1 = new MockRemoteCacheListener();
+        mockListener1.remoteType = IRemoteCacheAttributes.LOCAL;
         mockListener1.localAddress = expectedIp1;
         MockRemoteCacheListener mockListener2 = new MockRemoteCacheListener();
+        mockListener1.remoteType = IRemoteCacheAttributes.LOCAL;
         mockListener2.localAddress = expectedIp2;
 
         String cacheName = "testAddListener";
@@ -77,21 +79,63 @@
     }
 
     /**
-     * Add a listner. Pass the id of 0, verify that the server sets a new listener id. Do another
+     * Add a listener. Pass the id of 0, verify that the server sets a new listener id. Do another
+     * and verify that the second gets an id of 2.
+     * <p>
+     * @throws Exception
+     */
+    public void testAddListenerToCache_CLUSTERtype()
+        throws Exception
+    {
+        // SETUP
+        String expectedIp1 = "adfasdf";
+        String expectedIp2 = "adsfadsafaf";
+
+        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
+        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
+        RemoteCacheServer server = new RemoteCacheServer( rcsa );
+
+        MockRemoteCacheListener mockListener1 = new MockRemoteCacheListener();
+        mockListener1.remoteType = IRemoteCacheAttributes.CLUSTER;
+        mockListener1.localAddress = expectedIp1;
+        MockRemoteCacheListener mockListener2 = new MockRemoteCacheListener();
+        mockListener1.remoteType = IRemoteCacheAttributes.CLUSTER;
+        mockListener2.localAddress = expectedIp2;
+
+        String cacheName = "testAddListener";
+
+        // DO WORK
+        server.addCacheListener( cacheName, mockListener1 );
+        server.addCacheListener( cacheName, mockListener2 );
+
+        // VERIFY
+        assertEquals( "Wrong listener id.", 1, mockListener1.getListenerId() );
+        assertEquals( "Wrong listener id.", 2, mockListener2.getListenerId() );
+        assertEquals( "Wrong ip.", expectedIp1, server.getIPAddressForRequesterId( 1 ) );
+        assertEquals( "Wrong ip.", expectedIp2, server.getIPAddressForRequesterId( 2 ) );
+    }
+    
+    /**
+     * Add a listener. Pass the id of 0, verify that the server sets a new listener id. Do another
      * and verify that the second gets an id of 2.
      * <p>
      * @throws Exception
      */
-    public void testAddListenerToAll()
+    public void testAddListener_ToAll()
         throws Exception
     {
         // SETUP
+        String expectedIp1 = "adfasdf";
+        String expectedIp2 = "adsfadsafaf";
+        
         IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
         rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
         RemoteCacheServer server = new RemoteCacheServer( rcsa );
 
         MockRemoteCacheListener mockListener1 = new MockRemoteCacheListener();
+        mockListener1.localAddress = expectedIp1;
         MockRemoteCacheListener mockListener2 = new MockRemoteCacheListener();
+        mockListener2.localAddress = expectedIp2;
 
         // DO WORK
         // don't specify the cache name
@@ -101,6 +145,8 @@
         // VERIFY
         assertEquals( "Wrong listener id.", 1, mockListener1.getListenerId() );
         assertEquals( "Wrong listener id.", 2, mockListener2.getListenerId() );
+        assertEquals( "Wrong ip.", expectedIp1, server.getIPAddressForRequesterId( 1 ) );
+        assertEquals( "Wrong ip.", expectedIp2, server.getIPAddressForRequesterId( 2 ) );        
     }
 
     /**
@@ -110,7 +156,7 @@
      * <p>
      * @throws Exception
      */
-    public void testAddListenerToAllThenRemove()
+    public void testAddListener_ToAllThenRemove()
         throws Exception
     {
         // SETUP
@@ -138,13 +184,13 @@
     }
 
     /**
-     * Add a listner. Pass the id of 0, verify that the server sets a new listener id. Do another
+     * Add a listener. Pass the id of 0, verify that the server sets a new listener id. Do another
      * and verify that the second gets an id of 2. Call remove Listener and verify that it is
      * removed.
      * <p>
      * @throws Exception
      */
-    public void testAddListenerToAllThenRemove_clusterType()
+    public void testAddListener_ToAllThenRemove_clusterType()
         throws Exception
     {
         // SETUP
@@ -232,7 +278,7 @@
         rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
         RemoteCacheServer server = new RemoteCacheServer( rcsa );
 
-        // this is to get the listenr id for inserts.
+        // this is to get the listener id for inserts.
         MockRemoteCacheListener clusterListener = new MockRemoteCacheListener();
         clusterListener.remoteType = IRemoteCacheAttributes.CLUSTER;
 
@@ -422,7 +468,7 @@
         server.setCacheEventLogger( cacheEventLogger );
 
         // DO WORK
-        server.remove( "region", "key" );
+        server.removeAll( "region" );
 
         // VERIFY
         assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls );



---------------------------------------------------------------------
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