private void reconnectAfterTimeout() { receiveOneApplicationHeartbeat(); pollTwice(); assertTrue("Library still timed out", library.isConnected()); }
private void disconnectDueToTimeout() { advanceBeyondReplyTimeout(); pollTwice(); assertFalse("Library failed to timeout", library.isConnected()); }
@Test public void shouldStopResendingConnectToSameEngineAfterHeartbeat() { shouldResendConnectToSameEngineWhenConnectionTimesOut(); reset(outboundPublication); reconnectAfterTimeout(); clock.advanceMilliSeconds(CONNECT_ATTEMPT_TIMEOUT + 1); pollTwice(); sendsLibraryConnect(never()); }
private void connectToSingleEngine() { receiveOneApplicationHeartbeat(); newLibraryPoller(singletonList(IPC_CHANNEL)); library.startConnecting(); pollTwice(); assertTrue("Failed to connect", library.isConnected()); }
@Test public void shouldResendConnectToSameEngineWhenConnectionTimesOut() { setupAndConnectToFirstChannel(); pollTwice(); clock.advanceMilliSeconds(CONNECT_ATTEMPT_TIMEOUT + 1); poll(); sendsLibraryConnect(times(1)); doesNotAttemptConnectTo(LEADER_CHANNEL); }
@Test public void shouldAttemptNextEngineWhenEngineTimesOut() { setupAndConnectToFirstChannel(); pollTwice(); clock.advanceMilliSeconds(DEFAULT_REPLY_TIMEOUT_IN_MS + 1); poll(); attemptToConnectTo(LEADER_CHANNEL); }
private void shouldReplyToOnNotLeaderWith( final IntSupplier libraryId, final LongSupplier connectCorrelationId, final String... channels) { whenPolled() .then( (inv) -> { library.onNotLeader(libraryId.getAsInt(), connectCorrelationId.getAsLong(), LEADER_CHANNEL); return 1; }) .then(replyWithApplicationHeartbeat()) .then(noReply()); newLibraryPoller(CLUSTER_CHANNELS); library.startConnecting(); pollTwice(); poll(); attemptToConnectTo(channels); verify(connectHandler).onConnect(fixLibrary); }