Search in sources :

Example 21 with SingleInputGateBuilder

use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder in project flink by apache.

the class TestCheckpointedInputGateBuilder method buildRemoteGate.

private SingleInputGate buildRemoteGate() throws IOException {
    int maxUsedBuffers = 10;
    NetworkBufferPool networkBufferPool = new NetworkBufferPool(numChannels * maxUsedBuffers, 4096);
    SingleInputGate gate = new SingleInputGateBuilder().setChannelFactory(InputChannelBuilder::buildRemoteChannel).setNumberOfChannels(numChannels).setSegmentProvider(networkBufferPool).setBufferPoolFactory(networkBufferPool.createBufferPool(numChannels, maxUsedBuffers)).setChannelStateWriter(channelStateWriter).build();
    gate.setup();
    gate.requestPartitions();
    return gate;
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) NetworkBufferPool(org.apache.flink.runtime.io.network.buffer.NetworkBufferPool)

Example 22 with SingleInputGateBuilder

use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder in project flink by apache.

the class CreditBasedPartitionRequestClientHandlerTest method testReceiveCompressedBuffer.

/**
 * Verifies that {@link BufferResponse} of compressed {@link Buffer} can be handled correctly.
 */
@Test
public void testReceiveCompressedBuffer() throws Exception {
    int bufferSize = 1024;
    String compressionCodec = "LZ4";
    BufferCompressor compressor = new BufferCompressor(bufferSize, compressionCodec);
    BufferDecompressor decompressor = new BufferDecompressor(bufferSize, compressionCodec);
    NetworkBufferPool networkBufferPool = new NetworkBufferPool(10, bufferSize);
    SingleInputGate inputGate = new SingleInputGateBuilder().setBufferDecompressor(decompressor).setSegmentProvider(networkBufferPool).build();
    RemoteInputChannel inputChannel = createRemoteInputChannel(inputGate, null);
    inputGate.setInputChannels(inputChannel);
    try {
        BufferPool bufferPool = networkBufferPool.createBufferPool(8, 8);
        inputGate.setBufferPool(bufferPool);
        inputGate.setupChannels();
        CreditBasedPartitionRequestClientHandler handler = new CreditBasedPartitionRequestClientHandler();
        handler.addInputChannel(inputChannel);
        Buffer buffer = compressor.compressToOriginalBuffer(TestBufferFactory.createBuffer(bufferSize));
        BufferResponse bufferResponse = createBufferResponse(buffer, 0, inputChannel.getInputChannelId(), 2, new NetworkBufferAllocator(handler));
        assertTrue(bufferResponse.isCompressed);
        handler.channelRead(null, bufferResponse);
        Buffer receivedBuffer = inputChannel.getNextReceivedBuffer();
        assertNotNull(receivedBuffer);
        assertTrue(receivedBuffer.isCompressed());
        receivedBuffer.recycleBuffer();
    } finally {
        releaseResource(inputGate, networkBufferPool);
    }
}
Also used : Buffer(org.apache.flink.runtime.io.network.buffer.Buffer) InputChannelTestUtils.createSingleInputGate(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createSingleInputGate) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) BufferDecompressor(org.apache.flink.runtime.io.network.buffer.BufferDecompressor) NetworkBufferPool(org.apache.flink.runtime.io.network.buffer.NetworkBufferPool) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel) InputChannelTestUtils.createRemoteInputChannel(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createRemoteInputChannel) SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) NetworkBufferPool(org.apache.flink.runtime.io.network.buffer.NetworkBufferPool) BufferPool(org.apache.flink.runtime.io.network.buffer.BufferPool) BufferCompressor(org.apache.flink.runtime.io.network.buffer.BufferCompressor) BufferResponse(org.apache.flink.runtime.io.network.netty.NettyMessage.BufferResponse) Test(org.junit.Test)

Aggregations

SingleInputGateBuilder (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder)22 SingleInputGate (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)20 Test (org.junit.Test)11 RemoteInputChannel (org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)9 InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)8 NetworkBufferPool (org.apache.flink.runtime.io.network.buffer.NetworkBufferPool)7 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)5 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)5 TestInputChannel (org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel)5 TestingConnectionManager (org.apache.flink.runtime.io.network.TestingConnectionManager)4 NettyShuffleEnvironment (org.apache.flink.runtime.io.network.NettyShuffleEnvironment)3 NettyShuffleEnvironmentBuilder (org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder)3 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)3 InputChannelBuilder (org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder)3 Closer (org.apache.flink.shaded.guava30.com.google.common.io.Closer)3 MailboxExecutorImpl (org.apache.flink.streaming.runtime.tasks.mailbox.MailboxExecutorImpl)3 TaskMailboxImpl (org.apache.flink.streaming.runtime.tasks.mailbox.TaskMailboxImpl)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 Deadline (org.apache.flink.api.common.time.Deadline)2 CheckedThread (org.apache.flink.core.testutils.CheckedThread)2