Search in sources :

Example 6 with RemoteTransportException

use of org.apache.flink.runtime.io.network.netty.exception.RemoteTransportException in project flink by apache.

the class ClientTransportErrorHandlingTest method testConnectionResetByPeer.

/**
	 * Verifies that "Connection reset by peer" Exceptions are special-cased and are reported as
	 * an instance of {@link RemoteTransportException}.
	 */
@Test
public void testConnectionResetByPeer() throws Throwable {
    EmbeddedChannel ch = createEmbeddedChannel();
    PartitionRequestClientHandler handler = getClientHandler(ch);
    RemoteInputChannel rich = addInputChannel(handler);
    final Throwable[] error = new Throwable[1];
    // Verify the Exception
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            Throwable cause = (Throwable) invocation.getArguments()[0];
            try {
                assertEquals(RemoteTransportException.class, cause.getClass());
                assertNotEquals("Connection reset by peer", cause.getMessage());
                assertEquals(IOException.class, cause.getCause().getClass());
                assertEquals("Connection reset by peer", cause.getCause().getMessage());
            } catch (Throwable t) {
                error[0] = t;
            }
            return null;
        }
    }).when(rich).onError(any(Throwable.class));
    ch.pipeline().fireExceptionCaught(new IOException("Connection reset by peer"));
    assertNull(error[0]);
}
Also used : RemoteTransportException(org.apache.flink.runtime.io.network.netty.exception.RemoteTransportException) InvocationOnMock(org.mockito.invocation.InvocationOnMock) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) IOException(java.io.IOException) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel) Test(org.junit.Test)

Aggregations

RemoteTransportException (org.apache.flink.runtime.io.network.netty.exception.RemoteTransportException)6 RemoteInputChannel (org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)4 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)3 IOException (java.io.IOException)3 SocketAddress (java.net.SocketAddress)3 Test (org.junit.Test)3 LocalTransportException (org.apache.flink.runtime.io.network.netty.exception.LocalTransportException)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Channel (io.netty.channel.Channel)1 ChannelHandler (io.netty.channel.ChannelHandler)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 NettyServerAndClient (org.apache.flink.runtime.io.network.netty.NettyTestUtil.NettyServerAndClient)1 TransportException (org.apache.flink.runtime.io.network.netty.exception.TransportException)1 PartitionNotFoundException (org.apache.flink.runtime.io.network.partition.PartitionNotFoundException)1 InputChannelID (org.apache.flink.runtime.io.network.partition.consumer.InputChannelID)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 Answer (org.mockito.stubbing.Answer)1