use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.
the class CompletedCheckpointTest method testCompareCheckpointsWithSameCheckpointId.
/**
* Verify that both JobID and checkpoint id are taken into account when comparing.
*/
@Test
public void testCompareCheckpointsWithSameCheckpointId() {
JobID jobID1 = new JobID();
JobID jobID2 = new JobID();
CompletedCheckpoint checkpoint1 = new CompletedCheckpoint(jobID1, 0, 0, 1, new HashMap<>(), Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.RETAIN_ON_FAILURE), new TestCompletedCheckpointStorageLocation());
CompletedCheckpoint checkpoint2 = new CompletedCheckpoint(jobID2, 0, 0, 1, new HashMap<>(), Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.RETAIN_ON_FAILURE), new TestCompletedCheckpointStorageLocation());
List<CompletedCheckpoint> checkpoints1 = new ArrayList<>();
checkpoints1.add(checkpoint1);
List<CompletedCheckpoint> checkpoints2 = new ArrayList<>();
checkpoints2.add(checkpoint2);
assertFalse(CompletedCheckpoint.checkpointsMatch(checkpoints1, checkpoints2));
}
use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.
the class CompletedCheckpointTest method testCompareCheckpointsWithSameJobID.
/**
* Verify that both JobID and checkpoint id are taken into account when comparing.
*/
@Test
public void testCompareCheckpointsWithSameJobID() {
JobID jobID = new JobID();
CompletedCheckpoint checkpoint1 = new CompletedCheckpoint(jobID, 0, 0, 1, new HashMap<>(), Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.RETAIN_ON_FAILURE), new TestCompletedCheckpointStorageLocation());
CompletedCheckpoint checkpoint2 = new CompletedCheckpoint(jobID, 1, 0, 1, new HashMap<>(), Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.RETAIN_ON_FAILURE), new TestCompletedCheckpointStorageLocation());
List<CompletedCheckpoint> checkpoints1 = new ArrayList<>();
checkpoints1.add(checkpoint1);
List<CompletedCheckpoint> checkpoints2 = new ArrayList<>();
checkpoints2.add(checkpoint2);
assertFalse(CompletedCheckpoint.checkpointsMatch(checkpoints1, checkpoints2));
}
use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.
the class CompletedCheckpointTest method testCleanUpOnSubsume.
/**
* Tests that the garbage collection properties are respected when subsuming checkpoints.
*/
@Test
public void testCleanUpOnSubsume() throws Exception {
OperatorState state = mock(OperatorState.class);
Map<OperatorID, OperatorState> operatorStates = new HashMap<>();
operatorStates.put(new OperatorID(), state);
EmptyStreamStateHandle metadata = new EmptyStreamStateHandle();
TestCompletedCheckpointStorageLocation location = new TestCompletedCheckpointStorageLocation(metadata, "ptr");
CheckpointProperties props = new CheckpointProperties(false, CheckpointType.CHECKPOINT, true, false, false, false, false, false);
CompletedCheckpoint checkpoint = new CompletedCheckpoint(new JobID(), 0, 0, 1, operatorStates, Collections.emptyList(), props, location);
SharedStateRegistry sharedStateRegistry = new SharedStateRegistryImpl();
checkpoint.registerSharedStatesAfterRestored(sharedStateRegistry);
verify(state, times(1)).registerSharedStates(sharedStateRegistry, 0L);
// Subsume
checkpoint.discardOnSubsume();
verify(state, times(1)).discardState();
assertTrue(location.isDisposed());
assertTrue(metadata.isDisposed());
}
use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.
the class StandaloneCompletedCheckpointStoreTest method testAddCheckpointWithFailedRemove.
/**
* Tests that the checkpoint does not exist in the store when we fail to add it into the store
* (i.e., there exists an exception thrown by the method).
*/
@Test
public void testAddCheckpointWithFailedRemove() throws Exception {
final int numCheckpointsToRetain = 1;
CompletedCheckpointStore store = createRecoveredCompletedCheckpointStore(numCheckpointsToRetain, Executors.directExecutor());
CountDownLatch discardAttempted = new CountDownLatch(1);
for (long i = 0; i < numCheckpointsToRetain + 1; ++i) {
CompletedCheckpoint checkpointToAdd = new CompletedCheckpoint(new JobID(), i, i, i, Collections.emptyMap(), Collections.emptyList(), CheckpointProperties.forCheckpoint(NEVER_RETAIN_AFTER_TERMINATION), new TestCompletedCheckpointStorageLocation()) {
@Override
public boolean discardOnSubsume() {
discardAttempted.countDown();
throw new RuntimeException();
}
};
// should fail despite the exception
store.addCheckpointAndSubsumeOldestOne(checkpointToAdd, new CheckpointsCleaner(), () -> {
});
}
discardAttempted.await();
}
use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.
the class SchedulerUtilsTest method buildCheckpoint.
private CompletedCheckpoint buildCheckpoint(KeyedStateHandle incremental) {
OperatorID operatorID = new OperatorID();
OperatorState operatorState = new OperatorState(operatorID, 1, 1);
operatorState.putState(0, OperatorSubtaskState.builder().setManagedKeyedState(incremental).build());
return new CompletedCheckpoint(new JobID(), 1, 1, 1, singletonMap(operatorID, operatorState), emptyList(), CheckpointProperties.forCheckpoint(NEVER_RETAIN_AFTER_TERMINATION), new TestCompletedCheckpointStorageLocation());
}
Aggregations