public void testParseServerAndPort() { RemoteCacheAttributes rca = new RemoteCacheAttributes(); RemoteUtils.parseServerAndPort("server1:1234", rca); assertEquals("server1", rca.getRemoteHost()); assertEquals(1234, rca.getRemotePort()); RemoteUtils.parseServerAndPort(" server2 : 4567 ", rca); assertEquals("server2", rca.getRemoteHost()); assertEquals(4567, rca.getRemotePort()); rca.setRemoteHost(""); rca.setRemotePort(0); // Should not change anything RemoteUtils.parseServerAndPort("server2 : port", rca); assertEquals("", rca.getRemoteHost()); assertEquals(0, rca.getRemotePort()); } }
if ( rca.getRemoteType() == RemoteType.LOCAL ) if ( rca.getRemoteHost() != null ) failovers.add( rca.getRemoteHost() + ":" + rca.getRemotePort() ); String failoverList = rca.getFailoverServers(); if ( failoverList != null ) rca.setFailovers( failovers.toArray( new String[0] ) ); else if ( rca.getRemoteType() == RemoteType.CLUSTER ) StringTokenizer it = new StringTokenizer( rca.getClusterServers(), "," ); while ( it.hasMoreElements() ) rca.setRemoteHost( server.substring( 0, server.indexOf( ":" ) ) ); rca.setRemotePort( Integer.parseInt( server.substring( server.indexOf( ":" ) + 1 ) ) ); RemoteCacheManager rcm = RemoteCacheManager.getInstance( rca, cacheMgr, cacheEventLogger, elementSerializer ); rca.setRemoteType( RemoteType.CLUSTER ); ICache<K, V> ic = rcm.getCache( rca ); noWaits.add( ic ); new RemoteCacheNoWaitFacade<K, V>(rcnwArray, rca, cacheMgr, cacheEventLogger, elementSerializer ); getFacades().put( rca.getCacheName(), rcnwf );
/** * @return String, all the important values that can be configured */ @Override public String toString() { StringBuilder buf = new StringBuilder(super.toString()); buf.append( "\n receive = [" + isReceive() + "]" ); buf.append( "\n getTimeoutMillis = [" + getGetTimeoutMillis() + "]" ); buf.append( "\n threadPoolName = [" + getThreadPoolName() + "]" ); buf.append( "\n localClusterConsistency = [" + isLocalClusterConsistency() + "]" ); buf.append( "\n zombieQueueMaxSize = [" + getZombieQueueMaxSize() + "]" ); return buf.toString(); } }
switch (rca.getRemoteType()) if ( rca.getRemoteLocation() != null ) failovers.add( rca.getRemoteLocation() ); RemoteCacheManager rcm = getManager( rca, cacheMgr, cacheEventLogger, elementSerializer ); RemoteCacheNoWait<K,V> ic = rcm.getCache( rca ); String failoverList = rca.getFailoverServers(); if ( failoverList != null ) rca.setRemoteLocation(location); RemoteCacheManager rcm = getManager( rca, cacheMgr, cacheEventLogger, elementSerializer ); rca.setFailovers( failovers ); break; StringTokenizer it = new StringTokenizer( rca.getClusterServers(), "," ); while ( it.hasMoreElements() ) rca.setRemoteLocation(location); RemoteCacheManager rcm = getManager( rca, cacheMgr, cacheEventLogger, elementSerializer ); rca.setRemoteType( RemoteType.CLUSTER ); RemoteCacheNoWait<K,V> ic = rcm.getCache( rca ); noWaits.add( ic );
RemoteCacheAttributes attributes = new RemoteCacheAttributes(); attributes.setRemoteHost("localhost"); attributes.setLocalPort(1202); attributes.setRemotePort(remotePort);
RemoteCacheAttributes attributes = new RemoteCacheAttributes(); attributes.setRemoteLocation("localhost", remotePort); attributes.setLocalPort(LOCAL_PORT); attributes.setCacheName("testPutaMultipleAndListen");
log.debug( "RemoteCacheAttributes for failover = " + rca.toString() ); ICache<K, V> ic = rcm.getCache( rca.getCacheName() ); if ( ic.getStatus() == CacheStatus.ALIVE ) log.info( "CONNECTED to host = [" + rca.getRemoteHost() + "] port = [" + rca.getRemotePort() + "]" ); String remoteHost = (rca == null) ? "null" : rca.getRemoteHost(); int remotePort = (rca == null) ? 0 : rca.getRemotePort(); if ( i == 0 )
/** * @see junit.framework.TestCase#setUp() */ @Override protected void setUp() throws Exception { super.setUp(); cattr = new RemoteCacheAttributes(); service = new MockRemoteCacheService<String, String>(); listener = new MockRemoteCacheListener<String, String>(); monitor = new RemoteCacheMonitor(); }
RemoteCacheAttributes rca = new RemoteCacheAttributes(); rca.setRemoteHost( "localhost" ); rca.setRemotePort( 1101 );
RemoteCacheAttributes rca = new RemoteCacheAttributes(); rca.setRemoteLocation( "localhost", 1101 ); rca.setCacheName( "testCache" );
RemoteCacheAttributes attributes = new RemoteCacheAttributes(); attributes.setRemoteHost("localhost"); attributes.setLocalPort(1202); attributes.setRemotePort(remotePort);
RemoteCacheAttributes attributes = new RemoteCacheAttributes(); attributes.setRemoteLocation("localhost", remotePort); attributes.setLocalPort(LOCAL_PORT); attributes.setCacheName("testSinglePut");
/** * Verify that we can add an item. */ public void testAddNoWait_InList() { // SETUP List<RemoteCacheNoWait<String, String>> noWaits = new ArrayList<RemoteCacheNoWait<String,String>>(); IRemoteCacheAttributes cattr = new RemoteCacheAttributes(); cattr.setCacheName( "testCache1" ); RemoteCache<String, String> client = new RemoteCache<String, String>(cattr, null, null, null); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); noWaits.add( noWait ); RemoteCacheNoWaitFacade<String, String> facade = new RemoteCacheNoWaitFacade<String, String>(noWaits, cattr, null, null, null ); // VERIFY assertEquals( "Should have one entry.", 1, facade.noWaits.size() ); assertTrue( "Should be in the list.", facade.noWaits.contains( noWait ) ); assertSame( "Should have same facade.", facade, ((RemoteCache<String, String>)facade.noWaits.get(0).getRemoteCache()).getFacade() ); } }
RemoteCacheAttributes attributes = new RemoteCacheAttributes(); attributes.setRemoteHost("localhost"); attributes.setLocalPort(1202); attributes.setRemotePort(remotePort);
/** * @return String, all the important values that can be configured */ @Override public String toString() { StringBuilder buf = new StringBuilder(super.toString()); buf.append( "\n receive = [" + isReceive() + "]" ); buf.append( "\n getTimeoutMillis = [" + getGetTimeoutMillis() + "]" ); buf.append( "\n threadPoolName = [" + getThreadPoolName() + "]" ); buf.append( "\n localClusterConsistency = [" + isLocalClusterConsistency() + "]" ); buf.append( "\n zombieQueueMaxSize = [" + getZombieQueueMaxSize() + "]" ); return buf.toString(); } }
RemoteCacheAttributes attributes = new RemoteCacheAttributes(); attributes.setRemoteLocation("localhost", remotePort); attributes.setLocalPort(LOCAL_PORT); attributes.setCacheName("testPutAndListen");
/** * Verify event log calls. * <p> * @throws Exception */ public void testGetMultiple_simple() throws Exception { // SETUP IRemoteCacheAttributes cattr = new RemoteCacheAttributes(); MockRemoteCacheService<String, String> service = new MockRemoteCacheService<String, String>(); MockRemoteCacheListener<String, String> listener = new MockRemoteCacheListener<String, String>(); RemoteCache<String, String> remoteCache = new RemoteCache<String, String>( cattr, service, listener ); MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger(); remoteCache.setCacheEventLogger( cacheEventLogger ); // DO WORK remoteCache.getMultiple( new HashSet<String>() ); // VERIFY assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls ); assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls ); }
RemoteCacheAttributes attributes = new RemoteCacheAttributes(); attributes.setRemoteHost("localhost"); attributes.setLocalPort(1202); attributes.setRemotePort(remotePort);
RemoteCacheAttributes attributes = new RemoteCacheAttributes(); attributes.setRemoteLocation("localhost", remotePort); attributes.setLocalPort(LOCAL_PORT); attributes.setCacheName("testPutRemove");
/** * Verify that there is no problem if there is no listener. * <p> * @throws Exception */ public void testDispose_nullListener() throws Exception { // SETUP IRemoteCacheAttributes cattr = new RemoteCacheAttributes(); MockRemoteCacheService<String, String> service = new MockRemoteCacheService<String, String>(); MockRemoteCacheListener<String, String> listener = null; RemoteCache<String, String> remoteCache = new RemoteCache<String, String>( cattr, service, listener ); MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger(); remoteCache.setCacheEventLogger( cacheEventLogger ); // DO WORK remoteCache.dispose( ); // VERIFY assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls ); assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls ); } }