use of org.apache.flink.runtime.checkpoint.CheckpointOptions in project flink by apache.
the class SubtaskCheckpointCoordinatorTest method testSavepointNotResultingInPriorityEvents.
@Test
public void testSavepointNotResultingInPriorityEvents() throws Exception {
MockEnvironment mockEnvironment = MockEnvironment.builder().build();
try (SubtaskCheckpointCoordinator coordinator = new MockSubtaskCheckpointCoordinatorBuilder().setUnalignedCheckpointEnabled(true).setEnvironment(mockEnvironment).build()) {
AtomicReference<Boolean> broadcastedPriorityEvent = new AtomicReference<>(null);
final OperatorChain<?, ?> operatorChain = new RegularOperatorChain(new MockStreamTaskBuilder(mockEnvironment).build(), new NonRecordWriter<>()) {
@Override
public void broadcastEvent(AbstractEvent event, boolean isPriorityEvent) throws IOException {
super.broadcastEvent(event, isPriorityEvent);
broadcastedPriorityEvent.set(isPriorityEvent);
}
};
coordinator.checkpointState(new CheckpointMetaData(0, 0), new CheckpointOptions(SavepointType.savepoint(SavepointFormatType.CANONICAL), CheckpointStorageLocationReference.getDefault()), new CheckpointMetricsBuilder(), operatorChain, false, () -> true);
assertEquals(false, broadcastedPriorityEvent.get());
}
}
use of org.apache.flink.runtime.checkpoint.CheckpointOptions in project flink by apache.
the class SubtaskCheckpointCoordinatorTest method testForceAlignedCheckpointResultingInPriorityEvents.
@Test
public void testForceAlignedCheckpointResultingInPriorityEvents() throws Exception {
final long checkpointId = 42L;
MockEnvironment mockEnvironment = MockEnvironment.builder().build();
try (SubtaskCheckpointCoordinator coordinator = new MockSubtaskCheckpointCoordinatorBuilder().setUnalignedCheckpointEnabled(true).setEnvironment(mockEnvironment).build()) {
AtomicReference<Boolean> broadcastedPriorityEvent = new AtomicReference<>(null);
final OperatorChain<?, ?> operatorChain = new RegularOperatorChain(new MockStreamTaskBuilder(mockEnvironment).build(), new NonRecordWriter<>()) {
@Override
public void broadcastEvent(AbstractEvent event, boolean isPriorityEvent) throws IOException {
super.broadcastEvent(event, isPriorityEvent);
broadcastedPriorityEvent.set(isPriorityEvent);
// test if we can write output data
coordinator.getChannelStateWriter().addOutputData(checkpointId, new ResultSubpartitionInfo(0, 0), 0, BufferBuilderTestUtils.buildSomeBuffer(500));
}
};
CheckpointOptions forcedAlignedOptions = CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, CheckpointStorageLocationReference.getDefault()).withUnalignedUnsupported();
coordinator.checkpointState(new CheckpointMetaData(checkpointId, 0), forcedAlignedOptions, new CheckpointMetricsBuilder(), operatorChain, false, () -> true);
assertEquals(true, broadcastedPriorityEvent.get());
}
}
use of org.apache.flink.runtime.checkpoint.CheckpointOptions in project flink by apache.
the class SynchronousCheckpointITCase method taskDispatcherThreadPoolAllowsForSynchronousCheckpoints.
@Test
public void taskDispatcherThreadPoolAllowsForSynchronousCheckpoints() throws Exception {
final Task task = createTask(SynchronousCheckpointTestingTask.class);
try (TaskCleaner ignored = new TaskCleaner(task)) {
task.startTaskThread();
assertThat(eventQueue.take(), is(Event.TASK_IS_RUNNING));
assertTrue(eventQueue.isEmpty());
assertEquals(ExecutionState.RUNNING, task.getExecutionState());
task.triggerCheckpointBarrier(42, 156865867234L, new CheckpointOptions(SavepointType.suspend(SavepointFormatType.CANONICAL), CheckpointStorageLocationReference.getDefault()));
assertThat(eventQueue.take(), is(Event.PRE_TRIGGER_CHECKPOINT));
assertThat(eventQueue.take(), is(Event.POST_TRIGGER_CHECKPOINT));
assertTrue(eventQueue.isEmpty());
task.notifyCheckpointComplete(42);
assertThat(eventQueue.take(), is(Event.PRE_NOTIFY_CHECKPOINT_COMPLETE));
assertThat(eventQueue.take(), is(Event.POST_NOTIFY_CHECKPOINT_COMPLETE));
assertTrue(eventQueue.isEmpty());
assertEquals(ExecutionState.RUNNING, task.getExecutionState());
}
}
use of org.apache.flink.runtime.checkpoint.CheckpointOptions in project flink by apache.
the class SynchronousCheckpointTest method launchSynchronousSavepointAndWaitForSyncSavepointIdToBeSet.
private void launchSynchronousSavepointAndWaitForSyncSavepointIdToBeSet() throws InterruptedException {
streamTaskUnderTest.triggerCheckpointAsync(new CheckpointMetaData(42, System.currentTimeMillis()), new CheckpointOptions(SavepointType.suspend(SavepointFormatType.CANONICAL), CheckpointStorageLocationReference.getDefault()));
waitForSyncSavepointIdToBeSet(streamTaskUnderTest);
}
use of org.apache.flink.runtime.checkpoint.CheckpointOptions in project flink by apache.
the class EventSerializerTest method testCheckpointBarrierSerialization.
@Test
public void testCheckpointBarrierSerialization() throws Exception {
long id = Integer.MAX_VALUE + 123123L;
long timestamp = Integer.MAX_VALUE + 1228L;
CheckpointOptions checkpoint = CheckpointOptions.forFullCheckpoint();
testCheckpointBarrierSerialization(id, timestamp, checkpoint);
CheckpointOptions savepoint = CheckpointOptions.forSavepoint("1289031838919123");
testCheckpointBarrierSerialization(id, timestamp, savepoint);
}
Aggregations