Search in sources :

Example 6 with RecordingChannelStateWriter

use of org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter in project flink-mirror by flink-ci.

the class LocalInputChannelTest method testNoDataPersistedAfterReceivingAlignedBarrier.

@Test
public void testNoDataPersistedAfterReceivingAlignedBarrier() throws Exception {
    CheckpointBarrier barrier = new CheckpointBarrier(1L, 0L, CheckpointOptions.alignedWithTimeout(CheckpointType.CHECKPOINT, getDefault(), 123L));
    BufferConsumer barrierHolder = EventSerializer.toBufferConsumer(barrier, false);
    BufferConsumer data = createFilledFinishedBufferConsumer(1);
    RecordingChannelStateWriter stateWriter = new RecordingChannelStateWriter();
    LocalInputChannel channel = InputChannelBuilder.newBuilder().setPartitionManager(new TestingResultPartitionManager(InputChannelTestUtils.createResultSubpartitionView(barrierHolder, data))).setStateWriter(stateWriter).buildLocalChannel(new SingleInputGateBuilder().build());
    channel.requestSubpartition();
    // pull AC barrier
    channel.getNextBuffer();
    // pretend that alignment timed out
    stateWriter.start(barrier.getId(), barrier.getCheckpointOptions());
    channel.checkpointStarted(barrier);
    // pull data
    channel.getNextBuffer();
    assertTrue("no data should be persisted after receiving a barrier", stateWriter.getAddedInput().isEmpty());
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) RecordingChannelStateWriter(org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter) BufferConsumer(org.apache.flink.runtime.io.network.buffer.BufferConsumer) BufferBuilderTestUtils.createFilledFinishedBufferConsumer(org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledFinishedBufferConsumer) InputChannelTestUtils.createLocalInputChannel(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createLocalInputChannel) TestingResultPartitionManager(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateTest.TestingResultPartitionManager) Test(org.junit.Test)

Example 7 with RecordingChannelStateWriter

use of org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter in project flink-mirror by flink-ci.

the class ChannelStatePersisterTest method testNewBarrierNotOverwrittenByStopPersisting.

@Test
public void testNewBarrierNotOverwrittenByStopPersisting() throws Exception {
    RecordingChannelStateWriter channelStateWriter = new RecordingChannelStateWriter();
    InputChannelInfo channelInfo = new InputChannelInfo(0, 0);
    ChannelStatePersister persister = new ChannelStatePersister(channelStateWriter, channelInfo);
    long checkpointId = 1L;
    channelStateWriter.start(checkpointId, CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, getDefault()));
    persister.checkForBarrier(barrier(checkpointId));
    persister.startPersisting(checkpointId, Arrays.asList(buildSomeBuffer()));
    assertEquals(1, channelStateWriter.getAddedInput().get(channelInfo).size());
    persister.maybePersist(buildSomeBuffer());
    assertEquals(1, channelStateWriter.getAddedInput().get(channelInfo).size());
    // meanwhile, checkpoint coordinator timed out the 1st checkpoint and started the 2nd
    // now task thread is picking up the barrier and aborts the 1st:
    persister.checkForBarrier(barrier(checkpointId + 1));
    persister.maybePersist(buildSomeBuffer());
    persister.stopPersisting(checkpointId);
    persister.maybePersist(buildSomeBuffer());
    assertEquals(1, channelStateWriter.getAddedInput().get(channelInfo).size());
    assertTrue(persister.hasBarrierReceived());
}
Also used : InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) RecordingChannelStateWriter(org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter) Test(org.junit.Test)

Example 8 with RecordingChannelStateWriter

use of org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter in project flink-mirror by flink-ci.

the class ChannelStatePersisterTest method testLateBarrier.

private void testLateBarrier(boolean startCheckpointOnLateBarrier, boolean cancelCheckpointBeforeLateBarrier) throws Exception {
    RecordingChannelStateWriter channelStateWriter = new RecordingChannelStateWriter();
    InputChannelInfo channelInfo = new InputChannelInfo(0, 0);
    ChannelStatePersister persister = new ChannelStatePersister(channelStateWriter, channelInfo);
    long lateCheckpointId = 1L;
    long checkpointId = 2L;
    if (startCheckpointOnLateBarrier) {
        persister.startPersisting(lateCheckpointId, Collections.emptyList());
    }
    if (cancelCheckpointBeforeLateBarrier) {
        persister.stopPersisting(lateCheckpointId);
    }
    persister.checkForBarrier(barrier(lateCheckpointId));
    channelStateWriter.start(checkpointId, CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, getDefault()));
    persister.startPersisting(checkpointId, Arrays.asList(buildSomeBuffer()));
    persister.maybePersist(buildSomeBuffer());
    persister.checkForBarrier(barrier(checkpointId));
    persister.maybePersist(buildSomeBuffer());
    assertTrue(persister.hasBarrierReceived());
    assertEquals(2, channelStateWriter.getAddedInput().get(channelInfo).size());
}
Also used : InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) RecordingChannelStateWriter(org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter)

