public void testL1ProbingL2() throws Exception { HealthCheckerConfig hcConfig = new HealthCheckerConfigImpl(4000, 2000, 1, "ClientCommsHC-Test01", false); this.setUp(null, hcConfig); ClientMessageChannel clientMsgCh = createClientMsgCh(); clientMsgCh.open(); // Verifications ConnectionHealthCheckerImpl connHC = (ConnectionHealthCheckerImpl) ((CommunicationsManagerImpl) clientComms).getConnHealthChecker(); assertNotNull(connHC); while (!connHC.isRunning() || (connHC.getTotalConnsUnderMonitor() <= 0)) { System.out.println("Yet to start the connection health cheker thread..."); ThreadUtil.reallySleep(1000); } SequenceGenerator sq = new SequenceGenerator(); for (int i = 1; i <= 5; i++) { PingMessage ping = (PingMessage) clientMsgCh.createMessage(TCMessageType.PING_MESSAGE); ping.initialize(sq); ping.send(); } ThreadUtil.reallySleep(getMinSleepTimeToSendFirstProbe(hcConfig)); System.out.println("Successfully sent " + connHC.getTotalProbesSentOnAllConns() + " Probes"); assertTrue(connHC.getTotalProbesSentOnAllConns() > 0); clientMsgCh.close(); }
public void testL1L2ProbingBothsideAndClientClose() throws Exception { HealthCheckerConfig hcConfig = new HealthCheckerConfigImpl(4000, 2000, 5, "ServerCommsHC-Test03", false); HealthCheckerConfig hcConfig2 = new HealthCheckerConfigImpl(10000, 4000, 3, "ClientCommsHC-Test03", false); this.setUp(hcConfig, new DisabledHealthCheckerConfigImpl()); CommunicationsManager clientComms1 = new CommunicationsManagerImpl( "TestCommsMgr-Client1", new NullMessageMonitor(), new PlainNetworkStackHarnessFactory(true), new NullConnectionPolicy(), hcConfig2); CommunicationsManager clientComms2 = new CommunicationsManagerImpl( "TestCommsMgr-Client2", new NullMessageMonitor(), new PlainNetworkStackHarnessFactory(true), new NullConnectionPolicy(), hcConfig2); ClientMessageChannel clientMsgCh1 = createClientMsgCh(clientComms1); clientMsgCh1.open(); ClientMessageChannel clientMsgCh2 = createClientMsgCh(clientComms2); clientMsgCh2.open(); // Verifications ConnectionHealthCheckerImpl connHC = (ConnectionHealthCheckerImpl) ((CommunicationsManagerImpl) serverComms).getConnHealthChecker(); assertNotNull(connHC); while (!connHC.isRunning() && (connHC.getTotalConnsUnderMonitor() != 2)) { System.out.println("Yet to start the connection health cheker thread..."); ThreadUtil.reallySleep(1000); } SequenceGenerator sq = new SequenceGenerator(); for (int i = 1; i <= 5; i++) { PingMessage ping = (PingMessage) clientMsgCh1.createMessage(TCMessageType.PING_MESSAGE); ping.initialize(sq); ping.send(); ping = (PingMessage) clientMsgCh2.createMessage(TCMessageType.PING_MESSAGE); ping.initialize(sq); ping.send(); } ThreadUtil.reallySleep(getMinSleepTimeToSendFirstProbe(hcConfig)); System.out.println("Successfully sent " + connHC.getTotalProbesSentOnAllConns() + " Probes"); assertTrue(connHC.getTotalProbesSentOnAllConns() > 0); clientMsgCh1.close(); System.out.println("ClientMessasgeChannel 1 Closed"); ThreadUtil.reallySleep(getMinSleepTimeToSendFirstProbe(hcConfig)); assertEquals(1, connHC.getTotalConnsUnderMonitor()); }
public void testL2ProbingL1AndClientClose() throws Exception { HealthCheckerConfig hcConfig = new HealthCheckerConfigImpl("ServerCommsHC-Test02"); this.setUp(hcConfig, new DisabledHealthCheckerConfigImpl()); ClientMessageChannel clientMsgCh = createClientMsgCh(); clientMsgCh.open(); // Verifications ConnectionHealthCheckerImpl connHC = (ConnectionHealthCheckerImpl) ((CommunicationsManagerImpl) serverComms).getConnHealthChecker(); assertNotNull(connHC); while (!connHC.isRunning() && (connHC.getTotalConnsUnderMonitor() != 1)) { System.out.println("Yet to start the connection health cheker thread..."); ThreadUtil.reallySleep(1000); } SequenceGenerator sq = new SequenceGenerator(); for (int i = 1; i <= 5; i++) { PingMessage ping = (PingMessage) clientMsgCh.createMessage(TCMessageType.PING_MESSAGE); ping.initialize(sq); ping.send(); } ThreadUtil.reallySleep(getMinSleepTimeToSendFirstProbe(hcConfig)); System.out.println("Successfully sent " + connHC.getTotalProbesSentOnAllConns() + " Probes"); assertTrue(connHC.getTotalProbesSentOnAllConns() > 0); clientMsgCh.close(); System.out.println("ClientMessasgeChannel Closed"); System.out.println("Sleeping for " + getMinSleepTimeToConirmDeath(hcConfig)); ThreadUtil.reallySleep(getMinSleepTimeToConirmDeath(hcConfig)); while (connHC.getTotalConnsUnderMonitor() != 0) { ThreadUtil.reallySleep(1000); System.out.println("Waiting for Client removal from Health Checker"); } System.out.println("Success"); }