use of org.apache.flink.runtime.state.SharedStateRegistryImpl in project flink by apache.
the class ZooKeeperCompletedCheckpointStoreITCase method testSuspendKeepsCheckpoints.
/**
* Tests that suspends keeps all checkpoints (so that they can be recovered later by the
* ZooKeeper store). Furthermore, suspending a job should release all locks.
*/
@Test
public void testSuspendKeepsCheckpoints() throws Exception {
CuratorFramework client = ZOOKEEPER.getClient();
SharedStateRegistry sharedStateRegistry = new SharedStateRegistryImpl();
CompletedCheckpointStore store = createRecoveredCompletedCheckpointStore(1);
TestCompletedCheckpoint checkpoint = createCheckpoint(0, sharedStateRegistry);
store.addCheckpointAndSubsumeOldestOne(checkpoint, new CheckpointsCleaner(), () -> {
});
assertEquals(1, store.getNumberOfRetainedCheckpoints());
assertNotNull(client.checkExists().forPath(CHECKPOINT_PATH + checkpointStoreUtil.checkpointIDToName(checkpoint.getCheckpointID())));
store.shutdown(JobStatus.SUSPENDED, new CheckpointsCleaner());
assertEquals(0, store.getNumberOfRetainedCheckpoints());
final String checkpointPath = CHECKPOINT_PATH + checkpointStoreUtil.checkpointIDToName(checkpoint.getCheckpointID());
Stat stat = client.checkExists().forPath(checkpointPath);
assertNotNull("The checkpoint node should exist.", stat);
assertEquals("The checkpoint node should not be locked.", 0, stat.getNumChildren());
// Recover again
sharedStateRegistry.close();
store = createRecoveredCompletedCheckpointStore(1);
CompletedCheckpoint recovered = store.getLatestCheckpoint();
assertEquals(checkpoint, recovered);
}
use of org.apache.flink.runtime.state.SharedStateRegistryImpl in project flink by apache.
the class ZooKeeperCompletedCheckpointStoreITCase method testLatestCheckpointRecovery.
/**
* FLINK-6284.
*
* <p>Tests that the latest recovered checkpoint is the one with the highest checkpoint id
*/
@Test
public void testLatestCheckpointRecovery() throws Exception {
final int numCheckpoints = 3;
SharedStateRegistry sharedStateRegistry = new SharedStateRegistryImpl();
CompletedCheckpointStore checkpointStore = createRecoveredCompletedCheckpointStore(numCheckpoints);
List<CompletedCheckpoint> checkpoints = new ArrayList<>(numCheckpoints);
checkpoints.add(createCheckpoint(9, sharedStateRegistry));
checkpoints.add(createCheckpoint(10, sharedStateRegistry));
checkpoints.add(createCheckpoint(11, sharedStateRegistry));
for (CompletedCheckpoint checkpoint : checkpoints) {
checkpointStore.addCheckpointAndSubsumeOldestOne(checkpoint, new CheckpointsCleaner(), () -> {
});
}
sharedStateRegistry.close();
final CompletedCheckpoint latestCheckpoint = createRecoveredCompletedCheckpointStore(numCheckpoints).getLatestCheckpoint();
assertEquals(checkpoints.get(checkpoints.size() - 1), latestCheckpoint);
}
use of org.apache.flink.runtime.state.SharedStateRegistryImpl 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.SharedStateRegistryImpl in project flink by apache.
the class StandaloneCompletedCheckpointStoreTest method testShutdownDiscardsCheckpoints.
/**
* Tests that shutdown discards all checkpoints.
*/
@Test
public void testShutdownDiscardsCheckpoints() throws Exception {
SharedStateRegistry sharedStateRegistry = new SharedStateRegistryImpl();
CompletedCheckpointStore store = createRecoveredCompletedCheckpointStore(1);
TestCompletedCheckpoint checkpoint = createCheckpoint(0, sharedStateRegistry);
Collection<OperatorState> operatorStates = checkpoint.getOperatorStates().values();
store.addCheckpointAndSubsumeOldestOne(checkpoint, new CheckpointsCleaner(), () -> {
});
assertEquals(1, store.getNumberOfRetainedCheckpoints());
verifyCheckpointRegistered(operatorStates, sharedStateRegistry);
store.shutdown(JobStatus.FINISHED, new CheckpointsCleaner());
assertEquals(0, store.getNumberOfRetainedCheckpoints());
assertTrue(checkpoint.isDiscarded());
verifyCheckpointDiscarded(operatorStates);
}
use of org.apache.flink.runtime.state.SharedStateRegistryImpl in project flink by apache.
the class ZooKeeperCompletedCheckpointStoreITCase method testShutdownDiscardsCheckpoints.
/**
* Tests that shutdown discards all checkpoints.
*/
@Test
public void testShutdownDiscardsCheckpoints() throws Exception {
CuratorFramework client = ZOOKEEPER.getClient();
SharedStateRegistry sharedStateRegistry = new SharedStateRegistryImpl();
CompletedCheckpointStore store = createRecoveredCompletedCheckpointStore(1);
TestCompletedCheckpoint checkpoint = createCheckpoint(0, sharedStateRegistry);
store.addCheckpointAndSubsumeOldestOne(checkpoint, new CheckpointsCleaner(), () -> {
});
assertEquals(1, store.getNumberOfRetainedCheckpoints());
assertNotNull(client.checkExists().forPath(CHECKPOINT_PATH + checkpointStoreUtil.checkpointIDToName(checkpoint.getCheckpointID())));
store.shutdown(JobStatus.FINISHED, new CheckpointsCleaner());
assertEquals(0, store.getNumberOfRetainedCheckpoints());
assertNull(client.checkExists().forPath(CHECKPOINT_PATH + checkpointStoreUtil.checkpointIDToName(checkpoint.getCheckpointID())));
sharedStateRegistry.close();
assertEquals(0, createRecoveredCompletedCheckpointStore(1).getNumberOfRetainedCheckpoints());
}
Aggregations