Java Code Examples for org.apache.flink.api.common.restartstrategy.RestartStrategies#fixedDelayRestart()
The following examples show how to use
org.apache.flink.api.common.restartstrategy.RestartStrategies#fixedDelayRestart() .
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: ExecutionConfig.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Returns the restart strategy which has been set for the current job. * * @return The specified restart configuration */ @PublicEvolving @SuppressWarnings("deprecation") public RestartStrategies.RestartStrategyConfiguration getRestartStrategy() { if (restartStrategyConfiguration instanceof RestartStrategies.FallbackRestartStrategyConfiguration) { // support the old API calls by creating a restart strategy from them if (getNumberOfExecutionRetries() > 0 && getExecutionRetryDelay() >= 0) { return RestartStrategies.fixedDelayRestart(getNumberOfExecutionRetries(), getExecutionRetryDelay()); } else if (getNumberOfExecutionRetries() == 0) { return RestartStrategies.noRestart(); } else { return restartStrategyConfiguration; } } else { return restartStrategyConfiguration; } }
Example 2
Source File: ExecutionConfig.java From flink with Apache License 2.0 | 6 votes |
/** * Returns the restart strategy which has been set for the current job. * * @return The specified restart configuration */ @PublicEvolving @SuppressWarnings("deprecation") public RestartStrategies.RestartStrategyConfiguration getRestartStrategy() { if (restartStrategyConfiguration instanceof RestartStrategies.FallbackRestartStrategyConfiguration) { // support the old API calls by creating a restart strategy from them if (getNumberOfExecutionRetries() > 0 && getExecutionRetryDelay() >= 0) { return RestartStrategies.fixedDelayRestart(getNumberOfExecutionRetries(), getExecutionRetryDelay()); } else if (getNumberOfExecutionRetries() == 0) { return RestartStrategies.noRestart(); } else { return restartStrategyConfiguration; } } else { return restartStrategyConfiguration; } }
Example 3
Source File: DataStreamAllroundTestJobFactory.java From flink with Apache License 2.0 | 6 votes |
private static void setupRestartStrategy(final StreamExecutionEnvironment env, final ParameterTool pt) { String restartStrategyConfig = pt.get(ENVIRONMENT_RESTART_STRATEGY.key()); if (restartStrategyConfig != null) { RestartStrategies.RestartStrategyConfiguration restartStrategy; switch (restartStrategyConfig) { case "fixed_delay": restartStrategy = RestartStrategies.fixedDelayRestart( pt.getInt( ENVIRONMENT_RESTART_STRATEGY_FIXED_ATTEMPTS.key(), ENVIRONMENT_RESTART_STRATEGY_FIXED_ATTEMPTS.defaultValue()), pt.getLong( ENVIRONMENT_RESTART_STRATEGY_FIXED_DELAY.key(), ENVIRONMENT_RESTART_STRATEGY_FIXED_DELAY.defaultValue())); break; case "no_restart": restartStrategy = RestartStrategies.noRestart(); break; default: throw new IllegalArgumentException("Unknown restart strategy: " + restartStrategyConfig); } env.setRestartStrategy(restartStrategy); } }
Example 4
Source File: ExecutionConfig.java From flink with Apache License 2.0 | 6 votes |
/** * Returns the restart strategy which has been set for the current job. * * @return The specified restart configuration */ @PublicEvolving @SuppressWarnings("deprecation") public RestartStrategies.RestartStrategyConfiguration getRestartStrategy() { if (restartStrategyConfiguration instanceof RestartStrategies.FallbackRestartStrategyConfiguration) { // support the old API calls by creating a restart strategy from them if (getNumberOfExecutionRetries() > 0 && getExecutionRetryDelay() >= 0) { return RestartStrategies.fixedDelayRestart(getNumberOfExecutionRetries(), getExecutionRetryDelay()); } else if (getNumberOfExecutionRetries() == 0) { return RestartStrategies.noRestart(); } else { return restartStrategyConfiguration; } } else { return restartStrategyConfiguration; } }
Example 5
Source File: DataStreamAllroundTestJobFactory.java From flink with Apache License 2.0 | 6 votes |
private static void setupRestartStrategy(final StreamExecutionEnvironment env, final ParameterTool pt) { String restartStrategyConfig = pt.get(ENVIRONMENT_RESTART_STRATEGY.key()); if (restartStrategyConfig != null) { RestartStrategies.RestartStrategyConfiguration restartStrategy; switch (restartStrategyConfig) { case "fixed_delay": restartStrategy = RestartStrategies.fixedDelayRestart( pt.getInt( ENVIRONMENT_RESTART_STRATEGY_FIXED_ATTEMPTS.key(), ENVIRONMENT_RESTART_STRATEGY_FIXED_ATTEMPTS.defaultValue()), pt.getLong( ENVIRONMENT_RESTART_STRATEGY_FIXED_DELAY.key(), ENVIRONMENT_RESTART_STRATEGY_FIXED_DELAY.defaultValue())); break; case "no_restart": restartStrategy = RestartStrategies.noRestart(); break; default: throw new IllegalArgumentException("Unknown restart strategy: " + restartStrategyConfig); } env.setRestartStrategy(restartStrategy); } }
Example 6
Source File: ExecutionConfigTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testNotOverridingRestartStrategiesWithDefaultsFromConfiguration() { ExecutionConfig config = new ExecutionConfig(); RestartStrategies.RestartStrategyConfiguration restartStrategyConfiguration = RestartStrategies.fixedDelayRestart( 10, Time.minutes(2)); config.setRestartStrategy(restartStrategyConfiguration); // mutate config according to configuration config.configure(new Configuration(), Thread.currentThread().getContextClassLoader()); assertThat(config.getRestartStrategy(), equalTo(restartStrategyConfiguration)); }
Example 7
Source File: DataStreamAllroundTestJobFactory.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public static void setupEnvironment(StreamExecutionEnvironment env, ParameterTool pt) throws Exception { // set checkpointing semantics String semantics = pt.get(TEST_SEMANTICS.key(), TEST_SEMANTICS.defaultValue()); long checkpointInterval = pt.getLong(ENVIRONMENT_CHECKPOINT_INTERVAL.key(), ENVIRONMENT_CHECKPOINT_INTERVAL.defaultValue()); CheckpointingMode checkpointingMode = semantics.equalsIgnoreCase("exactly-once") ? CheckpointingMode.EXACTLY_ONCE : CheckpointingMode.AT_LEAST_ONCE; env.enableCheckpointing(checkpointInterval, checkpointingMode); // use event time env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime); // parallelism env.setParallelism(pt.getInt(ENVIRONMENT_PARALLELISM.key(), ENVIRONMENT_PARALLELISM.defaultValue())); env.setMaxParallelism(pt.getInt(ENVIRONMENT_MAX_PARALLELISM.key(), ENVIRONMENT_MAX_PARALLELISM.defaultValue())); // restart strategy String restartStrategyConfig = pt.get(ENVIRONMENT_RESTART_STRATEGY.key()); if (restartStrategyConfig != null) { RestartStrategies.RestartStrategyConfiguration restartStrategy; switch (restartStrategyConfig) { case "fixed_delay": restartStrategy = RestartStrategies.fixedDelayRestart( pt.getInt( ENVIRONMENT_RESTART_STRATEGY_FIXED_ATTEMPTS.key(), ENVIRONMENT_RESTART_STRATEGY_FIXED_ATTEMPTS.defaultValue()), pt.getLong( ENVIRONMENT_RESTART_STRATEGY_FIXED_DELAY.key(), ENVIRONMENT_RESTART_STRATEGY_FIXED_DELAY.defaultValue())); break; case "no_restart": restartStrategy = RestartStrategies.noRestart(); break; default: throw new IllegalArgumentException("Unkown restart strategy: " + restartStrategyConfig); } env.setRestartStrategy(restartStrategy); } // state backend final String stateBackend = pt.get( STATE_BACKEND.key(), STATE_BACKEND.defaultValue()); final String checkpointDir = pt.getRequired(STATE_BACKEND_CHECKPOINT_DIR.key()); if ("file".equalsIgnoreCase(stateBackend)) { boolean asyncCheckpoints = pt.getBoolean( STATE_BACKEND_FILE_ASYNC.key(), STATE_BACKEND_FILE_ASYNC.defaultValue()); env.setStateBackend((StateBackend) new FsStateBackend(checkpointDir, asyncCheckpoints)); } else if ("rocks".equalsIgnoreCase(stateBackend)) { boolean incrementalCheckpoints = pt.getBoolean( STATE_BACKEND_ROCKS_INCREMENTAL.key(), STATE_BACKEND_ROCKS_INCREMENTAL.defaultValue()); env.setStateBackend((StateBackend) new RocksDBStateBackend(checkpointDir, incrementalCheckpoints)); } else { throw new IllegalArgumentException("Unknown backend requested: " + stateBackend); } boolean enableExternalizedCheckpoints = pt.getBoolean( ENVIRONMENT_EXTERNALIZE_CHECKPOINT.key(), ENVIRONMENT_EXTERNALIZE_CHECKPOINT.defaultValue()); if (enableExternalizedCheckpoints) { String cleanupModeConfig = pt.get( ENVIRONMENT_EXTERNALIZE_CHECKPOINT_CLEANUP.key(), ENVIRONMENT_EXTERNALIZE_CHECKPOINT_CLEANUP.defaultValue()); CheckpointConfig.ExternalizedCheckpointCleanup cleanupMode; switch (cleanupModeConfig) { case "retain": cleanupMode = CheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION; break; case "delete": cleanupMode = CheckpointConfig.ExternalizedCheckpointCleanup.DELETE_ON_CANCELLATION; break; default: throw new IllegalArgumentException("Unknown clean up mode for externalized checkpoints: " + cleanupModeConfig); } env.getCheckpointConfig().enableExternalizedCheckpoints(cleanupMode); } // make parameters available in the web interface env.getConfig().setGlobalJobParameters(pt); }