Search in sources :

Example 11 with CheckpointOptions

use of org.apache.flink.runtime.checkpoint.CheckpointOptions 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 12 with CheckpointOptions

use of org.apache.flink.runtime.checkpoint.CheckpointOptions in project flink by apache.

the class CheckpointSerializationTest method testCheckpointWithDefaultLocationSerialization.

@Test
public void testCheckpointWithDefaultLocationSerialization() throws Exception {
    CheckpointOptions checkpointToSerialize = CheckpointOptions.forCheckpointWithDefaultLocation();
    testCheckpointBarrierSerialization(checkpointToSerialize);
}
Also used : CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) Test(org.junit.Test)

Example 13 with CheckpointOptions

use of org.apache.flink.runtime.checkpoint.CheckpointOptions 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 14 with CheckpointOptions

use of org.apache.flink.runtime.checkpoint.CheckpointOptions in project flink by apache.

the class AlternatingCheckpointsTest method testHasInflightDataBeforeProcessBarrier.

@Test
public void testHasInflightDataBeforeProcessBarrier() throws Exception {
    SingleInputGate inputGate = new SingleInputGateBuilder().setNumberOfChannels(2).build();
    inputGate.setInputChannels(new TestInputChannel(inputGate, 0), new TestInputChannel(inputGate, 1));
    ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
    SingleCheckpointBarrierHandler barrierHandler = getTestBarrierHandlerFactory(target).create(inputGate);
    final long id = 1;
    barrierHandler.processBarrier(new CheckpointBarrier(id, clock.relativeTimeMillis(), new CheckpointOptions(CHECKPOINT, getDefault())), new InputChannelInfo(0, 0), false);
    assertFalse(barrierHandler.getAllBarriersReceivedFuture(id).isDone());
}
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) TestInputChannel(org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) Test(org.junit.Test)

Example 15 with CheckpointOptions

use of org.apache.flink.runtime.checkpoint.CheckpointOptions in project flink by apache.

the class AlternatingCheckpointsTest method testPreviousHandlerReset.

@Test
public void testPreviousHandlerReset() throws Exception {
    SingleInputGate inputGate = new SingleInputGateBuilder().setNumberOfChannels(2).build();
    TestInputChannel[] channels = { new TestInputChannel(inputGate, 0), new TestInputChannel(inputGate, 1) };
    inputGate.setInputChannels(channels);
    ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
    SingleCheckpointBarrierHandler barrierHandler = getTestBarrierHandlerFactory(target).create(inputGate);
    for (int i = 0; i < 4; i++) {
        int channel = i % 2;
        SnapshotType type = channel == 0 ? SavepointType.savepoint(SavepointFormatType.CANONICAL) : CHECKPOINT;
        target.setNextExpectedCheckpointId(-1);
        if (type.isSavepoint()) {
            channels[channel].setBlocked(true);
        }
        barrierHandler.processBarrier(new CheckpointBarrier(i, clock.relativeTimeMillis(), new CheckpointOptions(type, getDefault())), new InputChannelInfo(0, channel), false);
        if (type.isSavepoint()) {
            assertTrue(channels[channel].isBlocked());
            assertFalse(channels[(channel + 1) % 2].isBlocked());
        } else {
            assertFalse(channels[0].isBlocked());
            assertFalse(channels[1].isBlocked());
        }
        assertTrue(barrierHandler.isCheckpointPending());
        assertFalse(barrierHandler.getAllBarriersReceivedFuture(i).isDone());
        channels[0].setBlocked(false);
        channels[1].setBlocked(false);
    }
}
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) TestInputChannel(org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) SnapshotType(org.apache.flink.runtime.checkpoint.SnapshotType) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) Test(org.junit.Test)

Aggregations

CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)43 Test (org.junit.Test)23 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)14 CheckpointStorageLocationReference (org.apache.flink.runtime.state.CheckpointStorageLocationReference)13 CheckpointMetaData (org.apache.flink.runtime.checkpoint.CheckpointMetaData)12 IOException (java.io.IOException)7 CheckpointMetricsBuilder (org.apache.flink.runtime.checkpoint.CheckpointMetricsBuilder)5 InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)5 TestInputChannel (org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel)5 List (java.util.List)4 Map (java.util.Map)4 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 SnapshotType (org.apache.flink.runtime.checkpoint.SnapshotType)3 EndOfData (org.apache.flink.runtime.io.network.api.EndOfData)3 SingleInputGate (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)3 SingleInputGateBuilder (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder)3 StreamConfig (org.apache.flink.streaming.api.graph.StreamConfig)3 ByteBuffer (java.nio.ByteBuffer)2