/** * Tries to lookup the server. If unsuccessful it will rebind the server using the factory * rebind method. * <p> */ @Override public void run() { checkAndRestoreIfNeeded(); }
/** * Creates the registry and registers the server. * <p> * @param registry */ protected void createAndRegister( String registry ) { createReqistry( registry ); registerServer( registry ); }
/** Verify that we get the appropriate event log */ public void testCheckAndRestoreIfNeeded_failure() { // SETUP String host = "localhost"; int port = 1234; String service = "doesn'texist"; MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger(); RegistryKeepAliveRunner runner = new RegistryKeepAliveRunner( host, port, service ); runner.setCacheEventLogger( cacheEventLogger ); // DO WORK runner.checkAndRestoreIfNeeded(); // VERIFY // 1 for the lookup, one for the rebind since the server isn't created yet assertEquals( "error tally", 2, cacheEventLogger.errorEventCalls ); //System.out.println( cacheEventLogger.errorMessages ); } }
new DaemonThreadFactory("JCS-RemoteCacheServerFactory-")); RegistryKeepAliveRunner runner = new RegistryKeepAliveRunner( host, port, serviceName ); runner.setCacheEventLogger( cacheEventLogger ); keepAliveDaemon.scheduleAtFixedRate(runner, 0, rcsa.getRegistryKeepAliveDelayMillis(), TimeUnit.MILLISECONDS);
createAndRegister( serviceName );
/** Verify that we get the appropriate event log */ public void testCheckAndRestoreIfNeeded_failure() { // SETUP String host = "localhost"; int port = 1234; String service = "doesn'texist"; MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger(); RegistryKeepAliveRunner runner = new RegistryKeepAliveRunner( host, port, service ); runner.setCacheEventLogger( cacheEventLogger ); // DO WORK runner.checkAndRestoreIfNeeded(); // VERIFY // 1 for the lookup, one for the rebind since the server isn't created yet assertEquals( "error tally", 2, cacheEventLogger.errorEventCalls ); //System.out.println( cacheEventLogger.errorMessages ); } }
new DaemonThreadFactory("JCS-RemoteCacheServerFactory-")); RegistryKeepAliveRunner runner = new RegistryKeepAliveRunner( host, port, serviceName ); runner.setCacheEventLogger( cacheEventLogger ); keepAliveDaemon.scheduleAtFixedRate(runner, 0, rcsa.getRegistryKeepAliveDelayMillis(), TimeUnit.MILLISECONDS);
/** * Tries to lookup the server. If unsuccessful it will rebind the server using the factory * rebind method. * <p> */ @Override public void run() { checkAndRestoreIfNeeded(); }
/** * Creates the registry and registers the server. * <p> * @param serviceName the service name */ protected void createAndRegister( String serviceName ) { createReqistry( serviceName ); registerServer( serviceName ); }