Search in sources :

Example 6 with CheckpointOptions

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

the class SourceOperatorStreamTask method triggerCheckpointForExternallyInducedSource.

// --------------------------
private void triggerCheckpointForExternallyInducedSource(long checkpointId) {
    final CheckpointOptions checkpointOptions = CheckpointOptions.forConfig(CheckpointType.CHECKPOINT, CheckpointStorageLocationReference.getDefault(), configuration.isExactlyOnceCheckpointMode(), configuration.isUnalignedCheckpointsEnabled(), configuration.getAlignedCheckpointTimeout().toMillis());
    final long timestamp = System.currentTimeMillis();
    final CheckpointMetaData checkpointMetaData = new CheckpointMetaData(checkpointId, timestamp, timestamp);
    super.triggerCheckpointAsync(checkpointMetaData, checkpointOptions);
}
Also used : CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) CheckpointMetaData(org.apache.flink.runtime.checkpoint.CheckpointMetaData)

Example 7 with CheckpointOptions

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

the class SourceTaskTerminationTest method stopWithSavepointStreamTaskTestHelper.

private void stopWithSavepointStreamTaskTestHelper(final boolean shouldTerminate) throws Exception {
    final long syncSavepointId = 34L;
    try (StreamTaskMailboxTestHarness<Long> srcTaskTestHarness = getSourceStreamTaskTestHarness()) {
        final StreamTask<Long, ?> srcTask = srcTaskTestHarness.getStreamTask();
        srcTaskTestHarness.processAll();
        // step by step let the source thread emit elements
        emitAndVerifyWatermarkAndElement(srcTaskTestHarness, 1L);
        emitAndVerifyWatermarkAndElement(srcTaskTestHarness, 2L);
        srcTaskTestHarness.processUntil(srcTask.triggerCheckpointAsync(new CheckpointMetaData(31L, 900), CheckpointOptions.forCheckpointWithDefaultLocation())::isDone);
        verifyCheckpointBarrier(srcTaskTestHarness.getOutput(), 31L);
        emitAndVerifyWatermarkAndElement(srcTaskTestHarness, 3L);
        srcTaskTestHarness.processUntil(srcTask.triggerCheckpointAsync(new CheckpointMetaData(syncSavepointId, 900), new CheckpointOptions(shouldTerminate ? SavepointType.terminate(SavepointFormatType.CANONICAL) : SavepointType.suspend(SavepointFormatType.CANONICAL), CheckpointStorageLocationReference.getDefault()))::isDone);
        if (shouldTerminate) {
            // if we are in TERMINATE mode, we expect the source task
            // to emit MAX_WM before the SYNC_SAVEPOINT barrier.
            verifyWatermark(srcTaskTestHarness.getOutput(), Watermark.MAX_WATERMARK);
        }
        verifyEvent(srcTaskTestHarness.getOutput(), new EndOfData(shouldTerminate ? StopMode.DRAIN : StopMode.NO_DRAIN));
        verifyCheckpointBarrier(srcTaskTestHarness.getOutput(), syncSavepointId);
        waitForSynchronousSavepointIdToBeSet(srcTask);
        assertTrue(srcTask.getSynchronousSavepointId().isPresent());
        srcTaskTestHarness.processUntil(srcTask.notifyCheckpointCompleteAsync(syncSavepointId)::isDone);
        srcTaskTestHarness.waitForTaskCompletion();
    }
}
Also used : EndOfData(org.apache.flink.runtime.io.network.api.EndOfData) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) CheckpointMetaData(org.apache.flink.runtime.checkpoint.CheckpointMetaData)

Example 8 with CheckpointOptions

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

the class StreamTaskExecutionDecorationTest method testTriggerCheckpointOnBarrierIsDecorated.

@Test
public void testTriggerCheckpointOnBarrierIsDecorated() throws Exception {
    task.triggerCheckpointOnBarrier(new CheckpointMetaData(1, 2), new CheckpointOptions(CheckpointType.CHECKPOINT, new CheckpointStorageLocationReference(new byte[] { 1 })), null);
    Assert.assertTrue("execution decorator was not called", decorator.wasCalled());
}
Also used : CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) CheckpointMetaData(org.apache.flink.runtime.checkpoint.CheckpointMetaData) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) Test(org.junit.Test)

Example 9 with CheckpointOptions

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

the class StreamTaskExecutionDecorationTest method testTriggerCheckpointAsyncIsDecorated.

@Test
public void testTriggerCheckpointAsyncIsDecorated() {
    task.triggerCheckpointAsync(new CheckpointMetaData(1, 2), new CheckpointOptions(CheckpointType.CHECKPOINT, new CheckpointStorageLocationReference(new byte[] { 1 })));
    Assert.assertTrue("mailbox is empty", mailbox.hasMail());
    Assert.assertFalse("execution decorator was called preliminary", decorator.wasCalled());
    mailbox.drain().forEach(m -> {
        try {
            m.run();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
    Assert.assertTrue("execution decorator was not called", decorator.wasCalled());
}
Also used : CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) CheckpointMetaData(org.apache.flink.runtime.checkpoint.CheckpointMetaData) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) RunnableWithException(org.apache.flink.util.function.RunnableWithException) CheckpointException(org.apache.flink.runtime.checkpoint.CheckpointException) Test(org.junit.Test)

Example 10 with CheckpointOptions

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

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