Java Code Examples for org.apache.flink.runtime.state.SnapshotDirectory#permanent()
The following examples show how to use
org.apache.flink.runtime.state.SnapshotDirectory#permanent() .
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: RocksIncrementalSnapshotStrategy.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Nonnull private SnapshotDirectory prepareLocalSnapshotDirectory(long checkpointId) throws IOException { if (localRecoveryConfig.isLocalRecoveryEnabled()) { // create a "permanent" snapshot directory for local recovery. LocalRecoveryDirectoryProvider directoryProvider = localRecoveryConfig.getLocalStateDirectoryProvider(); File directory = directoryProvider.subtaskSpecificCheckpointDirectory(checkpointId); if (!directory.exists() && !directory.mkdirs()) { throw new IOException("Local state base directory for checkpoint " + checkpointId + " already exists: " + directory); } // introduces an extra directory because RocksDB wants a non-existing directory for native checkpoints. // append localDirectoryName here to solve directory collision problem when two stateful operators chained in one task. File rdbSnapshotDir = new File(directory, localDirectoryName); if (rdbSnapshotDir.exists()) { FileUtils.deleteDirectory(rdbSnapshotDir); } Path path = new Path(rdbSnapshotDir.toURI()); // create a "permanent" snapshot directory because local recovery is active. try { return SnapshotDirectory.permanent(path); } catch (IOException ex) { try { FileUtils.deleteDirectory(directory); } catch (IOException delEx) { ex = ExceptionUtils.firstOrSuppressed(delEx, ex); } throw ex; } } else { // create a "temporary" snapshot directory because local recovery is inactive. File snapshotDir = new File(instanceBasePath, "chk-" + checkpointId); return SnapshotDirectory.temporary(snapshotDir); } }
Example 2
Source File: RocksIncrementalSnapshotStrategy.java From flink with Apache License 2.0 | 5 votes |
@Nonnull private SnapshotDirectory prepareLocalSnapshotDirectory(long checkpointId) throws IOException { if (localRecoveryConfig.isLocalRecoveryEnabled()) { // create a "permanent" snapshot directory for local recovery. LocalRecoveryDirectoryProvider directoryProvider = localRecoveryConfig.getLocalStateDirectoryProvider(); File directory = directoryProvider.subtaskSpecificCheckpointDirectory(checkpointId); if (!directory.exists() && !directory.mkdirs()) { throw new IOException("Local state base directory for checkpoint " + checkpointId + " already exists: " + directory); } // introduces an extra directory because RocksDB wants a non-existing directory for native checkpoints. // append localDirectoryName here to solve directory collision problem when two stateful operators chained in one task. File rdbSnapshotDir = new File(directory, localDirectoryName); if (rdbSnapshotDir.exists()) { FileUtils.deleteDirectory(rdbSnapshotDir); } Path path = new Path(rdbSnapshotDir.toURI()); // create a "permanent" snapshot directory because local recovery is active. try { return SnapshotDirectory.permanent(path); } catch (IOException ex) { try { FileUtils.deleteDirectory(directory); } catch (IOException delEx) { ex = ExceptionUtils.firstOrSuppressed(delEx, ex); } throw ex; } } else { // create a "temporary" snapshot directory because local recovery is inactive. File snapshotDir = new File(instanceBasePath, "chk-" + checkpointId); return SnapshotDirectory.temporary(snapshotDir); } }
Example 3
Source File: RocksIncrementalSnapshotStrategy.java From flink with Apache License 2.0 | 5 votes |
@Nonnull private SnapshotDirectory prepareLocalSnapshotDirectory(long checkpointId) throws IOException { if (localRecoveryConfig.isLocalRecoveryEnabled()) { // create a "permanent" snapshot directory for local recovery. LocalRecoveryDirectoryProvider directoryProvider = localRecoveryConfig.getLocalStateDirectoryProvider(); File directory = directoryProvider.subtaskSpecificCheckpointDirectory(checkpointId); if (!directory.exists() && !directory.mkdirs()) { throw new IOException("Local state base directory for checkpoint " + checkpointId + " does not exist and could not be created: " + directory); } // introduces an extra directory because RocksDB wants a non-existing directory for native checkpoints. // append localDirectoryName here to solve directory collision problem when two stateful operators chained in one task. File rdbSnapshotDir = new File(directory, localDirectoryName); if (rdbSnapshotDir.exists()) { FileUtils.deleteDirectory(rdbSnapshotDir); } Path path = rdbSnapshotDir.toPath(); // create a "permanent" snapshot directory because local recovery is active. try { return SnapshotDirectory.permanent(path); } catch (IOException ex) { try { FileUtils.deleteDirectory(directory); } catch (IOException delEx) { ex = ExceptionUtils.firstOrSuppressed(delEx, ex); } throw ex; } } else { // create a "temporary" snapshot directory because local recovery is inactive. File snapshotDir = new File(instanceBasePath, "chk-" + checkpointId); return SnapshotDirectory.temporary(snapshotDir); } }