Search in sources :

Example 1 with InputChannelBuilder

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

the class InputChannelTestUtils method createLocalInputChannel.

public static LocalInputChannel createLocalInputChannel(SingleInputGate inputGate, ResultPartitionManager partitionManager, int initialBackoff, int maxBackoff, Consumer<InputChannelBuilder> setter) {
    InputChannelBuilder inputChannelBuilder = InputChannelBuilder.newBuilder().setPartitionManager(partitionManager).setInitialBackoff(initialBackoff).setMaxBackoff(maxBackoff);
    setter.accept(inputChannelBuilder);
    return inputChannelBuilder.buildLocalChannel(inputGate);
}
Also used : InputChannelBuilder(org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder)

Example 2 with InputChannelBuilder

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

the class CreditBasedPartitionRequestClientHandlerTest method testReadBufferResponseWithReleasingOrRemovingChannel.

private void testReadBufferResponseWithReleasingOrRemovingChannel(boolean isRemoved, boolean readBeforeReleasingOrRemoving) throws Exception {
    int bufferSize = 1024;
    NetworkBufferPool networkBufferPool = new NetworkBufferPool(10, bufferSize);
    SingleInputGate inputGate = createSingleInputGate(1, networkBufferPool);
    RemoteInputChannel inputChannel = new InputChannelBuilder().buildRemoteChannel(inputGate);
    inputGate.setInputChannels(inputChannel);
    inputGate.setup();
    CreditBasedPartitionRequestClientHandler handler = new CreditBasedPartitionRequestClientHandler();
    EmbeddedChannel embeddedChannel = new EmbeddedChannel(handler);
    handler.addInputChannel(inputChannel);
    try {
        if (!readBeforeReleasingOrRemoving) {
            // Release the channel.
            inputGate.close();
            if (isRemoved) {
                handler.removeInputChannel(inputChannel);
            }
        }
        BufferResponse bufferResponse = createBufferResponse(TestBufferFactory.createBuffer(bufferSize), 0, inputChannel.getInputChannelId(), 1, new NetworkBufferAllocator(handler));
        if (readBeforeReleasingOrRemoving) {
            // Release the channel.
            inputGate.close();
            if (isRemoved) {
                handler.removeInputChannel(inputChannel);
            }
        }
        handler.channelRead(null, bufferResponse);
        assertEquals(0, inputChannel.getNumberOfQueuedBuffers());
        if (!readBeforeReleasingOrRemoving) {
            assertNull(bufferResponse.getBuffer());
        } else {
            assertNotNull(bufferResponse.getBuffer());
            assertTrue(bufferResponse.getBuffer().isRecycled());
        }
        embeddedChannel.runScheduledPendingTasks();
        NettyMessage.CancelPartitionRequest cancelPartitionRequest = embeddedChannel.readOutbound();
        assertNotNull(cancelPartitionRequest);
        assertEquals(inputChannel.getInputChannelId(), cancelPartitionRequest.receiverId);
    } finally {
        releaseResource(inputGate, networkBufferPool);
        embeddedChannel.close();
    }
}
Also used : InputChannelBuilder(org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder) EmbeddedChannel(org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel) BufferResponse(org.apache.flink.runtime.io.network.netty.NettyMessage.BufferResponse) InputChannelTestUtils.createSingleInputGate(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createSingleInputGate) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) 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)

Example 3 with InputChannelBuilder

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

the class UnalignedCheckpointsTest method testEndOfStreamWithPendingCheckpoint.

