view2.expectOpen(IdFilters.ALL_IDS, createKnownVersions(WAVELET_ID_1, 1, SIG1, WAVELET_ID_2, 20, SIG2)); viewListener.onException(new ChannelException("failed for testing", Recoverable.RECOVERABLE));
public void testMuxReconnectsAfterSubmitFailure() throws ChannelException { final ConnectionInfo chInfo1 = new ConnectionInfo(WAVELET_ID_1, 1, SIG1); MockViewChannel view = openMux(); muxListener.verifyNoMoreInteractions(); ViewChannel.Listener viewListener = view.takeListener(); viewListener.onConnected(); // Receive initial snapshots. ConnectedChannel ch = connectChannelSnapshot(viewListener, chInfo1); triggerAndCheckOpenFinished(viewListener); // Send but don't ack delta. WaveletDelta delta = checkSendDelta(view, ch.channel, chInfo1.initialHashedVersion, WAVELET_ID_1); // Fail the submission, expecting reconnection. MockViewChannel view2 = failViewAndExpectReconnection(viewListener, view, "View failed with outstanding submit", createKnownVersions(WAVELET_ID_1, 1, SIG1)); // Expect retransmit of the sent delta after reconnect. view2.expectSubmitDelta(WAVELET_ID_1, delta); ViewChannel.Listener viewListener2 = reconnectView(view2, chInfo1); muxListener.verifyNoMoreInteractions(); // No callback on reconnection. checkAckDelta(view2, ch.channel, ch.listener, 1, chInfo1.initialVersion + 1, SIG2); // If the first view later disconnects, it should be ignored viewListener.onException(new ChannelException("failed for testing", Recoverable.RECOVERABLE)); checkReceiveAndSend(viewListener2, view2, ch, WAVELET_ID_1, chInfo1.initialVersion + 1); view.checkExpectationsSatisified(); view2.checkExpectationsSatisified(); ch.listener.checkOpsReceived(0); muxListener.verifyNoMoreInteractions(); }
view2.expectOpen(IdFilters.ALL_IDS, createKnownVersions(WAVELET_ID_1, 1, SIG1, WAVELET_ID_2, 20, SIG2)); viewListener.onException(new ChannelException("failed for testing", Recoverable.RECOVERABLE));
public void testMuxReconnectsAfterSubmitFailure() throws ChannelException { final ConnectionInfo chInfo1 = new ConnectionInfo(WAVELET_ID_1, 1, SIG1); MockViewChannel view = openMux(); muxListener.verifyNoMoreInteractions(); ViewChannel.Listener viewListener = view.takeListener(); viewListener.onConnected(); // Receive initial snapshots. ConnectedChannel ch = connectChannelSnapshot(viewListener, chInfo1); triggerAndCheckOpenFinished(viewListener); // Send but don't ack delta. WaveletDelta delta = checkSendDelta(view, ch.channel, chInfo1.initialHashedVersion, WAVELET_ID_1); // Fail the submission, expecting reconnection. MockViewChannel view2 = failViewAndExpectReconnection(viewListener, view, "View failed with outstanding submit", createKnownVersions(WAVELET_ID_1, 1, SIG1)); // Expect retransmit of the sent delta after reconnect. view2.expectSubmitDelta(WAVELET_ID_1, delta); ViewChannel.Listener viewListener2 = reconnectView(view2, chInfo1); muxListener.verifyNoMoreInteractions(); // No callback on reconnection. checkAckDelta(view2, ch.channel, ch.listener, 1, chInfo1.initialVersion + 1, SIG2); // If the first view later disconnects, it should be ignored viewListener.onException(new ChannelException("failed for testing", Recoverable.RECOVERABLE)); checkReceiveAndSend(viewListener2, view2, ch, WAVELET_ID_1, chInfo1.initialVersion + 1); view.checkExpectationsSatisified(); view2.checkExpectationsSatisified(); ch.listener.checkOpsReceived(0); muxListener.verifyNoMoreInteractions(); }
/** * Sends a ChannelException to a view listener and expects a new view to be opened * to reconnect it. * * @return the new mock view */ private MockViewChannel failViewAndExpectReconnection(ViewChannel.Listener viewListenerToFail, MockViewChannel failingView, String failureReason, Map<WaveletId, List<HashedVersion>> expectedReconnectionSigs) { failingView.expectClose(); MockViewChannel newView = viewFactory.expectCreate(); newView.expectOpen(IdFilters.ALL_IDS, expectedReconnectionSigs); viewListenerToFail.onException(new ChannelException(failureReason, Recoverable.RECOVERABLE)); viewListenerToFail.onClosed(); failingView.checkExpectationsSatisified(); return newView; }
/** * Sends a ChannelException to a view listener and expects a new view to be opened * to reconnect it. * * @return the new mock view */ private MockViewChannel failViewAndExpectReconnection(ViewChannel.Listener viewListenerToFail, MockViewChannel failingView, String failureReason, Map<WaveletId, List<HashedVersion>> expectedReconnectionSigs) { failingView.expectClose(); MockViewChannel newView = viewFactory.expectCreate(); newView.expectOpen(IdFilters.ALL_IDS, expectedReconnectionSigs); viewListenerToFail.onException(new ChannelException(failureReason, Recoverable.RECOVERABLE)); viewListenerToFail.onClosed(); failingView.checkExpectationsSatisified(); return newView; }
/** * Tells the listener of an exception on handling server messages. Wave and * wavelet id context is attached to the exception. * * @param e exception causing failure * @param waveletId associated wavelet id (may be null) */ private void triggerOnException(ChannelException e, WaveletId waveletId) { if (openListener != null) { openListener.onException( new ChannelException(e.getResponseCode(), "Exception in view channel, state " + this, e, e.getRecoverable(), waveId, waveletId)); } }