Java Code Examples for org.apache.flink.runtime.state.SharedStateRegistry#close()

The following examples show how to use org.apache.flink.runtime.state.SharedStateRegistry#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZooKeeperCompletedCheckpointStoreITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that shutdown discards all checkpoints.
 */
@Test
public void testShutdownDiscardsCheckpoints() throws Exception {
	CuratorFramework client = ZOOKEEPER.getClient();

	SharedStateRegistry sharedStateRegistry = new SharedStateRegistry();
	CompletedCheckpointStore store = createCompletedCheckpoints(1);
	TestCompletedCheckpoint checkpoint = createCheckpoint(0, sharedStateRegistry);

	store.addCheckpoint(checkpoint);
	assertEquals(1, store.getNumberOfRetainedCheckpoints());
	assertNotNull(client.checkExists().forPath(CHECKPOINT_PATH + ZooKeeperCompletedCheckpointStore.checkpointIdToPath(checkpoint.getCheckpointID())));

	store.shutdown(JobStatus.FINISHED);
	assertEquals(0, store.getNumberOfRetainedCheckpoints());
	assertNull(client.checkExists().forPath(CHECKPOINT_PATH + ZooKeeperCompletedCheckpointStore.checkpointIdToPath(checkpoint.getCheckpointID())));

	sharedStateRegistry.close();
	store.recover();

	assertEquals(0, store.getNumberOfRetainedCheckpoints());
}
 
Example 2
Source File: ZooKeeperCompletedCheckpointStoreITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * FLINK-6284
 *
 * 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 SharedStateRegistry();
	CompletedCheckpointStore checkpointStore = createCompletedCheckpoints(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.addCheckpoint(checkpoint);
	}

	sharedStateRegistry.close();
	checkpointStore.recover();

	CompletedCheckpoint latestCheckpoint = checkpointStore.getLatestCheckpoint();

	assertEquals(checkpoints.get(checkpoints.size() -1), latestCheckpoint);
}
 
Example 3
Source File: ZooKeeperCompletedCheckpointStoreITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that shutdown discards all checkpoints.
 */
@Test
public void testShutdownDiscardsCheckpoints() throws Exception {
	CuratorFramework client = ZOOKEEPER.getClient();

	SharedStateRegistry sharedStateRegistry = new SharedStateRegistry();
	CompletedCheckpointStore store = createCompletedCheckpoints(1);
	TestCompletedCheckpoint checkpoint = createCheckpoint(0, sharedStateRegistry);

	store.addCheckpoint(checkpoint);
	assertEquals(1, store.getNumberOfRetainedCheckpoints());
	assertNotNull(client.checkExists().forPath(CHECKPOINT_PATH + ZooKeeperCompletedCheckpointStore.checkpointIdToPath(checkpoint.getCheckpointID())));

	store.shutdown(JobStatus.FINISHED);
	assertEquals(0, store.getNumberOfRetainedCheckpoints());
	assertNull(client.checkExists().forPath(CHECKPOINT_PATH + ZooKeeperCompletedCheckpointStore.checkpointIdToPath(checkpoint.getCheckpointID())));

	sharedStateRegistry.close();
	store.recover();

	assertEquals(0, store.getNumberOfRetainedCheckpoints());
}
 
Example 4
Source File: ZooKeeperCompletedCheckpointStoreITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * FLINK-6284
 *
 * 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 SharedStateRegistry();
	CompletedCheckpointStore checkpointStore = createCompletedCheckpoints(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.addCheckpoint(checkpoint);
	}

	sharedStateRegistry.close();
	checkpointStore.recover();

	CompletedCheckpoint latestCheckpoint = checkpointStore.getLatestCheckpoint(false);

	assertEquals(checkpoints.get(checkpoints.size() -1), latestCheckpoint);
}
 
Example 5
Source File: ZooKeeperCompletedCheckpointStoreITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that shutdown discards all checkpoints.
 */