@Test
public void testEndOfStreamWithPendingCheckpoint() throws Exception {
    final int numberOfChannels = 2;
    final ValidatingCheckpointInvokable invokable = new ValidatingCheckpointInvokable();
    final SingleInputGate inputGate = new SingleInputGateBuilder().setChannelFactory(InputChannelBuilder::buildLocalChannel).setNumberOfChannels(numberOfChannels).build();
    final SingleCheckpointBarrierHandler handler = SingleCheckpointBarrierHandler.createUnalignedCheckpointBarrierHandler(TestSubtaskCheckpointCoordinator.INSTANCE, "test", invokable, SystemClock.getInstance(), false, inputGate);
    // should trigger respective checkpoint
    handler.processBarrier(buildCheckpointBarrier(DEFAULT_CHECKPOINT_ID), new InputChannelInfo(0, 0), false);
    assertTrue(handler.isCheckpointPending());
    assertEquals(DEFAULT_CHECKPOINT_ID, handler.getLatestCheckpointId());
    assertEquals(numberOfChannels, handler.getNumOpenChannels());
    // should abort current checkpoint while processing eof
    handler.processEndOfPartition(new InputChannelInfo(0, 0));
    assertFalse(handler.isCheckpointPending());
    assertEquals(DEFAULT_CHECKPOINT_ID, handler.getLatestCheckpointId());
    assertEquals(numberOfChannels - 1, handler.getNumOpenChannels());
    assertEquals(DEFAULT_CHECKPOINT_ID, invokable.getAbortedCheckpointId());
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) InputChannelBuilder(org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) Test(org.junit.Test)

Example 4 with InputChannelBuilder

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

the class ChannelPersistenceITCase method buildGate.

private SingleInputGate buildGate(NetworkBufferPool networkBufferPool, int numberOfChannels) throws IOException {
    SingleInputGate gate = new SingleInputGateBuilder().setChannelFactory(InputChannelBuilder::buildRemoteRecoveredChannel).setBufferPoolFactory(networkBufferPool.createBufferPool(numberOfChannels, Integer.MAX_VALUE)).setSegmentProvider(networkBufferPool).setNumberOfChannels(numberOfChannels).build();
    gate.setup();
    return gate;
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) InputChannelBuilder(org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)

Example 5 with InputChannelBuilder

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

the class NettyMessageClientDecoderDelegateTest method setup.

@Before
public void setup() throws IOException, InterruptedException {
    CreditBasedPartitionRequestClientHandler handler = new CreditBasedPartitionRequestClientHandler();
    networkBufferPool = new NetworkBufferPool(NUMBER_OF_BUFFER_RESPONSES, BUFFER_SIZE);
    channel = new EmbeddedChannel(new NettyMessageClientDecoderDelegate(handler));
    inputGate = createSingleInputGate(1, networkBufferPool);
    RemoteInputChannel inputChannel = createRemoteInputChannel(inputGate, new TestingPartitionRequestClient(), NUMBER_OF_BUFFER_RESPONSES);
    inputGate.setInputChannels(inputChannel);
    inputGate.setup();
    inputChannel.requestSubpartition();
    handler.addInputChannel(inputChannel);
    inputChannelId = inputChannel.getInputChannelId();
    SingleInputGate releasedInputGate = createSingleInputGate(1, networkBufferPool);
    RemoteInputChannel releasedInputChannel = new InputChannelBuilder().buildRemoteChannel(inputGate);
    releasedInputGate.close();
    handler.addInputChannel(releasedInputChannel);
    releasedInputChannelId = releasedInputChannel.getInputChannelId();
}
Also used : InputChannelBuilder(org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder) EmbeddedChannel(org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel) TestingPartitionRequestClient(org.apache.flink.runtime.io.network.TestingPartitionRequestClient) InputChannelTestUtils.createSingleInputGate(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createSingleInputGate) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) 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) Before(org.junit.Before)

Aggregations

InputChannelBuilder (org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder)5 SingleInputGate (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)4 NetworkBufferPool (org.apache.flink.runtime.io.network.buffer.NetworkBufferPool)2 InputChannelTestUtils.createRemoteInputChannel (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createRemoteInputChannel)2 InputChannelTestUtils.createSingleInputGate (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createSingleInputGate)2 RemoteInputChannel (org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)2 SingleInputGateBuilder (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder)2 EmbeddedChannel (org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel)2 InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)1 TestingPartitionRequestClient (org.apache.flink.runtime.io.network.TestingPartitionRequestClient)1 BufferResponse (org.apache.flink.runtime.io.network.netty.NettyMessage.BufferResponse)1 Before (org.junit.Before)1 Test (org.junit.Test)1