Java Code Examples for org.apache.flink.runtime.state.CheckpointMetadataOutputStream#closeAndFinalizeCheckpoint()
The following examples show how to use
org.apache.flink.runtime.state.CheckpointMetadataOutputStream#closeAndFinalizeCheckpoint() .
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: DispatcherTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Nonnull private URI createTestingSavepoint() throws IOException, URISyntaxException { final StateBackend stateBackend = Checkpoints.loadStateBackend(configuration, Thread.currentThread().getContextClassLoader(), log); final CheckpointStorage checkpointStorage = stateBackend.createCheckpointStorage(jobGraph.getJobID()); final File savepointFile = temporaryFolder.newFolder(); final long checkpointId = 1L; final CheckpointStorageLocation checkpointStorageLocation = checkpointStorage.initializeLocationForSavepoint(checkpointId, savepointFile.getAbsolutePath()); final CheckpointMetadataOutputStream metadataOutputStream = checkpointStorageLocation.createMetadataOutputStream(); Checkpoints.storeCheckpointMetadata(new SavepointV2(checkpointId, Collections.emptyList(), Collections.emptyList()), metadataOutputStream); final CompletedCheckpointStorageLocation completedCheckpointStorageLocation = metadataOutputStream.closeAndFinalizeCheckpoint(); return new URI(completedCheckpointStorageLocation.getExternalPointer()); }
Example 2
Source File: MemoryCheckpointStorageTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testNonPersistentCheckpointLocation() throws Exception { MemoryBackendCheckpointStorage storage = new MemoryBackendCheckpointStorage( new JobID(), null, null, DEFAULT_MAX_STATE_SIZE); CheckpointStorageLocation location = storage.initializeLocationForCheckpoint(9); CheckpointMetadataOutputStream stream = location.createMetadataOutputStream(); stream.write(99); CompletedCheckpointStorageLocation completed = stream.closeAndFinalizeCheckpoint(); StreamStateHandle handle = completed.getMetadataHandle(); assertTrue(handle instanceof ByteStreamStateHandle); // the reference is not valid in that case try { storage.resolveCheckpoint(completed.getExternalPointer()); fail("should fail with an exception"); } catch (Exception e) { // expected } }
Example 3
Source File: DispatcherTest.java From flink with Apache License 2.0 | 6 votes |
@Nonnull private URI createTestingSavepoint() throws IOException, URISyntaxException { final StateBackend stateBackend = Checkpoints.loadStateBackend(configuration, Thread.currentThread().getContextClassLoader(), log); final CheckpointStorageCoordinatorView checkpointStorage = stateBackend.createCheckpointStorage(jobGraph.getJobID()); final File savepointFile = temporaryFolder.newFolder(); final long checkpointId = 1L; final CheckpointStorageLocation checkpointStorageLocation = checkpointStorage.initializeLocationForSavepoint(checkpointId, savepointFile.getAbsolutePath()); final CheckpointMetadataOutputStream metadataOutputStream = checkpointStorageLocation.createMetadataOutputStream(); Checkpoints.storeCheckpointMetadata(new SavepointV2(checkpointId, Collections.emptyList(), Collections.emptyList()), metadataOutputStream); final CompletedCheckpointStorageLocation completedCheckpointStorageLocation = metadataOutputStream.closeAndFinalizeCheckpoint(); return new URI(completedCheckpointStorageLocation.getExternalPointer()); }
Example 4
Source File: MemoryCheckpointStorageTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testNonPersistentCheckpointLocation() throws Exception { MemoryBackendCheckpointStorage storage = new MemoryBackendCheckpointStorage( new JobID(), null, null, DEFAULT_MAX_STATE_SIZE); CheckpointStorageLocation location = storage.initializeLocationForCheckpoint(9); CheckpointMetadataOutputStream stream = location.createMetadataOutputStream(); stream.write(99); CompletedCheckpointStorageLocation completed = stream.closeAndFinalizeCheckpoint(); StreamStateHandle handle = completed.getMetadataHandle(); assertTrue(handle instanceof ByteStreamStateHandle); // the reference is not valid in that case try { storage.resolveCheckpoint(completed.getExternalPointer()); fail("should fail with an exception"); } catch (Exception e) { // expected } }
Example 5
Source File: DispatcherTest.java From flink with Apache License 2.0 | 6 votes |
@Nonnull private URI createTestingSavepoint() throws IOException, URISyntaxException { final StateBackend stateBackend = Checkpoints.loadStateBackend(configuration, Thread.currentThread().getContextClassLoader(), log); final CheckpointStorageCoordinatorView checkpointStorage = stateBackend.createCheckpointStorage(jobGraph.getJobID()); final File savepointFile = temporaryFolder.newFolder(); final long checkpointId = 1L; final CheckpointStorageLocation checkpointStorageLocation = checkpointStorage.initializeLocationForSavepoint(checkpointId, savepointFile.getAbsolutePath()); final CheckpointMetadataOutputStream metadataOutputStream = checkpointStorageLocation.createMetadataOutputStream(); Checkpoints.storeCheckpointMetadata(new CheckpointMetadata(checkpointId, Collections.emptyList(), Collections.emptyList()), metadataOutputStream); final CompletedCheckpointStorageLocation completedCheckpointStorageLocation = metadataOutputStream.closeAndFinalizeCheckpoint(); return new URI(completedCheckpointStorageLocation.getExternalPointer()); }
Example 6
Source File: MemoryCheckpointStorageTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testNonPersistentCheckpointLocation() throws Exception { MemoryBackendCheckpointStorage storage = new MemoryBackendCheckpointStorage( new JobID(), null, null, DEFAULT_MAX_STATE_SIZE); CheckpointStorageLocation location = storage.initializeLocationForCheckpoint(9); CheckpointMetadataOutputStream stream = location.createMetadataOutputStream(); stream.write(99); CompletedCheckpointStorageLocation completed = stream.closeAndFinalizeCheckpoint(); StreamStateHandle handle = completed.getMetadataHandle(); assertTrue(handle instanceof ByteStreamStateHandle); // the reference is not valid in that case try { storage.resolveCheckpoint(completed.getExternalPointer()); fail("should fail with an exception"); } catch (Exception e) { // expected } }