You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by zh...@apache.org on 2024/09/18 02:39:51 UTC
(flink) 02/02: [FLINK-36249][streaming-java] Remove RestartStrategy-related configuration getters/setters that return/set complex Java objects.
This is an automated email from the ASF dual-hosted git repository.
zhuzh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 4e825107c34d4163edb0691332877be2004b28e3
Author: JunRuiLee <jr...@gmail.com>
AuthorDate: Mon Aug 26 14:27:05 2024 +0800
[FLINK-36249][streaming-java] Remove RestartStrategy-related configuration getters/setters that return/set complex Java objects.
This closes #25256.
---
.../connector/base/sink/AsyncSinkBaseITCase.java | 6 +-
.../base/source/hybrid/HybridSourceITCase.java | 11 +-
.../source/reader/CoordinatedSourceITCase.java | 6 +-
.../reader/CoordinatedSourceRescaleITCase.java | 4 +-
.../file/sink/BatchExecutionFileSinkITCase.java | 8 +-
.../file/sink/FileSinkCompactionSwitchITCase.java | 4 +-
.../sink/StreamingExecutionFileSinkITCase.java | 7 +-
.../file/src/FileSourceTextLinesITCase.java | 4 +-
.../flink/connectors/hive/HiveTableSinkITCase.java | 4 +-
.../flink/api/common/ArchivedExecutionConfig.java | 8 +-
.../apache/flink/api/common/ExecutionConfig.java | 173 +-------
.../common/RestartStrategyDescriptionUtils.java | 114 +++++
.../common/restartstrategy/RestartStrategies.java | 476 ---------------------
.../flink/api/common/ExecutionConfigTest.java | 13 +-
.../RestartStrategyDescriptionUtilsTest.java | 122 ++++++
.../tests/DataStreamAllroundTestJobFactory.java | 30 +-
.../flink/connector/file/sink/FileSinkProgram.java | 13 +-
.../StickyAllocationAndLocalRecoveryTestJob.java | 17 +-
.../apache/flink/test/StatefulStreamingJob.java | 4 +-
.../flink/sql/tests/StreamSQLTestProgram.java | 11 +-
.../flink/fs/s3/common/S5CmdOnMinioITCase.java | 4 +-
.../flink/formats/csv/DataStreamCsvITCase.java | 4 +-
.../flink/api/java/ExecutionEnvironment.java | 55 ---
.../stream_execution_environment.rst | 2 -
flink-python/pyflink/common/execution_config.py | 37 --
.../pyflink/common/tests/test_execution_config.py | 25 +-
.../datastream/stream_execution_environment.py | 33 --
.../tests/test_stream_execution_environment.py | 9 +-
flink-python/pyflink/java_gateway.py | 1 -
.../itcases/AbstractQueryableStateTestBase.java | 27 +-
.../RestartBackoffTimeStrategyFactoryLoader.java | 72 +---
.../runtime/scheduler/DefaultSchedulerFactory.java | 3 -
.../adaptive/AdaptiveSchedulerFactory.java | 3 -
.../AdaptiveBatchSchedulerFactory.java | 1 -
.../environment/StreamExecutionEnvironment.java | 67 ---
.../executiongraph/ArchivedExecutionGraphTest.java | 5 +-
.../executiongraph/ExecutionGraphRestartTest.java | 16 +-
...estartBackoffTimeStrategyFactoryLoaderTest.java | 115 +----
.../jobmaster/JobIntermediateDatasetReuseTest.java | 7 +-
.../flink/runtime/jobmaster/JobMasterTest.java | 16 +-
.../flink/runtime/jobmaster/JobRecoveryITCase.java | 18 +-
.../runtime/minicluster/MiniClusterITCase.java | 8 +-
.../adaptive/AdaptiveSchedulerClusterITCase.java | 7 +-
.../adaptive/AdaptiveSchedulerSimpleITCase.java | 13 +-
.../flink/runtime/shuffle/ShuffleMasterTest.java | 7 +-
.../runtime/taskexecutor/TaskExecutorITCase.java | 7 +-
.../flink/streaming/api/RestartStrategyTest.java | 122 ------
.../flink/streaming/util/RestartStrategyUtils.java | 110 +++++
.../flink/api/scala/ExecutionEnvironment.scala | 51 ---
.../api/scala/StreamExecutionEnvironment.scala | 49 ---
.../utils/DummyStreamExecutionEnvironment.java | 24 --
.../runtime/stream/sql/WindowAggregateITCase.scala | 12 +-
.../stream/sql/WindowDeduplicateITCase.scala | 14 +-
.../stream/sql/WindowDistinctAggregateITCase.scala | 13 +-
.../runtime/stream/sql/WindowJoinITCase.scala | 14 +-
.../runtime/stream/sql/WindowRankITCase.scala | 14 +-
.../stream/sql/WindowTableFunctionITCase.scala | 12 +-
.../runtime/utils/StreamingWithStateTestBase.scala | 12 +-
.../testframe/testsuites/SinkTestSuiteBase.java | 4 +-
.../testframe/testsuites/SourceTestSuiteBase.java | 4 +-
.../source/lib/NumberSequenceSourceITCase.java | 4 +-
.../datastream/DataStreamBatchExecutionITCase.java | 5 +-
.../lifecycle/PartiallyFinishedSourcesITCase.java | 4 +-
.../operators/lifecycle/graph/TestJobBuilders.java | 4 +-
.../ApproximateLocalRecoveryDownstreamITCase.java | 16 +-
.../test/checkpointing/AutoRescalingITCase.java | 8 +-
.../ChangelogLocalRecoveryITCase.java | 6 +-
.../checkpointing/ChangelogRecoveryITCaseBase.java | 6 +-
.../CheckpointAfterAllTasksFinishedITCase.java | 6 +-
.../CheckpointFailureManagerITCase.java | 6 +-
.../CheckpointRestoreWithUidHashITCase.java | 4 +-
.../test/checkpointing/CheckpointStoreITCase.java | 5 +-
.../checkpointing/CoStreamCheckpointingITCase.java | 4 +-
.../EventTimeAllWindowCheckpointingITCase.java | 10 +-
.../EventTimeWindowCheckpointingITCase.java | 12 +-
.../checkpointing/IgnoreInFlightDataITCase.java | 4 +-
.../IncrementalStateReuseAfterFailureITCase.java | 4 +-
.../KeyedStateCheckpointingITCase.java | 4 +-
.../ProcessingTimeWindowCheckpointingITCase.java | 10 +-
.../RescaleCheckpointManuallyITCase.java | 4 +-
.../flink/test/checkpointing/RescalingITCase.java | 8 +-
.../ResumeCheckpointManuallyITCase.java | 4 +-
.../flink/test/checkpointing/SavepointITCase.java | 18 +-
.../test/checkpointing/StateHandleReuseITCase.java | 4 +-
.../StatefulJobSnapshotMigrationITCase.java | 4 +-
.../StatefulJobWBroadcastStateMigrationITCase.java | 4 +-
.../StreamCheckpointNotifierITCase.java | 4 +-
.../StreamFaultToleranceTestBase.java | 4 +-
.../UnalignedCheckpointCompatibilityITCase.java | 4 +-
.../UnalignedCheckpointStressITCase.java | 4 +-
.../checkpointing/UnalignedCheckpointTestBase.java | 8 +-
.../jar/CheckpointedStreamingProgram.java | 4 +-
.../jar/CheckpointingCustomKvStateProgram.java | 4 +-
.../execution/JobStatusChangedListenerITCase.java | 4 +-
...tractTaskManagerProcessFailureRecoveryTest.java | 5 +
.../recovery/BatchFineGrainedRecoveryITCase.java | 12 +-
.../flink/test/recovery/FastFailuresITCase.java | 4 +-
.../JobManagerHAProcessFailureRecoveryITCase.java | 10 +-
.../recovery/ProcessFailureCancelingITCase.java | 8 +-
.../test/recovery/SimpleRecoveryITCaseBase.java | 11 +-
...skManagerProcessFailureBatchRecoveryITCase.java | 3 -
...nagerProcessFailureStreamingRecoveryITCase.java | 4 +-
.../flink/test/runtime/BatchShuffleITCaseBase.java | 4 +-
.../DefaultSchedulerLocalRecoveryITCase.java | 16 +-
.../flink/test/runtime/SchedulingITCase.java | 15 +-
.../test/runtime/entrypoint/StreamingNoop.java | 4 +-
.../ZooKeeperLeaderElectionITCase.java | 18 +-
.../test/scheduling/AdaptiveSchedulerITCase.java | 15 +-
.../flink/test/scheduling/ReactiveModeITCase.java | 4 +-
.../TaskManagerWideRocksDbMemorySharingITCase.java | 4 +-
.../restore/AbstractOperatorRestoreTestBase.java | 4 +-
.../state/operator/restore/keyed/KeyedJob.java | 4 +-
.../operator/restore/unkeyed/NonKeyedJob.java | 4 +-
.../ReinterpretDataStreamAsKeyedStreamITCase.java | 4 +-
.../streaming/runtime/LatencyMarkerITCase.java | 4 +-
.../test/streaming/runtime/StateBackendITCase.java | 4 +-
.../runtime/UnifiedSinkMigrationITCase.java | 4 +-
117 files changed, 764 insertions(+), 1657 deletions(-)
diff --git a/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/sink/AsyncSinkBaseITCase.java b/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/sink/AsyncSinkBaseITCase.java
index 4d83093a820..e3880abade2 100644
--- a/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/sink/AsyncSinkBaseITCase.java
+++ b/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/sink/AsyncSinkBaseITCase.java
@@ -17,10 +17,10 @@
package org.apache.flink.connector.base.sink;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.runtime.client.JobExecutionException;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.junit5.MiniClusterExtension;
import org.apache.flink.util.TestLoggerExtension;
@@ -28,8 +28,6 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;
-import java.time.Duration;
-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/** Integration tests of a baseline generic sink that implements the AsyncSinkBase. */
@@ -67,7 +65,7 @@ public class AsyncSinkBaseITCase {
@Test
public void testThatNoIssuesOccurWhenCheckpointingIsEnabled() throws Exception {
env.enableCheckpointing(20);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, Duration.ofMillis(200)));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 200);
env.fromSequence(1, 10_000).map(Object::toString).sinkTo(new ArrayListAsyncSink());
env.execute("Integration Test: AsyncSinkBaseITCase");
}
diff --git a/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/hybrid/HybridSourceITCase.java b/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/hybrid/HybridSourceITCase.java
index ae04ce6c9ae..fc172af7f27 100644
--- a/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/hybrid/HybridSourceITCase.java
+++ b/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/hybrid/HybridSourceITCase.java
@@ -20,7 +20,6 @@ package org.apache.flink.connector.base.source.hybrid;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.connector.source.Boundedness;
import org.apache.flink.api.connector.source.Source;
import org.apache.flink.connector.base.source.reader.mocks.MockBaseSource;
@@ -32,6 +31,7 @@ import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamUtils;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.operators.collect.ClientAndIterator;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.util.TestLogger;
@@ -122,10 +122,11 @@ public class HybridSourceITCase extends TestLogger {
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
- env.setRestartStrategy(
- FailoverType.NONE == failoverType
- ? RestartStrategies.noRestart()
- : RestartStrategies.fixedDelayRestart(1, 0));
+ if (FailoverType.NONE == failoverType) {
+ RestartStrategyUtils.configureNoRestartStrategy(env);
+ } else {
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0);
+ }
final DataStream<Integer> stream =
env.fromSource(source, WatermarkStrategy.noWatermarks(), "hybrid-source")
diff --git a/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/reader/CoordinatedSourceITCase.java b/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/reader/CoordinatedSourceITCase.java
index 6d3a736cb2e..af8fa8026ef 100644
--- a/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/reader/CoordinatedSourceITCase.java
+++ b/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/reader/CoordinatedSourceITCase.java
@@ -21,7 +21,6 @@ package org.apache.flink.connector.base.source.reader;
import org.apache.flink.api.common.accumulators.ListAccumulator;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.api.common.functions.OpenContext;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.connector.source.Boundedness;
import org.apache.flink.api.connector.source.Source;
import org.apache.flink.api.connector.source.SplitEnumerator;
@@ -32,6 +31,7 @@ import org.apache.flink.connector.base.source.reader.mocks.MockSplitEnumerator;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.AbstractTestBaseJUnit4;
import org.apache.flink.util.FlinkRuntimeException;
@@ -74,7 +74,7 @@ public class CoordinatedSourceITCase extends AbstractTestBaseJUnit4 {
OnceFailingToCreateEnumeratorSource.reset();
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 0L);
final Source<Integer, ?, ?> source =
new OnceFailingToCreateEnumeratorSource(2, 10, Boundedness.BOUNDED);
final DataStream<Integer> stream =
@@ -87,7 +87,7 @@ public class CoordinatedSourceITCase extends AbstractTestBaseJUnit4 {
OnceFailingToRestoreEnumeratorSource.reset();
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 0L);
env.enableCheckpointing(10);
final Source<Integer, ?, ?> source =
diff --git a/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/reader/CoordinatedSourceRescaleITCase.java b/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/reader/CoordinatedSourceRescaleITCase.java
index 6a805a22d1a..7368214b30d 100644
--- a/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/reader/CoordinatedSourceRescaleITCase.java
+++ b/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/source/reader/CoordinatedSourceRescaleITCase.java
@@ -18,7 +18,6 @@
package org.apache.flink.connector.base.source.reader;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.configuration.CheckpointingOptions;
import org.apache.flink.configuration.Configuration;
@@ -30,6 +29,7 @@ import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.SinkFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.util.TestLogger;
@@ -124,7 +124,7 @@ public class CoordinatedSourceRescaleITCase extends TestLogger {
env.getCheckpointConfig()
.setExternalizedCheckpointRetention(
ExternalizedCheckpointRetention.RETAIN_ON_CANCELLATION);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
DataStream<Long> stream = env.fromSequence(0, Long.MAX_VALUE);
stream.map(new FailingMapFunction(restoreCheckpoint == null)).addSink(new SleepySink());
diff --git a/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/sink/BatchExecutionFileSinkITCase.java b/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/sink/BatchExecutionFileSinkITCase.java
index e16ebb1fe78..c6741e40759 100644
--- a/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/sink/BatchExecutionFileSinkITCase.java
+++ b/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/sink/BatchExecutionFileSinkITCase.java
@@ -20,7 +20,6 @@ package org.apache.flink.connector.file.sink;
import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
import org.apache.flink.api.connector.source.Boundedness;
import org.apache.flink.configuration.Configuration;
@@ -32,8 +31,7 @@ import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
import org.apache.flink.streaming.api.graph.StreamGraph;
import org.apache.flink.streaming.api.operators.StreamSource;
-
-import java.time.Duration;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
/** Tests the functionality of the {@link FileSink} in BATCH mode. */
class BatchExecutionFileSinkITCase extends FileSinkITBase {
@@ -50,9 +48,9 @@ class BatchExecutionFileSinkITCase extends FileSinkITBase {
env.configure(config, getClass().getClassLoader());
if (triggerFailover) {
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, Duration.ofMillis(100)));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 100);
} else {
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
}
// Create a testing job with a bounded legacy source in a bit hacky way.
diff --git a/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/sink/FileSinkCompactionSwitchITCase.java b/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/sink/FileSinkCompactionSwitchITCase.java
index 953b8d6833c..0f06fcf4f3b 100644
--- a/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/sink/FileSinkCompactionSwitchITCase.java
+++ b/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/sink/FileSinkCompactionSwitchITCase.java
@@ -19,7 +19,6 @@
package org.apache.flink.connector.file.sink;
import org.apache.flink.api.common.RuntimeExecutionMode;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
import org.apache.flink.configuration.Configuration;
@@ -53,6 +52,7 @@ import org.apache.flink.streaming.api.checkpoint.CheckpointedFunction;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
import org.apache.flink.streaming.api.graph.StreamGraph;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.junit5.MiniClusterExtension;
import org.apache.flink.testutils.junit.SharedObjectsExtension;
import org.apache.flink.testutils.junit.SharedReference;
@@ -222,7 +222,7 @@ public class FileSinkCompactionSwitchITCase {
env.configure(config, getClass().getClassLoader());
env.enableCheckpointing(100, CheckpointingMode.EXACTLY_ONCE);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.getCheckpointConfig().setCheckpointStorage(new FileSystemCheckpointStorage(cpPath));
env.setStateBackend(new HashMapStateBackend());
diff --git a/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/sink/StreamingExecutionFileSinkITCase.java b/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/sink/StreamingExecutionFileSinkITCase.java
index 1ea0a7b5922..6a21fea3ec2 100644
--- a/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/sink/StreamingExecutionFileSinkITCase.java
+++ b/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/sink/StreamingExecutionFileSinkITCase.java
@@ -19,7 +19,6 @@
package org.apache.flink.connector.file.sink;
import org.apache.flink.api.common.RuntimeExecutionMode;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
import org.apache.flink.configuration.Configuration;
@@ -34,11 +33,11 @@ import org.apache.flink.streaming.api.datastream.DataStreamSink;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
import org.apache.flink.streaming.api.graph.StreamGraph;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
-import java.time.Duration;
import java.util.Collections;
import java.util.Map;
import java.util.UUID;
@@ -82,9 +81,9 @@ class StreamingExecutionFileSinkITCase extends FileSinkITBase {
env.enableCheckpointing(10, CheckpointingMode.EXACTLY_ONCE);
if (triggerFailover) {
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, Duration.ofMillis(100)));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 100);
} else {
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
}
DataStreamSink<Integer> sink =
diff --git a/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/src/FileSourceTextLinesITCase.java b/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/src/FileSourceTextLinesITCase.java
index f0ff3fb5cb2..101a212b86b 100644
--- a/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/src/FileSourceTextLinesITCase.java
+++ b/flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/src/FileSourceTextLinesITCase.java
@@ -21,7 +21,6 @@ package org.apache.flink.connector.file.src;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.configuration.BatchExecutionOptions;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.connector.file.src.reader.TextLineInputFormat;
@@ -36,6 +35,7 @@ import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamUtils;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.operators.collect.ClientAndIterator;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.junit5.InjectMiniCluster;
import org.apache.flink.test.junit5.MiniClusterExtension;
import org.apache.flink.test.util.MiniClusterWithClientResource;
@@ -148,7 +148,7 @@ class FileSourceTextLinesITCase {
.build();
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.setParallelism(PARALLELISM);
if (batchMode) {
diff --git a/flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveTableSinkITCase.java b/flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveTableSinkITCase.java
index 573facf4881..fcde2042cce 100644
--- a/flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveTableSinkITCase.java
+++ b/flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveTableSinkITCase.java
@@ -19,7 +19,6 @@
package org.apache.flink.connectors.hive;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.api.java.typeutils.RowTypeInfo;
import org.apache.flink.connector.datagen.source.TestDataGenerators;
@@ -27,6 +26,7 @@ import org.apache.flink.connector.file.table.FileSystemConnectorOptions;
import org.apache.flink.core.fs.Path;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.table.api.DataTypes;
import org.apache.flink.table.api.ExplainDetail;
import org.apache.flink.table.api.Expressions;
@@ -774,7 +774,7 @@ class HiveTableSinkITCase {
env.setParallelism(1);
env.enableCheckpointing(100);
// avoid the job to restart infinitely
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(3, 1_000));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 3, 1000L);
StreamTableEnvironment tEnv = HiveTestUtils.createTableEnvInStreamingMode(env);
tEnv.registerCatalog(hiveCatalog.getName(), hiveCatalog);
diff --git a/flink-core/src/main/java/org/apache/flink/api/common/ArchivedExecutionConfig.java b/flink-core/src/main/java/org/apache/flink/api/common/ArchivedExecutionConfig.java
index a2690c0d351..aa37a52d852 100644
--- a/flink-core/src/main/java/org/apache/flink/api/common/ArchivedExecutionConfig.java
+++ b/flink-core/src/main/java/org/apache/flink/api/common/ArchivedExecutionConfig.java
@@ -44,11 +44,9 @@ public class ArchivedExecutionConfig implements Serializable {
public ArchivedExecutionConfig(ExecutionConfig ec) {
executionMode = ec.getExecutionMode().name();
- if (ec.getRestartStrategy() != null) {
- restartStrategyDescription = ec.getRestartStrategy().getDescription();
- } else {
- restartStrategyDescription = "default";
- }
+ restartStrategyDescription =
+ RestartStrategyDescriptionUtils.getRestartStrategyDescription(ec.toConfiguration());
+
maxParallelism = ec.getMaxParallelism();
parallelism = ec.getParallelism();
objectReuseEnabled = ec.isObjectReuseEnabled();
diff --git a/flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java b/flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java
index ff605284b80..e3f1aab193f 100644
--- a/flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java
+++ b/flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java
@@ -22,7 +22,6 @@ import org.apache.flink.annotation.Experimental;
import org.apache.flink.annotation.Internal;
import org.apache.flink.annotation.Public;
import org.apache.flink.annotation.PublicEvolving;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.serialization.SerializerConfig;
import org.apache.flink.api.common.serialization.SerializerConfigImpl;
import org.apache.flink.configuration.ConfigOption;
@@ -109,8 +108,6 @@ public class ExecutionConfig implements Serializable, Archiveable<ArchivedExecut
*/
public static final int PARALLELISM_UNKNOWN = -2;
- private static final long DEFAULT_RESTART_DELAY = 10000L;
-
/**
* Internal {@link ConfigOption}s, that are not exposed and it's not possible to configure them
* via config files. We are defining them here, so that we can store them in the {@link
@@ -127,17 +124,6 @@ public class ExecutionConfig implements Serializable, Archiveable<ArchivedExecut
.defaultValue(ExecutionMode.PIPELINED)
.withDescription("Defines how data exchange happens - batch or pipelined");
- /**
- * Use {@link
- * org.apache.flink.api.common.restartstrategy.RestartStrategies.RestartStrategyConfiguration}
- */
- @Deprecated
- private static final ConfigOption<Integer> EXECUTION_RETRIES =
- key("hidden.execution.retries")
- .intType()
- .defaultValue(-1)
- .withDescription(
- "Should no longer be used because it is subsumed by RestartStrategyConfiguration");
// --------------------------------------------------------------------------------------------
/**
@@ -153,23 +139,6 @@ public class ExecutionConfig implements Serializable, Archiveable<ArchivedExecut
return serializerConfig;
}
- /**
- * @deprecated Should no longer be used because it is subsumed by RestartStrategyConfiguration
- */
- @Deprecated private long executionRetryDelay = DEFAULT_RESTART_DELAY;
-
- /**
- * @deprecated The field is marked as deprecated because starting from Flink 1.19, the usage of
- * all complex Java objects related to configuration, including their getter and setter
- * methods, should be replaced by ConfigOption. In a future major version of Flink, this
- * method will be removed entirely. It is recommended to switch to using the ConfigOptions
- * provided by {@link org.apache.flink.configuration.RestartStrategyOptions} for configuring
- * restart strategies.
- */
- @Deprecated
- private RestartStrategies.RestartStrategyConfiguration restartStrategyConfiguration =
- new RestartStrategies.FallbackRestartStrategyConfiguration();
-
public ExecutionConfig() {
this(new Configuration());
}
@@ -438,131 +407,11 @@ public class ExecutionConfig implements Serializable, Archiveable<ArchivedExecut
return this;
}
- /**
- * Sets the restart strategy to be used for recovery.
- *
- * <pre>{@code
- * ExecutionConfig config = env.getConfig();
- *
- * config.setRestartStrategy(RestartStrategies.fixedDelayRestart(
- * 10, // number of retries
- * 1000 // delay between retries));
- * }</pre>
- *
- * @deprecated The method is marked as deprecated because starting from Flink 1.19, the usage of
- * all complex Java objects related to configuration, including their getter and setter
- * methods, should be replaced by ConfigOption. In a future major version of Flink, this
- * method will be removed entirely. It is recommended to switch to using the ConfigOptions
- * provided by {@link org.apache.flink.configuration.RestartStrategyOptions} for configuring
- * restart strategies.
- * @param restartStrategyConfiguration Configuration defining the restart strategy to use
- */
- @Deprecated
- @PublicEvolving
- public void setRestartStrategy(
- RestartStrategies.RestartStrategyConfiguration restartStrategyConfiguration) {
- this.restartStrategyConfiguration =
- Preconditions.checkNotNull(restartStrategyConfiguration);
- }
-
- /**
- * Returns the restart strategy which has been set for the current job.
- *
- * @deprecated The method is marked as deprecated because starting from Flink 1.19, the usage of
- * all complex Java objects related to configuration, including their getter and setter
- * methods, should be replaced by ConfigOption. In a future major version of Flink, this
- * method will be removed entirely. It is recommended to switch to using the ConfigOptions
- * provided by {@link org.apache.flink.configuration.RestartStrategyOptions} for configuring
- * restart strategies.
- * @return The specified restart configuration
- */
- @Deprecated
- @PublicEvolving
- 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;
- }
- }
-
@Internal
public Optional<SchedulerType> getSchedulerType() {
return configuration.getOptional(JobManagerOptions.SCHEDULER);
}
- /**
- * Gets the number of times the system will try to re-execute failed tasks. A value of {@code
- * -1} indicates that the system default value (as defined in the configuration) should be used.
- *
- * @return The number of times the system will try to re-execute failed tasks.
- * @deprecated Should no longer be used because it is subsumed by RestartStrategyConfiguration
- */
- @Deprecated
- public int getNumberOfExecutionRetries() {
- return configuration.get(EXECUTION_RETRIES);
- }
-
- /**
- * Returns the delay between execution retries.
- *
- * @return The delay between successive execution retries in milliseconds.
- * @deprecated Should no longer be used because it is subsumed by RestartStrategyConfiguration
- */
- @Deprecated
- public long getExecutionRetryDelay() {
- return executionRetryDelay;
- }
-
- /**
- * Sets the number of times that failed tasks are re-executed. A value of zero effectively
- * disables fault tolerance. A value of {@code -1} indicates that the system default value (as
- * defined in the configuration) should be used.
- *
- * @param numberOfExecutionRetries The number of times the system will try to re-execute failed
- * tasks.
- * @return The current execution configuration
- * @deprecated This method will be replaced by {@link #setRestartStrategy}. The {@link
- * RestartStrategies.FixedDelayRestartStrategyConfiguration} contains the number of
- * execution retries.
- */
- @Deprecated
- public ExecutionConfig setNumberOfExecutionRetries(int numberOfExecutionRetries) {
- if (numberOfExecutionRetries < -1) {
- throw new IllegalArgumentException(
- "The number of execution retries must be non-negative, or -1 (use system default)");
- }
- configuration.set(EXECUTION_RETRIES, numberOfExecutionRetries);
- return this;
- }
-
- /**
- * Sets the delay between executions.
- *
- * @param executionRetryDelay The number of milliseconds the system will wait to retry.
- * @return The current execution configuration
- * @deprecated This method will be replaced by {@link #setRestartStrategy}. The {@link
- * RestartStrategies.FixedDelayRestartStrategyConfiguration} contains the delay between
- * successive execution attempts.
- */
- @Deprecated
- public ExecutionConfig setExecutionRetryDelay(long executionRetryDelay) {
- if (executionRetryDelay < 0) {
- throw new IllegalArgumentException("The delay between retries must be non-negative.");
- }
- this.executionRetryDelay = executionRetryDelay;
- return this;
- }
-
/**
* Sets the execution mode to execute the program. The execution mode defines whether data
* exchanges are performed in a batch or on a pipelined manner.
@@ -1130,13 +979,7 @@ public class ExecutionConfig implements Serializable, Archiveable<ArchivedExecut
ExecutionConfig other = (ExecutionConfig) obj;
return Objects.equals(configuration, other.configuration)
- && Objects.equals(serializerConfig, other.serializerConfig)
- && ((restartStrategyConfiguration == null
- && other.restartStrategyConfiguration == null)
- || (null != restartStrategyConfiguration
- && restartStrategyConfiguration.equals(
- other.restartStrategyConfiguration)));
-
+ && Objects.equals(serializerConfig, other.serializerConfig);
} else {
return false;
}
@@ -1144,7 +987,7 @@ public class ExecutionConfig implements Serializable, Archiveable<ArchivedExecut
@Override
public int hashCode() {
- return Objects.hash(configuration, serializerConfig, restartStrategyConfiguration);
+ return Objects.hash(configuration, serializerConfig);
}
@Override
@@ -1154,10 +997,6 @@ public class ExecutionConfig implements Serializable, Archiveable<ArchivedExecut
+ configuration
+ ", serializerConfig="
+ serializerConfig
- + ", executionRetryDelay="
- + executionRetryDelay
- + ", restartStrategyConfiguration="
- + restartStrategyConfiguration
+ '}';
}
@@ -1317,13 +1156,7 @@ public class ExecutionConfig implements Serializable, Archiveable<ArchivedExecut
.ifPresent(this::setUseSnapshotCompression);
configuration
.getOptional(RestartStrategyOptions.RESTART_STRATEGY)
- .ifPresent(
- s -> {
- this.setRestartStrategy(configuration);
- // reset RestartStrategies for backward compatibility
- this.setRestartStrategy(
- new RestartStrategies.FallbackRestartStrategyConfiguration());
- });
+ .ifPresent(s -> this.setRestartStrategy(configuration));
configuration
.getOptional(JobManagerOptions.SCHEDULER)
diff --git a/flink-core/src/main/java/org/apache/flink/api/common/RestartStrategyDescriptionUtils.java b/flink-core/src/main/java/org/apache/flink/api/common/RestartStrategyDescriptionUtils.java
new file mode 100644
index 00000000000..64ce42e18b4
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/common/RestartStrategyDescriptionUtils.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.api.common;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.RestartStrategyOptions;
+
+import java.time.Duration;
+import java.util.Optional;
+
+/** Utility class for describing restart strategies. */
+@Internal
+public class RestartStrategyDescriptionUtils {
+
+ /**
+ * Returns a descriptive string of the restart strategy configured in the given Configuration
+ * object.
+ *
+ * @param configuration the Configuration to extract the restart strategy from
+ * @return a description of the restart strategy
+ */
+ public static String getRestartStrategyDescription(Configuration configuration) {
+ final Optional<String> restartStrategyNameOptional =
+ configuration.getOptional(RestartStrategyOptions.RESTART_STRATEGY);
+
+ return restartStrategyNameOptional
+ .map(
+ restartStrategyName -> {
+ switch (RestartStrategyOptions.RestartStrategyType.of(
+ restartStrategyName.toLowerCase())) {
+ case NO_RESTART_STRATEGY:
+ return "Restart deactivated.";
+ case FIXED_DELAY:
+ return getFixedDelayDescription(configuration);
+ case FAILURE_RATE:
+ return getFailureRateDescription(configuration);
+ case EXPONENTIAL_DELAY:
+ return getExponentialDelayDescription(configuration);
+ default:
+ throw new IllegalArgumentException(
+ "Unknown restart strategy "
+ + restartStrategyName
+ + ".");
+ }
+ })
+ .orElse("Cluster level default restart strategy");
+ }
+
+ private static String getExponentialDelayDescription(Configuration configuration) {
+ Duration initialBackoff =
+ configuration.get(
+ RestartStrategyOptions.RESTART_STRATEGY_EXPONENTIAL_DELAY_INITIAL_BACKOFF);
+ Duration maxBackoff =
+ configuration.get(
+ RestartStrategyOptions.RESTART_STRATEGY_EXPONENTIAL_DELAY_MAX_BACKOFF);
+ double backoffMultiplier =
+ configuration.get(
+ RestartStrategyOptions
+ .RESTART_STRATEGY_EXPONENTIAL_DELAY_BACKOFF_MULTIPLIER);
+ Duration resetBackoffThreshold =
+ configuration.get(
+ RestartStrategyOptions
+ .RESTART_STRATEGY_EXPONENTIAL_DELAY_RESET_BACKOFF_THRESHOLD);
+ double jitter =
+ configuration.get(
+ RestartStrategyOptions.RESTART_STRATEGY_EXPONENTIAL_DELAY_JITTER_FACTOR);
+ return String.format(
+ "Restart with exponential delay: starting at %s, increasing by %f, with maximum %s. "
+ + "Delay resets after %s with jitter %f",
+ initialBackoff, backoffMultiplier, maxBackoff, resetBackoffThreshold, jitter);
+ }
+
+ private static String getFailureRateDescription(Configuration configuration) {
+ int maxFailures =
+ configuration.get(
+ RestartStrategyOptions
+ .RESTART_STRATEGY_FAILURE_RATE_MAX_FAILURES_PER_INTERVAL);
+ Duration failureRateInterval =
+ configuration.get(
+ RestartStrategyOptions.RESTART_STRATEGY_FAILURE_RATE_FAILURE_RATE_INTERVAL);
+ Duration failureRateDelay =
+ configuration.get(RestartStrategyOptions.RESTART_STRATEGY_FAILURE_RATE_DELAY);
+
+ return String.format(
+ "Failure rate restart with maximum of %d failures within interval %s and fixed delay %s.",
+ maxFailures, failureRateInterval, failureRateDelay);
+ }
+
+ private static String getFixedDelayDescription(Configuration configuration) {
+ int attempts =
+ configuration.get(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS);
+ Duration delay =
+ configuration.get(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY);
+ return String.format(
+ "Restart with fixed delay (%s). #%d restart attempts.", delay, attempts);
+ }
+}
diff --git a/flink-core/src/main/java/org/apache/flink/api/common/restartstrategy/RestartStrategies.java b/flink-core/src/main/java/org/apache/flink/api/common/restartstrategy/RestartStrategies.java
deleted file mode 100644
index 1dd56fdb55a..00000000000
--- a/flink-core/src/main/java/org/apache/flink/api/common/restartstrategy/RestartStrategies.java
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.api.common.restartstrategy;
-
-import org.apache.flink.annotation.PublicEvolving;
-import org.apache.flink.configuration.ReadableConfig;
-import org.apache.flink.configuration.RestartStrategyOptions;
-import org.apache.flink.configuration.RestartStrategyOptions.RestartStrategyType;
-
-import java.io.Serializable;
-import java.time.Duration;
-import java.util.Objects;
-import java.util.Optional;
-
-/**
- * This class defines methods to generate RestartStrategyConfigurations. These configurations are
- * used to create RestartStrategies at runtime.
- *
- * <p>The RestartStrategyConfigurations are used to decouple the core module from the runtime
- * module.
- *
- * @deprecated The {@link RestartStrategies} class is marked as deprecated because starting from
- * Flink 1.19, all complex Java objects related to configuration should be replaced by
- * ConfigOption. In a future major version of Flink, this class will be removed entirely. It is
- * recommended to switch to using the ConfigOptions provided by {@link
- * org.apache.flink.configuration.RestartStrategyOptions} for configuring restart strategies
- * like the following code snippet:
- * <pre>{@code
- * Configuration config = new Configuration();
- * config.set(RestartStrategyOptions.RESTART_STRATEGY, "fixed-delay");
- * config.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, 3);
- * config.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY, Duration.ofMinutes(1));
- * StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(config);
- * }</pre>
- * For more details on using ConfigOption for restart strategies, please refer to the Flink
- * documentation: <a
- * href="https://nightlies.apache.org/flink/flink-docs-stable/docs/ops/state/task_failure_recovery/#restart-strategies">restart-strategies</a>
- */
-@Deprecated
-@PublicEvolving
-public class RestartStrategies {
-
- /**
- * Generates NoRestartStrategyConfiguration.
- *
- * @return NoRestartStrategyConfiguration
- */
- public static RestartStrategyConfiguration noRestart() {
- return new NoRestartStrategyConfiguration();
- }
-
- public static RestartStrategyConfiguration fallBackRestart() {
- return new FallbackRestartStrategyConfiguration();
- }
-
- /**
- * Generates a FixedDelayRestartStrategyConfiguration.
- *
- * @param restartAttempts Number of restart attempts for the FixedDelayRestartStrategy
- * @param delayBetweenAttempts Delay in-between restart attempts for the
- * FixedDelayRestartStrategy
- * @return FixedDelayRestartStrategy
- */
- public static RestartStrategyConfiguration fixedDelayRestart(
- int restartAttempts, long delayBetweenAttempts) {
- return fixedDelayRestart(restartAttempts, Duration.ofMillis(delayBetweenAttempts));
- }
-
- /**
- * Generates a FixedDelayRestartStrategyConfiguration.
- *
- * @param restartAttempts Number of restart attempts for the FixedDelayRestartStrategy
- * @param delayInterval Delay in-between restart attempts for the FixedDelayRestartStrategy
- * @return FixedDelayRestartStrategy
- */
- public static RestartStrategyConfiguration fixedDelayRestart(
- int restartAttempts, Duration delayInterval) {
- return new FixedDelayRestartStrategyConfiguration(restartAttempts, delayInterval);
- }
-
- /**
- * Generates a FailureRateRestartStrategyConfiguration.
- *
- * @param failureRate Maximum number of restarts in given interval {@code failureInterval}
- * before failing a job
- * @param failureInterval Time interval for failures
- * @param delayInterval Delay in-between restart attempts
- */
- public static FailureRateRestartStrategyConfiguration failureRateRestart(
- int failureRate, Duration failureInterval, Duration delayInterval) {
- return new FailureRateRestartStrategyConfiguration(
- failureRate, failureInterval, delayInterval);
- }
-
- /**
- * Generates a ExponentialDelayRestartStrategyConfiguration.
- *
- * @param initialBackoff Starting duration between restarts
- * @param maxBackoff The highest possible duration between restarts
- * @param backoffMultiplier Delay multiplier how many times is the delay longer than before
- * @param resetBackoffThreshold How long the job must run smoothly to reset the time interval
- * @param jitterFactor How much the delay may differ (in percentage)
- */
- public static ExponentialDelayRestartStrategyConfiguration exponentialDelayRestart(
- Duration initialBackoff,
- Duration maxBackoff,
- double backoffMultiplier,
- Duration resetBackoffThreshold,
- double jitterFactor) {
- return new ExponentialDelayRestartStrategyConfiguration(
- initialBackoff, maxBackoff, backoffMultiplier, resetBackoffThreshold, jitterFactor);
- }
-
- /** Abstract configuration for restart strategies. */
- @PublicEvolving
- public abstract static class RestartStrategyConfiguration implements Serializable {
- private static final long serialVersionUID = 6285853591578313960L;
-
- private RestartStrategyConfiguration() {}
-
- /**
- * Returns a description which is shown in the web interface.
- *
- * @return Description of the restart strategy
- */
- public abstract String getDescription();
-
- @Override
- public String toString() {
- return getDescription();
- }
- }
-
- /** Configuration representing no restart strategy. */
- @PublicEvolving
- public static final class NoRestartStrategyConfiguration extends RestartStrategyConfiguration {
- private static final long serialVersionUID = -5894362702943349962L;
-
- @Override
- public String getDescription() {
- return "Restart deactivated.";
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- return o instanceof NoRestartStrategyConfiguration;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash();
- }
- }
-
- /** Configuration representing a fixed delay restart strategy. */
- @PublicEvolving
- public static final class FixedDelayRestartStrategyConfiguration
- extends RestartStrategyConfiguration {
- private static final long serialVersionUID = 4149870149673363190L;
-
- private final int restartAttempts;
- private final Duration delayBetweenAttemptsInterval;
-
- FixedDelayRestartStrategyConfiguration(
- int restartAttempts, Duration delayBetweenAttemptsInterval) {
- this.restartAttempts = restartAttempts;
- this.delayBetweenAttemptsInterval = delayBetweenAttemptsInterval;
- }
-
- public int getRestartAttempts() {
- return restartAttempts;
- }
-
- public Duration getDurationBetweenAttempts() {
- return delayBetweenAttemptsInterval;
- }
-
- @Override
- public int hashCode() {
- int result = restartAttempts;
- result =
- 31 * result
- + (delayBetweenAttemptsInterval != null
- ? delayBetweenAttemptsInterval.hashCode()
- : 0);
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof FixedDelayRestartStrategyConfiguration) {
- FixedDelayRestartStrategyConfiguration other =
- (FixedDelayRestartStrategyConfiguration) obj;
-
- return restartAttempts == other.restartAttempts
- && delayBetweenAttemptsInterval.equals(other.delayBetweenAttemptsInterval);
- } else {
- return false;
- }
- }
-
- @Override
- public String getDescription() {
- return String.format(
- "Restart with fixed delay (%s). #%d restart attempts.",
- delayBetweenAttemptsInterval, restartAttempts);
- }
- }
-
- /** Configuration representing an exponential delay restart strategy. */
- @PublicEvolving
- public static final class ExponentialDelayRestartStrategyConfiguration
- extends RestartStrategyConfiguration {
- private static final long serialVersionUID = 1467941615941965194L;
-
- private final Duration initialBackoff;
- private final Duration maxBackoff;
- private final double backoffMultiplier;
- private final Duration resetBackoffThreshold;
- private final double jitterFactor;
-
- public ExponentialDelayRestartStrategyConfiguration(
- Duration initialBackoff,
- Duration maxBackoff,
- double backoffMultiplier,
- Duration resetBackoffThreshold,
- double jitterFactor) {
- this.initialBackoff = initialBackoff;
- this.maxBackoff = maxBackoff;
- this.backoffMultiplier = backoffMultiplier;
- this.resetBackoffThreshold = resetBackoffThreshold;
- this.jitterFactor = jitterFactor;
- }
-
- public Duration getInitialBackoffDuration() {
- return initialBackoff;
- }
-
- public Duration getMaxBackoffDuration() {
- return maxBackoff;
- }
-
- public double getBackoffMultiplier() {
- return backoffMultiplier;
- }
-
- public Duration getResetBackoffDurationThreshold() {
- return resetBackoffThreshold;
- }
-
- public double getJitterFactor() {
- return jitterFactor;
- }
-
- @Override
- public String getDescription() {
- return String.format(
- "Restart with exponential delay: starting at %s, increasing by %f, with maximum %s. "
- + "Delay resets after %s with jitter %f",
- initialBackoff,
- backoffMultiplier,
- maxBackoff,
- resetBackoffThreshold,
- jitterFactor);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- ExponentialDelayRestartStrategyConfiguration that =
- (ExponentialDelayRestartStrategyConfiguration) o;
- return Double.compare(that.backoffMultiplier, backoffMultiplier) == 0
- && Double.compare(that.jitterFactor, jitterFactor) == 0
- && Objects.equals(initialBackoff, that.initialBackoff)
- && Objects.equals(maxBackoff, that.maxBackoff)
- && Objects.equals(resetBackoffThreshold, that.resetBackoffThreshold);
- }
-
- @Override
- public int hashCode() {
- int result = initialBackoff.hashCode();
- result = 31 * result + maxBackoff.hashCode();
- result = 31 * result + (int) backoffMultiplier;
- result = 31 * result + resetBackoffThreshold.hashCode();
- result = 31 * result + (int) jitterFactor;
- return result;
- }
- }
-
- /** Configuration representing a failure rate restart strategy. */
- @PublicEvolving
- public static final class FailureRateRestartStrategyConfiguration
- extends RestartStrategyConfiguration {
- private static final long serialVersionUID = 1195028697539661739L;
- private final int maxFailureRate;
-
- private final Duration failureInterval;
- private final Duration delayBetweenAttemptsInterval;
-
- public FailureRateRestartStrategyConfiguration(
- int maxFailureRate,
- Duration failureInterval,
- Duration delayBetweenAttemptsInterval) {
- this.maxFailureRate = maxFailureRate;
- this.failureInterval = failureInterval;
- this.delayBetweenAttemptsInterval = delayBetweenAttemptsInterval;
- }
-
- public int getMaxFailureRate() {
- return maxFailureRate;
- }
-
- public Duration getFailureIntervalDuration() {
- return failureInterval;
- }
-
- public Duration getDurationBetweenAttempts() {
- return delayBetweenAttemptsInterval;
- }
-
- @Override
- public String getDescription() {
- return String.format(
- "Failure rate restart with maximum of %d failures within interval %s and fixed delay %s.",
- maxFailureRate,
- failureInterval.toString(),
- delayBetweenAttemptsInterval.toString());
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- FailureRateRestartStrategyConfiguration that =
- (FailureRateRestartStrategyConfiguration) o;
- return maxFailureRate == that.maxFailureRate
- && Objects.equals(failureInterval, that.failureInterval)
- && Objects.equals(
- delayBetweenAttemptsInterval, that.delayBetweenAttemptsInterval);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(maxFailureRate, failureInterval, delayBetweenAttemptsInterval);
- }
- }
-
- /**
- * Restart strategy configuration that could be used by jobs to use cluster level restart
- * strategy. Useful especially when one has a custom implementation of restart strategy set via
- * config.yaml.
- */
- @PublicEvolving
- public static final class FallbackRestartStrategyConfiguration
- extends RestartStrategyConfiguration {
- private static final long serialVersionUID = -4441787204284085544L;
-
- @Override
- public String getDescription() {
- return "Cluster level default restart strategy";
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- return o instanceof FallbackRestartStrategyConfiguration;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash();
- }
- }
-
- /**
- * Reads a {@link RestartStrategyConfiguration} from a given {@link ReadableConfig}.
- *
- * @param configuration configuration object to retrieve parameters from
- * @return {@link Optional#empty()} when no restart strategy parameters provided
- */
- public static Optional<RestartStrategyConfiguration> fromConfiguration(
- ReadableConfig configuration) {
- return configuration
- .getOptional(RestartStrategyOptions.RESTART_STRATEGY)
- .map(confName -> parseConfiguration(confName, configuration));
- }
-
- private static RestartStrategyConfiguration parseConfiguration(
- String restartstrategyKind, ReadableConfig configuration) {
- switch (RestartStrategyType.of(restartstrategyKind.toLowerCase())) {
- case NO_RESTART_STRATEGY:
- return noRestart();
- case FIXED_DELAY:
- int attempts =
- configuration.get(
- RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS);
- Duration delay =
- configuration.get(
- RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY);
- return fixedDelayRestart(attempts, delay.toMillis());
- case EXPONENTIAL_DELAY:
- Duration initialBackoff =
- configuration.get(
- RestartStrategyOptions
- .RESTART_STRATEGY_EXPONENTIAL_DELAY_INITIAL_BACKOFF);
- Duration maxBackoff =
- configuration.get(
- RestartStrategyOptions
- .RESTART_STRATEGY_EXPONENTIAL_DELAY_MAX_BACKOFF);
- double backoffMultiplier =
- configuration.get(
- RestartStrategyOptions
- .RESTART_STRATEGY_EXPONENTIAL_DELAY_BACKOFF_MULTIPLIER);
- Duration resetBackoffThreshold =
- configuration.get(
- RestartStrategyOptions
- .RESTART_STRATEGY_EXPONENTIAL_DELAY_RESET_BACKOFF_THRESHOLD);
- double jitter =
- configuration.get(
- RestartStrategyOptions
- .RESTART_STRATEGY_EXPONENTIAL_DELAY_JITTER_FACTOR);
- return exponentialDelayRestart(
- initialBackoff,
- maxBackoff,
- backoffMultiplier,
- resetBackoffThreshold,
- jitter);
- case FAILURE_RATE:
- int maxFailures =
- configuration.get(
- RestartStrategyOptions
- .RESTART_STRATEGY_FAILURE_RATE_MAX_FAILURES_PER_INTERVAL);
- Duration failureRateInterval =
- configuration.get(
- RestartStrategyOptions
- .RESTART_STRATEGY_FAILURE_RATE_FAILURE_RATE_INTERVAL);
- Duration failureRateDelay =
- configuration.get(
- RestartStrategyOptions.RESTART_STRATEGY_FAILURE_RATE_DELAY);
- return failureRateRestart(maxFailures, failureRateInterval, failureRateDelay);
- default:
- throw new IllegalArgumentException(
- "Unknown restart strategy " + restartstrategyKind + ".");
- }
- }
-}
diff --git a/flink-core/src/test/java/org/apache/flink/api/common/ExecutionConfigTest.java b/flink-core/src/test/java/org/apache/flink/api/common/ExecutionConfigTest.java
index 8c80c1f5b4c..a361777a912 100644
--- a/flink-core/src/test/java/org/apache/flink/api/common/ExecutionConfigTest.java
+++ b/flink-core/src/test/java/org/apache/flink/api/common/ExecutionConfigTest.java
@@ -18,7 +18,6 @@
package org.apache.flink.api.common;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.serialization.SerializerConfigImpl;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.common.typeutils.TypeSerializer;
@@ -26,6 +25,7 @@ import org.apache.flink.api.java.typeutils.GenericTypeInfo;
import org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.JobManagerOptions;
+import org.apache.flink.configuration.RestartStrategyOptions;
import org.apache.flink.core.testutils.CommonTestUtils;
import org.apache.flink.util.SerializedValue;
@@ -36,7 +36,6 @@ import com.esotericsoftware.kryo.io.Output;
import org.junit.jupiter.api.Test;
import java.io.Serializable;
-import java.time.Duration;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -303,14 +302,16 @@ public class ExecutionConfigTest {
@Test
void testNotOverridingRestartStrategiesWithDefaultsFromConfiguration() {
ExecutionConfig config = new ExecutionConfig();
- RestartStrategies.RestartStrategyConfiguration restartStrategyConfiguration =
- RestartStrategies.fixedDelayRestart(10, Duration.ofMinutes(2));
- config.setRestartStrategy(restartStrategyConfiguration);
+ Configuration configuration = new Configuration();
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixed-delay");
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, 10);
+ config.configure(configuration, Thread.currentThread().getContextClassLoader());
// mutate config according to configuration
config.configure(new Configuration(), Thread.currentThread().getContextClassLoader());
- assertThat(config.getRestartStrategy()).isEqualTo(restartStrategyConfiguration);
+ assertThat(config.toConfiguration().get(RestartStrategyOptions.RESTART_STRATEGY))
+ .isEqualTo("fixed-delay");
}
@Test
diff --git a/flink-core/src/test/java/org/apache/flink/api/common/RestartStrategyDescriptionUtilsTest.java b/flink-core/src/test/java/org/apache/flink/api/common/RestartStrategyDescriptionUtilsTest.java
new file mode 100644
index 00000000000..45ea84734d3
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/common/RestartStrategyDescriptionUtilsTest.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.api.common;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.RestartStrategyOptions;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.time.Duration;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+
+/** Tests for {@link RestartStrategyDescriptionUtils} */
+public class RestartStrategyDescriptionUtilsTest {
+
+ private Configuration configuration;
+
+ @BeforeEach
+ public void setUp() {
+ configuration = new Configuration();
+ }
+
+ @Test
+ public void testGetNoRestartStrategyDescription() {
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "none");
+ String description =
+ RestartStrategyDescriptionUtils.getRestartStrategyDescription(configuration);
+ assertThat("Restart deactivated.").isEqualTo(description);
+ }
+
+ @Test
+ public void testGetFixedDelayDescription() {
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixed-delay");
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, 3);
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY, Duration.ofSeconds(10));
+
+ String description =
+ RestartStrategyDescriptionUtils.getRestartStrategyDescription(configuration);
+ assertThat("Restart with fixed delay (PT10S). #3 restart attempts.").isEqualTo(description);
+ }
+
+ @Test
+ public void testGetFailureRateDescription() {
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "failure-rate");
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FAILURE_RATE_MAX_FAILURES_PER_INTERVAL, 5);
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FAILURE_RATE_FAILURE_RATE_INTERVAL,
+ Duration.ofMinutes(1));
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FAILURE_RATE_DELAY, Duration.ofSeconds(15));
+
+ String description =
+ RestartStrategyDescriptionUtils.getRestartStrategyDescription(configuration);
+ assertThat(
+ "Failure rate restart with maximum of 5 failures within interval PT1M and fixed delay PT15S.")
+ .isEqualTo(description);
+ }
+
+ @Test
+ public void testGetExponentialDelayDescription() {
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "exponential-delay");
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_EXPONENTIAL_DELAY_INITIAL_BACKOFF,
+ Duration.ofSeconds(1));
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_EXPONENTIAL_DELAY_MAX_BACKOFF,
+ Duration.ofMinutes(2));
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_EXPONENTIAL_DELAY_BACKOFF_MULTIPLIER, 2.0);
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_EXPONENTIAL_DELAY_RESET_BACKOFF_THRESHOLD,
+ Duration.ofMinutes(5));
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_EXPONENTIAL_DELAY_JITTER_FACTOR, 0.5);
+
+ String description =
+ RestartStrategyDescriptionUtils.getRestartStrategyDescription(configuration);
+ assertThat(
+ "Restart with exponential delay: starting at PT1S, increasing by 2.000000, with maximum PT2M. "
+ + "Delay resets after PT5M with jitter 0.500000")
+ .isEqualTo(description);
+ }
+
+ @Test
+ public void testGetDefaultRestartStrategyDescription() {
+ String description =
+ RestartStrategyDescriptionUtils.getRestartStrategyDescription(configuration);
+ assertThat("Cluster level default restart strategy").isEqualTo(description);
+ }
+
+ @Test
+ public void testGetRestartStrategyDescriptionForUnknownStrategy() {
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "unknown");
+
+ assertThatThrownBy(
+ () ->
+ RestartStrategyDescriptionUtils.getRestartStrategyDescription(
+ configuration))
+ .isInstanceOf(IllegalArgumentException.class);
+ }
+}
diff --git a/flink-end-to-end-tests/flink-datastream-allround-test/src/main/java/org/apache/flink/streaming/tests/DataStreamAllroundTestJobFactory.java b/flink-end-to-end-tests/flink-datastream-allround-test/src/main/java/org/apache/flink/streaming/tests/DataStreamAllroundTestJobFactory.java
index e14ad4a6041..7a6164aea39 100644
--- a/flink-end-to-end-tests/flink-datastream-allround-test/src/main/java/org/apache/flink/streaming/tests/DataStreamAllroundTestJobFactory.java
+++ b/flink-end-to-end-tests/flink-datastream-allround-test/src/main/java/org/apache/flink/streaming/tests/DataStreamAllroundTestJobFactory.java
@@ -21,7 +21,6 @@ package org.apache.flink.streaming.tests;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.common.functions.JoinFunction;
import org.apache.flink.api.common.functions.MapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.ListStateDescriptor;
import org.apache.flink.api.common.state.ValueStateDescriptor;
import org.apache.flink.api.common.typeinfo.TypeInformation;
@@ -32,7 +31,9 @@ import org.apache.flink.api.java.typeutils.ResultTypeQueryable;
import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.configuration.ConfigOption;
import org.apache.flink.configuration.ConfigOptions;
+import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.ExternalizedCheckpointRetention;
+import org.apache.flink.configuration.RestartStrategyOptions;
import org.apache.flink.contrib.streaming.state.EmbeddedRocksDBStateBackend;
import org.apache.flink.core.execution.CheckpointingMode;
import org.apache.flink.runtime.state.hashmap.HashMapStateBackend;
@@ -53,6 +54,7 @@ import org.apache.flink.streaming.tests.artificialstate.builder.ArtificialStateB
import org.apache.flink.streaming.tests.artificialstate.builder.ArtificialValueStateBuilder;
import java.io.IOException;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
@@ -341,28 +343,34 @@ public class DataStreamAllroundTestJobFactory {
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()),
+ Configuration configuration = new Configuration();
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixed-delay");
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS,
+ pt.getInt(
+ ENVIRONMENT_RESTART_STRATEGY_FIXED_ATTEMPTS.key(),
+ ENVIRONMENT_RESTART_STRATEGY_FIXED_ATTEMPTS.defaultValue()));
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY,
+ Duration.ofMillis(
pt.getLong(
ENVIRONMENT_RESTART_STRATEGY_FIXED_DELAY.key(),
ENVIRONMENT_RESTART_STRATEGY_FIXED_DELAY
- .defaultValue()));
+ .defaultValue())));
+
+ env.configure(configuration);
break;
case "no_restart":
- restartStrategy = RestartStrategies.noRestart();
+ env.configure(
+ new Configuration()
+ .set(RestartStrategyOptions.RESTART_STRATEGY, "none"));
break;
default:
throw new IllegalArgumentException(
"Unknown restart strategy: " + restartStrategyConfig);
}
- env.setRestartStrategy(restartStrategy);
}
}
diff --git a/flink-end-to-end-tests/flink-file-sink-test/src/main/java/org/apache/flink/connector/file/sink/FileSinkProgram.java b/flink-end-to-end-tests/flink-file-sink-test/src/main/java/org/apache/flink/connector/file/sink/FileSinkProgram.java
index 500130b0246..c2cabe48132 100644
--- a/flink-end-to-end-tests/flink-file-sink-test/src/main/java/org/apache/flink/connector/file/sink/FileSinkProgram.java
+++ b/flink-end-to-end-tests/flink-file-sink-test/src/main/java/org/apache/flink/connector/file/sink/FileSinkProgram.java
@@ -18,13 +18,14 @@
package org.apache.flink.connector.file.sink;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.serialization.Encoder;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
import org.apache.flink.api.common.typeutils.base.IntSerializer;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.utils.ParameterTool;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.RestartStrategyOptions;
import org.apache.flink.core.fs.Path;
import org.apache.flink.core.io.SimpleVersionedSerializer;
import org.apache.flink.runtime.state.FunctionInitializationContext;
@@ -65,8 +66,14 @@ public enum FileSinkProgram {
env.setParallelism(4);
env.enableCheckpointing(5000L);
- env.setRestartStrategy(
- RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, Duration.ofSeconds(10L)));
+ Configuration configuration = new Configuration();
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixed-delay");
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, Integer.MAX_VALUE);
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY, Duration.ofSeconds(10L));
+
+ env.configure(configuration);
// generate data, shuffle, sink
DataStream<Tuple2<Integer, Integer>> source = env.addSource(new Generator(10, 10, 60));
diff --git a/flink-end-to-end-tests/flink-local-recovery-and-allocation-test/src/main/java/org/apache/flink/streaming/tests/StickyAllocationAndLocalRecoveryTestJob.java b/flink-end-to-end-tests/flink-local-recovery-and-allocation-test/src/main/java/org/apache/flink/streaming/tests/StickyAllocationAndLocalRecoveryTestJob.java
index 65e331e7814..14c21f09122 100644
--- a/flink-end-to-end-tests/flink-local-recovery-and-allocation-test/src/main/java/org/apache/flink/streaming/tests/StickyAllocationAndLocalRecoveryTestJob.java
+++ b/flink-end-to-end-tests/flink-local-recovery-and-allocation-test/src/main/java/org/apache/flink/streaming/tests/StickyAllocationAndLocalRecoveryTestJob.java
@@ -20,7 +20,6 @@ package org.apache.flink.streaming.tests;
import org.apache.flink.api.common.functions.RichFlatMapFunction;
import org.apache.flink.api.common.functions.RuntimeContext;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
@@ -28,7 +27,9 @@ import org.apache.flink.api.common.state.ValueState;
import org.apache.flink.api.common.state.ValueStateDescriptor;
import org.apache.flink.api.java.functions.KeySelector;
import org.apache.flink.api.java.utils.ParameterTool;
+import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.ExternalizedCheckpointRetention;
+import org.apache.flink.configuration.RestartStrategyOptions;
import org.apache.flink.contrib.streaming.state.EmbeddedRocksDBStateBackend;
import org.apache.flink.runtime.state.FunctionInitializationContext;
import org.apache.flink.runtime.state.FunctionSnapshotContext;
@@ -45,6 +46,7 @@ import org.apache.commons.lang3.RandomStringUtils;
import java.io.IOException;
import java.io.Serializable;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -88,9 +90,16 @@ public class StickyAllocationAndLocalRecoveryTestJob {
env.setParallelism(pt.getInt("parallelism", 1));
env.setMaxParallelism(pt.getInt("maxParallelism", pt.getInt("parallelism", 1)));
env.enableCheckpointing(pt.getInt("checkpointInterval", 1000));
- env.setRestartStrategy(
- RestartStrategies.fixedDelayRestart(
- Integer.MAX_VALUE, pt.getInt("restartDelay", 0)));
+
+ Configuration configuration = new Configuration();
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixed-delay");
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, Integer.MAX_VALUE);
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY,
+ Duration.ofMillis(pt.getInt("restartDelay", 0)));
+
+ env.configure(configuration);
if (pt.getBoolean("externalizedCheckpoints", false)) {
env.getCheckpointConfig()
.setExternalizedCheckpointRetention(
diff --git a/flink-end-to-end-tests/flink-state-evolution-test/src/main/java/org/apache/flink/test/StatefulStreamingJob.java b/flink-end-to-end-tests/flink-state-evolution-test/src/main/java/org/apache/flink/test/StatefulStreamingJob.java
index 59931276a26..74133b313d0 100644
--- a/flink-end-to-end-tests/flink-state-evolution-test/src/main/java/org/apache/flink/test/StatefulStreamingJob.java
+++ b/flink-end-to-end-tests/flink-state-evolution-test/src/main/java/org/apache/flink/test/StatefulStreamingJob.java
@@ -20,7 +20,6 @@ package org.apache.flink.test;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.ValueState;
import org.apache.flink.api.common.state.ValueStateDescriptor;
import org.apache.flink.api.common.typeinfo.TypeHint;
@@ -30,6 +29,7 @@ import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.avro.generated.Address;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.PipelineOptions;
+import org.apache.flink.configuration.RestartStrategyOptions;
import org.apache.flink.runtime.state.filesystem.FsStateBackend;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.v2.DiscardingSink;
@@ -156,10 +156,10 @@ public class StatefulStreamingJob {
final String checkpointDir = pt.getRequired("checkpoint.dir");
Configuration configuration = new Configuration();
configuration.set(PipelineOptions.GENERIC_TYPES, false);
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "none");
final StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment(configuration);
env.setStateBackend(new FsStateBackend(checkpointDir));
- env.setRestartStrategy(RestartStrategies.noRestart());
env.enableCheckpointing(1000L);
env.addSource(new MySource())
diff --git a/flink-end-to-end-tests/flink-stream-sql-test/src/main/java/org/apache/flink/sql/tests/StreamSQLTestProgram.java b/flink-end-to-end-tests/flink-stream-sql-test/src/main/java/org/apache/flink/sql/tests/StreamSQLTestProgram.java
index 52ae5782ab1..f8ffa509563 100644
--- a/flink-end-to-end-tests/flink-stream-sql-test/src/main/java/org/apache/flink/sql/tests/StreamSQLTestProgram.java
+++ b/flink-end-to-end-tests/flink-stream-sql-test/src/main/java/org/apache/flink/sql/tests/StreamSQLTestProgram.java
@@ -19,7 +19,6 @@
package org.apache.flink.sql.tests;
import org.apache.flink.api.common.functions.MapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.serialization.Encoder;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
@@ -29,6 +28,8 @@ import org.apache.flink.api.common.typeutils.base.IntSerializer;
import org.apache.flink.api.common.typeutils.base.LongSerializer;
import org.apache.flink.api.java.typeutils.ResultTypeQueryable;
import org.apache.flink.api.java.utils.ParameterTool;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.RestartStrategyOptions;
import org.apache.flink.core.fs.Path;
import org.apache.flink.core.io.SimpleVersionedSerializer;
import org.apache.flink.runtime.state.FunctionInitializationContext;
@@ -81,7 +82,13 @@ public class StreamSQLTestProgram {
final StreamExecutionEnvironment sEnv =
StreamExecutionEnvironment.getExecutionEnvironment();
- sEnv.setRestartStrategy(RestartStrategies.fixedDelayRestart(3, Duration.ofSeconds(10)));
+ Configuration configuration = new Configuration();
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixed-delay");
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, 3);
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY, Duration.ofSeconds(10L));
+
+ sEnv.configure(configuration);
sEnv.enableCheckpointing(4000);
sEnv.getConfig().setAutoWatermarkInterval(1000);
diff --git a/flink-filesystems/flink-s3-fs-base/src/test/java/org/apache/flink/fs/s3/common/S5CmdOnMinioITCase.java b/flink-filesystems/flink-s3-fs-base/src/test/java/org/apache/flink/fs/s3/common/S5CmdOnMinioITCase.java
index 78888e56a76..a6ceedb9733 100644
--- a/flink-filesystems/flink-s3-fs-base/src/test/java/org/apache/flink/fs/s3/common/S5CmdOnMinioITCase.java
+++ b/flink-filesystems/flink-s3-fs-base/src/test/java/org/apache/flink/fs/s3/common/S5CmdOnMinioITCase.java
@@ -19,7 +19,6 @@
package org.apache.flink.fs.s3.common;
import org.apache.flink.api.common.functions.ReduceFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
import org.apache.flink.configuration.Configuration;
@@ -36,6 +35,7 @@ import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.streaming.api.checkpoint.CheckpointedFunction;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.RichSourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.junit5.InjectMiniCluster;
import org.apache.flink.test.junit5.MiniClusterExtension;
import org.apache.flink.util.CloseableIterator;
@@ -212,7 +212,7 @@ public abstract class S5CmdOnMinioITCase {
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(2);
env.enableCheckpointing(CHECKPOINT_INTERVAL);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.setStateBackend(new EmbeddedRocksDBStateBackend());
// Disable changelog, to make sure state is stored in the RocksDB, not in changelog, as
// currently only RocksDB is using s5cmd.
diff --git a/flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/DataStreamCsvITCase.java b/flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/DataStreamCsvITCase.java
index d6b50badb07..6a2b213b50a 100644
--- a/flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/DataStreamCsvITCase.java
+++ b/flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/DataStreamCsvITCase.java
@@ -19,7 +19,6 @@
package org.apache.flink.formats.csv;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.serialization.BulkWriter;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.connector.file.sink.FileSink;
@@ -34,6 +33,7 @@ import org.apache.flink.streaming.api.datastream.DataStreamUtils;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.filesystem.bucketassigners.BasePathBucketAssigner;
import org.apache.flink.streaming.api.operators.collect.ClientAndIterator;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.junit5.MiniClusterExtension;
import org.apache.flink.util.function.FunctionWithException;
import org.apache.flink.util.jackson.JacksonMapperFactory;
@@ -345,7 +345,7 @@ class DataStreamCsvITCase {
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
final DataStream<T> stream =
env.fromSource(source, WatermarkStrategy.noWatermarks(), "file-source");
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java b/flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java
index 94e0a50bd26..ee2ce212f4c 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java
@@ -29,7 +29,6 @@ import org.apache.flink.api.common.cache.DistributedCache;
import org.apache.flink.api.common.cache.DistributedCache.DistributedCacheEntry;
import org.apache.flink.api.common.io.FileInputFormat;
import org.apache.flink.api.common.io.InputFormat;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.io.CollectionInputFormat;
@@ -274,60 +273,6 @@ public class ExecutionEnvironment {
config.setParallelism(parallelism);
}
- /**
- * Sets the restart strategy configuration. The configuration specifies which restart strategy
- * will be used for the execution graph in case of a restart.
- *
- * @param restartStrategyConfiguration Restart strategy configuration to be set
- */
- @PublicEvolving
- public void setRestartStrategy(
- RestartStrategies.RestartStrategyConfiguration restartStrategyConfiguration) {
- config.setRestartStrategy(restartStrategyConfiguration);
- }
-
- /**
- * Returns the specified restart strategy configuration.
- *
- * @return The restart strategy configuration to be used
- */
- @PublicEvolving
- public RestartStrategies.RestartStrategyConfiguration getRestartStrategy() {
- return config.getRestartStrategy();
- }
-
- /**
- * Sets the number of times that failed tasks are re-executed. A value of zero effectively
- * disables fault tolerance. A value of {@code -1} indicates that the system default value (as
- * defined in the configuration) should be used.
- *
- * @param numberOfExecutionRetries The number of times the system will try to re-execute failed
- * tasks.
- * @deprecated This method will be replaced by {@link #setRestartStrategy}. The {@link
- * RestartStrategies.FixedDelayRestartStrategyConfiguration} contains the number of
- * execution retries.
- */
- @Deprecated
- @PublicEvolving
- public void setNumberOfExecutionRetries(int numberOfExecutionRetries) {
- config.setNumberOfExecutionRetries(numberOfExecutionRetries);
- }
-
- /**
- * Gets the number of times the system will try to re-execute failed tasks. A value of {@code
- * -1} indicates that the system default value (as defined in the configuration) should be used.
- *
- * @return The number of times the system will try to re-execute failed tasks.
- * @deprecated This method will be replaced by {@link #getRestartStrategy}. The {@link
- * RestartStrategies.FixedDelayRestartStrategyConfiguration} contains the number of
- * execution retries.
- */
- @Deprecated
- @PublicEvolving
- public int getNumberOfExecutionRetries() {
- return config.getNumberOfExecutionRetries();
- }
-
/**
* Returns the {@link org.apache.flink.api.common.JobExecutionResult} of the last executed job.
*
diff --git a/flink-python/docs/reference/pyflink.datastream/stream_execution_environment.rst b/flink-python/docs/reference/pyflink.datastream/stream_execution_environment.rst
index 3a7b16de9cd..3f72836dbaf 100644
--- a/flink-python/docs/reference/pyflink.datastream/stream_execution_environment.rst
+++ b/flink-python/docs/reference/pyflink.datastream/stream_execution_environment.rst
@@ -57,8 +57,6 @@ access).
StreamExecutionEnvironment.is_changelog_state_backend_enabled
StreamExecutionEnvironment.set_default_savepoint_directory
StreamExecutionEnvironment.get_default_savepoint_directory
- StreamExecutionEnvironment.set_restart_strategy
- StreamExecutionEnvironment.get_restart_strategy
StreamExecutionEnvironment.add_default_kryo_serializer
StreamExecutionEnvironment.register_type_with_kryo_serializer
StreamExecutionEnvironment.register_type
diff --git a/flink-python/pyflink/common/execution_config.py b/flink-python/pyflink/common/execution_config.py
index fd42550c518..ad4934a0e5e 100644
--- a/flink-python/pyflink/common/execution_config.py
+++ b/flink-python/pyflink/common/execution_config.py
@@ -21,7 +21,6 @@ from typing import Dict, List
from pyflink.common.execution_mode import ExecutionMode
from pyflink.common.input_dependency_constraint import InputDependencyConstraint
-from pyflink.common.restart_strategy import RestartStrategies, RestartStrategyConfiguration
from pyflink.java_gateway import get_gateway
from pyflink.util.java_utils import load_java_class
@@ -250,42 +249,6 @@ class ExecutionConfig(object):
self._j_execution_config = self._j_execution_config.setTaskCancellationTimeout(timeout)
return self
- def set_restart_strategy(
- self,
- restart_strategy_configuration: RestartStrategyConfiguration) -> 'ExecutionConfig':
- """
- Sets the restart strategy to be used for recovery.
- ::
-
- >>> config = env.get_config()
- >>> config.set_restart_strategy(RestartStrategies.fixed_delay_restart(10, 1000))
-
- The restart strategy configurations are all created from :class:`RestartStrategies`.
-
- :param restart_strategy_configuration: Configuration defining the restart strategy to use.
-
- .. note:: Deprecated since version 1.19: This method is deprecated and will be removed in
- future FLINK major version. Use `stream_execution_environment.configure` method
- instead to set the restart strategy.
- """
- warnings.warn("Deprecated since version 1.19: This method is deprecated and will be removed"
- " in future FLINK major version. Use `stream_execution_environment.configure`"
- " method instead to set the restart strategy.", DeprecationWarning)
- self._j_execution_config.setRestartStrategy(
- restart_strategy_configuration._j_restart_strategy_configuration)
- return self
-
- def get_restart_strategy(self) -> RestartStrategyConfiguration:
- """
- Returns the restart strategy which has been set for the current job.
-
- .. seealso:: :func:`set_restart_strategy`
-
- :return: The specified restart configuration.
- """
- return RestartStrategies._from_j_restart_strategy(
- self._j_execution_config.getRestartStrategy())
-
def set_execution_mode(self, execution_mode: ExecutionMode) -> 'ExecutionConfig':
"""
Sets the execution mode to execute the program. The execution mode defines whether
diff --git a/flink-python/pyflink/common/tests/test_execution_config.py b/flink-python/pyflink/common/tests/test_execution_config.py
index 851413f26ff..7eab1e7efdc 100644
--- a/flink-python/pyflink/common/tests/test_execution_config.py
+++ b/flink-python/pyflink/common/tests/test_execution_config.py
@@ -16,7 +16,7 @@
# limitations under the License.
################################################################################
from pyflink.datastream import StreamExecutionEnvironment
-from pyflink.common import (ExecutionConfig, RestartStrategies, ExecutionMode, Configuration)
+from pyflink.common import (ExecutionConfig, ExecutionMode, Configuration)
from pyflink.java_gateway import get_gateway
from pyflink.testing.test_case_utils import PyFlinkTestCase
from pyflink.util.java_utils import get_j_env_configuration
@@ -91,29 +91,6 @@ class ExecutionConfigTests(PyFlinkTestCase):
self.assertEqual(self.execution_config.get_task_cancellation_timeout(), 3000)
- def test_get_set_restart_strategy(self):
-
- self.execution_config.set_restart_strategy(RestartStrategies.no_restart())
-
- self.assertEqual(self.execution_config.get_restart_strategy(),
- RestartStrategies.no_restart())
-
- self.execution_config.set_restart_strategy(
- RestartStrategies.failure_rate_restart(5, 10000, 5000))
-
- self.assertIsInstance(self.execution_config.get_restart_strategy(),
- RestartStrategies.FailureRateRestartStrategyConfiguration)
-
- self.execution_config.set_restart_strategy(RestartStrategies.fixed_delay_restart(4, 10000))
-
- self.assertIsInstance(self.execution_config.get_restart_strategy(),
- RestartStrategies.FixedDelayRestartStrategyConfiguration)
-
- self.execution_config.set_restart_strategy(RestartStrategies.fall_back_restart())
-
- self.assertEqual(self.execution_config.get_restart_strategy(),
- RestartStrategies.fall_back_restart())
-
def test_get_set_execution_mode(self):
self.execution_config.set_execution_mode(ExecutionMode.BATCH)
diff --git a/flink-python/pyflink/datastream/stream_execution_environment.py b/flink-python/pyflink/datastream/stream_execution_environment.py
index ce84e94ec0e..7c0b6d79012 100644
--- a/flink-python/pyflink/datastream/stream_execution_environment.py
+++ b/flink-python/pyflink/datastream/stream_execution_environment.py
@@ -28,7 +28,6 @@ from pyflink.common.execution_config import ExecutionConfig
from pyflink.common.io import InputFormat
from pyflink.common.job_client import JobClient
from pyflink.common.job_execution_result import JobExecutionResult
-from pyflink.common.restart_strategy import RestartStrategies, RestartStrategyConfiguration
from pyflink.common.typeinfo import TypeInformation, Types
from pyflink.datastream import SlotSharingGroup
from pyflink.datastream.checkpoint_config import CheckpointConfig
@@ -431,38 +430,6 @@ class StreamExecutionEnvironment(object):
else:
return j_path.toString()
- def set_restart_strategy(self, restart_strategy_configuration: RestartStrategyConfiguration):
- """
- Sets the restart strategy configuration. The configuration specifies which restart strategy
- will be used for the execution graph in case of a restart.
-
- Example:
- ::
-
- >>> env.set_restart_strategy(RestartStrategies.no_restart())
-
- :param restart_strategy_configuration: Restart strategy configuration to be set.
- :return:
-
- .. note:: Deprecated since version 1.19: This method is deprecated and will be removed in
- future FLINK major version. Use `stream_execution_environment.configure` method
- instead to set the restart strategy.
- """
- warnings.warn("Deprecated since version 1.19: This method is deprecated and will be removed"
- " in future FLINK major version. Use `stream_execution_environment.configure`"
- " method instead to set the restart strategy.", DeprecationWarning)
- self._j_stream_execution_environment.setRestartStrategy(
- restart_strategy_configuration._j_restart_strategy_configuration)
-
- def get_restart_strategy(self) -> RestartStrategyConfiguration:
- """
- Returns the specified restart strategy configuration.
-
- :return: The restart strategy configuration to be used.
- """
- return RestartStrategies._from_j_restart_strategy(
- self._j_stream_execution_environment.getRestartStrategy())
-
def add_default_kryo_serializer(self, type_class_name: str, serializer_class_name: str):
"""
Adds a new Kryo default serializer to the Runtime.
diff --git a/flink-python/pyflink/datastream/tests/test_stream_execution_environment.py b/flink-python/pyflink/datastream/tests/test_stream_execution_environment.py
index 5334481c248..d97b52eb35b 100644
--- a/flink-python/pyflink/datastream/tests/test_stream_execution_environment.py
+++ b/flink-python/pyflink/datastream/tests/test_stream_execution_environment.py
@@ -24,7 +24,7 @@ import tempfile
import time
import uuid
-from pyflink.common import Configuration, ExecutionConfig, RestartStrategies
+from pyflink.common import Configuration, ExecutionConfig
from pyflink.common.typeinfo import Types
from pyflink.datastream import (StreamExecutionEnvironment, CheckpointConfig,
CheckpointingMode, MemoryStateBackend,
@@ -77,13 +77,6 @@ class StreamExecutionEnvironmentTests(PyFlinkTestCase):
self.assertEqual(parallelism, 8)
- def test_set_get_restart_strategy(self):
- self.env.set_restart_strategy(RestartStrategies.no_restart())
-
- restart_strategy = self.env.get_restart_strategy()
-
- self.assertEqual(restart_strategy, RestartStrategies.no_restart())
-
def test_add_default_kryo_serializer(self):
self.env.add_default_kryo_serializer(
"org.apache.flink.runtime.state.StateBackendTestBase$TestPojo",
diff --git a/flink-python/pyflink/java_gateway.py b/flink-python/pyflink/java_gateway.py
index a7be4d24f91..195a36e60cd 100644
--- a/flink-python/pyflink/java_gateway.py
+++ b/flink-python/pyflink/java_gateway.py
@@ -160,7 +160,6 @@ def import_flink_view(gateway):
java_import(gateway.jvm, "org.apache.flink.api.java.ExecutionEnvironment")
java_import(gateway.jvm,
"org.apache.flink.streaming.api.environment.StreamExecutionEnvironment")
- java_import(gateway.jvm, "org.apache.flink.api.common.restartstrategy.RestartStrategies")
java_import(gateway.jvm, "org.apache.flink.python.util.PythonDependencyUtils")
java_import(gateway.jvm, "org.apache.flink.python.PythonOptions")
java_import(gateway.jvm, "org.apache.flink.client.python.PythonGatewayServer")
diff --git a/flink-queryable-state/flink-queryable-state-runtime/src/test/java/org/apache/flink/queryablestate/itcases/AbstractQueryableStateTestBase.java b/flink-queryable-state/flink-queryable-state-runtime/src/test/java/org/apache/flink/queryablestate/itcases/AbstractQueryableStateTestBase.java
index d9e448dd4b4..41948d75fce 100644
--- a/flink-queryable-state/flink-queryable-state-runtime/src/test/java/org/apache/flink/queryablestate/itcases/AbstractQueryableStateTestBase.java
+++ b/flink-queryable-state/flink-queryable-state-runtime/src/test/java/org/apache/flink/queryablestate/itcases/AbstractQueryableStateTestBase.java
@@ -23,7 +23,6 @@ import org.apache.flink.api.common.JobStatus;
import org.apache.flink.api.common.functions.AggregateFunction;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.ReduceFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.AggregatingState;
import org.apache.flink.api.common.state.AggregatingStateDescriptor;
import org.apache.flink.api.common.state.CheckpointListener;
@@ -59,6 +58,7 @@ import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunctio
import org.apache.flink.streaming.api.operators.AbstractStreamOperator;
import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.testutils.ClassLoaderUtils;
import org.apache.flink.testutils.executor.TestExecutorExtension;
import org.apache.flink.util.Collector;
@@ -163,8 +163,7 @@ public abstract class AbstractQueryableStateTestBase {
// Very important, because cluster is shared between tests and we
// don't explicitly check that all slots are available before
// submitting.
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000L));
-
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 1000L);
DataStream<Tuple2<Integer, Long>> source = env.addSource(new TestKeyRangeSource(numKeys));
ReducingStateDescriptor<Tuple2<Integer, Long>> reducingState =
@@ -267,7 +266,7 @@ public abstract class AbstractQueryableStateTestBase {
// Very important, because cluster is shared between tests and we
// don't explicitly check that all slots are available before
// submitting.
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 1000L);
DataStream<Tuple2<Integer, Long>> source = env.addSource(new TestKeyRangeSource(numKeys));
@@ -343,7 +342,7 @@ public abstract class AbstractQueryableStateTestBase {
// Very important, because cluster is shared between tests and we
// don't explicitly check that all slots are available before
// submitting.
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 1000L);
DataStream<Tuple2<Integer, Long>> source =
env.addSource(new TestAscendingValueSource(numElements));
@@ -391,7 +390,7 @@ public abstract class AbstractQueryableStateTestBase {
// Very important, because cluster is shared between tests and we
// don't explicitly check that all slots are available before
// submitting.
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 1000L);
// Custom serializer is not needed, it's used just to check if serialization works.
env.getConfig()
@@ -458,7 +457,7 @@ public abstract class AbstractQueryableStateTestBase {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setStateBackend(stateBackend);
env.setParallelism(maxParallelism);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 1000L);
DataStream<Tuple2<Integer, Long>> source =
env.addSource(new TestAscendingValueSource(numElements));
@@ -552,7 +551,7 @@ public abstract class AbstractQueryableStateTestBase {
// Very important, because clusterClient is shared between tests and we
// don't explicitly check that all slots are available before
// submitting.
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 1000L);
DataStream<Tuple2<Integer, Long>> source =
env.addSource(new TestAscendingValueSource(numElements));
@@ -613,7 +612,7 @@ public abstract class AbstractQueryableStateTestBase {
// Very important, because cluster is shared between tests and we
// don't explicitly check that all slots are available before
// submitting.
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 1000L);
DataStream<Tuple2<Integer, Long>> source =
env.addSource(new TestAscendingValueSource(numElements));
@@ -682,7 +681,7 @@ public abstract class AbstractQueryableStateTestBase {
// Very important, because cluster is shared between tests and we
// don't explicitly check that all slots are available before
// submitting.
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 1000L);
DataStream<Tuple2<Integer, Long>> source =
env.addSource(new TestAscendingValueSource(numElements));
@@ -732,7 +731,7 @@ public abstract class AbstractQueryableStateTestBase {
// Very important, because cluster is shared between tests and we
// don't explicitly check that all slots are available before
// submitting.
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 1000L);
DataStream<Tuple2<Integer, Long>> source =
env.addSource(new TestAscendingValueSource(numElements));
@@ -809,7 +808,7 @@ public abstract class AbstractQueryableStateTestBase {
// Very important, because cluster is shared between tests and we
// don't explicitly check that all slots are available before
// submitting.
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 1000L);
DataStream<Tuple2<Integer, Long>> source =
env.addSource(new TestAscendingValueSource(numElements));
@@ -912,7 +911,7 @@ public abstract class AbstractQueryableStateTestBase {
// Very important, because cluster is shared between tests and we
// don't explicitly check that all slots are available before
// submitting.
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 1000L);
DataStream<Tuple2<Integer, Long>> source =
env.addSource(new TestAscendingValueSource(numElements));
@@ -1016,7 +1015,7 @@ public abstract class AbstractQueryableStateTestBase {
// Very important, because cluster is shared between tests and we
// don't explicitly check that all slots are available before
// submitting.
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 1000L);
DataStream<Tuple2<Integer, Long>> source =
env.addSource(new TestAscendingValueSource(numElements));
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/RestartBackoffTimeStrategyFactoryLoader.java b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/RestartBackoffTimeStrategyFactoryLoader.java
index 8ea11a65ba3..061b025dbc9 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/RestartBackoffTimeStrategyFactoryLoader.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/RestartBackoffTimeStrategyFactoryLoader.java
@@ -18,12 +18,6 @@
package org.apache.flink.runtime.executiongraph.failover;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies.ExponentialDelayRestartStrategyConfiguration;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies.FailureRateRestartStrategyConfiguration;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies.FallbackRestartStrategyConfiguration;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies.FixedDelayRestartStrategyConfiguration;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies.NoRestartStrategyConfiguration;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.RestartStrategyOptions;
@@ -43,9 +37,7 @@ public final class RestartBackoffTimeStrategyFactoryLoader {
* <p>The strategy factory is decided in order as follows:
*
* <ol>
- * <li>Strategy set within job graph, i.e. {@link
- * RestartStrategies.RestartStrategyConfiguration}, unless the config is {@link
- * RestartStrategies.FallbackRestartStrategyConfiguration}.
+ * <li>Strategy set in the job-level config
* <li>Strategy set in the cluster(server-side) config (config.yaml), unless the strategy is
* not specified
* <li>{@link
@@ -54,77 +46,23 @@ public final class RestartBackoffTimeStrategyFactoryLoader {
* NoRestartBackoffTimeStrategy.NoRestartBackoffTimeStrategyFactory}
* </ol>
*
- * @param jobRestartStrategyConfiguration restart configuration given within the job graph
+ * @param jobConfiguration job configuration
* @param clusterConfiguration cluster(server-side) configuration
* @param isCheckpointingEnabled if checkpointing is enabled for the job
* @return new version restart strategy factory
*/
public static RestartBackoffTimeStrategy.Factory createRestartBackoffTimeStrategyFactory(
- final RestartStrategies.RestartStrategyConfiguration jobRestartStrategyConfiguration,
final Configuration jobConfiguration,
final Configuration clusterConfiguration,
final boolean isCheckpointingEnabled) {
- checkNotNull(jobRestartStrategyConfiguration);
checkNotNull(jobConfiguration);
checkNotNull(clusterConfiguration);
- return getJobRestartStrategyFactory(jobRestartStrategyConfiguration)
+ return getRestartStrategyFactoryFromConfig(jobConfiguration)
.orElse(
- getRestartStrategyFactoryFromConfig(jobConfiguration)
- .orElse(
- (getRestartStrategyFactoryFromConfig(clusterConfiguration)
- .orElse(
- getDefaultRestartStrategyFactory(
- isCheckpointingEnabled)))));
- }
-
- private static Optional<RestartBackoffTimeStrategy.Factory> getJobRestartStrategyFactory(
- final RestartStrategies.RestartStrategyConfiguration restartStrategyConfiguration) {
-
- if (restartStrategyConfiguration instanceof NoRestartStrategyConfiguration) {
- return Optional.of(
- NoRestartBackoffTimeStrategy.NoRestartBackoffTimeStrategyFactory.INSTANCE);
- } else if (restartStrategyConfiguration instanceof FixedDelayRestartStrategyConfiguration) {
- final FixedDelayRestartStrategyConfiguration fixedDelayConfig =
- (FixedDelayRestartStrategyConfiguration) restartStrategyConfiguration;
-
- return Optional.of(
- new FixedDelayRestartBackoffTimeStrategy
- .FixedDelayRestartBackoffTimeStrategyFactory(
- fixedDelayConfig.getRestartAttempts(),
- fixedDelayConfig.getDurationBetweenAttempts().toMillis()));
- } else if (restartStrategyConfiguration
- instanceof FailureRateRestartStrategyConfiguration) {
- final FailureRateRestartStrategyConfiguration failureRateConfig =
- (FailureRateRestartStrategyConfiguration) restartStrategyConfiguration;
-
- return Optional.of(
- new FailureRateRestartBackoffTimeStrategy
- .FailureRateRestartBackoffTimeStrategyFactory(
- failureRateConfig.getMaxFailureRate(),
- failureRateConfig.getFailureIntervalDuration().toMillis(),
- failureRateConfig.getDurationBetweenAttempts().toMillis()));
- } else if (restartStrategyConfiguration instanceof FallbackRestartStrategyConfiguration) {
- return Optional.empty();
- } else if (restartStrategyConfiguration
- instanceof ExponentialDelayRestartStrategyConfiguration) {
- final ExponentialDelayRestartStrategyConfiguration exponentialDelayConfig =
- (ExponentialDelayRestartStrategyConfiguration) restartStrategyConfiguration;
- return Optional.of(
- new ExponentialDelayRestartBackoffTimeStrategy
- .ExponentialDelayRestartBackoffTimeStrategyFactory(
- exponentialDelayConfig.getInitialBackoffDuration().toMillis(),
- exponentialDelayConfig.getMaxBackoffDuration().toMillis(),
- exponentialDelayConfig.getBackoffMultiplier(),
- exponentialDelayConfig.getResetBackoffDurationThreshold().toMillis(),
- exponentialDelayConfig.getJitterFactor(),
- RestartStrategyOptions.RESTART_STRATEGY_EXPONENTIAL_DELAY_ATTEMPTS
- .defaultValue()));
- } else {
- throw new IllegalArgumentException(
- "Unknown restart strategy configuration " + restartStrategyConfiguration + ".");
- }
+ getRestartStrategyFactoryFromConfig(clusterConfiguration)
+ .orElse(getDefaultRestartStrategyFactory(isCheckpointingEnabled)));
}
private static Optional<RestartBackoffTimeStrategy.Factory> getRestartStrategyFactoryFromConfig(
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/DefaultSchedulerFactory.java b/flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/DefaultSchedulerFactory.java
index 4e157964c07..911134cba62 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/DefaultSchedulerFactory.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/DefaultSchedulerFactory.java
@@ -98,9 +98,6 @@ public class DefaultSchedulerFactory implements SchedulerNGFactory {
slotRequestTimeout);
final RestartBackoffTimeStrategy restartBackoffTimeStrategy =
RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- jobGraph.getSerializedExecutionConfig()
- .deserializeValue(userCodeLoader)
- .getRestartStrategy(),
jobGraph.getJobConfiguration(),
jobMasterConfiguration,
jobGraph.isCheckpointingEnabled())
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerFactory.java b/flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerFactory.java
index ec7cedb1b11..733f67e58bf 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerFactory.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerFactory.java
@@ -90,9 +90,6 @@ public class AdaptiveSchedulerFactory implements SchedulerNGFactory {
"The AdaptiveScheduler requires a DeclarativeSlotPool."));
final RestartBackoffTimeStrategy restartBackoffTimeStrategy =
RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- jobGraph.getSerializedExecutionConfig()
- .deserializeValue(userCodeLoader)
- .getRestartStrategy(),
jobGraph.getJobConfiguration(),
jobMasterConfiguration,
jobGraph.isCheckpointingEnabled())
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptivebatch/AdaptiveBatchSchedulerFactory.java b/flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptivebatch/AdaptiveBatchSchedulerFactory.java
index 08a2aede43f..55325099598 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptivebatch/AdaptiveBatchSchedulerFactory.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptivebatch/AdaptiveBatchSchedulerFactory.java
@@ -138,7 +138,6 @@ public class AdaptiveBatchSchedulerFactory implements SchedulerNGFactory {
final RestartBackoffTimeStrategy restartBackoffTimeStrategy =
RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- executionConfig.getRestartStrategy(),
jobGraph.getJobConfiguration(),
jobMasterConfiguration,
jobGraph.isCheckpointingEnabled())
diff --git a/flink-runtime/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java b/flink-runtime/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java
index 5c5f60bd599..03cec211c34 100644
--- a/flink-runtime/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java
+++ b/flink-runtime/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java
@@ -34,7 +34,6 @@ import org.apache.flink.api.common.io.InputFormat;
import org.apache.flink.api.common.operators.ResourceSpec;
import org.apache.flink.api.common.operators.SlotSharingGroup;
import org.apache.flink.api.common.operators.util.SlotSharingGroupUtils;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.connector.source.Boundedness;
@@ -851,72 +850,6 @@ public class StreamExecutionEnvironment implements AutoCloseable {
return path == null ? null : new Path(path);
}
- /**
- * Sets the restart strategy configuration. The configuration specifies which restart strategy
- * will be used for the execution graph in case of a restart.
- *
- * @deprecated The method is marked as deprecated because starting from Flink 1.19, the usage of
- * all complex Java objects related to configuration, including their getter and setter
- * methods, should be replaced by ConfigOption. In a future major version of Flink, this
- * method will be removed entirely. It is recommended to switch to using the ConfigOptions
- * provided by {@link org.apache.flink.configuration.RestartStrategyOptions} for configuring
- * restart strategies.
- * @param restartStrategyConfiguration Restart strategy configuration to be set
- */
- @Deprecated
- @PublicEvolving
- public void setRestartStrategy(
- RestartStrategies.RestartStrategyConfiguration restartStrategyConfiguration) {
- config.setRestartStrategy(restartStrategyConfiguration);
- }
-
- /**
- * Returns the specified restart strategy configuration.
- *
- * @deprecated The method is marked as deprecated because starting from Flink 1.19, the usage of
- * all complex Java objects related to configuration, including their getter and setter
- * methods, should be replaced by ConfigOption. In a future major version of Flink, this
- * method will be removed entirely. It is recommended to switch to using the ConfigOptions
- * provided by {@link org.apache.flink.configuration.RestartStrategyOptions} for configuring
- * restart strategies.
- * @return The restart strategy configuration to be used
- */
- @Deprecated
- @PublicEvolving
- public RestartStrategies.RestartStrategyConfiguration getRestartStrategy() {
- return config.getRestartStrategy();
- }
-
- /**
- * Sets the number of times that failed tasks are re-executed. A value of zero effectively
- * disables fault tolerance. A value of {@code -1} indicates that the system default value (as
- * defined in the configuration) should be used.
- *
- * @param numberOfExecutionRetries The number of times the system will try to re-execute failed
- * tasks.
- * @deprecated This method will be replaced by {@link #setRestartStrategy}. The {@link
- * RestartStrategies#fixedDelayRestart(int, Duration)} contains the number of execution
- * retries.
- */
- @Deprecated
- @PublicEvolving
- public void setNumberOfExecutionRetries(int numberOfExecutionRetries) {
- config.setNumberOfExecutionRetries(numberOfExecutionRetries);
- }
-
- /**
- * Gets the number of times the system will try to re-execute failed tasks. A value of {@code
- * -1} indicates that the system default value (as defined in the configuration) should be used.
- *
- * @return The number of times the system will try to re-execute failed tasks.
- * @deprecated This method will be replaced by {@link #getRestartStrategy}.
- */
- @Deprecated
- @PublicEvolving
- public int getNumberOfExecutionRetries() {
- return config.getNumberOfExecutionRetries();
- }
-
// --------------------------------------------------------------------------------------------
// Registry for types and serializers
// --------------------------------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ArchivedExecutionGraphTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ArchivedExecutionGraphTest.java
index f91b53a2c67..b3ee27dfb79 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ArchivedExecutionGraphTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ArchivedExecutionGraphTest.java
@@ -22,7 +22,6 @@ import org.apache.flink.api.common.ArchivedExecutionConfig;
import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.JobStatus;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.core.testutils.CommonTestUtils;
import org.apache.flink.runtime.checkpoint.CheckpointRetentionPolicy;
import org.apache.flink.runtime.checkpoint.CheckpointStatsSnapshot;
@@ -43,6 +42,7 @@ import org.apache.flink.runtime.scheduler.DefaultVertexParallelismStore;
import org.apache.flink.runtime.scheduler.SchedulerBase;
import org.apache.flink.runtime.scheduler.SchedulerTestingUtils;
import org.apache.flink.runtime.taskmanager.TaskExecutionState;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.testutils.TestingUtils;
import org.apache.flink.testutils.executor.TestExecutorExtension;
@@ -92,7 +92,6 @@ public class ArchivedExecutionGraphTest {
ExecutionConfig config = new ExecutionConfig();
- config.setRestartStrategy(new RestartStrategies.NoRestartStrategyConfiguration());
config.setParallelism(4);
config.enableObjectReuse();
config.setGlobalJobParameters(new TestJobParameters());
@@ -118,6 +117,8 @@ public class ArchivedExecutionGraphTest {
.setExecutionConfig(config)
.build();
+ RestartStrategyUtils.configureNoRestartStrategy(jobGraph);
+
SchedulerBase scheduler =
SchedulerTestingUtils.createScheduler(
jobGraph,
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphRestartTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphRestartTest.java
index d4f9c22dd56..f87bcef4d63 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphRestartTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphRestartTest.java
@@ -18,9 +18,7 @@
package org.apache.flink.runtime.executiongraph;
-import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobStatus;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.core.testutils.FlinkAssertions;
import org.apache.flink.runtime.clusterframework.types.ResourceID;
import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
@@ -46,6 +44,7 @@ import org.apache.flink.runtime.scheduler.ExecutionSlotAllocatorFactory;
import org.apache.flink.runtime.scheduler.SchedulerBase;
import org.apache.flink.runtime.scheduler.SchedulerTestingUtils;
import org.apache.flink.runtime.testtasks.NoOpInvokable;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.testutils.TestingUtils;
import org.apache.flink.testutils.executor.TestExecutorExtension;
import org.apache.flink.util.concurrent.ManuallyTriggeredScheduledExecutor;
@@ -418,13 +417,10 @@ class ExecutionGraphRestartTest {
private static JobGraph createJobGraphToCancel() throws IOException {
JobVertex vertex =
ExecutionGraphTestUtils.createJobVertex("Test Vertex", 1, NoOpInvokable.class);
- ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.setRestartStrategy(
- RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, Integer.MAX_VALUE));
-
- return JobGraphBuilder.newStreamingJobGraphBuilder()
- .addJobVertex(vertex)
- .setExecutionConfig(executionConfig)
- .build();
+ JobGraph jobGraph =
+ JobGraphBuilder.newStreamingJobGraphBuilder().addJobVertex(vertex).build();
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(
+ jobGraph, Integer.MAX_VALUE, Integer.MAX_VALUE);
+ return jobGraph;
}
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/failover/RestartBackoffTimeStrategyFactoryLoaderTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/failover/RestartBackoffTimeStrategyFactoryLoaderTest.java
index 17b6b5d33a0..802db75ce30 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/failover/RestartBackoffTimeStrategyFactoryLoaderTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/failover/RestartBackoffTimeStrategyFactoryLoaderTest.java
@@ -18,14 +18,11 @@
package org.apache.flink.runtime.executiongraph.failover;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.RestartStrategyOptions;
import org.junit.jupiter.api.Test;
-import java.time.Duration;
-
import static org.apache.flink.configuration.RestartStrategyOptions.RestartStrategyType.EXPONENTIAL_DELAY;
import static org.apache.flink.configuration.RestartStrategyOptions.RestartStrategyType.FAILURE_RATE;
import static org.apache.flink.configuration.RestartStrategyOptions.RestartStrategyType.FIXED_DELAY;
@@ -36,82 +33,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
/** Unit tests for {@link RestartBackoffTimeStrategyFactoryLoader}. */
class RestartBackoffTimeStrategyFactoryLoaderTest {
- private static final RestartStrategies.RestartStrategyConfiguration
- DEFAULT_JOB_LEVEL_RESTART_CONFIGURATION = RestartStrategies.fallBackRestart();
-
- @Test
- void testNoRestartStrategySpecifiedInExecutionConfig() {
- final Configuration conf = new Configuration();
- conf.set(RestartStrategyOptions.RESTART_STRATEGY, FAILURE_RATE.getMainValue());
-
- final RestartBackoffTimeStrategy.Factory factory =
- RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- RestartStrategies.noRestart(), conf, conf, false);
-
- assertThat(NoRestartBackoffTimeStrategy.NoRestartBackoffTimeStrategyFactory.INSTANCE)
- .isEqualTo(factory);
- }
-
- @Test
- void testFixedDelayRestartStrategySpecifiedInExecutionConfig() {
- final Configuration conf = new Configuration();
- conf.set(RestartStrategyOptions.RESTART_STRATEGY, FAILURE_RATE.getMainValue());
-
- final RestartBackoffTimeStrategy.Factory factory =
- RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- RestartStrategies.fixedDelayRestart(1, Duration.ofMillis(1000)),
- conf,
- conf,
- false);
-
- assertThat(factory)
- .isInstanceOf(
- FixedDelayRestartBackoffTimeStrategy
- .FixedDelayRestartBackoffTimeStrategyFactory.class);
- }
-
- @Test
- void testExponentialDelayRestartStrategySpecifiedInExecutionConfig() {
- final Configuration conf = new Configuration();
- conf.set(RestartStrategyOptions.RESTART_STRATEGY, FAILURE_RATE.getMainValue());
-
- final RestartBackoffTimeStrategy.Factory factory =
- RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- RestartStrategies.exponentialDelayRestart(
- Duration.ofMillis(1),
- Duration.ofMillis(1000),
- 1.1,
- Duration.ofMillis(2000),
- 0),
- conf,
- conf,
- false);
-
- assertThat(factory)
- .isInstanceOf(
- ExponentialDelayRestartBackoffTimeStrategy
- .ExponentialDelayRestartBackoffTimeStrategyFactory.class);
- }
-
- @Test
- void testFailureRateRestartStrategySpecifiedInExecutionConfig() {
- final Configuration conf = new Configuration();
- conf.set(RestartStrategyOptions.RESTART_STRATEGY, FIXED_DELAY.getMainValue());
-
- final RestartBackoffTimeStrategy.Factory factory =
- RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- RestartStrategies.failureRateRestart(
- 1, Duration.ofMillis(1000), Duration.ofMillis(1000)),
- conf,
- conf,
- false);
-
- assertThat(factory)
- .isInstanceOf(
- FailureRateRestartBackoffTimeStrategy
- .FailureRateRestartBackoffTimeStrategyFactory.class);
- }
-
@Test
void testNoRestartStrategySpecifiedInJobConfig() {
final Configuration jobConf = new Configuration();
@@ -121,7 +42,7 @@ class RestartBackoffTimeStrategyFactoryLoaderTest {
final RestartBackoffTimeStrategy.Factory factory =
RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- DEFAULT_JOB_LEVEL_RESTART_CONFIGURATION, jobConf, clusterConf, false);
+ jobConf, clusterConf, false);
assertThat(NoRestartBackoffTimeStrategy.NoRestartBackoffTimeStrategyFactory.INSTANCE)
.isEqualTo(factory);
@@ -136,7 +57,7 @@ class RestartBackoffTimeStrategyFactoryLoaderTest {
final RestartBackoffTimeStrategy.Factory factory =
RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- DEFAULT_JOB_LEVEL_RESTART_CONFIGURATION, jobConf, clusterConf, false);
+ jobConf, clusterConf, false);
assertThat(factory)
.isInstanceOf(
@@ -153,7 +74,7 @@ class RestartBackoffTimeStrategyFactoryLoaderTest {
final RestartBackoffTimeStrategy.Factory factory =
RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- DEFAULT_JOB_LEVEL_RESTART_CONFIGURATION, jobConf, clusterConf, false);
+ jobConf, clusterConf, false);
assertThat(factory)
.isInstanceOf(
@@ -170,7 +91,7 @@ class RestartBackoffTimeStrategyFactoryLoaderTest {
final RestartBackoffTimeStrategy.Factory factory =
RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- DEFAULT_JOB_LEVEL_RESTART_CONFIGURATION, jobConf, clusterConf, false);
+ jobConf, clusterConf, false);
assertThat(factory)
.isInstanceOf(
@@ -187,10 +108,7 @@ class RestartBackoffTimeStrategyFactoryLoaderTest {
() ->
RestartBackoffTimeStrategyFactoryLoader
.createRestartBackoffTimeStrategyFactory(
- DEFAULT_JOB_LEVEL_RESTART_CONFIGURATION,
- conf,
- new Configuration(),
- false))
+ conf, new Configuration(), false))
.isInstanceOf(IllegalArgumentException.class);
}
@@ -201,7 +119,7 @@ class RestartBackoffTimeStrategyFactoryLoaderTest {
final RestartBackoffTimeStrategy.Factory factory =
RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- DEFAULT_JOB_LEVEL_RESTART_CONFIGURATION, new Configuration(), conf, false);
+ new Configuration(), conf, false);
assertThat(NoRestartBackoffTimeStrategy.NoRestartBackoffTimeStrategyFactory.INSTANCE)
.isEqualTo(factory);
@@ -214,7 +132,7 @@ class RestartBackoffTimeStrategyFactoryLoaderTest {
final RestartBackoffTimeStrategy.Factory factory =
RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- DEFAULT_JOB_LEVEL_RESTART_CONFIGURATION, new Configuration(), conf, false);
+ new Configuration(), conf, false);
assertThat(factory)
.isInstanceOf(
@@ -229,7 +147,7 @@ class RestartBackoffTimeStrategyFactoryLoaderTest {
final RestartBackoffTimeStrategy.Factory factory =
RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- DEFAULT_JOB_LEVEL_RESTART_CONFIGURATION, new Configuration(), conf, false);
+ new Configuration(), conf, false);
assertThat(factory)
.isInstanceOf(
@@ -244,7 +162,7 @@ class RestartBackoffTimeStrategyFactoryLoaderTest {
final RestartBackoffTimeStrategy.Factory factory =
RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- DEFAULT_JOB_LEVEL_RESTART_CONFIGURATION, new Configuration(), conf, false);
+ new Configuration(), conf, false);
assertThat(factory)
.isInstanceOf(
@@ -261,10 +179,7 @@ class RestartBackoffTimeStrategyFactoryLoaderTest {
() ->
RestartBackoffTimeStrategyFactoryLoader
.createRestartBackoffTimeStrategyFactory(
- DEFAULT_JOB_LEVEL_RESTART_CONFIGURATION,
- new Configuration(),
- conf,
- false))
+ new Configuration(), conf, false))
.isInstanceOf(IllegalArgumentException.class);
}
@@ -272,10 +187,7 @@ class RestartBackoffTimeStrategyFactoryLoaderTest {
void testNoStrategySpecifiedWhenCheckpointingEnabled() {
final RestartBackoffTimeStrategy.Factory factory =
RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- DEFAULT_JOB_LEVEL_RESTART_CONFIGURATION,
- new Configuration(),
- new Configuration(),
- true);
+ new Configuration(), new Configuration(), true);
RestartBackoffTimeStrategy strategy = factory.create();
assertThat(strategy).isInstanceOf(ExponentialDelayRestartBackoffTimeStrategy.class);
@@ -317,10 +229,7 @@ class RestartBackoffTimeStrategyFactoryLoaderTest {
void testNoStrategySpecifiedWhenCheckpointingDisabled() {
final RestartBackoffTimeStrategy.Factory factory =
RestartBackoffTimeStrategyFactoryLoader.createRestartBackoffTimeStrategyFactory(
- DEFAULT_JOB_LEVEL_RESTART_CONFIGURATION,
- new Configuration(),
- new Configuration(),
- false);
+ new Configuration(), new Configuration(), false);
assertThat(factory)
.isInstanceOf(
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobIntermediateDatasetReuseTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobIntermediateDatasetReuseTest.java
index e69f5b133b0..b4c3d98823d 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobIntermediateDatasetReuseTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobIntermediateDatasetReuseTest.java
@@ -17,9 +17,7 @@
package org.apache.flink.runtime.jobmaster;
-import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobID;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.runtime.execution.Environment;
import org.apache.flink.runtime.io.network.api.reader.RecordReader;
import org.apache.flink.runtime.io.network.api.writer.RecordWriter;
@@ -33,6 +31,7 @@ import org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable;
import org.apache.flink.runtime.minicluster.TestingMiniCluster;
import org.apache.flink.runtime.minicluster.TestingMiniClusterConfiguration;
import org.apache.flink.runtime.scheduler.ClusterDatasetCorruptedException;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.types.IntValue;
import org.assertj.core.api.Assertions;
@@ -136,9 +135,7 @@ class JobIntermediateDatasetReuseTest {
miniCluster.startTaskManager();
final JobGraph secondJobGraph = createSecondJobGraph(1, intermediateDataSetID);
- final ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(1024, 1000));
- secondJobGraph.setExecutionConfig(executionConfig);
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(secondJobGraph, 1024, 1000L);
miniCluster.submitJob(secondJobGraph).get();
jobResultFuture = miniCluster.requestJobResult(secondJobGraph.getJobID());
jobResult = jobResultFuture.get();
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
index 8eaaee20eb0..c75d46e0bed 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
@@ -23,7 +23,6 @@ import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.JobStatus;
import org.apache.flink.api.common.functions.AggregateFunction;
import org.apache.flink.api.common.io.DefaultInputSplitAssigner;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.ClosureCleaner;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple3;
@@ -122,6 +121,7 @@ import org.apache.flink.runtime.testtasks.NoOpInvokable;
import org.apache.flink.runtime.testutils.CommonTestUtils;
import org.apache.flink.runtime.util.NettyShuffleDescriptorBuilder;
import org.apache.flink.runtime.util.TestingFatalErrorHandler;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.testutils.TestingUtils;
import org.apache.flink.util.FlinkException;
import org.apache.flink.util.FlinkRuntimeException;
@@ -1076,14 +1076,9 @@ class JobMasterTest {
source.setInputSplitSource(inputSplitSource);
source.setInvokableClass(AbstractInvokable.class);
- final ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(100, 0));
-
final JobGraph inputSplitJobGraph =
- JobGraphBuilder.newStreamingJobGraphBuilder()
- .addJobVertex(source)
- .setExecutionConfig(executionConfig)
- .build();
+ JobGraphBuilder.newStreamingJobGraphBuilder().addJobVertex(source).build();
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(inputSplitJobGraph, 100, 0L);
try (final JobMaster jobMaster =
new JobMasterBuilder(inputSplitJobGraph, rpcService)
@@ -2555,10 +2550,7 @@ class JobMasterTest {
private JobGraph createSingleVertexJobWithRestartStrategy() throws IOException {
final JobGraph jobGraph = JobGraphTestUtils.singleNoOpJobGraph();
- final ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.setRestartStrategy(
- RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 0L));
- jobGraph.setExecutionConfig(executionConfig);
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(jobGraph, Integer.MAX_VALUE, 0L);
return jobGraph;
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobRecoveryITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobRecoveryITCase.java
index e075427e8b1..b30fafb8f4b 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobRecoveryITCase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobRecoveryITCase.java
@@ -18,8 +18,6 @@
package org.apache.flink.runtime.jobmaster;
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.runtime.execution.Environment;
import org.apache.flink.runtime.io.network.partition.ResultPartitionType;
import org.apache.flink.runtime.jobgraph.DistributionPattern;
@@ -30,6 +28,7 @@ import org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup;
import org.apache.flink.runtime.minicluster.MiniCluster;
import org.apache.flink.runtime.testutils.InternalMiniClusterExtension;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.util.FlinkRuntimeException;
import org.junit.jupiter.api.Test;
@@ -96,14 +95,15 @@ class JobRecoveryITCase {
receiver.connectNewDataSetAsInput(
sender, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
- final ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0L));
+ JobGraph jobGraph =
+ JobGraphBuilder.newStreamingJobGraphBuilder()
+ .addJobVertices(Arrays.asList(sender, receiver))
+ .setJobName(getClass().getSimpleName())
+ .build();
- return JobGraphBuilder.newStreamingJobGraphBuilder()
- .addJobVertices(Arrays.asList(sender, receiver))
- .setJobName(getClass().getSimpleName())
- .setExecutionConfig(executionConfig)
- .build();
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(jobGraph, 1, 0L);
+
+ return jobGraph;
}
/** Receiver which fails once before successfully completing. */
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java
index 20c9d86c4b9..f0a64c04212 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/minicluster/MiniClusterITCase.java
@@ -18,9 +18,7 @@
package org.apache.flink.runtime.minicluster;
-import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobSubmissionResult;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.JobManagerOptions;
import org.apache.flink.configuration.ResourceManagerOptions;
@@ -46,6 +44,7 @@ import org.apache.flink.runtime.jobmaster.TestingAbstractInvokables.Sender;
import org.apache.flink.runtime.testtasks.BlockingNoOpInvokable;
import org.apache.flink.runtime.testtasks.NoOpInvokable;
import org.apache.flink.runtime.testtasks.WaitingNoOpInvokable;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
@@ -704,10 +703,7 @@ class MiniClusterITCase {
final JobGraph jg = JobGraphTestUtils.streamingJobGraph(task);
- final ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.setRestartStrategy(
- RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000));
- jg.setExecutionConfig(executionConfig);
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(jg, Integer.MAX_VALUE, 1000);
return jg;
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerClusterITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerClusterITCase.java
index 46274b9ad6a..59af5eedb25 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerClusterITCase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerClusterITCase.java
@@ -18,9 +18,7 @@
package org.apache.flink.runtime.scheduler.adaptive;
-import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobID;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.JobManagerOptions;
import org.apache.flink.configuration.WebOptions;
@@ -45,6 +43,7 @@ import org.apache.flink.runtime.testtasks.OnceBlockingNoOpInvokable;
import org.apache.flink.runtime.testutils.CommonTestUtils;
import org.apache.flink.runtime.testutils.InternalMiniClusterExtension;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -260,9 +259,7 @@ public class AdaptiveSchedulerClusterITCase {
final JobGraph jobGraph = JobGraphTestUtils.streamingJobGraph(blockingOperator);
- ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0L));
- jobGraph.setExecutionConfig(executionConfig);
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(jobGraph, 1, 0L);
return jobGraph;
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerSimpleITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerSimpleITCase.java
index d0b2052c6e3..f0e4b2b9fee 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerSimpleITCase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptive/AdaptiveSchedulerSimpleITCase.java
@@ -18,10 +18,8 @@
package org.apache.flink.runtime.scheduler.adaptive;
-import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobExecutionResult;
import org.apache.flink.api.common.JobStatus;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.JobManagerOptions;
import org.apache.flink.runtime.execution.Environment;
@@ -37,6 +35,7 @@ import org.apache.flink.runtime.testtasks.NoOpInvokable;
import org.apache.flink.runtime.testutils.CommonTestUtils;
import org.apache.flink.runtime.testutils.InternalMiniClusterExtension;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.util.FlinkRuntimeException;
import org.junit.jupiter.api.Test;
@@ -115,11 +114,9 @@ class AdaptiveSchedulerSimpleITCase {
alwaysFailingOperator.setParallelism(1);
final JobGraph jobGraph = JobGraphTestUtils.streamingJobGraph(alwaysFailingOperator);
- ExecutionConfig executionConfig = new ExecutionConfig();
// configure a high delay between attempts: We'll stay in RESTARTING for 10 seconds.
- executionConfig.setRestartStrategy(
- RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, timeInRestartingState));
- jobGraph.setExecutionConfig(executionConfig);
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(
+ jobGraph, Integer.MAX_VALUE, timeInRestartingState);
miniCluster.submitJob(jobGraph).join();
@@ -156,9 +153,7 @@ class AdaptiveSchedulerSimpleITCase {
onceFailingOperator.setParallelism(1);
final JobGraph jobGraph = JobGraphTestUtils.streamingJobGraph(onceFailingOperator);
- ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0L));
- jobGraph.setExecutionConfig(executionConfig);
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(jobGraph, 1, 0L);
return jobGraph;
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/shuffle/ShuffleMasterTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/shuffle/ShuffleMasterTest.java
index 86d98f2ad0c..df8f48a6aed 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/shuffle/ShuffleMasterTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/shuffle/ShuffleMasterTest.java
@@ -18,7 +18,6 @@
package org.apache.flink.runtime.shuffle;
-import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobID;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.runtime.io.network.NettyShuffleServiceFactory;
@@ -31,6 +30,7 @@ import org.apache.flink.runtime.jobgraph.JobVertex;
import org.apache.flink.runtime.minicluster.MiniCluster;
import org.apache.flink.runtime.minicluster.MiniClusterConfiguration;
import org.apache.flink.runtime.testtasks.NoOpInvokable;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -43,7 +43,6 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
-import static org.apache.flink.api.common.restartstrategy.RestartStrategies.fixedDelayRestart;
import static org.apache.flink.configuration.ConfigurationUtils.getBooleanConfigOption;
import static org.assertj.core.api.Assertions.assertThat;
@@ -121,9 +120,7 @@ class ShuffleMasterTest {
source, DistributionPattern.ALL_TO_ALL, ResultPartitionType.BLOCKING);
JobGraph jobGraph = JobGraphTestUtils.batchJobGraph(source, sink);
- ExecutionConfig config = new ExecutionConfig();
- config.setRestartStrategy(fixedDelayRestart(2, Duration.ofSeconds(2)));
- jobGraph.setExecutionConfig(config);
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(jobGraph, 2, Duration.ofSeconds(2));
return jobGraph;
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorITCase.java
index 5f7c16e7909..b31ea081e20 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorITCase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorITCase.java
@@ -18,9 +18,7 @@
package org.apache.flink.runtime.taskexecutor;
-import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobStatus;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.core.testutils.CustomExtension;
import org.apache.flink.core.testutils.EachCallbackWrapper;
import org.apache.flink.runtime.execution.Environment;
@@ -40,6 +38,7 @@ import org.apache.flink.runtime.minicluster.MiniCluster;
import org.apache.flink.runtime.testutils.CommonTestUtils;
import org.apache.flink.runtime.testutils.InternalMiniClusterExtension;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.util.function.SupplierWithException;
import org.junit.jupiter.api.Test;
@@ -165,9 +164,7 @@ class TaskExecutorITCase {
private JobGraph createJobGraphWithRestartStrategy(int parallelism) throws IOException {
final JobGraph jobGraph = createJobGraph(parallelism);
- final ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(2, 0L));
- jobGraph.setExecutionConfig(executionConfig);
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(jobGraph, 2, 0L);
return jobGraph;
}
diff --git a/flink-runtime/src/test/java/org/apache/flink/streaming/api/RestartStrategyTest.java b/flink-runtime/src/test/java/org/apache/flink/streaming/api/RestartStrategyTest.java
deleted file mode 100644
index f2909276b36..00000000000
--- a/flink-runtime/src/test/java/org/apache/flink/streaming/api/RestartStrategyTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.streaming.api;
-
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
-import org.apache.flink.runtime.jobgraph.JobGraph;
-import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
-import org.apache.flink.streaming.api.graph.StreamGraph;
-
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/** Tests for {@link RestartStrategies}. */
-class RestartStrategyTest {
-
- /**
- * Tests that in a streaming use case where checkpointing is enabled, there is no default
- * strategy set on the client side.
- */
- @Test
- void testFallbackStrategyOnClientSideWhenCheckpointingEnabled() throws Exception {
- StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.enableCheckpointing(500);
-
- env.fromData(1).print();
-
- StreamGraph graph = env.getStreamGraph();
- JobGraph jobGraph = graph.getJobGraph();
-
- RestartStrategies.RestartStrategyConfiguration restartStrategy =
- jobGraph.getSerializedExecutionConfig()
- .deserializeValue(getClass().getClassLoader())
- .getRestartStrategy();
-
- assertThat(restartStrategy)
- .isNotNull()
- .isInstanceOf(RestartStrategies.FallbackRestartStrategyConfiguration.class);
- }
-
- /**
- * Checks that in a streaming use case where checkpointing is enabled and the number of
- * execution retries is set to 0, restarting is deactivated.
- */
- @Test
- void testNoRestartingWhenCheckpointingAndExplicitExecutionRetriesZero() throws Exception {
- StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.enableCheckpointing(500);
- env.setNumberOfExecutionRetries(0);
-
- env.fromData(1).print();
-
- StreamGraph graph = env.getStreamGraph();
- JobGraph jobGraph = graph.getJobGraph();
-
- RestartStrategies.RestartStrategyConfiguration restartStrategy =
- jobGraph.getSerializedExecutionConfig()
- .deserializeValue(getClass().getClassLoader())
- .getRestartStrategy();
-
- assertThat(restartStrategy)
- .isNotNull()
- .isInstanceOf(RestartStrategies.NoRestartStrategyConfiguration.class);
- }
-
- /**
- * Checks that in a streaming use case where checkpointing is enabled and the number of
- * execution retries is set to 42 and the delay to 1337, fixed delay restarting is used.
- */
- @Test
- void testFixedRestartingWhenCheckpointingAndExplicitExecutionRetriesNonZero() throws Exception {
- StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.enableCheckpointing(500);
- env.setNumberOfExecutionRetries(42);
- env.getConfig().setExecutionRetryDelay(1337);
-
- env.fromData(1).print();
-
- StreamGraph graph = env.getStreamGraph();
- JobGraph jobGraph = graph.getJobGraph();
-
- RestartStrategies.RestartStrategyConfiguration restartStrategy =
- jobGraph.getSerializedExecutionConfig()
- .deserializeValue(getClass().getClassLoader())
- .getRestartStrategy();
-
- assertThat(restartStrategy)
- .isNotNull()
- .isInstanceOfSatisfying(
- RestartStrategies.FixedDelayRestartStrategyConfiguration.class,
- strategy ->
- assertThat(strategy)
- .satisfies(
- fixedDelayRestartStrategy -> {
- assertThat(
- fixedDelayRestartStrategy
- .getRestartAttempts())
- .isEqualTo(42);
- assertThat(
- fixedDelayRestartStrategy
- .getDurationBetweenAttempts()
- .toMillis())
- .isEqualTo(1337);
- }));
- }
-}
diff --git a/flink-runtime/src/test/java/org/apache/flink/streaming/util/RestartStrategyUtils.java b/flink-runtime/src/test/java/org/apache/flink/streaming/util/RestartStrategyUtils.java
new file mode 100644
index 00000000000..53c7d2d739c
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/streaming/util/RestartStrategyUtils.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.streaming.util;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.RestartStrategyOptions;
+import org.apache.flink.runtime.jobgraph.JobGraph;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+
+import java.time.Duration;
+
+/** Utility class for configuring restart strategies. */
+public class RestartStrategyUtils {
+
+ /**
+ * Disables the restart strategy for the given StreamExecutionEnvironment.
+ *
+ * @param env the StreamExecutionEnvironment to configure
+ */
+ public static void configureNoRestartStrategy(StreamExecutionEnvironment env) {
+ env.configure(new Configuration().set(RestartStrategyOptions.RESTART_STRATEGY, "none"));
+ }
+
+ /**
+ * Disables the restart strategy for the given JobGraph.
+ *
+ * @param jobGraph the JobGraph to configure
+ */
+ public static void configureNoRestartStrategy(JobGraph jobGraph) {
+ jobGraph.getJobConfiguration().set(RestartStrategyOptions.RESTART_STRATEGY, "none");
+ }
+
+ /**
+ * Sets a fixed-delay restart strategy for the given StreamExecutionEnvironment.
+ *
+ * @param env the StreamExecutionEnvironment to configure
+ * @param restartAttempts the number of restart attempts
+ * @param delayBetweenAttempts the delay between restart attempts in milliseconds
+ */
+ public static void configureFixedDelayRestartStrategy(
+ StreamExecutionEnvironment env, int restartAttempts, long delayBetweenAttempts) {
+ configureFixedDelayRestartStrategy(
+ env, restartAttempts, Duration.ofMillis(delayBetweenAttempts));
+ }
+
+ /**
+ * Sets a fixed-delay restart strategy for the given StreamExecutionEnvironment.
+ *
+ * @param env the StreamExecutionEnvironment to configure
+ * @param restartAttempts the number of restart attempts
+ * @param delayBetweenAttempts the delay between restart attempts
+ */
+ public static void configureFixedDelayRestartStrategy(
+ StreamExecutionEnvironment env, int restartAttempts, Duration delayBetweenAttempts) {
+ Configuration configuration = new Configuration();
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixed-delay");
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, restartAttempts);
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY, delayBetweenAttempts);
+
+ env.configure(configuration);
+ }
+
+ /**
+ * Sets a fixed-delay restart strategy for the given JobGraph.
+ *
+ * @param jobGraph the JobGraph to configure
+ * @param restartAttempts the number of restart attempts
+ * @param delayBetweenAttempts the delay between restart attempts in milliseconds
+ */
+ public static void configureFixedDelayRestartStrategy(
+ JobGraph jobGraph, int restartAttempts, long delayBetweenAttempts) {
+ configureFixedDelayRestartStrategy(
+ jobGraph, restartAttempts, Duration.ofMillis(delayBetweenAttempts));
+ }
+
+ /**
+ * Sets a fixed-delay restart strategy for the given JobGraph.
+ *
+ * @param jobGraph the JobGraph to configure
+ * @param restartAttempts the number of restart attempts
+ * @param delayBetweenAttempts the delay between restart attempts
+ */
+ public static void configureFixedDelayRestartStrategy(
+ JobGraph jobGraph, int restartAttempts, Duration delayBetweenAttempts) {
+ Configuration configuration = jobGraph.getJobConfiguration();
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixed-delay");
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, restartAttempts);
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY, delayBetweenAttempts);
+ }
+}
diff --git a/flink-scala/src/main/scala/org/apache/flink/api/scala/ExecutionEnvironment.scala b/flink-scala/src/main/scala/org/apache/flink/api/scala/ExecutionEnvironment.scala
index 88a6d6b59a5..3a1f8f425a8 100644
--- a/flink-scala/src/main/scala/org/apache/flink/api/scala/ExecutionEnvironment.scala
+++ b/flink-scala/src/main/scala/org/apache/flink/api/scala/ExecutionEnvironment.scala
@@ -20,7 +20,6 @@ package org.apache.flink.api.scala
import org.apache.flink.annotation.{Public, PublicEvolving}
import org.apache.flink.api.common.{ExecutionConfig, JobExecutionResult}
import org.apache.flink.api.common.io.{FileInputFormat, InputFormat}
-import org.apache.flink.api.common.restartstrategy.RestartStrategies.RestartStrategyConfiguration
import org.apache.flink.api.common.typeinfo.{BasicTypeInfo, TypeInformation}
import org.apache.flink.api.common.typeutils.CompositeType
import org.apache.flink.api.java.{CollectionEnvironment, ExecutionEnvironment => JavaEnv}
@@ -92,56 +91,6 @@ class ExecutionEnvironment(javaEnv: JavaEnv) {
*/
def getParallelism = javaEnv.getParallelism
- /**
- * Sets the restart strategy configuration. The configuration specifies which restart strategy
- * will be used for the execution graph in case of a restart.
- *
- * @param restartStrategyConfiguration
- * Restart strategy configuration to be set
- */
- @PublicEvolving
- def setRestartStrategy(restartStrategyConfiguration: RestartStrategyConfiguration): Unit = {
- javaEnv.setRestartStrategy(restartStrategyConfiguration)
- }
-
- /**
- * Returns the specified restart strategy configuration.
- *
- * @return
- * The restart strategy configuration to be used
- */
- @PublicEvolving
- def getRestartStrategy: RestartStrategyConfiguration = {
- javaEnv.getRestartStrategy
- }
-
- /**
- * Sets the number of times that failed tasks are re-executed. A value of zero effectively
- * disables fault tolerance. A value of "-1" indicates that the system default value (as defined
- * in the configuration) should be used.
- *
- * @deprecated
- * This method will be replaced by [[setRestartStrategy()]]. The
- * FixedDelayRestartStrategyConfiguration contains the number of execution retries.
- */
- @Deprecated
- @PublicEvolving
- def setNumberOfExecutionRetries(numRetries: Int): Unit = {
- javaEnv.setNumberOfExecutionRetries(numRetries)
- }
-
- /**
- * Gets the number of times the system will try to re-execute failed tasks. A value of "-1"
- * indicates that the system default value (as defined in the configuration) should be used.
- *
- * @deprecated
- * This method will be replaced by [[getRestartStrategy]]. The
- * FixedDelayRestartStrategyConfiguration contains the number of execution retries.
- */
- @Deprecated
- @PublicEvolving
- def getNumberOfExecutionRetries = javaEnv.getNumberOfExecutionRetries
-
/** Gets the JobExecutionResult of the last executed job. */
def getLastJobExecutionResult = javaEnv.getLastJobExecutionResult
diff --git a/flink-streaming-scala/src/main/scala/org/apache/flink/streaming/api/scala/StreamExecutionEnvironment.scala b/flink-streaming-scala/src/main/scala/org/apache/flink/streaming/api/scala/StreamExecutionEnvironment.scala
index fc349c43240..c526c4d21f6 100644
--- a/flink-streaming-scala/src/main/scala/org/apache/flink/streaming/api/scala/StreamExecutionEnvironment.scala
+++ b/flink-streaming-scala/src/main/scala/org/apache/flink/streaming/api/scala/StreamExecutionEnvironment.scala
@@ -22,7 +22,6 @@ import org.apache.flink.api.common.{ExecutionConfig, RuntimeExecutionMode}
import org.apache.flink.api.common.eventtime.WatermarkStrategy
import org.apache.flink.api.common.io.{FileInputFormat, FilePathFilter, InputFormat}
import org.apache.flink.api.common.operators.SlotSharingGroup
-import org.apache.flink.api.common.restartstrategy.RestartStrategies.RestartStrategyConfiguration
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.connector.source.{Source, SourceSplit}
import org.apache.flink.api.connector.source.lib.NumberSequenceSource
@@ -435,54 +434,6 @@ class StreamExecutionEnvironment(javaEnv: JavaEnv) extends AutoCloseable {
@PublicEvolving
def getDefaultSavepointDirectory: Path = javaEnv.getDefaultSavepointDirectory
- /**
- * Sets the restart strategy configuration. The configuration specifies which restart strategy
- * will be used for the execution graph in case of a restart.
- *
- * @param restartStrategyConfiguration
- * Restart strategy configuration to be set
- */
- @PublicEvolving
- def setRestartStrategy(restartStrategyConfiguration: RestartStrategyConfiguration): Unit = {
- javaEnv.setRestartStrategy(restartStrategyConfiguration)
- }
-
- /**
- * Returns the specified restart strategy configuration.
- *
- * @return
- * The restart strategy configuration to be used
- */
- @PublicEvolving
- def getRestartStrategy: RestartStrategyConfiguration = {
- javaEnv.getRestartStrategy()
- }
-
- /**
- * Sets the number of times that failed tasks are re-executed. A value of zero effectively
- * disables fault tolerance. A value of "-1" indicates that the system default value (as defined
- * in the configuration) should be used.
- *
- * @deprecated
- * This method will be replaced by [[setRestartStrategy()]]. The
- * FixedDelayRestartStrategyConfiguration contains the number of execution retries.
- */
- @PublicEvolving
- def setNumberOfExecutionRetries(numRetries: Int): Unit = {
- javaEnv.setNumberOfExecutionRetries(numRetries)
- }
-
- /**
- * Gets the number of times the system will try to re-execute failed tasks. A value of "-1"
- * indicates that the system default value (as defined in the configuration) should be used.
- *
- * @deprecated
- * This method will be replaced by [[getRestartStrategy]]. The
- * FixedDelayRestartStrategyConfiguration contains the number of execution retries.
- */
- @PublicEvolving
- def getNumberOfExecutionRetries = javaEnv.getNumberOfExecutionRetries
-
// --------------------------------------------------------------------------------------------
// Registry for types and serializers
// --------------------------------------------------------------------------------------------
diff --git a/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/utils/DummyStreamExecutionEnvironment.java b/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/utils/DummyStreamExecutionEnvironment.java
index 0687773fc72..8ad9dc13a41 100644
--- a/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/utils/DummyStreamExecutionEnvironment.java
+++ b/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/utils/DummyStreamExecutionEnvironment.java
@@ -21,7 +21,6 @@ package org.apache.flink.table.planner.utils;
import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobExecutionResult;
import org.apache.flink.api.common.cache.DistributedCache;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.dag.Transformation;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.configuration.ReadableConfig;
@@ -208,29 +207,6 @@ public class DummyStreamExecutionEnvironment extends StreamExecutionEnvironment
return realExecEnv.getStateBackend();
}
- @Override
- public void setRestartStrategy(
- RestartStrategies.RestartStrategyConfiguration restartStrategyConfiguration) {
- throw new UnsupportedOperationException(
- "This is a dummy StreamExecutionEnvironment, setRestartStrategy method is unsupported.");
- }
-
- @Override
- public RestartStrategies.RestartStrategyConfiguration getRestartStrategy() {
- return realExecEnv.getRestartStrategy();
- }
-
- @Override
- public void setNumberOfExecutionRetries(int numberOfExecutionRetries) {
- throw new UnsupportedOperationException(
- "This is a dummy StreamExecutionEnvironment, setNumberOfExecutionRetries method is unsupported.");
- }
-
- @Override
- public int getNumberOfExecutionRetries() {
- return realExecEnv.getNumberOfExecutionRetries();
- }
-
@Override
public <T extends Serializer<?> & Serializable> void addDefaultKryoSerializer(
Class<?> type, T serializer) {
diff --git a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowAggregateITCase.scala b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowAggregateITCase.scala
index c8b442c9dd6..e8ce8256e67 100644
--- a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowAggregateITCase.scala
+++ b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowAggregateITCase.scala
@@ -17,8 +17,8 @@
*/
package org.apache.flink.table.planner.runtime.stream.sql
-import org.apache.flink.api.common.restartstrategy.RestartStrategies
import org.apache.flink.api.scala._
+import org.apache.flink.configuration.{Configuration, RestartStrategyOptions}
import org.apache.flink.core.execution.CheckpointingMode
import org.apache.flink.table.api._
import org.apache.flink.table.api.bridge.scala._
@@ -38,7 +38,7 @@ import org.assertj.core.data.Percentage
import org.junit.jupiter.api.{BeforeEach, TestTemplate}
import org.junit.jupiter.api.extension.ExtendWith
-import java.time.ZoneId
+import java.time.{Duration, ZoneId}
import java.util
import scala.collection.JavaConversions._
@@ -141,7 +141,13 @@ class WindowAggregateITCase(
// enable checkpoint, we are using failing source to force have a complete checkpoint
// and cover restore path
env.enableCheckpointing(100, CheckpointingMode.EXACTLY_ONCE)
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0))
+ val configuration = new Configuration()
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixeddelay")
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, Int.box(1))
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY,
+ Duration.ofMillis(0))
+ env.configure(configuration, Thread.currentThread.getContextClassLoader)
FailingCollectionSource.reset()
val insertOnlyDataId = if (useTimestampLtz) {
diff --git a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowDeduplicateITCase.scala b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowDeduplicateITCase.scala
index 1f30cc9df04..23870b987d0 100644
--- a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowDeduplicateITCase.scala
+++ b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowDeduplicateITCase.scala
@@ -17,8 +17,7 @@
*/
package org.apache.flink.table.planner.runtime.stream.sql
-import org.apache.flink.api.common.restartstrategy.RestartStrategies
-import org.apache.flink.api.scala._
+import org.apache.flink.configuration.{Configuration, RestartStrategyOptions}
import org.apache.flink.core.execution.CheckpointingMode
import org.apache.flink.table.api.bridge.scala._
import org.apache.flink.table.planner.factories.TestValuesTableFactory
@@ -26,12 +25,13 @@ import org.apache.flink.table.planner.plan.utils.JavaUserDefinedAggFunctions.Con
import org.apache.flink.table.planner.runtime.utils.{FailingCollectionSource, StreamingWithStateTestBase, TestData, TestingAppendSink}
import org.apache.flink.table.planner.runtime.utils.StreamingWithStateTestBase.StateBackendMode
import org.apache.flink.testutils.junit.extensions.parameterized.ParameterizedTestExtension
-import org.apache.flink.types.Row
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.{BeforeEach, TestTemplate}
import org.junit.jupiter.api.extension.ExtendWith
+import java.time.Duration
+
@ExtendWith(Array(classOf[ParameterizedTestExtension]))
class WindowDeduplicateITCase(mode: StateBackendMode) extends StreamingWithStateTestBase(mode) {
@@ -41,7 +41,13 @@ class WindowDeduplicateITCase(mode: StateBackendMode) extends StreamingWithState
// enable checkpoint, we are using failing source to force have a complete checkpoint
// and cover restore path
env.enableCheckpointing(100, CheckpointingMode.EXACTLY_ONCE)
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0))
+ val configuration = new Configuration()
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixeddelay")
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, Int.box(1))
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY,
+ Duration.ofMillis(0))
+ env.configure(configuration, Thread.currentThread.getContextClassLoader)
FailingCollectionSource.reset()
val dataId = TestValuesTableFactory.registerData(TestData.windowDataWithTimestamp)
diff --git a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowDistinctAggregateITCase.scala b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowDistinctAggregateITCase.scala
index fa2c0ebb201..5f24a88317e 100644
--- a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowDistinctAggregateITCase.scala
+++ b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowDistinctAggregateITCase.scala
@@ -17,8 +17,7 @@
*/
package org.apache.flink.table.planner.runtime.stream.sql
-import org.apache.flink.api.common.restartstrategy.RestartStrategies
-import org.apache.flink.api.scala._
+import org.apache.flink.configuration.{Configuration, RestartStrategyOptions}
import org.apache.flink.core.execution.CheckpointingMode
import org.apache.flink.table.api.bridge.scala.tableConversions
import org.apache.flink.table.api.config.OptimizerConfigOptions
@@ -26,12 +25,12 @@ import org.apache.flink.table.planner.factories.TestValuesTableFactory
import org.apache.flink.table.planner.runtime.utils.{FailingCollectionSource, StreamingWithStateTestBase, TestData, TestingAppendSink}
import org.apache.flink.table.planner.runtime.utils.StreamingWithStateTestBase.{HEAP_BACKEND, ROCKSDB_BACKEND, StateBackendMode}
import org.apache.flink.testutils.junit.extensions.parameterized.{ParameterizedTestExtension, Parameters}
-import org.apache.flink.types.Row
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.{BeforeEach, TestTemplate}
import org.junit.jupiter.api.extension.ExtendWith
+import java.time.Duration
import java.util
import scala.collection.JavaConversions._
@@ -145,7 +144,13 @@ class WindowDistinctAggregateITCase(splitDistinct: Boolean, backend: StateBacken
// enable checkpoint, we are using failing source to force have a complete checkpoint
// and cover restore path
env.enableCheckpointing(100, CheckpointingMode.EXACTLY_ONCE)
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0))
+ val configuration = new Configuration()
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixeddelay")
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, Int.box(1))
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY,
+ Duration.ofMillis(0))
+ env.configure(configuration, Thread.currentThread.getContextClassLoader)
FailingCollectionSource.reset()
val dataId = TestValuesTableFactory.registerData(TestData.windowDataWithTimestamp)
diff --git a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowJoinITCase.scala b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowJoinITCase.scala
index 67d02cee179..163fd343fee 100644
--- a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowJoinITCase.scala
+++ b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowJoinITCase.scala
@@ -17,21 +17,19 @@
*/
package org.apache.flink.table.planner.runtime.stream.sql
-import org.apache.flink.api.common.restartstrategy.RestartStrategies
-import org.apache.flink.api.scala._
+import org.apache.flink.configuration.{Configuration, RestartStrategyOptions}
import org.apache.flink.core.execution.CheckpointingMode
import org.apache.flink.table.api.bridge.scala._
import org.apache.flink.table.planner.factories.TestValuesTableFactory
import org.apache.flink.table.planner.runtime.utils.{FailingCollectionSource, StreamingWithStateTestBase, TestData, TestingAppendSink}
import org.apache.flink.table.planner.runtime.utils.StreamingWithStateTestBase.{HEAP_BACKEND, ROCKSDB_BACKEND, StateBackendMode}
import org.apache.flink.testutils.junit.extensions.parameterized.{ParameterizedTestExtension, Parameters}
-import org.apache.flink.types.Row
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.{BeforeEach, TestTemplate}
import org.junit.jupiter.api.extension.ExtendWith
-import java.time.ZoneId
+import java.time.{Duration, ZoneId}
import java.util
import scala.collection.JavaConversions._
@@ -48,7 +46,13 @@ class WindowJoinITCase(mode: StateBackendMode, useTimestampLtz: Boolean)
// enable checkpoint, we are using failing source to force have a complete checkpoint
// and cover restore path
env.enableCheckpointing(100, CheckpointingMode.EXACTLY_ONCE)
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0))
+ val configuration = new Configuration()
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixeddelay")
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, Int.box(1))
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY,
+ Duration.ofMillis(0))
+ env.configure(configuration, Thread.currentThread.getContextClassLoader)
FailingCollectionSource.reset()
val dataId1 = TestValuesTableFactory.registerData(TestData.windowDataWithTimestamp)
diff --git a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowRankITCase.scala b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowRankITCase.scala
index f8b47cfa624..9322378871c 100644
--- a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowRankITCase.scala
+++ b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowRankITCase.scala
@@ -17,8 +17,7 @@
*/
package org.apache.flink.table.planner.runtime.stream.sql
-import org.apache.flink.api.common.restartstrategy.RestartStrategies
-import org.apache.flink.api.scala._
+import org.apache.flink.configuration.{Configuration, RestartStrategyOptions}
import org.apache.flink.core.execution.CheckpointingMode
import org.apache.flink.table.api.bridge.scala._
import org.apache.flink.table.planner.factories.TestValuesTableFactory
@@ -26,12 +25,13 @@ import org.apache.flink.table.planner.plan.utils.JavaUserDefinedAggFunctions.Con
import org.apache.flink.table.planner.runtime.utils.{FailingCollectionSource, StreamingWithStateTestBase, TestData, TestingAppendSink}
import org.apache.flink.table.planner.runtime.utils.StreamingWithStateTestBase.StateBackendMode
import org.apache.flink.testutils.junit.extensions.parameterized.ParameterizedTestExtension
-import org.apache.flink.types.Row
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.{BeforeEach, TestTemplate}
import org.junit.jupiter.api.extension.ExtendWith
+import java.time.Duration
+
@ExtendWith(Array(classOf[ParameterizedTestExtension]))
class WindowRankITCase(mode: StateBackendMode) extends StreamingWithStateTestBase(mode) {
@@ -41,7 +41,13 @@ class WindowRankITCase(mode: StateBackendMode) extends StreamingWithStateTestBas
// enable checkpoint, we are using failing source to force have a complete checkpoint
// and cover restore path
env.enableCheckpointing(100, CheckpointingMode.EXACTLY_ONCE)
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0))
+ val configuration = new Configuration()
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixeddelay")
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, Int.box(1))
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY,
+ Duration.ofMillis(0))
+ env.configure(configuration, Thread.currentThread.getContextClassLoader)
FailingCollectionSource.reset()
val dataId = TestValuesTableFactory.registerData(TestData.windowDataWithTimestamp)
diff --git a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowTableFunctionITCase.scala b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowTableFunctionITCase.scala
index b0edc034ec7..eadaa34d79d 100644
--- a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowTableFunctionITCase.scala
+++ b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/WindowTableFunctionITCase.scala
@@ -17,7 +17,7 @@
*/
package org.apache.flink.table.planner.runtime.stream.sql
-import org.apache.flink.api.common.restartstrategy.RestartStrategies
+import org.apache.flink.configuration.{Configuration, RestartStrategyOptions}
import org.apache.flink.core.execution.CheckpointingMode
import org.apache.flink.table.api.bridge.scala._
import org.apache.flink.table.planner.factories.TestValuesTableFactory
@@ -29,6 +29,8 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.{BeforeEach, TestTemplate}
import org.junit.jupiter.api.extension.ExtendWith
+import java.time.Duration
+
@ExtendWith(Array(classOf[ParameterizedTestExtension]))
class WindowTableFunctionITCase(mode: StateBackendMode) extends StreamingWithStateTestBase(mode) {
@@ -38,7 +40,13 @@ class WindowTableFunctionITCase(mode: StateBackendMode) extends StreamingWithSta
// enable checkpoint, we are using failing source to force have a complete checkpoint
// and cover restore path
env.enableCheckpointing(100, CheckpointingMode.EXACTLY_ONCE)
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0))
+ val configuration = new Configuration()
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixeddelay")
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, Int.box(1))
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY,
+ Duration.ofMillis(0))
+ env.configure(configuration, Thread.currentThread.getContextClassLoader)
FailingCollectionSource.reset()
val dataId = TestValuesTableFactory.registerData(TestData.windowDataWithTimestamp)
diff --git a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/utils/StreamingWithStateTestBase.scala b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/utils/StreamingWithStateTestBase.scala
index 279218bee26..317495a7c2c 100644
--- a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/utils/StreamingWithStateTestBase.scala
+++ b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/utils/StreamingWithStateTestBase.scala
@@ -17,10 +17,9 @@
*/
package org.apache.flink.table.planner.runtime.utils
-import org.apache.flink.api.common.restartstrategy.RestartStrategies
import org.apache.flink.api.common.typeinfo.{TypeInformation, Types}
import org.apache.flink.api.common.typeutils.CompositeType
-import org.apache.flink.configuration.{CheckpointingOptions, Configuration}
+import org.apache.flink.configuration.{CheckpointingOptions, Configuration, RestartStrategyOptions}
import org.apache.flink.contrib.streaming.state.RocksDBStateBackend
import org.apache.flink.core.execution.CheckpointingMode
import org.apache.flink.runtime.state.memory.MemoryStateBackend
@@ -41,6 +40,7 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.{AfterEach, BeforeEach}
import java.nio.file.Files
+import java.time.Duration
import java.util
import scala.collection.JavaConversions._
@@ -114,7 +114,13 @@ class StreamingWithStateTestBase(state: StateBackendMode) extends StreamingTestB
/** Creates a DataStream from the given non-empty [[Seq]]. */
def failingDataSource[T: TypeInformation](data: Seq[T]): DataStream[T] = {
env.enableCheckpointing(100, CheckpointingMode.EXACTLY_ONCE)
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0))
+ val configuration = new Configuration()
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixeddelay")
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, Int.box(1))
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY,
+ Duration.ofMillis(0))
+ env.configure(configuration, Thread.currentThread.getContextClassLoader)
// reset failedBefore flag to false
FailingCollectionSource.reset()
diff --git a/flink-test-utils-parent/flink-connector-test-utils/src/main/java/org/apache/flink/connector/testframe/testsuites/SinkTestSuiteBase.java b/flink-test-utils-parent/flink-connector-test-utils/src/main/java/org/apache/flink/connector/testframe/testsuites/SinkTestSuiteBase.java
index 895469d7e83..4e36cdb8d40 100644
--- a/flink-test-utils-parent/flink-connector-test-utils/src/main/java/org/apache/flink/connector/testframe/testsuites/SinkTestSuiteBase.java
+++ b/flink-test-utils-parent/flink-connector-test-utils/src/main/java/org/apache/flink/connector/testframe/testsuites/SinkTestSuiteBase.java
@@ -22,7 +22,6 @@ import org.apache.flink.annotation.Experimental;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.JobStatus;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.typeutils.TypeSerializer;
import org.apache.flink.api.connector.sink2.Sink;
import org.apache.flink.api.connector.source.Boundedness;
@@ -53,6 +52,7 @@ import org.apache.flink.streaming.api.operators.collect.CollectResultIterator;
import org.apache.flink.streaming.api.operators.collect.CollectSinkOperator;
import org.apache.flink.streaming.api.operators.collect.CollectSinkOperatorFactory;
import org.apache.flink.streaming.api.operators.collect.CollectStreamSink;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.util.TestLoggerExtension;
import org.apache.commons.math3.util.Precision;
@@ -238,7 +238,7 @@ public abstract class SinkTestSuiteBase<T extends Comparable<T>> {
TestEnvironmentSettings.builder()
.setConnectorJarPaths(externalContext.getConnectorJarPaths())
.build());
- execEnv.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(execEnv);
// Step 2: Generate test data
final List<T> testRecords = generateTestData(sinkSettings, externalContext);
diff --git a/flink-test-utils-parent/flink-connector-test-utils/src/main/java/org/apache/flink/connector/testframe/testsuites/SourceTestSuiteBase.java b/flink-test-utils-parent/flink-connector-test-utils/src/main/java/org/apache/flink/connector/testframe/testsuites/SourceTestSuiteBase.java
index acbbd929c9b..bea16c71dd2 100644
--- a/flink-test-utils-parent/flink-connector-test-utils/src/main/java/org/apache/flink/connector/testframe/testsuites/SourceTestSuiteBase.java
+++ b/flink-test-utils-parent/flink-connector-test-utils/src/main/java/org/apache/flink/connector/testframe/testsuites/SourceTestSuiteBase.java
@@ -22,7 +22,6 @@ import org.apache.flink.annotation.Experimental;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.JobStatus;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.typeutils.TypeSerializer;
import org.apache.flink.api.connector.source.Boundedness;
import org.apache.flink.api.connector.source.Source;
@@ -52,6 +51,7 @@ import org.apache.flink.streaming.api.operators.collect.CollectResultIterator;
import org.apache.flink.streaming.api.operators.collect.CollectSinkOperator;
import org.apache.flink.streaming.api.operators.collect.CollectSinkOperatorFactory;
import org.apache.flink.streaming.api.operators.collect.CollectStreamSink;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.util.CloseableIterator;
import org.apache.flink.util.TestLoggerExtension;
@@ -312,7 +312,7 @@ public abstract class SourceTestSuiteBase<T> {
execEnv.getCheckpointConfig()
.setCheckpointingConsistencyMode(CheckpointingMode.EXACTLY_ONCE);
execEnv.enableCheckpointing(50);
- execEnv.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(execEnv);
DataStreamSource<T> source =
execEnv.fromSource(
tryCreateSource(externalContext, sourceSettings),
diff --git a/flink-tests/src/test/java/org/apache/flink/api/connector/source/lib/NumberSequenceSourceITCase.java b/flink-tests/src/test/java/org/apache/flink/api/connector/source/lib/NumberSequenceSourceITCase.java
index e5c608a0e0e..619dc617f4a 100644
--- a/flink-tests/src/test/java/org/apache/flink/api/connector/source/lib/NumberSequenceSourceITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/api/connector/source/lib/NumberSequenceSourceITCase.java
@@ -19,12 +19,12 @@
package org.apache.flink.api.connector.source.lib;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.core.execution.CheckpointingMode;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.util.TestLogger;
@@ -77,7 +77,7 @@ public class NumberSequenceSourceITCase extends TestLogger {
public void testCheckpointingWithDelayedAssignment() throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(1);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.enableCheckpointing(10, CheckpointingMode.EXACTLY_ONCE);
final SingleOutputStreamOperator<Long> stream =
env.fromSequence(0, 100)
diff --git a/flink-tests/src/test/java/org/apache/flink/api/datastream/DataStreamBatchExecutionITCase.java b/flink-tests/src/test/java/org/apache/flink/api/datastream/DataStreamBatchExecutionITCase.java
index db04a0636ff..1cba45de3f3 100644
--- a/flink-tests/src/test/java/org/apache/flink/api/datastream/DataStreamBatchExecutionITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/api/datastream/DataStreamBatchExecutionITCase.java
@@ -21,7 +21,6 @@ package org.apache.flink.api.datastream;
import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.BroadcastState;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
@@ -53,6 +52,7 @@ import org.apache.flink.streaming.api.operators.TwoInputStreamOperator;
import org.apache.flink.streaming.api.transformations.KeyedMultipleInputTransformation;
import org.apache.flink.streaming.api.transformations.TwoInputTransformation;
import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.util.CloseableIterator;
import org.apache.flink.util.CollectionUtil;
@@ -61,7 +61,6 @@ import org.apache.flink.util.Collector;
import org.junit.ClassRule;
import org.junit.Test;
-import java.time.Duration;
import java.util.Arrays;
import java.util.List;
@@ -555,7 +554,7 @@ public class DataStreamBatchExecutionITCase {
// trick the collecting sink into working even in the face of failures 🙏
env.enableCheckpointing(42);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(10, Duration.ofMillis(1)));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 10, 1L);
return env;
}
diff --git a/flink-tests/src/test/java/org/apache/flink/runtime/operators/lifecycle/PartiallyFinishedSourcesITCase.java b/flink-tests/src/test/java/org/apache/flink/runtime/operators/lifecycle/PartiallyFinishedSourcesITCase.java
index 1269a1010e1..5d8edf4925f 100644
--- a/flink-tests/src/test/java/org/apache/flink/runtime/operators/lifecycle/PartiallyFinishedSourcesITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/runtime/operators/lifecycle/PartiallyFinishedSourcesITCase.java
@@ -27,6 +27,7 @@ import org.apache.flink.runtime.operators.lifecycle.graph.TestJobBuilders.Testin
import org.apache.flink.runtime.operators.lifecycle.validation.DrainingValidator;
import org.apache.flink.runtime.operators.lifecycle.validation.FinishingValidator;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.testutils.junit.SharedObjects;
import org.apache.flink.util.TestLogger;
@@ -50,7 +51,6 @@ import java.util.concurrent.TimeUnit;
import static java.util.Arrays.asList;
import static java.util.stream.StreamSupport.stream;
-import static org.apache.flink.api.common.restartstrategy.RestartStrategies.fixedDelayRestart;
import static org.apache.flink.configuration.JobManagerOptions.EXECUTION_FAILOVER_STRATEGY;
import static org.apache.flink.runtime.operators.lifecycle.command.TestCommand.FINISH_SOURCES;
import static org.apache.flink.runtime.operators.lifecycle.command.TestCommandDispatcher.TestCommandScope.ALL_SUBTASKS;
@@ -165,7 +165,7 @@ public class PartiallyFinishedSourcesITCase extends TestLogger {
sharedObjects,
cfg -> {},
env -> {
- env.setRestartStrategy(fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
// checkpoints can hang (because of not yet fixed bugs and triggering
// checkpoint while the source finishes), so we reduce the timeout to
// avoid hanging for too long.
diff --git a/flink-tests/src/test/java/org/apache/flink/runtime/operators/lifecycle/graph/TestJobBuilders.java b/flink-tests/src/test/java/org/apache/flink/runtime/operators/lifecycle/graph/TestJobBuilders.java
index aedac271ab9..e3e22fbd8be 100644
--- a/flink-tests/src/test/java/org/apache/flink/runtime/operators/lifecycle/graph/TestJobBuilders.java
+++ b/flink-tests/src/test/java/org/apache/flink/runtime/operators/lifecycle/graph/TestJobBuilders.java
@@ -35,6 +35,7 @@ import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.v2.DiscardingSink;
import org.apache.flink.streaming.api.operators.ChainingStrategy;
import org.apache.flink.streaming.api.transformations.MultipleInputTransformation;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.testutils.junit.SharedObjects;
import org.apache.flink.util.function.ThrowingConsumer;
@@ -45,7 +46,6 @@ import java.util.Map;
import static java.util.Arrays.asList;
import static java.util.Collections.singleton;
import static java.util.Collections.singletonList;
-import static org.apache.flink.api.common.restartstrategy.RestartStrategies.noRestart;
import static org.apache.flink.configuration.JobManagerOptions.EXECUTION_FAILOVER_STRATEGY;
/** Helper to build {@link TestJobWithDescription}. */
@@ -265,7 +265,7 @@ public class TestJobBuilders {
StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment(configuration);
env.setParallelism(4);
- env.setRestartStrategy(noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.enableCheckpointing(200); // shouldn't matter
env.getCheckpointConfig().setCheckpointingConsistencyMode(CheckpointingMode.EXACTLY_ONCE);
env.getConfig().setAutoWatermarkInterval(50);
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ApproximateLocalRecoveryDownstreamITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ApproximateLocalRecoveryDownstreamITCase.java
index b59d74200a5..7b2b55c1b99 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ApproximateLocalRecoveryDownstreamITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ApproximateLocalRecoveryDownstreamITCase.java
@@ -20,7 +20,6 @@ package org.apache.flink.test.checkpointing;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.MemorySize;
import org.apache.flink.configuration.TaskManagerOptions;
@@ -29,6 +28,7 @@ import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.test.util.SuccessException;
import org.apache.flink.util.TestLogger;
@@ -78,11 +78,8 @@ public class ApproximateLocalRecoveryDownstreamITCase extends TestLogger {
public void localTaskFailureRecoveryThreeTasks() throws Exception {
final int failAfterElements = 150;
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.setParallelism(1)
- .setBufferTimeout(0)
- .setMaxParallelism(128)
- .disableOperatorChaining()
- .setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ env.setParallelism(1).setBufferTimeout(0).setMaxParallelism(128).disableOperatorChaining();
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.getCheckpointConfig().enableApproximateLocalRecovery(true);
env.addSource(new AppSourceFunction())
@@ -112,11 +109,8 @@ public class ApproximateLocalRecoveryDownstreamITCase extends TestLogger {
final int failAfterElements = 20;
final int keyByChannelNumber = 2;
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.setParallelism(1)
- .setBufferTimeout(0)
- .disableOperatorChaining()
- .setMaxParallelism(128)
- .setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ env.setParallelism(1).setBufferTimeout(0).disableOperatorChaining().setMaxParallelism(128);
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.getCheckpointConfig().enableApproximateLocalRecovery(true);
env.addSource(
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/AutoRescalingITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/AutoRescalingITCase.java
index a912daa2899..cc537ee6cf3 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/AutoRescalingITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/AutoRescalingITCase.java
@@ -21,7 +21,6 @@ package org.apache.flink.test.checkpointing;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.functions.RichFlatMapFunction;
import org.apache.flink.api.common.functions.RuntimeContext;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
import org.apache.flink.api.common.state.ValueState;
@@ -59,6 +58,7 @@ import org.apache.flink.streaming.api.functions.sink.SinkFunction;
import org.apache.flink.streaming.api.functions.sink.v2.DiscardingSink;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
import org.apache.flink.streaming.api.functions.source.SourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.testutils.TestingUtils;
import org.apache.flink.testutils.executor.TestExecutorResource;
@@ -586,7 +586,7 @@ public class AutoRescalingITCase extends TestLogger {
configureCheckpointing(env.getCheckpointConfig());
env.setParallelism(parallelism);
env.getConfig().setMaxParallelism(maxParallelism);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
StateSourceBase.workStartedLatch = new CountDownLatch(parallelism);
@@ -627,7 +627,7 @@ public class AutoRescalingITCase extends TestLogger {
}
configureCheckpointing(env.getCheckpointConfig());
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.getConfig().setUseSnapshotCompression(true);
DataStream<Integer> input =
@@ -665,7 +665,7 @@ public class AutoRescalingITCase extends TestLogger {
env.setParallelism(parallelism);
env.getConfig().setMaxParallelism(maxParallelism);
configureCheckpointing(env.getCheckpointConfig());
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
DataStream<Integer> input =
env.addSource(
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ChangelogLocalRecoveryITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ChangelogLocalRecoveryITCase.java
index 6350009a3d3..58ba035272b 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ChangelogLocalRecoveryITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ChangelogLocalRecoveryITCase.java
@@ -17,7 +17,6 @@
package org.apache.flink.test.checkpointing;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.changelog.fs.FsStateChangelogStorageFactory;
import org.apache.flink.configuration.CheckpointingOptions;
import org.apache.flink.configuration.Configuration;
@@ -31,6 +30,7 @@ import org.apache.flink.runtime.state.StateBackend;
import org.apache.flink.runtime.state.hashmap.HashMapStateBackend;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.checkpointing.ChangelogRecoveryITCaseBase.CollectionSink;
import org.apache.flink.test.checkpointing.ChangelogRecoveryITCaseBase.CountFunction;
import org.apache.flink.test.util.InfiniteIntegerSource;
@@ -163,8 +163,8 @@ public class ChangelogLocalRecoveryITCase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.enableCheckpointing(checkpointInterval);
env.getCheckpointConfig().enableUnalignedCheckpoints(false);
- env.setStateBackend(stateBackend)
- .setRestartStrategy(RestartStrategies.fixedDelayRestart(3, 10));
+ env.setStateBackend(stateBackend);
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 3, 10L);
env.configure(new Configuration().set(LOCAL_RECOVERY, true));
env.getCheckpointConfig().setCheckpointStorage(checkpointFile.toURI());
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ChangelogRecoveryITCaseBase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ChangelogRecoveryITCaseBase.java
index 72d301aed1f..020b6448f59 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ChangelogRecoveryITCaseBase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ChangelogRecoveryITCaseBase.java
@@ -21,7 +21,6 @@ import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.JobSubmissionResult;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.api.common.functions.OpenContext;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
@@ -58,6 +57,7 @@ import org.apache.flink.streaming.api.functions.windowing.ProcessWindowFunction;
import org.apache.flink.streaming.api.windowing.assigners.TumblingProcessingTimeWindows;
import org.apache.flink.streaming.api.windowing.time.Time;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.testutils.junit.SharedObjects;
import org.apache.flink.util.AbstractID;
@@ -161,8 +161,8 @@ public abstract class ChangelogRecoveryITCaseBase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
env.enableCheckpointing(checkpointInterval).enableChangelogStateBackend(true);
env.getCheckpointConfig().enableUnalignedCheckpoints(false);
- env.setStateBackend(stateBackend)
- .setRestartStrategy(RestartStrategies.fixedDelayRestart(restartAttempts, 0));
+ env.setStateBackend(stateBackend);
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, restartAttempts, 0);
if (materializationInterval >= 0) {
env.configure(
new Configuration()
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointAfterAllTasksFinishedITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointAfterAllTasksFinishedITCase.java
index a0114ea5637..f0848193a3d 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointAfterAllTasksFinishedITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointAfterAllTasksFinishedITCase.java
@@ -19,7 +19,6 @@
package org.apache.flink.test.checkpointing;
import org.apache.flink.api.common.functions.OpenContext;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.JobManagerOptions;
@@ -38,6 +37,7 @@ import org.apache.flink.streaming.api.graph.StreamGraph;
import org.apache.flink.streaming.api.operators.AbstractStreamOperator;
import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.AbstractTestBaseJUnit4;
import org.apache.flink.testutils.junit.SharedObjectsExtension;
import org.apache.flink.testutils.junit.SharedReference;
@@ -82,7 +82,7 @@ public class CheckpointAfterAllTasksFinishedITCase extends AbstractTestBaseJUnit
@Test
public void testImmediateCheckpointing() throws Exception {
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
// Checkpointing is enabled with a large interval, and no checkpoints will be triggered.
env.enableCheckpointing(
Duration.ofNanos(Long.MAX_VALUE) /* max duration allowed by FLINK */.toMillis());
@@ -103,7 +103,7 @@ public class CheckpointAfterAllTasksFinishedITCase extends AbstractTestBaseJUnit
try (MiniCluster miniCluster = new MiniCluster(cfg)) {
miniCluster.start();
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.enableCheckpointing(100);
JobGraph jobGraph = getStreamGraph(env, true, false).getJobGraph();
miniCluster.submitJob(jobGraph).get();
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointFailureManagerITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointFailureManagerITCase.java
index 27a52790d07..ba7242686c0 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointFailureManagerITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointFailureManagerITCase.java
@@ -19,7 +19,6 @@
package org.apache.flink.test.checkpointing;
import org.apache.flink.api.common.JobID;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
import org.apache.flink.configuration.ReadableConfig;
@@ -54,6 +53,7 @@ import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.v2.DiscardingSink;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
import org.apache.flink.streaming.api.graph.StreamingJobGraphGenerator;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.test.util.TestUtils;
import org.apache.flink.util.ExceptionUtils;
@@ -89,7 +89,7 @@ public class CheckpointFailureManagerITCase extends TestLogger {
env.enableCheckpointing(10);
env.getCheckpointConfig().setCheckpointStorage(new FailingFinalizationCheckpointStorage());
env.getCheckpointConfig().setTolerableCheckpointFailureNumber(0);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.fromSequence(Long.MIN_VALUE, Long.MAX_VALUE).sinkTo(new DiscardingSink<>());
JobGraph jobGraph = StreamingJobGraphGenerator.createJobGraph(env.getStreamGraph());
try {
@@ -112,7 +112,7 @@ public class CheckpointFailureManagerITCase extends TestLogger {
public void testAsyncCheckpointFailureTriggerJobFailed() throws Exception {
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.enableCheckpointing(500);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.setStateBackend(new AsyncFailureStateBackend());
env.addSource(new StringGeneratingSourceFunction()).sinkTo(new DiscardingSink<>());
JobGraph jobGraph = StreamingJobGraphGenerator.createJobGraph(env.getStreamGraph());
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointRestoreWithUidHashITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointRestoreWithUidHashITCase.java
index bef3058b0ab..5c9aecc91a2 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointRestoreWithUidHashITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointRestoreWithUidHashITCase.java
@@ -19,7 +19,6 @@
package org.apache.flink.test.checkpointing;
import org.apache.flink.api.common.JobID;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
@@ -38,6 +37,7 @@ import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.SinkFunction;
import org.apache.flink.streaming.api.functions.source.RichSourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.testutils.junit.SharedObjects;
import org.apache.flink.testutils.junit.SharedReference;
@@ -140,7 +140,7 @@ public class CheckpointRestoreWithUidHashITCase {
final int maxNumber = 100;
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(2, 500));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 2, 500L);
env.enableCheckpointing(500, CheckpointingMode.EXACTLY_ONCE);
JobGraph jobGraph =
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointStoreITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointStoreITCase.java
index 22b705d2432..efce0c561a2 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointStoreITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CheckpointStoreITCase.java
@@ -32,6 +32,7 @@ import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.v2.DiscardingSink;
import org.apache.flink.streaming.api.functions.source.SourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.util.ExceptionUtils;
import org.apache.flink.util.TestLogger;
@@ -44,7 +45,6 @@ import org.junit.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
-import static org.apache.flink.api.common.restartstrategy.RestartStrategies.fixedDelayRestart;
import static org.apache.flink.util.Preconditions.checkState;
import static org.junit.Assert.assertEquals;
@@ -78,7 +78,8 @@ public class CheckpointStoreITCase extends TestLogger {
throws Exception {
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.enableCheckpointing(10);
- env.setRestartStrategy(fixedDelayRestart(2 /* failure on processing + on recovery */, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(
+ env, 2 /* failure on processing + on recovery */, 0L);
env.addSource(emitUntil(() -> FailingMapper.failedAndProcessed))
.map(new FailingMapper())
.sinkTo(new DiscardingSink<>());
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CoStreamCheckpointingITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CoStreamCheckpointingITCase.java
index 2007ac5b289..84eb0a1eb4c 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CoStreamCheckpointingITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/CoStreamCheckpointingITCase.java
@@ -22,7 +22,6 @@ import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.RichFilterFunction;
import org.apache.flink.api.common.functions.RichMapFunction;
import org.apache.flink.api.common.functions.RichReduceFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.streaming.api.checkpoint.ListCheckpointed;
import org.apache.flink.streaming.api.datastream.DataStream;
@@ -30,6 +29,7 @@ import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.co.RichCoFlatMapFunction;
import org.apache.flink.streaming.api.functions.sink.SinkFunction;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.AbstractTestBaseJUnit4;
import org.apache.flink.test.util.TestUtils;
import org.apache.flink.util.Collector;
@@ -76,7 +76,7 @@ public class CoStreamCheckpointingITCase extends AbstractTestBaseJUnit4 {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
env.enableCheckpointing(50);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 0L);
DataStream<String> stream =
env.addSource(new StringGeneratingSourceFunction(NUM_STRINGS, NUM_STRINGS / 5));
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/EventTimeAllWindowCheckpointingITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/EventTimeAllWindowCheckpointingITCase.java
index 0fe64cf0377..1cb1f69586d 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/EventTimeAllWindowCheckpointingITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/EventTimeAllWindowCheckpointingITCase.java
@@ -20,7 +20,6 @@ package org.apache.flink.test.checkpointing;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.ReduceFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple4;
import org.apache.flink.configuration.Configuration;
@@ -34,6 +33,7 @@ import org.apache.flink.streaming.api.windowing.assigners.SlidingEventTimeWindow
import org.apache.flink.streaming.api.windowing.assigners.TumblingEventTimeWindows;
import org.apache.flink.streaming.api.windowing.time.Time;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.checkpointing.utils.FailingSource;
import org.apache.flink.test.checkpointing.utils.IntType;
import org.apache.flink.test.checkpointing.utils.ValidatingSink;
@@ -89,7 +89,7 @@ public class EventTimeAllWindowCheckpointingITCase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.addSource(
new FailingSource(
@@ -166,7 +166,7 @@ public class EventTimeAllWindowCheckpointingITCase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.addSource(
new FailingSource(
@@ -244,7 +244,7 @@ public class EventTimeAllWindowCheckpointingITCase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.addSource(
new FailingSource(
@@ -325,7 +325,7 @@ public class EventTimeAllWindowCheckpointingITCase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.addSource(
new FailingSource(
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/EventTimeWindowCheckpointingITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/EventTimeWindowCheckpointingITCase.java
index 6405546d3d4..d2606dc308a 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/EventTimeWindowCheckpointingITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/EventTimeWindowCheckpointingITCase.java
@@ -20,7 +20,6 @@ package org.apache.flink.test.checkpointing;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.ReduceFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.ValueState;
import org.apache.flink.api.common.state.ValueStateDescriptor;
import org.apache.flink.api.java.tuple.Tuple;
@@ -50,6 +49,7 @@ import org.apache.flink.streaming.api.windowing.assigners.SlidingEventTimeWindow
import org.apache.flink.streaming.api.windowing.assigners.TumblingEventTimeWindows;
import org.apache.flink.streaming.api.windowing.time.Time;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.checkpointing.utils.FailingSource;
import org.apache.flink.test.checkpointing.utils.IntType;
import org.apache.flink.test.checkpointing.utils.ValidatingSink;
@@ -283,7 +283,7 @@ public class EventTimeWindowCheckpointingITCase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.setStateBackend(this.stateBackend);
env.getConfig().setUseSnapshotCompression(true);
@@ -374,7 +374,7 @@ public class EventTimeWindowCheckpointingITCase extends TestLogger {
env.setParallelism(PARALLELISM);
env.setMaxParallelism(maxParallelism);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.setStateBackend(this.stateBackend);
env.getConfig().setUseSnapshotCompression(true);
@@ -463,7 +463,7 @@ public class EventTimeWindowCheckpointingITCase extends TestLogger {
env.setMaxParallelism(2 * PARALLELISM);
env.setParallelism(PARALLELISM);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.setStateBackend(this.stateBackend);
env.getConfig().setUseSnapshotCompression(true);
@@ -545,7 +545,7 @@ public class EventTimeWindowCheckpointingITCase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.setStateBackend(this.stateBackend);
env.getConfig().setUseSnapshotCompression(true);
@@ -629,7 +629,7 @@ public class EventTimeWindowCheckpointingITCase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.setStateBackend(this.stateBackend);
env.getConfig().setUseSnapshotCompression(true);
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/IgnoreInFlightDataITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/IgnoreInFlightDataITCase.java
index 0f073bd72ef..739300b319a 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/IgnoreInFlightDataITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/IgnoreInFlightDataITCase.java
@@ -35,6 +35,7 @@ import org.apache.flink.streaming.api.checkpoint.CheckpointedFunction;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.SinkFunction;
import org.apache.flink.streaming.api.functions.source.SourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.testutils.junit.SharedObjects;
import org.apache.flink.testutils.junit.SharedReference;
@@ -51,7 +52,6 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.LockSupport;
import static java.util.Collections.singletonList;
-import static org.apache.flink.api.common.restartstrategy.RestartStrategies.fixedDelayRestart;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertEquals;
@@ -125,7 +125,7 @@ public class IgnoreInFlightDataITCase extends TestLogger {
env.getCheckpointConfig().setAlignmentTimeout(Duration.ZERO);
env.getCheckpointConfig().setCheckpointingConsistencyMode(CheckpointingMode.EXACTLY_ONCE);
env.getCheckpointConfig().setCheckpointIdOfIgnoredInFlightData(1);
- env.setRestartStrategy(fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.addSource(new NumberSource(lastCheckpointValue))
// map for having parallel execution.
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/IncrementalStateReuseAfterFailureITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/IncrementalStateReuseAfterFailureITCase.java
index e2d2a7117ac..b752018c08b 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/IncrementalStateReuseAfterFailureITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/IncrementalStateReuseAfterFailureITCase.java
@@ -17,7 +17,6 @@
package org.apache.flink.test.checkpointing;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.changelog.fs.FsStateChangelogStorageFactory;
import org.apache.flink.configuration.Configuration;
@@ -36,6 +35,7 @@ import org.apache.flink.streaming.api.datastream.DataStreamUtils;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.v2.DiscardingSink;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.testutils.junit.SharedObjects;
@@ -101,7 +101,7 @@ public class IncrementalStateReuseAfterFailureITCase {
// reliably fails Changelog with FLINK-25395, but might affect any incremental backend
env.enableChangelogStateBackend(true);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 1));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 1L);
env.setMaxParallelism(1); // simplify debugging
env.setParallelism(1); // simplify debugging
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/KeyedStateCheckpointingITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/KeyedStateCheckpointingITCase.java
index 83241a2419f..b5d681b3982 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/KeyedStateCheckpointingITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/KeyedStateCheckpointingITCase.java
@@ -20,7 +20,6 @@ package org.apache.flink.test.checkpointing;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.api.common.state.ValueState;
import org.apache.flink.api.common.state.ValueStateDescriptor;
@@ -39,6 +38,7 @@ import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.util.TestLogger;
@@ -151,7 +151,7 @@ public class KeyedStateCheckpointingITCase extends TestLogger {
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
env.enableCheckpointing(500);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 0L);
env.setStateBackend(stateBackend);
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ProcessingTimeWindowCheckpointingITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ProcessingTimeWindowCheckpointingITCase.java
index 686537adad8..2abce186928 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ProcessingTimeWindowCheckpointingITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ProcessingTimeWindowCheckpointingITCase.java
@@ -21,7 +21,6 @@ package org.apache.flink.test.checkpointing;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.ReduceFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.tuple.Tuple;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.configuration.Configuration;
@@ -35,6 +34,7 @@ import org.apache.flink.streaming.api.windowing.assigners.SlidingProcessingTimeW
import org.apache.flink.streaming.api.windowing.assigners.TumblingProcessingTimeWindows;
import org.apache.flink.streaming.api.windowing.time.Time;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.checkpointing.utils.FailingSource;
import org.apache.flink.test.checkpointing.utils.IntType;
import org.apache.flink.test.checkpointing.utils.ValidatingSink;
@@ -87,7 +87,7 @@ public class ProcessingTimeWindowCheckpointingITCase extends TestLogger {
env.setParallelism(PARALLELISM);
env.getConfig().setAutoWatermarkInterval(10);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
SinkValidatorUpdaterAndChecker updaterAndChecker =
new SinkValidatorUpdaterAndChecker(numElements, 1);
@@ -150,7 +150,7 @@ public class ProcessingTimeWindowCheckpointingITCase extends TestLogger {
env.setParallelism(PARALLELISM);
env.getConfig().setAutoWatermarkInterval(10);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
SinkValidatorUpdaterAndChecker updaterAndChecker =
new SinkValidatorUpdaterAndChecker(numElements, 3);
env.addSource(new FailingSource(new Generator(), numElements, true))
@@ -213,7 +213,7 @@ public class ProcessingTimeWindowCheckpointingITCase extends TestLogger {
env.setParallelism(PARALLELISM);
env.getConfig().setAutoWatermarkInterval(10);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
SinkValidatorUpdaterAndChecker updaterAndChecker =
new SinkValidatorUpdaterAndChecker(numElements, 1);
env.addSource(new FailingSource(new Generator(), numElements, true))
@@ -256,7 +256,7 @@ public class ProcessingTimeWindowCheckpointingITCase extends TestLogger {
env.setParallelism(PARALLELISM);
env.getConfig().setAutoWatermarkInterval(10);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
SinkValidatorUpdaterAndChecker updaterAndChecker =
new SinkValidatorUpdaterAndChecker(numElements, 3);
env.addSource(new FailingSource(new Generator(), numElements, true))
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/RescaleCheckpointManuallyITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/RescaleCheckpointManuallyITCase.java
index 868889edb1a..2d79ff14264 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/RescaleCheckpointManuallyITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/RescaleCheckpointManuallyITCase.java
@@ -20,7 +20,6 @@ package org.apache.flink.test.checkpointing;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.functions.RichFlatMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.ValueState;
import org.apache.flink.api.common.state.ValueStateDescriptor;
import org.apache.flink.api.java.functions.KeySelector;
@@ -40,6 +39,7 @@ import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.SinkFunction;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.testutils.junit.SharedObjects;
import org.apache.flink.testutils.junit.SharedReference;
@@ -242,7 +242,7 @@ public class RescaleCheckpointManuallyITCase extends TestLogger {
env.getCheckpointConfig()
.setExternalizedCheckpointRetention(
ExternalizedCheckpointRetention.RETAIN_ON_CANCELLATION);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.getConfig().setUseSnapshotCompression(true);
SharedReference<JobID> jobID = sharedObjects.add(new JobID());
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/RescalingITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/RescalingITCase.java
index 6ffc8629383..6d2bde2b3be 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/RescalingITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/RescalingITCase.java
@@ -20,7 +20,6 @@ package org.apache.flink.test.checkpointing;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.functions.RichFlatMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
import org.apache.flink.api.common.state.ValueState;
@@ -52,6 +51,7 @@ import org.apache.flink.streaming.api.functions.sink.SinkFunction;
import org.apache.flink.streaming.api.functions.sink.v2.DiscardingSink;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
import org.apache.flink.streaming.api.functions.source.SourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.testutils.TestingUtils;
import org.apache.flink.testutils.executor.TestExecutorResource;
@@ -630,7 +630,7 @@ public class RescalingITCase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(parallelism);
env.getConfig().setMaxParallelism(maxParallelism);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
StateSourceBase.workStartedLatch = new CountDownLatch(parallelism);
@@ -674,7 +674,7 @@ public class RescalingITCase extends TestLogger {
env.getConfig().setMaxParallelism(maxParallelism);
}
env.enableCheckpointing(checkpointingInterval);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.getConfig().setUseSnapshotCompression(true);
DataStream<Integer> input =
@@ -715,7 +715,7 @@ public class RescalingITCase extends TestLogger {
env.setParallelism(parallelism);
env.getConfig().setMaxParallelism(maxParallelism);
env.enableCheckpointing(checkpointingInterval);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
DataStream<Integer> input =
env.addSource(
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ResumeCheckpointManuallyITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ResumeCheckpointManuallyITCase.java
index 9c51b73e3df..5f2b9db86a1 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ResumeCheckpointManuallyITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/ResumeCheckpointManuallyITCase.java
@@ -24,7 +24,6 @@ import org.apache.flink.api.common.eventtime.TimestampAssignerSupplier;
import org.apache.flink.api.common.eventtime.WatermarkGenerator;
import org.apache.flink.api.common.eventtime.WatermarkGeneratorSupplier;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.changelog.fs.FsStateChangelogStorageFactory;
import org.apache.flink.configuration.CheckpointingOptions;
@@ -44,6 +43,7 @@ import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.graph.StreamGraph;
import org.apache.flink.streaming.api.windowing.assigners.TumblingEventTimeWindows;
import org.apache.flink.streaming.api.windowing.time.Time;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.state.ManualWindowSpeedITCase;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.util.TestLogger;
@@ -465,7 +465,7 @@ public class ResumeCheckpointManuallyITCase extends TestLogger {
retainCheckpoints
? ExternalizedCheckpointRetention.RETAIN_ON_CANCELLATION
: ExternalizedCheckpointRetention.DELETE_ON_CANCELLATION);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.addSource(new NotifyingInfiniteTupleSource(10_000))
.assignTimestampsAndWatermarks(IngestionTimeWatermarkStrategy.create())
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/SavepointITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/SavepointITCase.java
index d2fd4fed8e2..4caf8cb5e6f 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/SavepointITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/SavepointITCase.java
@@ -24,7 +24,6 @@ import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.RichFlatMapFunction;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
@@ -88,6 +87,7 @@ import org.apache.flink.streaming.api.operators.BoundedOneInput;
import org.apache.flink.streaming.api.operators.ChainingStrategy;
import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.testutils.EntropyInjectingTestFileSystem;
import org.apache.flink.testutils.TestingUtils;
@@ -252,7 +252,7 @@ public class SavepointITCase extends TestLogger {
.build());
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.getConfig().setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.addSource(new InfiniteTestSource())
.setParallelism(1)
.name("Infinite Source")
@@ -315,7 +315,7 @@ public class SavepointITCase extends TestLogger {
.build());
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.getConfig().setRestartStrategy(RestartStrategies.fixedDelayRestart(3, 10));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 3, 10);
env.setParallelism(1);
env.addSource(new InfiniteTestSource())
.name("Infinite Source")
@@ -1049,8 +1049,7 @@ public class SavepointITCase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(parallelism);
- env.getConfig()
- .setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 0L);
env.addSource(new InfiniteTestSource())
.name("Infinite test source")
.sinkTo(new DiscardingSink<>());
@@ -1135,9 +1134,8 @@ public class SavepointITCase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(1);
- env.getConfig()
- .setRestartStrategy(
- RestartStrategies.fixedDelayRestart(expectedMaximumNumberOfRestarts, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(
+ env, expectedMaximumNumberOfRestarts, 0L);
env.addSource(failingSource)
.name("Failing Source")
.map(
@@ -1361,9 +1359,7 @@ public class SavepointITCase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(parallelism);
env.disableOperatorChaining();
- env.getConfig()
- .setRestartStrategy(
- RestartStrategies.fixedDelayRestart(numberOfRetries, restartDelay));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, numberOfRetries, restartDelay);
DataStream<Integer> stream =
env.addSource(new InfiniteTestSource()).shuffle().map(new StatefulCounter());
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StateHandleReuseITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StateHandleReuseITCase.java
index b830f4d0a32..acf1549e9e8 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StateHandleReuseITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StateHandleReuseITCase.java
@@ -17,7 +17,6 @@
package org.apache.flink.test.checkpointing;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.runtime.operators.lifecycle.TestJobExecutor;
import org.apache.flink.runtime.operators.lifecycle.TestJobWithDescription;
import org.apache.flink.runtime.operators.lifecycle.event.CheckpointCompletedEvent;
@@ -30,6 +29,7 @@ import org.apache.flink.runtime.state.StateSnapshotTransformer;
import org.apache.flink.runtime.state.memory.ByteStreamStateHandle;
import org.apache.flink.runtime.state.ttl.mock.MockKeyedStateBackend.MockSnapshotSupplier;
import org.apache.flink.runtime.state.ttl.mock.MockStateBackend;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.AbstractTestBaseJUnit4;
import org.apache.flink.testutils.junit.SharedObjects;
@@ -74,7 +74,7 @@ public class StateHandleReuseITCase extends AbstractTestBaseJUnit4 {
env -> {
env.setParallelism(1);
env.enableCheckpointing(10);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.setStateBackend(new MockStateBackend(new SingleHandleSnapshotSupplier()));
// changelog backend doesn't work with the mock backend
env.enableChangelogStateBackend(false);
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StatefulJobSnapshotMigrationITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StatefulJobSnapshotMigrationITCase.java
index eb613563d5f..600d246d4e6 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StatefulJobSnapshotMigrationITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StatefulJobSnapshotMigrationITCase.java
@@ -22,7 +22,6 @@ import org.apache.flink.FlinkVersion;
import org.apache.flink.api.common.accumulators.IntCounter;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.RichFlatMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.ValueState;
import org.apache.flink.api.common.state.ValueStateDescriptor;
import org.apache.flink.api.common.typeinfo.TypeHint;
@@ -41,6 +40,7 @@ import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
import org.apache.flink.streaming.api.operators.Triggerable;
import org.apache.flink.streaming.api.watermark.Watermark;
import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.checkpointing.utils.MigrationTestUtils;
import org.apache.flink.test.checkpointing.utils.SnapshotMigrationTestBase;
import org.apache.flink.test.util.MigrationTest;
@@ -165,7 +165,7 @@ public class StatefulJobSnapshotMigrationITCase extends SnapshotMigrationTestBas
final int parallelism = 4;
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
switch (snapshotSpec.getStateBackendType()) {
case StateBackendLoader.ROCKSDB_STATE_BACKEND_NAME:
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StatefulJobWBroadcastStateMigrationITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StatefulJobWBroadcastStateMigrationITCase.java
index 3154b621e00..7e96e48bcf6 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StatefulJobWBroadcastStateMigrationITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StatefulJobWBroadcastStateMigrationITCase.java
@@ -20,7 +20,6 @@ package org.apache.flink.test.checkpointing;
import org.apache.flink.FlinkVersion;
import org.apache.flink.api.common.functions.OpenContext;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.MapStateDescriptor;
import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
import org.apache.flink.api.java.functions.KeySelector;
@@ -34,6 +33,7 @@ import org.apache.flink.streaming.api.datastream.KeyedStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.co.KeyedBroadcastProcessFunction;
import org.apache.flink.streaming.api.functions.source.SourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.checkpointing.utils.MigrationTestUtils;
import org.apache.flink.test.checkpointing.utils.SnapshotMigrationTestBase;
import org.apache.flink.test.util.MigrationTest;
@@ -159,7 +159,7 @@ public class StatefulJobWBroadcastStateMigrationITCase extends SnapshotMigration
final int parallelism = 4;
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
switch (snapshotSpec.getStateBackendType()) {
case StateBackendLoader.ROCKSDB_STATE_BACKEND_NAME:
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StreamCheckpointNotifierITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StreamCheckpointNotifierITCase.java
index 649526df06e..66c7e3cc575 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StreamCheckpointNotifierITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StreamCheckpointNotifierITCase.java
@@ -22,7 +22,6 @@ import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.RichFilterFunction;
import org.apache.flink.api.common.functions.RichMapFunction;
import org.apache.flink.api.common.functions.RichReduceFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.api.java.tuple.Tuple1;
import org.apache.flink.streaming.api.checkpoint.ListCheckpointed;
@@ -34,6 +33,7 @@ import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction;
import org.apache.flink.streaming.api.functions.source.RichSourceFunction;
import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
import org.apache.flink.streaming.api.operators.TwoInputStreamOperator;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.AbstractTestBaseJUnit4;
import org.apache.flink.util.Collector;
@@ -90,7 +90,7 @@ public class StreamCheckpointNotifierITCase extends AbstractTestBaseJUnit4 {
assertEquals("test setup broken", PARALLELISM, env.getParallelism());
env.enableCheckpointing(500);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 0L);
final int numElements = 10000;
final int numTaskTotal = PARALLELISM * 5;
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StreamFaultToleranceTestBase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StreamFaultToleranceTestBase.java
index 568c8bfab65..a0e13ef9d50 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StreamFaultToleranceTestBase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/StreamFaultToleranceTestBase.java
@@ -18,13 +18,13 @@
package org.apache.flink.test.checkpointing;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.changelog.fs.FsStateChangelogStorageFactory;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.JobManagerOptions;
import org.apache.flink.runtime.jobgraph.JobGraph;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.test.util.SuccessException;
import org.apache.flink.util.ExceptionUtils;
@@ -127,7 +127,7 @@ public abstract class StreamFaultToleranceTestBase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
env.enableCheckpointing(500);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 0L);
testProgram(env);
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/UnalignedCheckpointCompatibilityITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/UnalignedCheckpointCompatibilityITCase.java
index 40d740f8636..db21bd203f9 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/UnalignedCheckpointCompatibilityITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/UnalignedCheckpointCompatibilityITCase.java
@@ -18,7 +18,6 @@
package org.apache.flink.test.checkpointing;
import org.apache.flink.api.common.JobExecutionResult;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.core.execution.JobClient;
@@ -29,6 +28,7 @@ import org.apache.flink.runtime.jobgraph.SavepointRestoreSettings;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.graph.StreamGraph;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.checkpointing.utils.AccumulatingIntegerSink;
import org.apache.flink.test.checkpointing.utils.CancellingIntegerSource;
import org.apache.flink.test.util.MiniClusterWithClientResource;
@@ -197,7 +197,7 @@ public class UnalignedCheckpointCompatibilityITCase extends TestLogger {
private StreamExecutionEnvironment env(boolean isAligned, int checkpointingInterval) {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
- env.setRestartStrategy(new RestartStrategies.NoRestartStrategyConfiguration());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.getCheckpointConfig().enableUnalignedCheckpoints(!isAligned);
env.getCheckpointConfig().setAlignmentTimeout(Duration.ZERO);
env.getCheckpointConfig().setExternalizedCheckpointRetention(RETAIN_ON_CANCELLATION);
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/UnalignedCheckpointStressITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/UnalignedCheckpointStressITCase.java
index 66f5f977952..392d18da4d9 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/UnalignedCheckpointStressITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/UnalignedCheckpointStressITCase.java
@@ -20,7 +20,6 @@ package org.apache.flink.test.checkpointing;
import org.apache.flink.api.common.functions.AbstractRichFunction;
import org.apache.flink.api.common.functions.MapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
@@ -48,6 +47,7 @@ import org.apache.flink.streaming.api.graph.StreamGraph;
import org.apache.flink.streaming.api.windowing.assigners.TumblingProcessingTimeWindows;
import org.apache.flink.streaming.api.windowing.time.Time;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.testutils.junit.utils.TempDirUtils;
import org.apache.flink.util.Collector;
@@ -301,7 +301,7 @@ class UnalignedCheckpointStressITCase {
env.setParallelism(PARALLELISM);
env.enableCheckpointing(CHECKPOINT_INTERVAL);
env.getCheckpointConfig().enableUnalignedCheckpoints();
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.getCheckpointConfig()
.setExternalizedCheckpointRetention(
ExternalizedCheckpointRetention.DELETE_ON_CANCELLATION);
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/UnalignedCheckpointTestBase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/UnalignedCheckpointTestBase.java
index 6f733628c7a..83965b57a74 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/UnalignedCheckpointTestBase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/UnalignedCheckpointTestBase.java
@@ -25,7 +25,6 @@ import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.Partitioner;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
@@ -61,6 +60,7 @@ import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.co.RichCoFlatMapFunction;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;
import org.apache.flink.streaming.api.graph.StreamGraph;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.test.util.TestUtils;
import org.apache.flink.testutils.junit.FailsWithAdaptiveScheduler;
@@ -753,10 +753,8 @@ public abstract class UnalignedCheckpointTestBase extends TestLogger {
env.getCheckpointConfig()
.setTolerableCheckpointFailureNumber(tolerableCheckpointFailures);
env.setParallelism(parallelism);
- env.setRestartStrategy(
- RestartStrategies.fixedDelayRestart(
- generateCheckpoint ? expectedFailures / 2 : expectedFailures,
- Duration.ofMillis(100)));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(
+ env, generateCheckpoint ? expectedFailures / 2 : expectedFailures, 100L);
env.getCheckpointConfig().enableUnalignedCheckpoints(true);
// for custom partitioner
env.getCheckpointConfig().setForceUnalignedCheckpoints(true);
diff --git a/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CheckpointedStreamingProgram.java b/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CheckpointedStreamingProgram.java
index 8bcfecc6c44..e5fbfa8ac2f 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CheckpointedStreamingProgram.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CheckpointedStreamingProgram.java
@@ -19,13 +19,13 @@
package org.apache.flink.test.classloading.jar;
import org.apache.flink.api.common.functions.MapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.streaming.api.checkpoint.ListCheckpointed;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.v2.DiscardingSink;
import org.apache.flink.streaming.api.functions.source.SourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import java.util.Collections;
import java.util.List;
@@ -43,7 +43,7 @@ public class CheckpointedStreamingProgram {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.enableCheckpointing(CHECKPOINT_INTERVALL);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 100L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 100L);
env.disableOperatorChaining();
DataStream<String> text = env.addSource(new SimpleStringGenerator());
diff --git a/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CheckpointingCustomKvStateProgram.java b/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CheckpointingCustomKvStateProgram.java
index 5f4bb727012..e984a7f1f4b 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CheckpointingCustomKvStateProgram.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CheckpointingCustomKvStateProgram.java
@@ -22,7 +22,6 @@ import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.ReduceFunction;
import org.apache.flink.api.common.functions.RichFlatMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.api.common.state.ReducingState;
import org.apache.flink.api.common.state.ReducingStateDescriptor;
@@ -40,6 +39,7 @@ import org.apache.flink.streaming.api.checkpoint.ListCheckpointed;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.SuccessException;
import org.apache.flink.util.Collector;
@@ -60,7 +60,7 @@ public class CheckpointingCustomKvStateProgram {
env.setParallelism(parallelism);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 1000));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 1000L);
env.setStateBackend(new FsStateBackend(checkpointPath));
DataStream<Integer> source = env.addSource(new InfiniteIntegerSource());
diff --git a/flink-tests/src/test/java/org/apache/flink/test/execution/JobStatusChangedListenerITCase.java b/flink-tests/src/test/java/org/apache/flink/test/execution/JobStatusChangedListenerITCase.java
index 8530aec01c6..e533b224dcb 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/execution/JobStatusChangedListenerITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/execution/JobStatusChangedListenerITCase.java
@@ -21,7 +21,6 @@ package org.apache.flink.test.execution;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.JobStatus;
import org.apache.flink.api.common.RuntimeExecutionMode;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.connector.source.Boundedness;
import org.apache.flink.client.program.ClusterClient;
import org.apache.flink.configuration.Configuration;
@@ -46,6 +45,7 @@ import org.apache.flink.streaming.api.lineage.LineageVertex;
import org.apache.flink.streaming.api.lineage.LineageVertexProvider;
import org.apache.flink.streaming.runtime.execution.DefaultJobCreatedEvent;
import org.apache.flink.streaming.runtime.execution.JobCreatedEvent;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.util.CloseableIterator;
import org.apache.flink.util.TestLogger;
@@ -137,7 +137,7 @@ public class JobStatusChangedListenerITCase extends TestLogger {
try (StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment(configuration)) {
env.setParallelism(PARALLELISM);
- env.getConfig().setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.addSource(new FastFailureSourceFunction()).addSink(new SleepingSink());
StreamGraph streamGraph = env.getStreamGraph();
diff --git a/flink-tests/src/test/java/org/apache/flink/test/recovery/AbstractTaskManagerProcessFailureRecoveryTest.java b/flink-tests/src/test/java/org/apache/flink/test/recovery/AbstractTaskManagerProcessFailureRecoveryTest.java
index 1a14bfd3dd1..4ca3365fe11 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/recovery/AbstractTaskManagerProcessFailureRecoveryTest.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/recovery/AbstractTaskManagerProcessFailureRecoveryTest.java
@@ -25,6 +25,7 @@ import org.apache.flink.configuration.JobManagerOptions;
import org.apache.flink.configuration.MemorySize;
import org.apache.flink.configuration.NettyShuffleEnvironmentOptions;
import org.apache.flink.configuration.RestOptions;
+import org.apache.flink.configuration.RestartStrategyOptions;
import org.apache.flink.configuration.TaskManagerOptions;
import org.apache.flink.core.testutils.EachCallbackWrapper;
import org.apache.flink.runtime.entrypoint.StandaloneSessionClusterEntrypoint;
@@ -115,6 +116,10 @@ abstract class AbstractTaskManagerProcessFailureRecoveryTest {
config.set(TaskManagerOptions.CPU_CORES, 1.0);
config.set(JobManagerOptions.EXECUTION_FAILOVER_STRATEGY, "full");
config.set(JobManagerOptions.RESOURCE_WAIT_TIMEOUT, Duration.ofSeconds(30L));
+ config.set(RestartStrategyOptions.RESTART_STRATEGY, "fixed-delay");
+ config.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, 1);
+ config.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY, Duration.ofMillis(5000));
try (final StandaloneSessionClusterEntrypoint clusterEntrypoint =
new StandaloneSessionClusterEntrypoint(config)) {
diff --git a/flink-tests/src/test/java/org/apache/flink/test/recovery/BatchFineGrainedRecoveryITCase.java b/flink-tests/src/test/java/org/apache/flink/test/recovery/BatchFineGrainedRecoveryITCase.java
index 69ba9dface4..5d9b2a97cb5 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/recovery/BatchFineGrainedRecoveryITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/recovery/BatchFineGrainedRecoveryITCase.java
@@ -21,12 +21,12 @@ package org.apache.flink.test.recovery;
import org.apache.flink.api.common.ExecutionMode;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.functions.RichMapPartitionFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.JobManagerOptions;
+import org.apache.flink.configuration.RestartStrategyOptions;
import org.apache.flink.configuration.UnmodifiableConfiguration;
import org.apache.flink.runtime.io.network.partition.PartitionNotFoundException;
import org.apache.flink.runtime.jobgraph.JobVertexID;
@@ -235,6 +235,12 @@ public class BatchFineGrainedRecoveryITCase extends TestLogger {
configuration.set(
JobManagerOptions.EXECUTION_FAILOVER_STRATEGY,
PIPELINED_REGION_RESTART_STRATEGY_NAME);
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixed-delay");
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS,
+ MAX_JOB_RESTART_ATTEMPTS);
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY, Duration.ofMillis(10));
return configuration;
}
@@ -259,9 +265,7 @@ public class BatchFineGrainedRecoveryITCase extends TestLogger {
private static ExecutionEnvironment createExecutionEnvironment() {
@SuppressWarnings("StaticVariableUsedBeforeInitialization")
ExecutionEnvironment env = new TestEnvironment(miniCluster, 1, true);
- env.setRestartStrategy(
- RestartStrategies.fixedDelayRestart(
- MAX_JOB_RESTART_ATTEMPTS, Duration.ofMillis(10)));
+
env.getConfig()
.setExecutionMode(
ExecutionMode.BATCH_FORCED); // forces all partitions to be blocking
diff --git a/flink-tests/src/test/java/org/apache/flink/test/recovery/FastFailuresITCase.java b/flink-tests/src/test/java/org/apache/flink/test/recovery/FastFailuresITCase.java
index ef534667a1a..cfc5fff4b69 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/recovery/FastFailuresITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/recovery/FastFailuresITCase.java
@@ -20,12 +20,12 @@ package org.apache.flink.test.recovery;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.common.functions.OpenContext;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.SinkFunction;
import org.apache.flink.streaming.api.functions.source.RichSourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.AbstractTestBaseJUnit4;
import org.junit.Test;
@@ -47,7 +47,7 @@ public class FastFailuresITCase extends AbstractTestBaseJUnit4 {
env.setParallelism(parallelism);
env.enableCheckpointing(1000);
- env.getConfig().setRestartStrategy(RestartStrategies.fixedDelayRestart(210, 0));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 210, 0L);
DataStream<Tuple2<Integer, Integer>> input =
env.addSource(
diff --git a/flink-tests/src/test/java/org/apache/flink/test/recovery/JobManagerHAProcessFailureRecoveryITCase.java b/flink-tests/src/test/java/org/apache/flink/test/recovery/JobManagerHAProcessFailureRecoveryITCase.java
index 1a54d5a1181..cb6355f3812 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/recovery/JobManagerHAProcessFailureRecoveryITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/recovery/JobManagerHAProcessFailureRecoveryITCase.java
@@ -22,7 +22,6 @@ import org.apache.flink.api.common.ExecutionMode;
import org.apache.flink.api.common.functions.ReduceFunction;
import org.apache.flink.api.common.functions.RichFlatMapFunction;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.time.Deadline;
import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
@@ -31,6 +30,7 @@ import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.HighAvailabilityOptions;
import org.apache.flink.configuration.MemorySize;
import org.apache.flink.configuration.NettyShuffleEnvironmentOptions;
+import org.apache.flink.configuration.RestartStrategyOptions;
import org.apache.flink.configuration.TaskManagerOptions;
import org.apache.flink.core.plugin.PluginManager;
import org.apache.flink.core.plugin.PluginUtils;
@@ -146,7 +146,13 @@ class JobManagerHAProcessFailureRecoveryITCase {
ExecutionEnvironment env =
ExecutionEnvironment.createRemoteEnvironment("leader", 1, config);
env.setParallelism(PARALLELISM);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0L));
+ Configuration configuration = new Configuration();
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixed-delay");
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_ATTEMPTS, 1);
+ configuration.set(
+ RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY, Duration.ofMillis(0));
+ env.configure(configuration, Thread.currentThread().getContextClassLoader());
+
env.getConfig().setExecutionMode(executionMode);
final long numElements = 100000L;
diff --git a/flink-tests/src/test/java/org/apache/flink/test/recovery/ProcessFailureCancelingITCase.java b/flink-tests/src/test/java/org/apache/flink/test/recovery/ProcessFailureCancelingITCase.java
index 246399b1a26..081cd0cfc45 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/recovery/ProcessFailureCancelingITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/recovery/ProcessFailureCancelingITCase.java
@@ -19,7 +19,6 @@
package org.apache.flink.test.recovery;
import org.apache.flink.api.common.functions.MapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.io.DiscardingOutputFormat;
import org.apache.flink.client.program.ProgramInvocationException;
@@ -28,6 +27,7 @@ import org.apache.flink.configuration.HighAvailabilityOptions;
import org.apache.flink.configuration.JobManagerOptions;
import org.apache.flink.configuration.MemorySize;
import org.apache.flink.configuration.RestOptions;
+import org.apache.flink.configuration.RestartStrategyOptions;
import org.apache.flink.configuration.RpcOptions;
import org.apache.flink.configuration.TaskManagerOptions;
import org.apache.flink.core.testutils.CommonTestUtils;
@@ -180,7 +180,11 @@ class ProcessFailureCancelingITCase {
ExecutionEnvironment.createRemoteEnvironment(
"localhost", 1337, config);
env.setParallelism(2);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ Configuration configuration = new Configuration();
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "none");
+ env.configure(
+ configuration,
+ Thread.currentThread().getContextClassLoader());
env.generateSequence(0, Long.MAX_VALUE)
.map(
diff --git a/flink-tests/src/test/java/org/apache/flink/test/recovery/SimpleRecoveryITCaseBase.java b/flink-tests/src/test/java/org/apache/flink/test/recovery/SimpleRecoveryITCaseBase.java
index cef9ed45e34..472fe93f5d9 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/recovery/SimpleRecoveryITCaseBase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/recovery/SimpleRecoveryITCaseBase.java
@@ -20,8 +20,9 @@ package org.apache.flink.test.recovery;
import org.apache.flink.api.common.functions.ReduceFunction;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.ExecutionEnvironment;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.RestartStrategyOptions;
import org.apache.flink.runtime.client.JobExecutionException;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.test.util.MiniClusterWithClientResource;
@@ -59,7 +60,9 @@ public abstract class SimpleRecoveryITCaseBase extends TestLogger {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(4);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ Configuration configuration = new Configuration();
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "none");
+ env.configure(configuration, Thread.currentThread().getContextClassLoader());
try {
env.generateSequence(1, 10)
@@ -78,7 +81,9 @@ public abstract class SimpleRecoveryITCaseBase extends TestLogger {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(4);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ Configuration configuration = new Configuration();
+ configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "none");
+ env.configure(configuration, Thread.currentThread().getContextClassLoader());
List<Long> resultCollection =
env.generateSequence(1, 10)
diff --git a/flink-tests/src/test/java/org/apache/flink/test/recovery/TaskManagerProcessFailureBatchRecoveryITCase.java b/flink-tests/src/test/java/org/apache/flink/test/recovery/TaskManagerProcessFailureBatchRecoveryITCase.java
index 457131d57bb..134e54c7705 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/recovery/TaskManagerProcessFailureBatchRecoveryITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/recovery/TaskManagerProcessFailureBatchRecoveryITCase.java
@@ -21,7 +21,6 @@ package org.apache.flink.test.recovery;
import org.apache.flink.api.common.ExecutionMode;
import org.apache.flink.api.common.functions.ReduceFunction;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.configuration.Configuration;
@@ -63,11 +62,9 @@ public class TaskManagerProcessFailureBatchRecoveryITCase
@Override
public void testTaskManagerFailure(Configuration configuration, final File coordinateDir)
throws Exception {
-
ExecutionEnvironment env =
ExecutionEnvironment.createRemoteEnvironment("localhost", 1337, configuration);
env.setParallelism(PARALLELISM);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 5000L));
env.getConfig().setExecutionMode(executionMode);
final long numElements = 100000L;
diff --git a/flink-tests/src/test/java/org/apache/flink/test/recovery/TaskManagerProcessFailureStreamingRecoveryITCase.java b/flink-tests/src/test/java/org/apache/flink/test/recovery/TaskManagerProcessFailureStreamingRecoveryITCase.java
index 9c0bf6ae2ce..ac3d20de52d 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/recovery/TaskManagerProcessFailureStreamingRecoveryITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/recovery/TaskManagerProcessFailureStreamingRecoveryITCase.java
@@ -22,7 +22,6 @@ import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.RichMapFunction;
import org.apache.flink.api.common.functions.RuntimeContext;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.runtime.state.filesystem.FsStateBackend;
import org.apache.flink.streaming.api.checkpoint.ListCheckpointed;
@@ -30,6 +29,7 @@ import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.testutils.junit.extensions.parameterized.NoOpTestExtension;
import org.apache.flink.testutils.junit.utils.TempDirUtils;
@@ -69,7 +69,7 @@ class TaskManagerProcessFailureStreamingRecoveryITCase
1337, // not needed since we use ZooKeeper
configuration);
env.setParallelism(PARALLELISM);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 1000));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 1000L);
env.enableCheckpointing(200);
env.setStateBackend(new FsStateBackend(tempCheckpointDir.getAbsoluteFile().toURI()));
diff --git a/flink-tests/src/test/java/org/apache/flink/test/runtime/BatchShuffleITCaseBase.java b/flink-tests/src/test/java/org/apache/flink/test/runtime/BatchShuffleITCaseBase.java
index 3f03c06d287..6d1454f99ce 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/runtime/BatchShuffleITCaseBase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/runtime/BatchShuffleITCaseBase.java
@@ -21,7 +21,6 @@ package org.apache.flink.test.runtime;
import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.api.common.eventtime.Watermark;
import org.apache.flink.api.common.functions.OpenContext;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
import org.apache.flink.api.connector.source.Boundedness;
import org.apache.flink.configuration.BatchExecutionOptions;
@@ -39,6 +38,7 @@ import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction;
import org.apache.flink.streaming.api.graph.StreamGraph;
import org.apache.flink.streaming.api.graph.StreamingJobGraphGenerator;
import org.apache.flink.streaming.api.operators.StreamSource;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.testutils.junit.utils.TempDirUtils;
import org.junit.jupiter.api.BeforeAll;
@@ -102,7 +102,7 @@ class BatchShuffleITCaseBase {
enableAdaptiveAutoParallelism);
StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment(configuration);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(2, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 2, 0L);
env.setParallelism(NUM_SLOTS_PER_TASK_MANAGER);
DataStream<String> source =
diff --git a/flink-tests/src/test/java/org/apache/flink/test/runtime/DefaultSchedulerLocalRecoveryITCase.java b/flink-tests/src/test/java/org/apache/flink/test/runtime/DefaultSchedulerLocalRecoveryITCase.java
index ddab29f1138..119d0055ec7 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/runtime/DefaultSchedulerLocalRecoveryITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/runtime/DefaultSchedulerLocalRecoveryITCase.java
@@ -18,9 +18,7 @@
package org.apache.flink.test.runtime;
-import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobID;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.client.program.MiniClusterClient;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.JobManagerOptions;
@@ -38,6 +36,7 @@ import org.apache.flink.runtime.minicluster.MiniClusterConfiguration;
import org.apache.flink.runtime.scheduler.DefaultScheduler;
import org.apache.flink.runtime.testutils.CommonTestUtils;
import org.apache.flink.runtime.testutils.WaitingCancelableInvokable;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.testutils.junit.FailsWithAdaptiveScheduler;
import org.apache.flink.util.TestLogger;
@@ -172,12 +171,13 @@ public class DefaultSchedulerLocalRecoveryITCase extends TestLogger {
source.setInvokableClass(WaitingCancelableInvokable.class);
source.setParallelism(parallelism);
- ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 10));
+ JobGraph jobGraph =
+ JobGraphBuilder.newStreamingJobGraphBuilder()
+ .addJobVertices(Arrays.asList(source))
+ .build();
+
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(jobGraph, 1, 10L);
- return JobGraphBuilder.newStreamingJobGraphBuilder()
- .addJobVertices(Arrays.asList(source))
- .setExecutionConfig(executionConfig)
- .build();
+ return jobGraph;
}
}
diff --git a/flink-tests/src/test/java/org/apache/flink/test/runtime/SchedulingITCase.java b/flink-tests/src/test/java/org/apache/flink/test/runtime/SchedulingITCase.java
index e530f3c2a3c..7a164bd2c32 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/runtime/SchedulingITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/runtime/SchedulingITCase.java
@@ -18,9 +18,7 @@
package org.apache.flink.test.runtime;
-import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobID;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.client.program.MiniClusterClient;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.JobManagerOptions;
@@ -39,6 +37,7 @@ import org.apache.flink.runtime.jobmaster.JobResult;
import org.apache.flink.runtime.minicluster.MiniCluster;
import org.apache.flink.runtime.minicluster.MiniClusterConfiguration;
import org.apache.flink.runtime.testtasks.NoOpInvokable;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.util.FlinkException;
import org.apache.flink.util.TestLogger;
@@ -144,13 +143,13 @@ public class SchedulingITCase extends TestLogger {
sink.connectNewDataSetAsInput(
source, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
- ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, delay));
+ JobGraph jobGraph =
+ JobGraphBuilder.newStreamingJobGraphBuilder()
+ .addJobVertices(Arrays.asList(source, sink))
+ .build();
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(jobGraph, 1, delay);
- return JobGraphBuilder.newStreamingJobGraphBuilder()
- .addJobVertices(Arrays.asList(source, sink))
- .setExecutionConfig(executionConfig)
- .build();
+ return jobGraph;
}
/** Invokable which fails exactly once (one sub task of it). */
diff --git a/flink-tests/src/test/java/org/apache/flink/test/runtime/entrypoint/StreamingNoop.java b/flink-tests/src/test/java/org/apache/flink/test/runtime/entrypoint/StreamingNoop.java
index aba81d8c1a5..0980e7cd243 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/runtime/entrypoint/StreamingNoop.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/runtime/entrypoint/StreamingNoop.java
@@ -18,12 +18,12 @@
package org.apache.flink.test.runtime.entrypoint;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.runtime.jobgraph.JobGraph;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.v2.DiscardingSink;
import org.apache.flink.streaming.api.functions.source.FileMonitoringFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import java.io.File;
import java.io.FileOutputStream;
@@ -45,7 +45,7 @@ public class StreamingNoop {
// define the dataflow
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(2);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(10, 1000));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 10, 1000);
env.readFileStream("input/", 60000, FileMonitoringFunction.WatchType.ONLY_NEW_FILES)
.sinkTo(new DiscardingSink<>());
diff --git a/flink-tests/src/test/java/org/apache/flink/test/runtime/leaderelection/ZooKeeperLeaderElectionITCase.java b/flink-tests/src/test/java/org/apache/flink/test/runtime/leaderelection/ZooKeeperLeaderElectionITCase.java
index 9907c80b622..95ddcbb4cf0 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/runtime/leaderelection/ZooKeeperLeaderElectionITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/runtime/leaderelection/ZooKeeperLeaderElectionITCase.java
@@ -18,9 +18,7 @@
package org.apache.flink.test.runtime.leaderelection;
-import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobStatus;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.configuration.ClusterOptions;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.runtime.dispatcher.DispatcherGateway;
@@ -38,6 +36,7 @@ import org.apache.flink.runtime.minicluster.TestingMiniClusterConfiguration;
import org.apache.flink.runtime.testutils.CommonTestUtils;
import org.apache.flink.runtime.testutils.ZooKeeperTestUtils;
import org.apache.flink.runtime.util.ZooKeeperUtils;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.util.TestLogger;
import org.apache.curator.test.TestingServer;
@@ -199,14 +198,13 @@ public class ZooKeeperLeaderElectionITCase extends TestLogger {
// is undefined behavior. By allowing restarts we prevent the job from reaching a globally
// terminal state,
// causing it to be recovered by the next Dispatcher.
- ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.setRestartStrategy(
- RestartStrategies.fixedDelayRestart(10, Duration.ofSeconds(10).toMillis()));
-
- return JobGraphBuilder.newStreamingJobGraphBuilder()
- .addJobVertex(vertex)
- .setExecutionConfig(executionConfig)
- .build();
+ JobGraph jobGraph =
+ JobGraphBuilder.newStreamingJobGraphBuilder().addJobVertex(vertex).build();
+
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(
+ jobGraph, 10, Duration.ofSeconds(10L));
+
+ return jobGraph;
}
/** Blocking invokable which is controlled by a static field. */
diff --git a/flink-tests/src/test/java/org/apache/flink/test/scheduling/AdaptiveSchedulerITCase.java b/flink-tests/src/test/java/org/apache/flink/test/scheduling/AdaptiveSchedulerITCase.java
index d21e7506653..954b819012c 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/scheduling/AdaptiveSchedulerITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/scheduling/AdaptiveSchedulerITCase.java
@@ -18,10 +18,8 @@
package org.apache.flink.test.scheduling;
-import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.JobStatus;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
@@ -58,6 +56,7 @@ import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.DiscardingSink;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.util.FlinkException;
import org.apache.flink.util.Preconditions;
@@ -181,7 +180,7 @@ public class AdaptiveSchedulerITCase extends TestLogger {
public void testStopWithSavepointFailOnCheckpoint() throws Exception {
StreamExecutionEnvironment env =
getEnvWithSource(StopWithSavepointTestBehavior.FAIL_ON_CHECKPOINT);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 0L);
DummySource.resetForParallelism(PARALLELISM);
@@ -206,7 +205,7 @@ public class AdaptiveSchedulerITCase extends TestLogger {
public void testStopWithSavepointFailOnStop() throws Throwable {
StreamExecutionEnvironment env =
getEnvWithSource(StopWithSavepointTestBehavior.FAIL_ON_CHECKPOINT_COMPLETE);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, Integer.MAX_VALUE, 0L);
DummySource.resetForParallelism(PARALLELISM);
@@ -235,7 +234,7 @@ public class AdaptiveSchedulerITCase extends TestLogger {
@Test
public void testStopWithSavepointFailOnFirstSavepointSucceedOnSecond() throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
env.setParallelism(PARALLELISM);
@@ -312,15 +311,11 @@ public class AdaptiveSchedulerITCase extends TestLogger {
new FailingCoordinatorProvider(OperatorID.fromJobVertexID(jobVertexId))));
jobVertex.setParallelism(1);
- final ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.setRestartStrategy(
- RestartStrategies.fixedDelayRestart(1, Duration.ofHours(1)));
-
final JobGraph jobGraph =
JobGraphBuilder.newStreamingJobGraphBuilder()
.addJobVertices(Collections.singletonList(jobVertex))
- .setExecutionConfig(executionConfig)
.build();
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(jobGraph, 1, Duration.ofHours(1L));
miniCluster.submitJob(jobGraph).join();
// We rely on waiting in restarting state (see the restart strategy above)
diff --git a/flink-tests/src/test/java/org/apache/flink/test/scheduling/ReactiveModeITCase.java b/flink-tests/src/test/java/org/apache/flink/test/scheduling/ReactiveModeITCase.java
index 009eae3cc06..9de3f812082 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/scheduling/ReactiveModeITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/scheduling/ReactiveModeITCase.java
@@ -20,7 +20,6 @@ package org.apache.flink.test.scheduling;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.functions.OpenContext;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.client.program.rest.RestClusterClient;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.JobManagerOptions;
@@ -35,6 +34,7 @@ import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.v2.DiscardingSink;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
import org.apache.flink.streaming.api.functions.source.SourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.util.TestLogger;
import org.apache.flink.util.jackson.JacksonMapperFactory;
@@ -175,7 +175,7 @@ public class ReactiveModeITCase extends TestLogger {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
// configure exactly one restart to avoid restart loops in error cases
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
final DataStream<String> input = env.addSource(new DummySource());
input.sinkTo(new DiscardingSink<>());
diff --git a/flink-tests/src/test/java/org/apache/flink/test/state/TaskManagerWideRocksDbMemorySharingITCase.java b/flink-tests/src/test/java/org/apache/flink/test/state/TaskManagerWideRocksDbMemorySharingITCase.java
index f99968263f5..2b87ce76d0b 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/state/TaskManagerWideRocksDbMemorySharingITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/state/TaskManagerWideRocksDbMemorySharingITCase.java
@@ -33,6 +33,7 @@ import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.v2.DiscardingSink;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.testutils.junit.SharedObjects;
import org.apache.flink.testutils.junit.SharedReference;
@@ -51,7 +52,6 @@ import java.util.List;
import java.util.Random;
import java.util.concurrent.CopyOnWriteArrayList;
-import static org.apache.flink.api.common.restartstrategy.RestartStrategies.noRestart;
import static org.apache.flink.runtime.testutils.CommonTestUtils.waitForAllTaskRunning;
/**
@@ -126,7 +126,7 @@ public class TaskManagerWideRocksDbMemorySharingITCase extends TestLogger {
// don't flush memtables by checkpoints
env.enableCheckpointing(24 * 60 * 60 * 1000, CheckpointingMode.EXACTLY_ONCE);
- env.setRestartStrategy(noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
DataStreamSource<Long> src = env.fromSequence(Long.MIN_VALUE, Long.MAX_VALUE);
src.keyBy(number -> number)
diff --git a/flink-tests/src/test/java/org/apache/flink/test/state/operator/restore/AbstractOperatorRestoreTestBase.java b/flink-tests/src/test/java/org/apache/flink/test/state/operator/restore/AbstractOperatorRestoreTestBase.java
index f96a4fc7a77..1554eb75175 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/state/operator/restore/AbstractOperatorRestoreTestBase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/state/operator/restore/AbstractOperatorRestoreTestBase.java
@@ -20,7 +20,6 @@ package org.apache.flink.test.state.operator.restore;
import org.apache.flink.FlinkVersion;
import org.apache.flink.api.common.JobStatus;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.time.Deadline;
import org.apache.flink.client.program.ClusterClient;
import org.apache.flink.core.execution.CheckpointingMode;
@@ -33,6 +32,7 @@ import org.apache.flink.runtime.state.memory.MemoryStateBackend;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.graph.StreamingJobGraphGenerator;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.MigrationTest;
import org.apache.flink.test.util.MiniClusterWithClientResource;
import org.apache.flink.testutils.TestingUtils;
@@ -258,7 +258,7 @@ public abstract class AbstractOperatorRestoreTestBase extends TestLogger impleme
private JobGraph createJobGraph(ExecutionMode mode) {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.enableCheckpointing(500, CheckpointingMode.EXACTLY_ONCE);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.setStateBackend((StateBackend) new MemoryStateBackend());
switch (mode) {
diff --git a/flink-tests/src/test/java/org/apache/flink/test/state/operator/restore/keyed/KeyedJob.java b/flink-tests/src/test/java/org/apache/flink/test/state/operator/restore/keyed/KeyedJob.java
index 91c0f65f07c..99547e5c7a3 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/state/operator/restore/keyed/KeyedJob.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/state/operator/restore/keyed/KeyedJob.java
@@ -20,7 +20,6 @@ package org.apache.flink.test.state.operator.restore.keyed;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
import org.apache.flink.api.java.tuple.Tuple;
@@ -37,6 +36,7 @@ import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.RichSourceFunction;
import org.apache.flink.streaming.api.functions.windowing.RichWindowFunction;
import org.apache.flink.streaming.api.windowing.windows.GlobalWindow;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.state.operator.restore.ExecutionMode;
import org.apache.flink.util.Collector;
@@ -67,7 +67,7 @@ public class KeyedJob {
StreamExecutionEnvironment env =
StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(config);
env.enableCheckpointing(500, CheckpointingMode.EXACTLY_ONCE);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.setStateBackend(new MemoryStateBackend());
diff --git a/flink-tests/src/test/java/org/apache/flink/test/state/operator/restore/unkeyed/NonKeyedJob.java b/flink-tests/src/test/java/org/apache/flink/test/state/operator/restore/unkeyed/NonKeyedJob.java
index f86df36bd99..844385a49ab 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/state/operator/restore/unkeyed/NonKeyedJob.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/state/operator/restore/unkeyed/NonKeyedJob.java
@@ -20,7 +20,6 @@ package org.apache.flink.test.state.operator.restore.unkeyed;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.configuration.CheckpointingOptions;
import org.apache.flink.configuration.Configuration;
@@ -31,6 +30,7 @@ import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.state.operator.restore.ExecutionMode;
import org.junit.Assert;
@@ -59,7 +59,7 @@ public class NonKeyedJob {
StreamExecutionEnvironment env =
StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(config);
env.enableCheckpointing(500, CheckpointingMode.EXACTLY_ONCE);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.setStateBackend(new MemoryStateBackend());
diff --git a/flink-tests/src/test/java/org/apache/flink/test/streaming/api/datastream/ReinterpretDataStreamAsKeyedStreamITCase.java b/flink-tests/src/test/java/org/apache/flink/test/streaming/api/datastream/ReinterpretDataStreamAsKeyedStreamITCase.java
index 62ea34266fc..2c9b3742206 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/streaming/api/datastream/ReinterpretDataStreamAsKeyedStreamITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/streaming/api/datastream/ReinterpretDataStreamAsKeyedStreamITCase.java
@@ -25,7 +25,6 @@ import org.apache.flink.api.common.eventtime.WatermarkGeneratorSupplier;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.ReduceFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.CheckpointListener;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
@@ -43,6 +42,7 @@ import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction;
import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
import org.apache.flink.streaming.api.windowing.assigners.TumblingEventTimeWindows;
import org.apache.flink.streaming.api.windowing.time.Time;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.util.Preconditions;
import org.junit.Assert;
@@ -90,7 +90,7 @@ public class ReinterpretDataStreamAsKeyedStreamITCase {
env.setMaxParallelism(maxParallelism);
env.setParallelism(parallelism);
env.enableCheckpointing(100);
- env.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0L));
+ RestartStrategyUtils.configureFixedDelayRestartStrategy(env, 1, 0L);
final List<File> partitionFiles = new ArrayList<>(parallelism);
for (int i = 0; i < parallelism; ++i) {
diff --git a/flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/LatencyMarkerITCase.java b/flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/LatencyMarkerITCase.java
index 43f0a835a21..449870761ff 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/LatencyMarkerITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/LatencyMarkerITCase.java
@@ -18,13 +18,13 @@
package org.apache.flink.test.streaming.runtime;
import org.apache.flink.api.common.JobExecutionResult;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.MapStateDescriptor;
import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.co.BroadcastProcessFunction;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.checkpointing.utils.MigrationTestUtils.AccumulatorCountingSink;
import org.apache.flink.util.Collector;
@@ -49,7 +49,7 @@ public class LatencyMarkerITCase {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(parallelism);
env.getConfig().setLatencyTrackingInterval(2000);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
List<Integer> broadcastData =
IntStream.range(0, inputCount).boxed().collect(Collectors.toList());
diff --git a/flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/StateBackendITCase.java b/flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/StateBackendITCase.java
index fa1f0fbf0eb..de4fb76a98e 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/StateBackendITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/StateBackendITCase.java
@@ -21,7 +21,6 @@ package org.apache.flink.test.streaming.runtime;
import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.functions.OpenContext;
import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.state.ValueStateDescriptor;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.runtime.client.JobExecutionException;
@@ -33,6 +32,7 @@ import org.apache.flink.runtime.state.OperatorStateBackend;
import org.apache.flink.runtime.state.StateBackend;
import org.apache.flink.runtime.state.memory.MemoryBackendCheckpointStorageAccess;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.util.AbstractTestBaseJUnit4;
import org.apache.flink.util.ExceptionUtils;
@@ -53,7 +53,7 @@ public class StateBackendITCase extends AbstractTestBaseJUnit4 {
StreamExecutionEnvironment see = StreamExecutionEnvironment.getExecutionEnvironment();
see.setParallelism(1);
- see.getConfig().setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(see);
see.setStateBackend(new FailingStateBackend());
see.fromData(new Tuple2<>("Hello", 1))
diff --git a/flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/UnifiedSinkMigrationITCase.java b/flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/UnifiedSinkMigrationITCase.java
index 949d93da032..ac586c7df0c 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/UnifiedSinkMigrationITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/UnifiedSinkMigrationITCase.java
@@ -20,7 +20,6 @@ package org.apache.flink.test.streaming.runtime;
import org.apache.flink.api.common.JobStatus;
import org.apache.flink.api.common.functions.MapFunction;
-import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.connector.sink.Committer;
import org.apache.flink.api.connector.sink.GlobalCommitter;
import org.apache.flink.api.connector.sink.Sink;
@@ -35,6 +34,7 @@ import org.apache.flink.core.memory.DataOutputSerializer;
import org.apache.flink.core.testutils.OneShotLatch;
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.util.RestartStrategyUtils;
import org.apache.flink.test.junit5.MiniClusterExtension;
import org.apache.flink.testutils.junit.SharedObjectsExtension;
import org.apache.flink.testutils.junit.SharedReference;
@@ -136,7 +136,7 @@ class UnifiedSinkMigrationITCase {
env.enableCheckpointing(100);
env.setParallelism(1);
- env.setRestartStrategy(RestartStrategies.noRestart());
+ RestartStrategyUtils.configureNoRestartStrategy(env);
env.fromSequence(1, Long.MAX_VALUE)
.map(
(MapFunction<Long, Long>)