Search in sources :

Example 6 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.

the class CheckpointSerializationTest method testCheckpointBarrierSerialization.

@Test
public void testCheckpointBarrierSerialization() throws Exception {
    CheckpointOptions checkpointToSerialize = new CheckpointOptions(CheckpointType.CHECKPOINT, new CheckpointStorageLocationReference(STORAGE_LOCATION_REF));
    testCheckpointBarrierSerialization(checkpointToSerialize);
}
Also used : CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) Test(org.junit.Test)

Example 7 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.

the class CheckpointSerializationTest method testFullCheckpointBarrierSerialization.

@Test
public void testFullCheckpointBarrierSerialization() throws Exception {
    CheckpointOptions checkpointToSerialize = new CheckpointOptions(CheckpointType.FULL_CHECKPOINT, new CheckpointStorageLocationReference(STORAGE_LOCATION_REF));
    testCheckpointBarrierSerialization(checkpointToSerialize);
}
Also used : CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) Test(org.junit.Test)

Example 8 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.

the class AbstractStreamOperatorTestHarness method snapshotWithLocalState.

/**
 * Calls {@link StreamOperator#snapshotState(long, long, CheckpointOptions,
 * org.apache.flink.runtime.state.CheckpointStreamFactory)}.
 */
public OperatorSnapshotFinalizer snapshotWithLocalState(long checkpointId, long timestamp, SnapshotType checkpointType) throws Exception {
    CheckpointStorageLocationReference locationReference = CheckpointStorageLocationReference.getDefault();
    OperatorSnapshotFutures operatorStateResult = operator.snapshotState(checkpointId, timestamp, new CheckpointOptions(checkpointType, locationReference), checkpointStorageAccess.resolveCheckpointStorageLocation(checkpointId, locationReference));
    return new OperatorSnapshotFinalizer(operatorStateResult);
}
Also used : OperatorSnapshotFutures(org.apache.flink.streaming.api.operators.OperatorSnapshotFutures) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) OperatorSnapshotFinalizer(org.apache.flink.streaming.api.operators.OperatorSnapshotFinalizer)

Example 9 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.

the class LocalInputChannelTest method testCheckpointingInflightData.

@Test
public void testCheckpointingInflightData() throws Exception {
    SingleInputGate inputGate = new SingleInputGateBuilder().build();
    PipelinedResultPartition parent = (PipelinedResultPartition) PartitionTestUtils.createPartition(ResultPartitionType.PIPELINED, NoOpFileChannelManager.INSTANCE);
    ResultSubpartition subpartition = parent.getAllPartitions()[0];
    ResultSubpartitionView subpartitionView = subpartition.createReadView(() -> {
    });
    TestingResultPartitionManager partitionManager = new TestingResultPartitionManager(subpartitionView);
    final RecordingChannelStateWriter stateWriter = new RecordingChannelStateWriter();
    LocalInputChannel channel = createLocalInputChannel(inputGate, partitionManager, 0, 0, b -> b.setStateWriter(stateWriter));
    inputGate.setInputChannels(channel);
    channel.requestSubpartition();
    final CheckpointStorageLocationReference location = getDefault();
    CheckpointOptions options = CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, location);
    stateWriter.start(0, options);
    final CheckpointBarrier barrier = new CheckpointBarrier(0, 123L, options);
    channel.checkpointStarted(barrier);
    // add 1 buffer before barrier and 1 buffer afterwards. Only the first buffer should be
    // written.
    subpartition.add(createFilledFinishedBufferConsumer(1));
    assertTrue(channel.getNextBuffer().isPresent());
    subpartition.add(EventSerializer.toBufferConsumer(barrier, true));
    assertTrue(channel.getNextBuffer().isPresent());
    subpartition.add(createFilledFinishedBufferConsumer(2));
    assertTrue(channel.getNextBuffer().isPresent());
    assertArrayEquals(stateWriter.getAddedInput().get(channel.getChannelInfo()).stream().mapToInt(Buffer::getSize).toArray(), new int[] { 1 });
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) Buffer(org.apache.flink.runtime.io.network.buffer.Buffer) PipelinedResultPartition(org.apache.flink.runtime.io.network.partition.PipelinedResultPartition) ResultSubpartitionView(org.apache.flink.runtime.io.network.partition.ResultSubpartitionView) ResultSubpartition(org.apache.flink.runtime.io.network.partition.ResultSubpartition) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) RecordingChannelStateWriter(org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter) InputChannelTestUtils.createLocalInputChannel(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createLocalInputChannel) InputChannelTestUtils.createSingleInputGate(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createSingleInputGate) TestingResultPartitionManager(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateTest.TestingResultPartitionManager) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) Test(org.junit.Test)

Example 10 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.

the class SubtaskCheckpointCoordinatorTest method initCheckpoint.

private boolean initCheckpoint(boolean unalignedCheckpointEnabled, SnapshotType checkpointType) throws IOException, CheckpointException {
    class MockWriter extends ChannelStateWriterImpl.NoOpChannelStateWriter {

        private boolean started;

        @Override
        public void start(long checkpointId, CheckpointOptions checkpointOptions) {
            started = true;
        }
    }
    MockWriter writer = new MockWriter();
    SubtaskCheckpointCoordinator coordinator = coordinator(unalignedCheckpointEnabled, writer);
    CheckpointStorageLocationReference locationReference = CheckpointStorageLocationReference.getDefault();
    coordinator.initInputsCheckpoint(1L, unalignedCheckpointEnabled ? CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, locationReference) : CheckpointOptions.alignedNoTimeout(checkpointType, locationReference));
    return writer.started;
}
Also used : CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference)

Aggregations

CheckpointStorageLocationReference (org.apache.flink.runtime.state.CheckpointStorageLocationReference)19 Test (org.junit.Test)16 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)12 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)4 Random (java.util.Random)2 Path (org.apache.flink.core.fs.Path)2 CheckpointMetaData (org.apache.flink.runtime.checkpoint.CheckpointMetaData)2 RecordingChannelStateWriter (org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter)2 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)2 BufferBuilderTestUtils.createEventBufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createEventBufferConsumer)2 BufferBuilderTestUtils.createFilledFinishedBufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledFinishedBufferConsumer)2 BufferBuilderTestUtils.createFilledUnfinishedBufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledUnfinishedBufferConsumer)2 BufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferConsumer)2 IOException (java.io.IOException)1 JobID (org.apache.flink.api.common.JobID)1 DuplicatingFileSystem (org.apache.flink.core.fs.DuplicatingFileSystem)1 FileSystem (org.apache.flink.core.fs.FileSystem)1 LocalFileSystem (org.apache.flink.core.fs.local.LocalFileSystem)1 CheckpointException (org.apache.flink.runtime.checkpoint.CheckpointException)1 SnapshotType (org.apache.flink.runtime.checkpoint.SnapshotType)1