@Test
public void testShutdownDiscardsCheckpoints() throws Exception {
	CuratorFramework client = ZOOKEEPER.getClient();

	SharedStateRegistry sharedStateRegistry = new SharedStateRegistry();
	CompletedCheckpointStore store = createCompletedCheckpoints(1);
	TestCompletedCheckpoint checkpoint = createCheckpoint(0, sharedStateRegistry);

	store.addCheckpoint(checkpoint);
	assertEquals(1, store.getNumberOfRetainedCheckpoints());
	assertNotNull(client.checkExists().forPath(CHECKPOINT_PATH + ZooKeeperCompletedCheckpointStore.checkpointIdToPath(checkpoint.getCheckpointID())));

	store.shutdown(JobStatus.FINISHED);
	assertEquals(0, store.getNumberOfRetainedCheckpoints());
	assertNull(client.checkExists().forPath(CHECKPOINT_PATH + ZooKeeperCompletedCheckpointStore.checkpointIdToPath(checkpoint.getCheckpointID())));

	sharedStateRegistry.close();
	store.recover();

	assertEquals(0, store.getNumberOfRetainedCheckpoints());
}
 
Example 6
Source File: ZooKeeperCompletedCheckpointStoreITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * FLINK-6284
 *
 * 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 SharedStateRegistry();
	CompletedCheckpointStore checkpointStore = createCompletedCheckpoints(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.addCheckpoint(checkpoint);
	}

	sharedStateRegistry.close();
	checkpointStore.recover();

	CompletedCheckpoint latestCheckpoint = checkpointStore.getLatestCheckpoint(false);

	assertEquals(checkpoints.get(checkpoints.size() -1), latestCheckpoint);
}
 
Example 7
Source File: ZooKeeperCompletedCheckpointStoreITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * 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 SharedStateRegistry();
	CompletedCheckpointStore store = createCompletedCheckpoints(1);
	TestCompletedCheckpoint checkpoint = createCheckpoint(0, sharedStateRegistry);

	store.addCheckpoint(checkpoint);
	assertEquals(1, store.getNumberOfRetainedCheckpoints());
	assertNotNull(client.checkExists().forPath(CHECKPOINT_PATH + ZooKeeperCompletedCheckpointStore.checkpointIdToPath(checkpoint.getCheckpointID())));

	store.shutdown(JobStatus.SUSPENDED);

	assertEquals(0, store.getNumberOfRetainedCheckpoints());

	final String checkpointPath = CHECKPOINT_PATH + ZooKeeperCompletedCheckpointStore.checkpointIdToPath(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.recover();

	CompletedCheckpoint recovered = store.getLatestCheckpoint();
	assertEquals(checkpoint, recovered);
}
 
Example 8
Source File: ZooKeeperCompletedCheckpointStoreITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * 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 SharedStateRegistry();
	CompletedCheckpointStore store = createCompletedCheckpoints(1);
	TestCompletedCheckpoint checkpoint = createCheckpoint(0, sharedStateRegistry);

	store.addCheckpoint(checkpoint);
	assertEquals(1, store.getNumberOfRetainedCheckpoints());
	assertNotNull(client.checkExists().forPath(CHECKPOINT_PATH + ZooKeeperCompletedCheckpointStore.checkpointIdToPath(checkpoint.getCheckpointID())));

	store.shutdown(JobStatus.SUSPENDED);

	assertEquals(0, store.getNumberOfRetainedCheckpoints());

	final String checkpointPath = CHECKPOINT_PATH + ZooKeeperCompletedCheckpointStore.checkpointIdToPath(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.recover();

	CompletedCheckpoint recovered = store.getLatestCheckpoint(false);
	assertEquals(checkpoint, recovered);
}
 
Example 9
Source File: ZooKeeperCompletedCheckpointStoreITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * 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 SharedStateRegistry();
	CompletedCheckpointStore store = createCompletedCheckpoints(1);
	TestCompletedCheckpoint checkpoint = createCheckpoint(0, sharedStateRegistry);

	store.addCheckpoint(checkpoint);
	assertEquals(1, store.getNumberOfRetainedCheckpoints());
	assertNotNull(client.checkExists().forPath(CHECKPOINT_PATH + ZooKeeperCompletedCheckpointStore.checkpointIdToPath(checkpoint.getCheckpointID())));

	store.shutdown(JobStatus.SUSPENDED);

	assertEquals(0, store.getNumberOfRetainedCheckpoints());

	final String checkpointPath = CHECKPOINT_PATH + ZooKeeperCompletedCheckpointStore.checkpointIdToPath(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.recover();

	CompletedCheckpoint recovered = store.getLatestCheckpoint(false);
	assertEquals(checkpoint, recovered);
}