Java Code Examples for org.apache.flink.runtime.state.CheckpointStorage#initializeLocationForCheckpoint()
The following examples show how to use
org.apache.flink.runtime.state.CheckpointStorage#initializeLocationForCheckpoint() .
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: AbstractFileCheckpointStorageTestBase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void writeToAlreadyExistingCheckpointFails() throws Exception { final byte[] data = {8, 8, 4, 5, 2, 6, 3}; final long checkpointId = 177; final CheckpointStorage storage = createCheckpointStorage(randomTempPath()); final CheckpointStorageLocation loc = storage.initializeLocationForCheckpoint(checkpointId); // write to the metadata file for the checkpoint try (CheckpointMetadataOutputStream out = loc.createMetadataOutputStream()) { out.write(data); out.closeAndFinalizeCheckpoint(); } // create another writer to the metadata file for the checkpoint try { loc.createMetadataOutputStream(); fail("this should fail with an exception"); } catch (IOException ignored) {} }
Example 2
Source File: AbstractFileCheckpointStorageTestBase.java From flink with Apache License 2.0 | 6 votes |
@Test public void writeToAlreadyExistingCheckpointFails() throws Exception { final byte[] data = {8, 8, 4, 5, 2, 6, 3}; final long checkpointId = 177; final CheckpointStorage storage = createCheckpointStorage(randomTempPath()); final CheckpointStorageLocation loc = storage.initializeLocationForCheckpoint(checkpointId); // write to the metadata file for the checkpoint try (CheckpointMetadataOutputStream out = loc.createMetadataOutputStream()) { out.write(data); out.closeAndFinalizeCheckpoint(); } // create another writer to the metadata file for the checkpoint try { loc.createMetadataOutputStream(); fail("this should fail with an exception"); } catch (IOException ignored) {} }
Example 3
Source File: AbstractFileCheckpointStorageTestBase.java From flink with Apache License 2.0 | 6 votes |
@Test public void writeToAlreadyExistingCheckpointFails() throws Exception { final byte[] data = {8, 8, 4, 5, 2, 6, 3}; final long checkpointId = 177; final CheckpointStorage storage = createCheckpointStorage(randomTempPath()); storage.initializeBaseLocations(); final CheckpointStorageLocation loc = storage.initializeLocationForCheckpoint(checkpointId); // write to the metadata file for the checkpoint try (CheckpointMetadataOutputStream out = loc.createMetadataOutputStream()) { out.write(data); out.closeAndFinalizeCheckpoint(); } // create another writer to the metadata file for the checkpoint try { loc.createMetadataOutputStream(); fail("this should fail with an exception"); } catch (IOException ignored) {} }
Example 4
Source File: AbstractFileCheckpointStorageTestBase.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Validates that multiple checkpoints from different jobs with the same checkpoint ID do not * interfere with each other. */ @Test public void testPersistMultipleMetadataOnlyCheckpoints() throws Exception { final FileSystem fs = FileSystem.getLocalFileSystem(); final Path checkpointDir = new Path(tmp.newFolder().toURI()); final long checkpointId = 177; final CheckpointStorage storage1 = createCheckpointStorage(checkpointDir); final CheckpointStorage storage2 = createCheckpointStorage(checkpointDir); final CheckpointStorageLocation loc1 = storage1.initializeLocationForCheckpoint(checkpointId); final CheckpointStorageLocation loc2 = storage2.initializeLocationForCheckpoint(checkpointId); final byte[] data1 = {77, 66, 55, 99, 88}; final byte[] data2 = {1, 3, 2, 5, 4}; final CompletedCheckpointStorageLocation completedLocation1; try (CheckpointMetadataOutputStream out = loc1.createMetadataOutputStream()) { out.write(data1); completedLocation1 = out.closeAndFinalizeCheckpoint(); } final String result1 = completedLocation1.getExternalPointer(); final CompletedCheckpointStorageLocation completedLocation2; try (CheckpointMetadataOutputStream out = loc2.createMetadataOutputStream()) { out.write(data2); completedLocation2 = out.closeAndFinalizeCheckpoint(); } final String result2 = completedLocation2.getExternalPointer(); // check that this went to a file, but in a nested directory structure // one directory per storage FileStatus[] files = fs.listStatus(checkpointDir); assertEquals(2, files.length); // in each per-storage directory, one for the checkpoint FileStatus[] job1Files = fs.listStatus(files[0].getPath()); FileStatus[] job2Files = fs.listStatus(files[1].getPath()); assertTrue(job1Files.length >= 1); assertTrue(job2Files.length >= 1); assertTrue(fs.exists(new Path(result1, AbstractFsCheckpointStorage.METADATA_FILE_NAME))); assertTrue(fs.exists(new Path(result2, AbstractFsCheckpointStorage.METADATA_FILE_NAME))); // check that both storages can resolve each others contents validateContents(storage1.resolveCheckpoint(result1).getMetadataHandle(), data1); validateContents(storage1.resolveCheckpoint(result2).getMetadataHandle(), data2); validateContents(storage2.resolveCheckpoint(result1).getMetadataHandle(), data1); validateContents(storage2.resolveCheckpoint(result2).getMetadataHandle(), data2); }
Example 5
Source File: AbstractFileCheckpointStorageTestBase.java From flink with Apache License 2.0 | 4 votes |
/** * Validates that multiple checkpoints from different jobs with the same checkpoint ID do not * interfere with each other. */ @Test public void testPersistMultipleMetadataOnlyCheckpoints() throws Exception { final FileSystem fs = FileSystem.getLocalFileSystem(); final Path checkpointDir = new Path(tmp.newFolder().toURI()); final long checkpointId = 177; final CheckpointStorage storage1 = createCheckpointStorage(checkpointDir); final CheckpointStorage storage2 = createCheckpointStorage(checkpointDir); final CheckpointStorageLocation loc1 = storage1.initializeLocationForCheckpoint(checkpointId); final CheckpointStorageLocation loc2 = storage2.initializeLocationForCheckpoint(checkpointId); final byte[] data1 = {77, 66, 55, 99, 88}; final byte[] data2 = {1, 3, 2, 5, 4}; final CompletedCheckpointStorageLocation completedLocation1; try (CheckpointMetadataOutputStream out = loc1.createMetadataOutputStream()) { out.write(data1); completedLocation1 = out.closeAndFinalizeCheckpoint(); } final String result1 = completedLocation1.getExternalPointer(); final CompletedCheckpointStorageLocation completedLocation2; try (CheckpointMetadataOutputStream out = loc2.createMetadataOutputStream()) { out.write(data2); completedLocation2 = out.closeAndFinalizeCheckpoint(); } final String result2 = completedLocation2.getExternalPointer(); // check that this went to a file, but in a nested directory structure // one directory per storage FileStatus[] files = fs.listStatus(checkpointDir); assertEquals(2, files.length); // in each per-storage directory, one for the checkpoint FileStatus[] job1Files = fs.listStatus(files[0].getPath()); FileStatus[] job2Files = fs.listStatus(files[1].getPath()); assertTrue(job1Files.length >= 1); assertTrue(job2Files.length >= 1); assertTrue(fs.exists(new Path(result1, AbstractFsCheckpointStorage.METADATA_FILE_NAME))); assertTrue(fs.exists(new Path(result2, AbstractFsCheckpointStorage.METADATA_FILE_NAME))); // check that both storages can resolve each others contents validateContents(storage1.resolveCheckpoint(result1).getMetadataHandle(), data1); validateContents(storage1.resolveCheckpoint(result2).getMetadataHandle(), data2); validateContents(storage2.resolveCheckpoint(result1).getMetadataHandle(), data1); validateContents(storage2.resolveCheckpoint(result2).getMetadataHandle(), data2); }
Example 6
Source File: AbstractFileCheckpointStorageTestBase.java From flink with Apache License 2.0 | 4 votes |
/** * Validates that multiple checkpoints from different jobs with the same checkpoint ID do not * interfere with each other. */ @Test public void testPersistMultipleMetadataOnlyCheckpoints() throws Exception { final FileSystem fs = FileSystem.getLocalFileSystem(); final Path checkpointDir = new Path(tmp.newFolder().toURI()); final long checkpointId = 177; final CheckpointStorage storage1 = createCheckpointStorage(checkpointDir); storage1.initializeBaseLocations(); final CheckpointStorage storage2 = createCheckpointStorage(checkpointDir); storage2.initializeBaseLocations(); final CheckpointStorageLocation loc1 = storage1.initializeLocationForCheckpoint(checkpointId); final CheckpointStorageLocation loc2 = storage2.initializeLocationForCheckpoint(checkpointId); final byte[] data1 = {77, 66, 55, 99, 88}; final byte[] data2 = {1, 3, 2, 5, 4}; final CompletedCheckpointStorageLocation completedLocation1; try (CheckpointMetadataOutputStream out = loc1.createMetadataOutputStream()) { out.write(data1); completedLocation1 = out.closeAndFinalizeCheckpoint(); } final String result1 = completedLocation1.getExternalPointer(); final CompletedCheckpointStorageLocation completedLocation2; try (CheckpointMetadataOutputStream out = loc2.createMetadataOutputStream()) { out.write(data2); completedLocation2 = out.closeAndFinalizeCheckpoint(); } final String result2 = completedLocation2.getExternalPointer(); // check that this went to a file, but in a nested directory structure // one directory per storage FileStatus[] files = fs.listStatus(checkpointDir); assertEquals(2, files.length); // in each per-storage directory, one for the checkpoint FileStatus[] job1Files = fs.listStatus(files[0].getPath()); FileStatus[] job2Files = fs.listStatus(files[1].getPath()); assertTrue(job1Files.length >= 1); assertTrue(job2Files.length >= 1); assertTrue(fs.exists(new Path(result1, AbstractFsCheckpointStorage.METADATA_FILE_NAME))); assertTrue(fs.exists(new Path(result2, AbstractFsCheckpointStorage.METADATA_FILE_NAME))); // check that both storages can resolve each others contents validateContents(storage1.resolveCheckpoint(result1).getMetadataHandle(), data1); validateContents(storage1.resolveCheckpoint(result2).getMetadataHandle(), data2); validateContents(storage2.resolveCheckpoint(result1).getMetadataHandle(), data1); validateContents(storage2.resolveCheckpoint(result2).getMetadataHandle(), data2); }