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);
}
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();
}
}
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());
}
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());
}
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);
}
Aggregations