Author: tv Date: Wed Feb 10 13:11:44 2016 New Revision: 1729592 URL: http://svn.apache.org/viewvc?rev=1729592&view=rev Log: Strip down API
Removed: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheRestore.java Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFailoverRunner.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheMonitor.java commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWait.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFailoverRunner.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFailoverRunner.java?rev=1729592&r1=1729591&r2=1729592&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFailoverRunner.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFailoverRunner.java Wed Feb 10 13:11:44 2016 @@ -194,7 +194,7 @@ public class RemoteCacheFailoverRunner<K // add a listener if there are none, need to tell rca // what number it is at - ICache<K, V> ic = rcm.getCache( rca.getCacheName() ); + ICache<K, V> ic = rcm.getCache( rca ); if ( ic.getStatus() == CacheStatus.ALIVE ) { // may need to do this more gracefully @@ -320,7 +320,7 @@ public class RemoteCacheFailoverRunner<K // add a listener if there are none, need to tell rca what number it // is at - ICache<K, V> ic = rcm.getCache( rca.getCacheName() ); + ICache<K, V> ic = rcm.getCache( rca ); // by default the listener id should be 0, else it will be the // listener // Originally associated with the remote cache. either way is fine. Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java?rev=1729592&r1=1729591&r2=1729592&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java Wed Feb 10 13:11:44 2016 @@ -28,6 +28,7 @@ import java.util.concurrent.locks.Reentr import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes; import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheClient; import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheListener; +import org.apache.commons.jcs.engine.CacheStatus; import org.apache.commons.jcs.engine.CacheWatchRepairable; import org.apache.commons.jcs.engine.ZombieCacheServiceNonLocal; import org.apache.commons.jcs.engine.ZombieCacheWatch; @@ -58,9 +59,6 @@ public class RemoteCacheManager /** Lock for initialization of caches */ private ReentrantLock cacheLock = new ReentrantLock(); - /** The configuration attributes. */ - private IRemoteCacheAttributes remoteCacheAttributes; - /** The event logger. */ private final ICacheEventLogger cacheEventLogger; @@ -85,6 +83,9 @@ public class RemoteCacheManager /** The service found through lookup */ private final String registry; + /** can it be restored */ + private boolean canFix = true; + /** * Constructs an instance to with the given remote connection parameters. If the connection * cannot be made, "zombie" services will be temporarily used until a successful re-connection @@ -100,13 +101,34 @@ public class RemoteCacheManager RemoteCacheMonitor monitor, ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer) { - this.remoteCacheAttributes = cattr; this.cacheMgr = cacheMgr; this.monitor = monitor; this.cacheEventLogger = cacheEventLogger; this.elementSerializer = elementSerializer; + this.remoteWatch = new CacheWatchRepairable(); this.registry = RemoteUtils.getNamingURL(cattr.getRemoteLocation(), cattr.getRemoteServiceName()); + + try + { + lookupRemoteService(); + } + catch (IOException e) + { + log.error("Could not find server", e); + // Notify the cache monitor about the error, and kick off the + // recovery process. + monitor.notifyError(); + } + } + + /** + * Lookup remote service from registry + * @throws IOException if the remote service could not be found + * + */ + protected void lookupRemoteService() throws IOException + { if ( log.isInfoEnabled() ) { log.info( "Looking up server [" + registry + "]" ); @@ -120,29 +142,21 @@ public class RemoteCacheManager } // Successful connection to the remote server. - remoteService = (ICacheServiceNonLocal<?, ?>) obj; + this.remoteService = (ICacheServiceNonLocal<?, ?>) obj; if ( log.isDebugEnabled() ) { - log.debug( "remoteService = " + remoteService ); + log.debug( "Remote Service = " + remoteService ); } - - ICacheObserver remoteObserver = (ICacheObserver) obj; - remoteWatch = new CacheWatchRepairable(); - remoteWatch.setCacheWatch( remoteObserver ); + remoteWatch.setCacheWatch( (ICacheObserver) remoteService ); } catch ( Exception ex ) { // Failed to connect to the remote server. // Configure this RemoteCacheManager instance to use the "zombie" // services. - log.error( "Problem finding server at [" + registry + "]", ex ); - remoteService = new ZombieCacheServiceNonLocal<String, String>(); - remoteWatch = new CacheWatchRepairable(); + this.remoteService = new ZombieCacheServiceNonLocal<String, String>(); remoteWatch.setCacheWatch( new ZombieCacheWatch() ); - - // Notify the cache monitor about the error, and kick off the - // recovery process. - monitor.notifyError(); + throw new IOException( "Problem finding server at [" + registry + "]", ex ); } } @@ -183,35 +197,6 @@ public class RemoteCacheManager * all listeners to a remote server, in case a failover is a primary of another region. Having * one regions failover act as another servers primary is not currently supported. * <p> - * @param cacheName the name of the cache - * @param listener the listener to de-register - * @throws IOException - */ - public <K, V> void removeRemoteCacheListener( String cacheName, IRemoteCacheListener<K, V> listener ) - throws IOException - { - remoteWatch.removeCacheListener( cacheName, listener ); - } - - /** - * Removes a listener. When the primary recovers the failover must deregister itself for a - * region. The failover runner will call this method to de-register. We do not want to deregister - * all listeners to a remote server, in case a failover is a primary of another region. Having - * one regions failover act as another servers primary is not currently supported. - * <p> - * @param cattr - * @param listener - * @throws IOException - */ - public <K, V> void removeRemoteCacheListener( IRemoteCacheAttributes cattr, IRemoteCacheListener<K, V> listener ) - throws IOException - { - removeRemoteCacheListener(cattr.getCacheName(), listener); - } - - /** - * Stops a listener. This is used to deregister a failover after primary reconnection. - * <p> * @param cattr * @throws IOException */ @@ -237,22 +222,6 @@ public class RemoteCacheManager } } - /** - * Stops a listener. This is used to deregister a failover after primary reconnection. - * <p> - * @param cacheName - * @throws IOException - */ - public void removeRemoteCacheListener( String cacheName ) - throws IOException - { - RemoteCacheNoWait<?, ?> cache = caches.get( cacheName ); - if ( cache != null ) - { - removeListenerFromCache(cache); - } - } - // common helper method private void removeListenerFromCache(RemoteCacheNoWait<?, ?> cache) throws IOException { @@ -263,23 +232,10 @@ public class RemoteCacheManager } // could also store the listener for a server in the manager. IRemoteCacheListener<?, ?> listener = rc.getListener(); - removeRemoteCacheListener( cache.getCacheName(), listener ); + remoteWatch.removeCacheListener( cache.getCacheName(), listener ); } /** - * Returns a remote cache for the given cache name. - * <p> - * @param cacheName - * @return The cache value - */ - public <K, V> RemoteCacheNoWait<K, V> getCache( String cacheName ) - { - IRemoteCacheAttributes ca = (IRemoteCacheAttributes) remoteCacheAttributes.clone(); - ca.setCacheName( cacheName ); - return getCache( ca ); - } - - /** * Gets a RemoteCacheNoWait from the RemoteCacheManager. The RemoteCacheNoWait objects are * identified by the cache name value of the RemoteCacheAttributes object. * <p> @@ -346,58 +302,6 @@ public class RemoteCacheManager return remoteCacheNoWait; } - /** - * Releases the cache. - * <p> - * @param name the name of the cache - * @throws IOException - */ - public void freeCache( String name ) - throws IOException - { - RemoteCacheNoWait<?, ?> c = caches.remove( name ); - freeCache(c); - } - - /** - * Releases the cache. - * <p> - * @param cache the cache instance - * @throws IOException - */ - public void freeCache( RemoteCacheNoWait<?, ?> cache ) - throws IOException - { - if ( cache != null ) - { - if ( log.isInfoEnabled() ) - { - log.info( "freeCache [" + cache.getCacheName() + "]" ); - } - - removeListenerFromCache(cache); - cache.dispose(); - } - } - - /** - * Gets the stats attribute of the RemoteCacheManager object - * <p> - * @return The stats value - */ - public String getStats() - { - StringBuilder stats = new StringBuilder(); - for (RemoteCacheNoWait<?, ?> c : caches.values()) - { - if ( c != null ) - { - stats.append( c.getCacheName() ); - } - } - return stats.toString(); - } - /** Shutdown all. */ public void release() { @@ -409,7 +313,13 @@ public class RemoteCacheManager { try { - freeCache( c ); + if ( log.isInfoEnabled() ) + { + log.info( "freeCache [" + c.getCacheName() + "]" ); + } + + removeListenerFromCache(c); + c.dispose(); } catch ( IOException ex ) { @@ -425,50 +335,56 @@ public class RemoteCacheManager /** * Fixes up all the caches managed by this cache manager. - * <p> - * @param remoteService - * @param remoteWatch */ - public void fixCaches( ICacheServiceNonLocal<?, ?> remoteService, ICacheObserver remoteWatch ) + public void fixCaches() { + if ( !canFix ) + { + return; + } + if ( log.isInfoEnabled() ) { log.info( "Fixing caches. ICacheServiceNonLocal " + remoteService + " | IRemoteCacheObserver " + remoteWatch ); } - synchronized ( this ) + for (RemoteCacheNoWait<?, ?> c : caches.values()) { - this.remoteService = remoteService; - this.remoteWatch.setCacheWatch( remoteWatch ); - for (RemoteCacheNoWait<?, ?> c : caches.values()) + if (c.getStatus() == CacheStatus.ERROR) { c.fixCache( remoteService ); } } - } - - /** - * Get the registry RMI URL - * @return the registry URL - */ - public String getRegistryURL() - { - return registry; + if ( log.isInfoEnabled() ) + { + String msg = "Remote connection to " + registry + " resumed."; + if ( cacheEventLogger != null ) + { + cacheEventLogger.logApplicationEvent( "RemoteCacheManager", "fix", msg ); + } + log.info( msg ); + } } /** - * Logs an event if an event logger is configured. + * Returns true if the connection to the remote host can be + * successfully re-established. * <p> - * @param source - * @param eventName - * @param optionalDetails + * @return true if we found a failover server */ - protected void logApplicationEvent( String source, String eventName, String optionalDetails ) + public boolean canFixCaches() { - if ( cacheEventLogger != null ) + try { - cacheEventLogger.logApplicationEvent( source, eventName, optionalDetails ); + lookupRemoteService(); } + catch (IOException e) + { + log.error("Could not find server", e); + canFix = false; + } + + return canFix; } } Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheMonitor.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheMonitor.java?rev=1729592&r1=1729591&r2=1729592&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheMonitor.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheMonitor.java Wed Feb 10 13:11:44 2016 @@ -22,7 +22,6 @@ package org.apache.commons.jcs.auxiliary import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.jcs.auxiliary.AbstractAuxiliaryCacheMonitor; -import org.apache.commons.jcs.engine.CacheStatus; /** * Used to monitor and repair any failed connection for the remote cache service. By default the @@ -39,13 +38,13 @@ public class RemoteCacheMonitor extends /** * Map of managers to monitor */ - private ConcurrentHashMap<String, RemoteCacheManager> managers; + private ConcurrentHashMap<RemoteCacheManager, RemoteCacheManager> managers; /** Constructor for the RemoteCacheMonitor object */ public RemoteCacheMonitor() { super("JCS-RemoteCacheMonitor"); - this.managers = new ConcurrentHashMap<String, RemoteCacheManager>(); + this.managers = new ConcurrentHashMap<RemoteCacheManager, RemoteCacheManager>(); setIdlePeriod(30000L); } @@ -56,7 +55,7 @@ public class RemoteCacheMonitor extends */ public void addManager(RemoteCacheManager manager) { - this.managers.put(manager.getRegistryURL(), manager); + this.managers.put(manager, manager); // if not yet started, go ahead if (this.getState() == Thread.State.NEW) @@ -86,27 +85,15 @@ public class RemoteCacheMonitor extends // Each RemoteCacheManager corresponds to one remote connection. for (RemoteCacheManager mgr : managers.values()) { - // If any cache is in error, it strongly suggests all managers - // managed by the - // same RmicCacheManager instance are in error. So we fix - // them once and for all. - for (RemoteCacheNoWait<?, ?> c : mgr.caches.values()) + // If we can't fix them, just skip and re-try in + // the next round. + if ( mgr.canFixCaches() ) { - if ( c.getStatus() == CacheStatus.ERROR ) - { - RemoteCacheRestore repairer = new RemoteCacheRestore( mgr ); - // If we can't fix them, just skip and re-try in - // the next round. - if ( repairer.canFix() ) - { - repairer.fix(); - } - else - { - allright.set(false); - } - break; - } + mgr.fixCaches(); + } + else + { + allright.set(false); } } } Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWait.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWait.java?rev=1729592&r1=1729591&r2=1729592&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWait.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWait.java Wed Feb 10 13:11:44 2016 @@ -99,14 +99,7 @@ public class RemoteCacheNoWait<K, V> public RemoteCacheNoWait( IRemoteCacheClient<K, V> cache ) { remoteCacheClient = cache; - - CacheEventQueueFactory<K, V> factory = new CacheEventQueueFactory<K, V>(); - this.cacheEventQueue = factory.createCacheEventQueue( - new CacheAdaptor<K, V>( remoteCacheClient ), - remoteCacheClient.getListenerId(), - remoteCacheClient.getCacheName(), - remoteCacheClient.getAuxiliaryCacheAttributes().getEventQueuePoolName(), - remoteCacheClient.getAuxiliaryCacheAttributes().getEventQueueType() ); + this.cacheEventQueue = createCacheEventQueue(cache); if ( remoteCacheClient.getStatus() == CacheStatus.ERROR ) { @@ -115,6 +108,22 @@ public class RemoteCacheNoWait<K, V> } /** + * Create a cache event queue from the parameters of the remote client + * @param client the remote client + */ + private ICacheEventQueue<K, V> createCacheEventQueue( IRemoteCacheClient<K, V> client ) + { + CacheEventQueueFactory<K, V> factory = new CacheEventQueueFactory<K, V>(); + ICacheEventQueue<K, V> ceq = factory.createCacheEventQueue( + new CacheAdaptor<K, V>( client ), + client.getListenerId(), + client.getCacheName(), + client.getAuxiliaryCacheAttributes().getEventQueuePoolName(), + client.getAuxiliaryCacheAttributes().getEventQueueType() ); + return ceq; + } + + /** * Adds a put event to the queue. * <p> * @param element @@ -416,10 +425,7 @@ public class RemoteCacheNoWait<K, V> { ICacheEventQueue<K, V> previousQueue = cacheEventQueue; - CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<K, V>(); - this.cacheEventQueue = fact.createCacheEventQueue( new CacheAdaptor<K, V>( remoteCacheClient ), remoteCacheClient - .getListenerId(), remoteCacheClient.getCacheName(), remoteCacheClient.getAuxiliaryCacheAttributes() - .getEventQueuePoolName(), remoteCacheClient.getAuxiliaryCacheAttributes().getEventQueueType() ); + this.cacheEventQueue = createCacheEventQueue(this.remoteCacheClient); if ( previousQueue.isWorking() ) { Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java?rev=1729592&r1=1729591&r2=1729592&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java Wed Feb 10 13:11:44 2016 @@ -106,9 +106,10 @@ public class TestRemoteCache RemoteCacheAttributes rca = new RemoteCacheAttributes(); rca.setRemoteLocation( "localhost", 1101 ); + rca.setCacheName( "testCache" ); RemoteCacheManager mgr = RemoteCacheFactory.getManager( rca, cacheMgr, new MockCacheEventLogger(), new MockElementSerializer() ); - AuxiliaryCache<String, String> cache = mgr.getCache( "testCache" ); + AuxiliaryCache<String, String> cache = mgr.getCache( rca ); int numMes = 100; for ( int i = 0; i < numMes; i++ ) Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java?rev=1729592&r1=1729591&r2=1729592&view=diff ============================================================================== --- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java (original) +++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java Wed Feb 10 13:11:44 2016 @@ -145,14 +145,14 @@ public class BasicRemoteCacheClientServe RemoteCacheAttributes attributes = new RemoteCacheAttributes(); attributes.setRemoteLocation("localhost", remotePort); attributes.setLocalPort(LOCAL_PORT); + attributes.setCacheName("testSinglePut"); RemoteCacheManager remoteCacheManager = RemoteCacheFactory.getManager(attributes, compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer()); - String regionName = "testSinglePut"; - AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(regionName); + AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes); // DO WORK int numPutsPrior = server.getPutCount(); - ICacheElement<String, String> element = new CacheElement<String, String>(regionName, "key", "value"); + ICacheElement<String, String> element = new CacheElement<String, String>(cache.getCacheName(), "key", "value"); cache.update(element); SleepUtil.sleepAtLeast(200); @@ -192,16 +192,16 @@ public class BasicRemoteCacheClientServe RemoteCacheAttributes attributes = new RemoteCacheAttributes(); attributes.setRemoteLocation("localhost", remotePort); attributes.setLocalPort(LOCAL_PORT); + attributes.setCacheName("testPutRemove"); MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger(); RemoteCacheManager remoteCacheManager = RemoteCacheFactory.getManager(attributes, compositeCacheManager, cacheEventLogger, null); - String regionName = "testPutRemove"; - AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(regionName); + AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes); // DO WORK int numPutsPrior = server.getPutCount(); - ICacheElement<String, String> element = new CacheElement<String, String>(regionName, "key", "value"); + ICacheElement<String, String> element = new CacheElement<String, String>(cache.getCacheName(), "key", "value"); cache.update(element); SleepUtil.sleepAtLeast(50); @@ -248,17 +248,17 @@ public class BasicRemoteCacheClientServe RemoteCacheAttributes attributes = new RemoteCacheAttributes(); attributes.setRemoteLocation("localhost", remotePort); attributes.setLocalPort(LOCAL_PORT); + attributes.setCacheName("testPutAndListen"); RemoteCacheManager remoteCacheManager = RemoteCacheFactory.getManager(attributes, compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer()); - String regionName = "testPutAndListen"; - AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(regionName); + AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes); MockRemoteCacheListener<String, String> listener = new MockRemoteCacheListener<String, String>(); - server.addCacheListener(regionName, listener); + server.addCacheListener(cache.getCacheName(), listener); // DO WORK int numPutsPrior = server.getPutCount(); - ICacheElement<String, String> element = new CacheElement<String, String>(regionName, "key", "value"); + ICacheElement<String, String> element = new CacheElement<String, String>(cache.getCacheName(), "key", "value"); cache.update(element); SleepUtil.sleepAtLeast(50); @@ -280,7 +280,7 @@ public class BasicRemoteCacheClientServe // remove from all regions. server.removeCacheListener(listener); } - } + } /** * Register a listener with the server. Send an update. Verify that the listener received it. @@ -290,27 +290,27 @@ public class BasicRemoteCacheClientServe @Test public void test4PutaMultipleAndListen() throws Exception - { + { // SETUP MockCompositeCacheManager compositeCacheManager = new MockCompositeCacheManager(); RemoteCacheAttributes attributes = new RemoteCacheAttributes(); attributes.setRemoteLocation("localhost", remotePort); attributes.setLocalPort(LOCAL_PORT); + attributes.setCacheName("testPutaMultipleAndListen"); RemoteCacheManager remoteCacheManager = RemoteCacheFactory.getManager(attributes, compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer()); - String regionName = "testPutaMultipleAndListen"; - AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(regionName); + AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes); MockRemoteCacheListener<String, String> listener = new MockRemoteCacheListener<String, String>(); - server.addCacheListener(regionName, listener); + server.addCacheListener(cache.getCacheName(), listener); // DO WORK int numPutsPrior = server.getPutCount(); int numToPut = 100; for (int i = 0; i < numToPut; i++) { - ICacheElement<String, String> element = new CacheElement<String, String>(regionName, "key" + 1, "value" + i); + ICacheElement<String, String> element = new CacheElement<String, String>(cache.getCacheName(), "key" + 1, "value" + i); cache.update(element); } SleepUtil.sleepAtLeast(500); @@ -328,7 +328,7 @@ public class BasicRemoteCacheClientServe System.out.println(server.getStats()); throw e; } - } + } @Test public void testLocalHost() throws Exception