@Test public void testLiveIsolated() throws Exception { backupServer.stop(); liveServer.stop(); liveServer.getServer().getConfiguration().setNetworkCheckList(badAddress). setNetworkCheckPeriod(100).setNetworkCheckTimeout(100); try { liveServer.start(); Assert.assertEquals(100L, liveServer.getServer().getNetworkHealthCheck().getPeriod()); liveServer.getServer().getNetworkHealthCheck().setTimeUnit(TimeUnit.MILLISECONDS); Assert.assertFalse(liveServer.getServer().getNetworkHealthCheck().check()); long timeout = System.currentTimeMillis() + 30000; while (liveServer.isStarted() && System.currentTimeMillis() < timeout) { Thread.sleep(100); } Assert.assertFalse(liveServer.isStarted()); liveServer.getServer().getNetworkHealthCheck().setIgnoreLoopback(true).addAddress(InetAddress.getByName("127.0.0.1")); timeout = System.currentTimeMillis() + 30000; while (!liveServer.isStarted() && System.currentTimeMillis() < timeout) { Thread.sleep(100); } Assert.assertTrue(liveServer.isStarted()); } catch (Throwable e) { logger.warn(e.getMessage(), e); throw e; } finally { liveServer.getServer().stop(); backupServer.getServer().stop(); } }
@Override public final synchronized void start() throws Exception { SERVER_STATE originalState = state; try { internalStart(); } catch (Throwable t) { ActiveMQServerLogger.LOGGER.failedToStartServer(t); } finally { if (originalState == SERVER_STATE.STOPPED) { networkHealthCheck.setTimeUnit(TimeUnit.MILLISECONDS).setPeriod(configuration.getNetworkCheckPeriod()). setNetworkTimeout(configuration.getNetworkCheckTimeout()). parseAddressList(configuration.getNetworkCheckList()). parseURIList(configuration.getNetworkCheckURLList()). setNICName(configuration.getNetworkCheckNIC()). setIpv4Command(configuration.getNetworkCheckPingCommand()). setIpv6Command(configuration.getNetworkCheckPing6Command()); networkHealthCheck.addComponent(networkCheckMonitor); } } }