use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.
the class CompletedCheckpointTest method testCompletedCheckpointStatsCallbacks.
/**
* Tests that the stats callbacks happen if the callback is registered.
*/
@Test
public void testCompletedCheckpointStatsCallbacks() throws Exception {
CompletedCheckpoint completed = new CompletedCheckpoint(new JobID(), 0, 0, 1, Collections.emptyMap(), Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION), new TestCompletedCheckpointStorageLocation());
CompletedCheckpointStats.DiscardCallback callback = mock(CompletedCheckpointStats.DiscardCallback.class);
completed.setDiscardCallback(callback);
completed.discardOnShutdown(JobStatus.FINISHED);
verify(callback, times(1)).notifyDiscardedCheckpoint();
}
use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.
the class CompletedCheckpointTest method testCompareCheckpointsWithSameOrder.
@Test
public void testCompareCheckpointsWithSameOrder() {
CompletedCheckpoint checkpoint1 = new CompletedCheckpoint(new JobID(), 0, 0, 1, new HashMap<>(), Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.RETAIN_ON_FAILURE), new TestCompletedCheckpointStorageLocation());
CompletedCheckpoint checkpoint2 = new CompletedCheckpoint(new JobID(), 1, 0, 1, new HashMap<>(), Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.RETAIN_ON_FAILURE), new TestCompletedCheckpointStorageLocation());
List<CompletedCheckpoint> checkpoints1 = new ArrayList<>();
checkpoints1.add(checkpoint1);
checkpoints1.add(checkpoint2);
checkpoints1.add(checkpoint1);
List<CompletedCheckpoint> checkpoints2 = new ArrayList<>();
checkpoints2.add(checkpoint1);
checkpoints2.add(checkpoint2);
checkpoints2.add(checkpoint1);
assertTrue(CompletedCheckpoint.checkpointsMatch(checkpoints1, checkpoints2));
}
use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.
the class CompletedCheckpointTest method testRegisterStatesAtRegistry.
@Test
public void testRegisterStatesAtRegistry() {
OperatorState state = mock(OperatorState.class);
Map<OperatorID, OperatorState> operatorStates = new HashMap<>();
operatorStates.put(new OperatorID(), state);
CompletedCheckpoint checkpoint = new CompletedCheckpoint(new JobID(), 0, 0, 1, operatorStates, Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.RETAIN_ON_FAILURE), new TestCompletedCheckpointStorageLocation());
SharedStateRegistry sharedStateRegistry = new SharedStateRegistryImpl();
checkpoint.registerSharedStatesAfterRestored(sharedStateRegistry);
verify(state, times(1)).registerSharedStates(sharedStateRegistry, 0L);
}
use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.
the class CompletedCheckpointTest method testCompareCheckpointsWithDifferentOrder.
@Test
public void testCompareCheckpointsWithDifferentOrder() {
CompletedCheckpoint checkpoint1 = new CompletedCheckpoint(new JobID(), 0, 0, 1, new HashMap<>(), Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.RETAIN_ON_FAILURE), new TestCompletedCheckpointStorageLocation());
CompletedCheckpoint checkpoint2 = new CompletedCheckpoint(new JobID(), 1, 0, 1, new HashMap<>(), Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.RETAIN_ON_FAILURE), new TestCompletedCheckpointStorageLocation());
List<CompletedCheckpoint> checkpoints1 = new ArrayList<>();
checkpoints1.add(checkpoint1);
checkpoints1.add(checkpoint2);
checkpoints1.add(checkpoint1);
List<CompletedCheckpoint> checkpoints2 = new ArrayList<>();
checkpoints2.add(checkpoint2);
checkpoints2.add(checkpoint1);
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 testCleanUpOnShutdown.
/**
* Tests that the garbage collection properties are respected when shutting down.
*/
@Test
public void testCleanUpOnShutdown() throws Exception {
JobStatus[] terminalStates = new JobStatus[] { JobStatus.FINISHED, JobStatus.CANCELED, JobStatus.FAILED, JobStatus.SUSPENDED };
for (JobStatus status : terminalStates) {
OperatorState state = mock(OperatorState.class);
Map<OperatorID, OperatorState> operatorStates = new HashMap<>();
operatorStates.put(new OperatorID(), state);
EmptyStreamStateHandle retainedHandle = new EmptyStreamStateHandle();
TestCompletedCheckpointStorageLocation retainedLocation = new TestCompletedCheckpointStorageLocation(retainedHandle, "ptr");
// Keep
CheckpointProperties retainProps = new CheckpointProperties(false, CheckpointType.CHECKPOINT, false, false, false, false, false, false);
CompletedCheckpoint checkpoint = new CompletedCheckpoint(new JobID(), 0, 0, 1, new HashMap<>(operatorStates), Collections.emptyList(), retainProps, retainedLocation);
checkpoint.discardOnShutdown(status);
verify(state, times(0)).discardState();
assertFalse(retainedLocation.isDisposed());
assertFalse(retainedHandle.isDisposed());
// Discard
EmptyStreamStateHandle discardHandle = new EmptyStreamStateHandle();
TestCompletedCheckpointStorageLocation discardLocation = new TestCompletedCheckpointStorageLocation(discardHandle, "ptr");
// Keep
CheckpointProperties discardProps = new CheckpointProperties(false, CheckpointType.CHECKPOINT, true, true, true, true, true, false);
checkpoint = new CompletedCheckpoint(new JobID(), 0, 0, 1, new HashMap<>(operatorStates), Collections.emptyList(), discardProps, discardLocation);
checkpoint.discardOnShutdown(status);
verify(state, times(1)).discardState();
assertTrue(discardLocation.isDisposed());
assertTrue(discardHandle.isDisposed());
}
}
Aggregations