org.apache.flink.runtime.io.network.netty.NettyMessage.CloseRequest Java Examples
The following examples show how to use
org.apache.flink.runtime.io.network.netty.NettyMessage.CloseRequest.
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: CreditBasedPartitionRequestClientHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Verifies that {@link RemoteInputChannel} is enqueued in the pipeline, but {@link AddCredit} * message is not sent actually when this input channel is released. */ @Test public void testNotifyCreditAvailableAfterReleased() throws Exception { final CreditBasedPartitionRequestClientHandler handler = new CreditBasedPartitionRequestClientHandler(); final EmbeddedChannel channel = new EmbeddedChannel(handler); final PartitionRequestClient client = new PartitionRequestClient( channel, handler, mock(ConnectionID.class), mock(PartitionRequestClientFactory.class)); final NetworkBufferPool networkBufferPool = new NetworkBufferPool(10, 32); final SingleInputGate inputGate = createSingleInputGate(); final RemoteInputChannel inputChannel = createRemoteInputChannel(inputGate, client); try { final BufferPool bufferPool = networkBufferPool.createBufferPool(6, 6); inputGate.setBufferPool(bufferPool); final int numExclusiveBuffers = 2; inputGate.assignExclusiveSegments(networkBufferPool, numExclusiveBuffers); inputChannel.requestSubpartition(0); // This should send the partition request Object readFromOutbound = channel.readOutbound(); assertThat(readFromOutbound, instanceOf(PartitionRequest.class)); assertEquals(2, ((PartitionRequest) readFromOutbound).credit); // Trigger request floating buffers via buffer response to notify credits available final BufferResponse bufferResponse = createBufferResponse( TestBufferFactory.createBuffer(32), 0, inputChannel.getInputChannelId(), 1); handler.channelRead(mock(ChannelHandlerContext.class), bufferResponse); assertEquals(2, inputChannel.getUnannouncedCredit()); // Release the input channel inputGate.releaseAllResources(); // it should send a close request after releasing the input channel, // but will not notify credits for a released input channel. readFromOutbound = channel.readOutbound(); assertThat(readFromOutbound, instanceOf(CloseRequest.class)); channel.runPendingTasks(); assertNull(channel.readOutbound()); } finally { // Release all the buffer resources inputGate.releaseAllResources(); networkBufferPool.destroyAllBufferPools(); networkBufferPool.destroy(); } }
Example #2
Source File: CreditBasedPartitionRequestClientHandlerTest.java From flink with Apache License 2.0 | 4 votes |
/** * Verifies that {@link RemoteInputChannel} is enqueued in the pipeline, but {@link AddCredit} * message is not sent actually when this input channel is released. */ @Test public void testNotifyCreditAvailableAfterReleased() throws Exception { final CreditBasedPartitionRequestClientHandler handler = new CreditBasedPartitionRequestClientHandler(); final EmbeddedChannel channel = new EmbeddedChannel(handler); final PartitionRequestClient client = new NettyPartitionRequestClient( channel, handler, mock(ConnectionID.class), mock(PartitionRequestClientFactory.class)); final NetworkBufferPool networkBufferPool = new NetworkBufferPool(10, 32, 2); final SingleInputGate inputGate = createSingleInputGate(1); final RemoteInputChannel inputChannel = createRemoteInputChannel(inputGate, client, networkBufferPool); try { final BufferPool bufferPool = networkBufferPool.createBufferPool(6, 6); inputGate.setBufferPool(bufferPool); inputGate.assignExclusiveSegments(); inputChannel.requestSubpartition(0); // This should send the partition request Object readFromOutbound = channel.readOutbound(); assertThat(readFromOutbound, instanceOf(PartitionRequest.class)); assertEquals(2, ((PartitionRequest) readFromOutbound).credit); // Trigger request floating buffers via buffer response to notify credits available final BufferResponse bufferResponse = createBufferResponse( TestBufferFactory.createBuffer(32), 0, inputChannel.getInputChannelId(), 1); handler.channelRead(mock(ChannelHandlerContext.class), bufferResponse); assertEquals(2, inputChannel.getUnannouncedCredit()); // Release the input channel inputGate.close(); // it should send a close request after releasing the input channel, // but will not notify credits for a released input channel. readFromOutbound = channel.readOutbound(); assertThat(readFromOutbound, instanceOf(CloseRequest.class)); channel.runPendingTasks(); assertNull(channel.readOutbound()); } finally { // Release all the buffer resources inputGate.close(); networkBufferPool.destroyAllBufferPools(); networkBufferPool.destroy(); } }
Example #3
Source File: CreditBasedPartitionRequestClientHandlerTest.java From flink with Apache License 2.0 | 4 votes |
/** * Verifies that {@link RemoteInputChannel} is enqueued in the pipeline, but {@link AddCredit} * message is not sent actually when this input channel is released. */ @Test public void testNotifyCreditAvailableAfterReleased() throws Exception { final CreditBasedPartitionRequestClientHandler handler = new CreditBasedPartitionRequestClientHandler(); final EmbeddedChannel channel = new EmbeddedChannel(handler); final PartitionRequestClient client = new NettyPartitionRequestClient( channel, handler, mock(ConnectionID.class), mock(PartitionRequestClientFactory.class)); final NetworkBufferPool networkBufferPool = new NetworkBufferPool(10, 32, 2); final SingleInputGate inputGate = createSingleInputGate(1, networkBufferPool); final RemoteInputChannel inputChannel = createRemoteInputChannel(inputGate, client); try { inputGate.setInputChannels(inputChannel); final BufferPool bufferPool = networkBufferPool.createBufferPool(6, 6); inputGate.setBufferPool(bufferPool); inputGate.assignExclusiveSegments(); inputChannel.requestSubpartition(0); // This should send the partition request Object readFromOutbound = channel.readOutbound(); assertThat(readFromOutbound, instanceOf(PartitionRequest.class)); assertEquals(2, ((PartitionRequest) readFromOutbound).credit); // Trigger request floating buffers via buffer response to notify credits available final BufferResponse bufferResponse = createBufferResponse( TestBufferFactory.createBuffer(32), 0, inputChannel.getInputChannelId(), 1, new NetworkBufferAllocator(handler)); handler.channelRead(mock(ChannelHandlerContext.class), bufferResponse); assertEquals(2, inputChannel.getUnannouncedCredit()); // Release the input channel inputGate.close(); // it should send a close request after releasing the input channel, // but will not notify credits for a released input channel. readFromOutbound = channel.readOutbound(); assertThat(readFromOutbound, instanceOf(CloseRequest.class)); channel.runPendingTasks(); assertNull(channel.readOutbound()); } finally { releaseResource(inputGate, networkBufferPool); channel.close(); } }