Search in sources :

Example 16 with SingleInputGateBuilder

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

the class UnalignedCheckpointsCancellationTest method test.

@Test
public void test() throws Exception {
    TestInvokable invokable = new TestInvokable();
    final SingleInputGate inputGate = new SingleInputGateBuilder().setNumberOfChannels(numChannels).setChannelFactory(InputChannelBuilder::buildLocalChannel).build();
    SingleCheckpointBarrierHandler unaligner = SingleCheckpointBarrierHandler.createUnalignedCheckpointBarrierHandler(TestSubtaskCheckpointCoordinator.INSTANCE, "test", invokable, SystemClock.getInstance(), true, inputGate);
    for (RuntimeEvent e : events) {
        if (e instanceof CancelCheckpointMarker) {
            unaligner.processCancellationBarrier((CancelCheckpointMarker) e, new InputChannelInfo(0, channel));
        } else if (e instanceof CheckpointBarrier) {
            unaligner.processBarrier((CheckpointBarrier) e, new InputChannelInfo(0, channel), false);
        } else {
            throw new IllegalArgumentException("unexpected event type: " + e);
        }
    }
    assertEquals("expectAbortCheckpoint", expectAbortCheckpoint, invokable.checkpointAborted);
    assertEquals("expectTriggerCheckpoint", expectTriggerCheckpoint, invokable.checkpointTriggered);
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) CancelCheckpointMarker(org.apache.flink.runtime.io.network.api.CancelCheckpointMarker) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) RuntimeEvent(org.apache.flink.runtime.event.RuntimeEvent) Test(org.junit.Test)

Example 17 with SingleInputGateBuilder

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

the class UnalignedCheckpointsTest method testProcessCancellationBarrierBeforeProcessAndReceiveBarrier.

@Test
public void testProcessCancellationBarrierBeforeProcessAndReceiveBarrier() throws Exception {
    final ValidatingCheckpointInvokable invokable = new ValidatingCheckpointInvokable();
    final SingleInputGate inputGate = new SingleInputGateBuilder().setChannelFactory(InputChannelBuilder::buildLocalChannel).build();
    final SingleCheckpointBarrierHandler handler = SingleCheckpointBarrierHandler.createUnalignedCheckpointBarrierHandler(TestSubtaskCheckpointCoordinator.INSTANCE, "test", invokable, SystemClock.getInstance(), true, inputGate);
    handler.processCancellationBarrier(new CancelCheckpointMarker(DEFAULT_CHECKPOINT_ID), new InputChannelInfo(0, 0));
    verifyTriggeredCheckpoint(handler, invokable, DEFAULT_CHECKPOINT_ID);
    // it would not trigger checkpoint since the respective cancellation barrier already
    // happened before
    handler.processBarrier(buildCheckpointBarrier(DEFAULT_CHECKPOINT_ID), new InputChannelInfo(0, 0), false);
    verifyTriggeredCheckpoint(handler, invokable, DEFAULT_CHECKPOINT_ID);
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) CancelCheckpointMarker(org.apache.flink.runtime.io.network.api.CancelCheckpointMarker) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) Test(org.junit.Test)

Example 18 with SingleInputGateBuilder

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

the class UnalignedCheckpointsTest method testProcessCancellationBarrierAfterProcessBarrier.

/**
 * Tests {@link
 * SingleCheckpointBarrierHandler#processCancellationBarrier(CancelCheckpointMarker,
 * InputChannelInfo)} abort the current pending checkpoint triggered by {@link
 * CheckpointBarrierHandler#processBarrier(CheckpointBarrier, InputChannelInfo)}.
 */
@Test
public void testProcessCancellationBarrierAfterProcessBarrier() throws Exception {
    final ValidatingCheckpointInvokable invokable = new ValidatingCheckpointInvokable();
    final SingleInputGate inputGate = new SingleInputGateBuilder().setNumberOfChannels(2).setChannelFactory(InputChannelBuilder::buildLocalChannel).build();
    final SingleCheckpointBarrierHandler handler = SingleCheckpointBarrierHandler.createUnalignedCheckpointBarrierHandler(TestSubtaskCheckpointCoordinator.INSTANCE, "test", invokable, SystemClock.getInstance(), true, 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());
    testProcessCancellationBarrier(handler, invokable);
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) Test(org.junit.Test)

Example 19 with SingleInputGateBuilder

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

the class CheckpointBarrierTrackerTest method createCheckpointedInputGate.

// ------------------------------------------------------------------------
// Utils
// ------------------------------------------------------------------------
private CheckpointedInputGate createCheckpointedInputGate(int numberOfChannels, AbstractInvokable toNotify) throws IOException {
    final NettyShuffleEnvironment environment = new NettyShuffleEnvironmentBuilder().build();
    SingleInputGate gate = new SingleInputGateBuilder().setNumberOfChannels(numberOfChannels).setupBufferPoolFactory(environment).build();
    gate.setInputChannels(IntStream.range(0, numberOfChannels).mapToObj(channelIndex -> InputChannelBuilder.newBuilder().setChannelIndex(channelIndex).setupFromNettyShuffleEnvironment(environment).setConnectionManager(new TestingConnectionManager()).buildRemoteChannel(gate)).toArray(RemoteInputChannel[]::new));
    gate.setup();
    gate.requestPartitions();
    return createCheckpointedInputGate(gate, toNotify);
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) TestingConnectionManager(org.apache.flink.runtime.io.network.TestingConnectionManager) NettyShuffleEnvironmentBuilder(org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder) NettyShuffleEnvironment(org.apache.flink.runtime.io.network.NettyShuffleEnvironment) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)

Example 20 with SingleInputGateBuilder

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

the class TestCheckpointedInputGateBuilder method buildTestGate.

private SingleInputGate buildTestGate() {
    SingleInputGate gate = new SingleInputGateBuilder().setNumberOfChannels(numChannels).build();
    TestInputChannel[] channels = new TestInputChannel[numChannels];
    for (int i = 0; i < numChannels; i++) {
        channels[i] = new TestInputChannel(gate, i, false, true);
    }
    gate.setInputChannels(channels);
    return gate;
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) TestInputChannel(org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)

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