org.apache.flink.runtime.io.network.netty.NettyMessage.ErrorResponse Java Examples
The following examples show how to use
org.apache.flink.runtime.io.network.netty.NettyMessage.ErrorResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PartitionRequestServerHandlerTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that {@link PartitionRequestServerHandler} responds {@link ErrorResponse} with wrapped * {@link PartitionNotFoundException} after receiving invalid {@link PartitionRequest}. */ @Test public void testResponsePartitionNotFoundException() { final PartitionRequestServerHandler serverHandler = new PartitionRequestServerHandler( new ResultPartitionManager(), new TaskEventDispatcher(), new PartitionRequestQueue(), true); final EmbeddedChannel channel = new EmbeddedChannel(serverHandler); final ResultPartitionID partitionId = new ResultPartitionID(); // Write the message of partition request to server channel.writeInbound(new PartitionRequest(partitionId, 0, new InputChannelID(), 2)); channel.runPendingTasks(); // Read the response message after handling partition request final Object msg = channel.readOutbound(); assertThat(msg, instanceOf(ErrorResponse.class)); final ErrorResponse err = (ErrorResponse) msg; assertThat(err.cause, instanceOf(PartitionNotFoundException.class)); final ResultPartitionID actualPartitionId = ((PartitionNotFoundException) err.cause).getPartitionId(); assertThat(partitionId, is(actualPartitionId)); }
Example #2
Source File: PartitionRequestServerHandlerTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that {@link PartitionRequestServerHandler} responds {@link ErrorResponse} with wrapped * {@link PartitionNotFoundException} after receiving invalid {@link PartitionRequest}. */ @Test public void testResponsePartitionNotFoundException() { final PartitionRequestServerHandler serverHandler = new PartitionRequestServerHandler( new ResultPartitionManager(), new TaskEventDispatcher(), new PartitionRequestQueue()); final EmbeddedChannel channel = new EmbeddedChannel(serverHandler); final ResultPartitionID partitionId = new ResultPartitionID(); // Write the message of partition request to server channel.writeInbound(new PartitionRequest(partitionId, 0, new InputChannelID(), 2)); channel.runPendingTasks(); // Read the response message after handling partition request final Object msg = channel.readOutbound(); assertThat(msg, instanceOf(ErrorResponse.class)); final ErrorResponse err = (ErrorResponse) msg; assertThat(err.cause, instanceOf(PartitionNotFoundException.class)); final ResultPartitionID actualPartitionId = ((PartitionNotFoundException) err.cause).getPartitionId(); assertThat(partitionId, is(actualPartitionId)); }
Example #3
Source File: PartitionRequestQueue.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private void handleException(Channel channel, Throwable cause) throws IOException { LOG.error("Encountered error while consuming partitions", cause); fatalError = true; releaseAllResources(); if (channel.isActive()) { channel.writeAndFlush(new ErrorResponse(cause)).addListener(ChannelFutureListener.CLOSE); } }
Example #4
Source File: PartitionRequestClientHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Verifies that {@link RemoteInputChannel#onFailedPartitionRequest()} is called when a * {@link PartitionNotFoundException} is received. */ @Test public void testReceivePartitionNotFoundException() throws Exception { // Minimal mock of a remote input channel final BufferProvider bufferProvider = mock(BufferProvider.class); when(bufferProvider.requestBuffer()).thenReturn(TestBufferFactory.createBuffer(0)); final RemoteInputChannel inputChannel = mock(RemoteInputChannel.class); when(inputChannel.getInputChannelId()).thenReturn(new InputChannelID()); when(inputChannel.getBufferProvider()).thenReturn(bufferProvider); final ErrorResponse partitionNotFound = new ErrorResponse( new PartitionNotFoundException(new ResultPartitionID()), inputChannel.getInputChannelId()); final PartitionRequestClientHandler client = new PartitionRequestClientHandler(); client.addInputChannel(inputChannel); // Mock channel context ChannelHandlerContext ctx = mock(ChannelHandlerContext.class); when(ctx.channel()).thenReturn(mock(Channel.class)); client.channelActive(ctx); client.channelRead(ctx, partitionNotFound); verify(inputChannel, times(1)).onFailedPartitionRequest(); }
Example #5
Source File: CreditBasedPartitionRequestClientHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Verifies that {@link RemoteInputChannel#onFailedPartitionRequest()} is called when a * {@link PartitionNotFoundException} is received. */ @Test public void testReceivePartitionNotFoundException() throws Exception { // Minimal mock of a remote input channel final BufferProvider bufferProvider = mock(BufferProvider.class); when(bufferProvider.requestBuffer()).thenReturn(TestBufferFactory.createBuffer(0)); final RemoteInputChannel inputChannel = mock(RemoteInputChannel.class); when(inputChannel.getInputChannelId()).thenReturn(new InputChannelID()); when(inputChannel.getBufferProvider()).thenReturn(bufferProvider); final ErrorResponse partitionNotFound = new ErrorResponse( new PartitionNotFoundException(new ResultPartitionID()), inputChannel.getInputChannelId()); final CreditBasedPartitionRequestClientHandler client = new CreditBasedPartitionRequestClientHandler(); client.addInputChannel(inputChannel); // Mock channel context ChannelHandlerContext ctx = mock(ChannelHandlerContext.class); when(ctx.channel()).thenReturn(mock(Channel.class)); client.channelActive(ctx); client.channelRead(ctx, partitionNotFound); verify(inputChannel, times(1)).onFailedPartitionRequest(); }
Example #6
Source File: PartitionRequestQueue.java From flink with Apache License 2.0 | 5 votes |
private void handleException(Channel channel, Throwable cause) throws IOException { LOG.error("Encountered error while consuming partitions", cause); fatalError = true; releaseAllResources(); if (channel.isActive()) { channel.writeAndFlush(new ErrorResponse(cause)).addListener(ChannelFutureListener.CLOSE); } }
Example #7
Source File: PartitionRequestClientHandlerTest.java From flink with Apache License 2.0 | 5 votes |
/** * Verifies that {@link RemoteInputChannel#onFailedPartitionRequest()} is called when a * {@link PartitionNotFoundException} is received. */ @Test public void testReceivePartitionNotFoundException() throws Exception { // Minimal mock of a remote input channel final BufferProvider bufferProvider = mock(BufferProvider.class); when(bufferProvider.requestBuffer()).thenReturn(TestBufferFactory.createBuffer(0)); final RemoteInputChannel inputChannel = mock(RemoteInputChannel.class); when(inputChannel.getInputChannelId()).thenReturn(new InputChannelID()); when(inputChannel.getBufferProvider()).thenReturn(bufferProvider); final ErrorResponse partitionNotFound = new ErrorResponse( new PartitionNotFoundException(new ResultPartitionID()), inputChannel.getInputChannelId()); final PartitionRequestClientHandler client = new PartitionRequestClientHandler(); client.addInputChannel(inputChannel); // Mock channel context ChannelHandlerContext ctx = mock(ChannelHandlerContext.class); when(ctx.channel()).thenReturn(mock(Channel.class)); client.channelActive(ctx); client.channelRead(ctx, partitionNotFound); verify(inputChannel, times(1)).onFailedPartitionRequest(); }
Example #8
Source File: CreditBasedPartitionRequestClientHandlerTest.java From flink with Apache License 2.0 | 5 votes |
/** * Verifies that {@link RemoteInputChannel#onFailedPartitionRequest()} is called when a * {@link PartitionNotFoundException} is received. */ @Test public void testReceivePartitionNotFoundException() throws Exception { // Minimal mock of a remote input channel final BufferProvider bufferProvider = mock(BufferProvider.class); when(bufferProvider.requestBuffer()).thenReturn(TestBufferFactory.createBuffer(0)); final RemoteInputChannel inputChannel = mock(RemoteInputChannel.class); when(inputChannel.getInputChannelId()).thenReturn(new InputChannelID()); when(inputChannel.getBufferProvider()).thenReturn(bufferProvider); final ErrorResponse partitionNotFound = new ErrorResponse( new PartitionNotFoundException(new ResultPartitionID()), inputChannel.getInputChannelId()); final CreditBasedPartitionRequestClientHandler client = new CreditBasedPartitionRequestClientHandler(); client.addInputChannel(inputChannel); // Mock channel context ChannelHandlerContext ctx = mock(ChannelHandlerContext.class); when(ctx.channel()).thenReturn(mock(Channel.class)); client.channelActive(ctx); client.channelRead(ctx, partitionNotFound); verify(inputChannel, times(1)).onFailedPartitionRequest(); }
Example #9
Source File: PartitionRequestQueue.java From flink with Apache License 2.0 | 5 votes |
private void handleException(Channel channel, Throwable cause) throws IOException { LOG.error("Encountered error while consuming partitions", cause); fatalError = true; releaseAllResources(); if (channel.isActive()) { channel.writeAndFlush(new ErrorResponse(cause)).addListener(ChannelFutureListener.CLOSE); } }
Example #10
Source File: CreditBasedPartitionRequestClientHandlerTest.java From flink with Apache License 2.0 | 5 votes |
/** * Verifies that {@link RemoteInputChannel#onFailedPartitionRequest()} is called when a * {@link PartitionNotFoundException} is received. */ @Test public void testReceivePartitionNotFoundException() throws Exception { // Minimal mock of a remote input channel final BufferProvider bufferProvider = mock(BufferProvider.class); when(bufferProvider.requestBuffer()).thenReturn(TestBufferFactory.createBuffer(0)); final RemoteInputChannel inputChannel = mock(RemoteInputChannel.class); when(inputChannel.getInputChannelId()).thenReturn(new InputChannelID()); when(inputChannel.getBufferProvider()).thenReturn(bufferProvider); final ErrorResponse partitionNotFound = new ErrorResponse( new PartitionNotFoundException(new ResultPartitionID()), inputChannel.getInputChannelId()); final CreditBasedPartitionRequestClientHandler client = new CreditBasedPartitionRequestClientHandler(); client.addInputChannel(inputChannel); // Mock channel context ChannelHandlerContext ctx = mock(ChannelHandlerContext.class); when(ctx.channel()).thenReturn(mock(Channel.class)); client.channelActive(ctx); client.channelRead(ctx, partitionNotFound); verify(inputChannel, times(1)).onFailedPartitionRequest(); }