Java Code Examples for org.apache.flink.runtime.state.StateBackendLoader#fromApplicationOrConfigOrDefault()
The following examples show how to use
org.apache.flink.runtime.state.StateBackendLoader#fromApplicationOrConfigOrDefault() .
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: RocksDBStateBackendFactoryTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Validates taking the application-defined file system state backend and adding with additional * parameters from the cluster configuration, but giving precedence to application-defined * parameters over configuration-defined parameters. */ @Test public void testLoadFileSystemStateBackendMixed() throws Exception { final String appCheckpointDir = new Path(tmp.newFolder().toURI()).toString(); final String checkpointDir = new Path(tmp.newFolder().toURI()).toString(); final String savepointDir = new Path(tmp.newFolder().toURI()).toString(); final String localDir1 = tmp.newFolder().getAbsolutePath(); final String localDir2 = tmp.newFolder().getAbsolutePath(); final String localDir3 = tmp.newFolder().getAbsolutePath(); final String localDir4 = tmp.newFolder().getAbsolutePath(); final boolean incremental = !CheckpointingOptions.INCREMENTAL_CHECKPOINTS.defaultValue(); final Path expectedCheckpointsPath = new Path(appCheckpointDir); final Path expectedSavepointsPath = new Path(savepointDir); final RocksDBStateBackend backend = new RocksDBStateBackend(appCheckpointDir, incremental); backend.setDbStoragePaths(localDir1, localDir2); final Configuration config = new Configuration(); config.setString(backendKey, "jobmanager"); // this should not be picked up config.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir); // this should not be picked up config.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir); config.setBoolean(CheckpointingOptions.INCREMENTAL_CHECKPOINTS, !incremental); // this should not be picked up config.setString(RocksDBOptions.LOCAL_DIRECTORIES, localDir3 + ":" + localDir4); // this should not be picked up final StateBackend loadedBackend = StateBackendLoader.fromApplicationOrConfigOrDefault(backend, config, cl, null); assertTrue(loadedBackend instanceof RocksDBStateBackend); final RocksDBStateBackend loadedRocks = (RocksDBStateBackend) loadedBackend; assertEquals(incremental, loadedRocks.isIncrementalCheckpointsEnabled()); checkPaths(loadedRocks.getDbStoragePaths(), localDir1, localDir2); AbstractFileStateBackend fsBackend = (AbstractFileStateBackend) loadedRocks.getCheckpointBackend(); assertEquals(expectedCheckpointsPath, fsBackend.getCheckpointPath()); assertEquals(expectedSavepointsPath, fsBackend.getSavepointPath()); }
Example 2
Source File: StreamTask.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private StateBackend createStateBackend() throws Exception { final StateBackend fromApplication = configuration.getStateBackend(getUserCodeClassLoader()); return StateBackendLoader.fromApplicationOrConfigOrDefault( fromApplication, getEnvironment().getTaskManagerInfo().getConfiguration(), getUserCodeClassLoader(), LOG); }
Example 3
Source File: RocksDBStateBackendFactoryTest.java From flink with Apache License 2.0 | 5 votes |
/** * Validates taking the application-defined file system state backend and adding with additional * parameters from the cluster configuration, but giving precedence to application-defined * parameters over configuration-defined parameters. */ @Test public void testLoadFileSystemStateBackendMixed() throws Exception { final String appCheckpointDir = new Path(tmp.newFolder().toURI()).toString(); final String checkpointDir = new Path(tmp.newFolder().toURI()).toString(); final String savepointDir = new Path(tmp.newFolder().toURI()).toString(); final String localDir1 = tmp.newFolder().getAbsolutePath(); final String localDir2 = tmp.newFolder().getAbsolutePath(); final String localDir3 = tmp.newFolder().getAbsolutePath(); final String localDir4 = tmp.newFolder().getAbsolutePath(); final boolean incremental = !CheckpointingOptions.INCREMENTAL_CHECKPOINTS.defaultValue(); final Path expectedCheckpointsPath = new Path(appCheckpointDir); final Path expectedSavepointsPath = new Path(savepointDir); final RocksDBStateBackend backend = new RocksDBStateBackend(appCheckpointDir, incremental); backend.setDbStoragePaths(localDir1, localDir2); final Configuration config = new Configuration(); config.setString(backendKey, "jobmanager"); // this should not be picked up config.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir); // this should not be picked up config.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir); config.setBoolean(CheckpointingOptions.INCREMENTAL_CHECKPOINTS, !incremental); // this should not be picked up config.setString(RocksDBOptions.LOCAL_DIRECTORIES, localDir3 + ":" + localDir4); // this should not be picked up final StateBackend loadedBackend = StateBackendLoader.fromApplicationOrConfigOrDefault(backend, config, cl, null); assertTrue(loadedBackend instanceof RocksDBStateBackend); final RocksDBStateBackend loadedRocks = (RocksDBStateBackend) loadedBackend; assertEquals(incremental, loadedRocks.isIncrementalCheckpointsEnabled()); checkPaths(loadedRocks.getDbStoragePaths(), localDir1, localDir2); AbstractFileStateBackend fsBackend = (AbstractFileStateBackend) loadedRocks.getCheckpointBackend(); assertEquals(expectedCheckpointsPath, fsBackend.getCheckpointPath()); assertEquals(expectedSavepointsPath, fsBackend.getSavepointPath()); }
Example 4
Source File: StreamTask.java From flink with Apache License 2.0 | 5 votes |
private StateBackend createStateBackend() throws Exception { final StateBackend fromApplication = configuration.getStateBackend(getUserCodeClassLoader()); return StateBackendLoader.fromApplicationOrConfigOrDefault( fromApplication, getEnvironment().getTaskManagerInfo().getConfiguration(), getUserCodeClassLoader(), LOG); }
Example 5
Source File: RocksDBStateBackendFactoryTest.java From flink with Apache License 2.0 | 5 votes |
/** * Validates taking the application-defined file system state backend and adding with additional * parameters from the cluster configuration, but giving precedence to application-defined * parameters over configuration-defined parameters. */ @Test public void testLoadFileSystemStateBackendMixed() throws Exception { final String appCheckpointDir = new Path(tmp.newFolder().toURI()).toString(); final String checkpointDir = new Path(tmp.newFolder().toURI()).toString(); final String savepointDir = new Path(tmp.newFolder().toURI()).toString(); final String localDir1 = tmp.newFolder().getAbsolutePath(); final String localDir2 = tmp.newFolder().getAbsolutePath(); final String localDir3 = tmp.newFolder().getAbsolutePath(); final String localDir4 = tmp.newFolder().getAbsolutePath(); final boolean incremental = !CheckpointingOptions.INCREMENTAL_CHECKPOINTS.defaultValue(); final Path expectedCheckpointsPath = new Path(appCheckpointDir); final Path expectedSavepointsPath = new Path(savepointDir); final RocksDBStateBackend backend = new RocksDBStateBackend(appCheckpointDir, incremental); backend.setDbStoragePaths(localDir1, localDir2); final Configuration config = new Configuration(); config.setString(backendKey, "jobmanager"); // this should not be picked up config.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir); // this should not be picked up config.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir); config.setBoolean(CheckpointingOptions.INCREMENTAL_CHECKPOINTS, !incremental); // this should not be picked up config.setString(RocksDBOptions.LOCAL_DIRECTORIES, localDir3 + ":" + localDir4); // this should not be picked up final StateBackend loadedBackend = StateBackendLoader.fromApplicationOrConfigOrDefault(backend, config, cl, null); assertTrue(loadedBackend instanceof RocksDBStateBackend); final RocksDBStateBackend loadedRocks = (RocksDBStateBackend) loadedBackend; assertEquals(incremental, loadedRocks.isIncrementalCheckpointsEnabled()); checkPaths(loadedRocks.getDbStoragePaths(), localDir1, localDir2); AbstractFileStateBackend fsBackend = (AbstractFileStateBackend) loadedRocks.getCheckpointBackend(); assertEquals(expectedCheckpointsPath, fsBackend.getCheckpointPath()); assertEquals(expectedSavepointsPath, fsBackend.getSavepointPath()); }
Example 6
Source File: StreamTask.java From flink with Apache License 2.0 | 5 votes |
private StateBackend createStateBackend() throws Exception { final StateBackend fromApplication = configuration.getStateBackend(getUserCodeClassLoader()); return StateBackendLoader.fromApplicationOrConfigOrDefault( fromApplication, getEnvironment().getTaskManagerInfo().getConfiguration(), getUserCodeClassLoader(), LOG); }