Example 9 with RecordingChannelStateWriter

use of org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter in project flink-mirror by flink-ci.

the class AlternatingCheckpointsTest method testTimeoutAlignmentOnUnalignedCheckpoint.

/**
 * First we process aligned {@link CheckpointBarrier} and after that we receive an already
 * unaligned {@link CheckpointBarrier}, that has timed out on an upstream task.
 */
@Test
public void testTimeoutAlignmentOnUnalignedCheckpoint() throws Exception {
    ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
    RecordingChannelStateWriter channelStateWriter = new RecordingChannelStateWriter();
    CheckpointedInputGate gate = new TestCheckpointedInputGateBuilder(3, getTestBarrierHandlerFactory(target)).withChannelStateWriter(channelStateWriter).withRemoteChannels().withMailboxExecutor().build();
    getChannel(gate, 0).onBuffer(withTimeout(Integer.MAX_VALUE).retainBuffer(), 0, 0);
    assertAnnouncement(gate);
    assertBarrier(gate);
    getChannel(gate, 1).onBuffer(dataBuffer(), 0, 0);
    getChannel(gate, 1).onBuffer(dataBuffer(), 1, 0);
    getChannel(gate, 1).onBuffer(toBuffer(new CheckpointBarrier(1, clock.relativeTimeMillis(), unaligned(CheckpointType.CHECKPOINT, getDefault())), true).retainBuffer(), 2, 0);
    assertBarrier(gate);
    assertEquals(2, channelStateWriter.getAddedInput().get(getChannel(gate, 1).getChannelInfo()).size());
    assertEquals(1, target.getTriggeredCheckpointCounter());
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) TestCheckpointedInputGateBuilder(org.apache.flink.streaming.util.TestCheckpointedInputGateBuilder) RecordingChannelStateWriter(org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter) Test(org.junit.Test)

Example 10 with RecordingChannelStateWriter

use of org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter in project flink-mirror by flink-ci.

the class AlternatingCheckpointsTest method testChannelResetOnNewBarrier.

/**
 * Upon subsuming (or canceling) a checkpoint, channels should be notified regardless of whether
 * UC controller is currently being used or not. Otherwise, channels may not capture in-flight
 * buffers.
 */
@Test
public void testChannelResetOnNewBarrier() throws Exception {
    RecordingChannelStateWriter stateWriter = new RecordingChannelStateWriter();
    try (CheckpointedInputGate gate = new TestCheckpointedInputGateBuilder(2, getTestBarrierHandlerFactory(new ValidatingCheckpointHandler())).withChannelStateWriter(stateWriter).withRemoteChannels().withMailboxExecutor().build()) {
        sendBarrier(0, clock.relativeTimeMillis(), SavepointType.savepoint(SavepointFormatType.CANONICAL), gate, // using AC because UC would require ordering in gate while polling
        0);
        ((RemoteInputChannel) gate.getChannel(0)).onBuffer(createBuffer(1024), 1, // to be captured
        0);
        send(toBuffer(new CheckpointBarrier(1, clock.relativeTimeMillis(), unaligned(CheckpointType.CHECKPOINT, getDefault())), true), 1, gate);
        assertFalse(stateWriter.getAddedInput().isEmpty());
    }
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) TestCheckpointedInputGateBuilder(org.apache.flink.streaming.util.TestCheckpointedInputGateBuilder) RecordingChannelStateWriter(org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel) Test(org.junit.Test)

Aggregations

RecordingChannelStateWriter (org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter)27 Test (org.junit.Test)21 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)18 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)9 InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)9 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)9 CheckpointStorageLocationReference (org.apache.flink.runtime.state.CheckpointStorageLocationReference)9 BufferBuilderTestUtils.createFilledFinishedBufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledFinishedBufferConsumer)6 BufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferConsumer)6 NetworkBufferPool (org.apache.flink.runtime.io.network.buffer.NetworkBufferPool)6 InputChannelTestUtils.createLocalInputChannel (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createLocalInputChannel)6 RemoteInputChannel (org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)6 TestingResultPartitionManager (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateTest.TestingResultPartitionManager)6 TestCheckpointedInputGateBuilder (org.apache.flink.streaming.util.TestCheckpointedInputGateBuilder)4 IOException (java.io.IOException)3 Duration (java.time.Duration)3 HashMap (java.util.HashMap)3 Optional (java.util.Optional)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 Deadline (org.apache.flink.api.common.time.Deadline)3