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 2023/11/28 06:17:23 UTC
(flink) branch master updated (22028753985 -> dae2eb5b61f)
This is an automated email from the ASF dual-hosted git repository.
zhuzh pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
from 22028753985 [FLINK-33643][runtime] Allow StreamExecutionEnvironment's executeAsync API to use default JobName (#23794)
new 0e0099b4eb1 [FLINK-33581][core] Deprecate complex Java objects and their corresponding getter/setter methods related to restart strategies.
new 139db3f4bc7 [FLINK-33581][core] Deprecate getter/setter methods related to checkpoint storage in the CheckpointConfig.
new dae2eb5b61f [FLINK-33581][core] Deprecate getter/setter methods related to state backend in the StreamExecutionEnvironment.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../5b9eed8a-5fb6-4373-98ac-3be2a71941b8 | 4 --
.../apache/flink/api/common/ExecutionConfig.java | 24 +++++++-
.../common/restartstrategy/RestartStrategies.java | 18 ++++++
.../examples/statemachine/StateMachineExample.java | 24 +++++---
.../api/environment/CheckpointConfig.java | 68 ++++++++++++++++++++++
.../environment/StreamExecutionEnvironment.java | 47 ++++++++++++++-
6 files changed, 170 insertions(+), 15 deletions(-)
(flink) 02/03: [FLINK-33581][core] Deprecate getter/setter methods related to checkpoint storage in the CheckpointConfig.
Posted by zh...@apache.org.
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 139db3f4bc7faed4478393a91a063ad54d15a523
Author: JunRuiLee <jr...@gmail.com>
AuthorDate: Mon Nov 20 16:58:04 2023 +0800
[FLINK-33581][core] Deprecate getter/setter methods related to checkpoint storage in the CheckpointConfig.
---
.../examples/statemachine/StateMachineExample.java | 14 +++--
.../api/environment/CheckpointConfig.java | 68 ++++++++++++++++++++++
2 files changed, 78 insertions(+), 4 deletions(-)
diff --git a/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/statemachine/StateMachineExample.java b/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/statemachine/StateMachineExample.java
index 82ec3674178..f905043b2ee 100644
--- a/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/statemachine/StateMachineExample.java
+++ b/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/statemachine/StateMachineExample.java
@@ -27,6 +27,8 @@ import org.apache.flink.api.common.state.ValueStateDescriptor;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.connector.source.util.ratelimit.RateLimiterStrategy;
import org.apache.flink.api.java.utils.ParameterTool;
+import org.apache.flink.configuration.CheckpointingOptions;
+import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.MemorySize;
import org.apache.flink.connector.datagen.source.DataGeneratorSource;
import org.apache.flink.connector.datagen.source.GeneratorFunction;
@@ -82,20 +84,24 @@ public class StateMachineExample {
final ParameterTool params = ParameterTool.fromArgs(args);
// create the environment to create streams and configure execution
- final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- env.enableCheckpointing(2000L);
+ Configuration configuration = new Configuration();
final String stateBackend = params.get("backend", "memory");
if ("hashmap".equals(stateBackend)) {
final String checkpointDir = params.get("checkpoint-dir");
env.setStateBackend(new HashMapStateBackend());
- env.getCheckpointConfig().setCheckpointStorage(checkpointDir);
+ configuration.set(CheckpointingOptions.CHECKPOINT_STORAGE, "filesystem");
+ configuration.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir);
} else if ("rocks".equals(stateBackend)) {
final String checkpointDir = params.get("checkpoint-dir");
boolean incrementalCheckpoints = params.getBoolean("incremental-checkpoints", false);
env.setStateBackend(new EmbeddedRocksDBStateBackend(incrementalCheckpoints));
- env.getCheckpointConfig().setCheckpointStorage(checkpointDir);
+ configuration.set(CheckpointingOptions.CHECKPOINT_STORAGE, "filesystem");
+ configuration.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir);
}
+ final StreamExecutionEnvironment env =
+ StreamExecutionEnvironment.getExecutionEnvironment(configuration);
+ env.enableCheckpointing(2000L);
if (params.has("kafka-topic")) {
// set up the Kafka reader
diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/CheckpointConfig.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/CheckpointConfig.java
index b80ed10bb73..cf299080571 100644
--- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/CheckpointConfig.java
+++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/CheckpointConfig.java
@@ -747,8 +747,23 @@ public class CheckpointConfig implements java.io.Serializable {
* terabytes while providing a highly available foundation for stateful applications. This
* checkpoint storage policy is recommended for most production deployments.
*
+ * @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 for configuring checkpoint storage like the following code snippet:
+ * <pre>{@code
+ * Configuration config = new Configuration();
+ * config.set(CheckpointingOptions.CHECKPOINT_STORAGE, "filesystem");
+ * config.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, "file:///flink/checkpoints");
+ * StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(config);
+ * }</pre>
+ * For more details on using ConfigOption for checkpoint storage configuration, please refer
+ * to the Flink documentation: <a
+ * href="https://nightlies.apache.org/flink/flink-docs-stable/docs/ops/state/checkpoints">Checkpoints</a>
* @param storage The checkpoint storage policy.
*/
+ @Deprecated
@PublicEvolving
public void setCheckpointStorage(CheckpointStorage storage) {
Preconditions.checkNotNull(storage, "Checkpoint storage must not be null");
@@ -759,9 +774,24 @@ public class CheckpointConfig implements java.io.Serializable {
* Configures the application to write out checkpoint snapshots to the configured directory. See
* {@link FileSystemCheckpointStorage} for more details on checkpointing to a file system.
*
+ * @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 for configuring checkpoint storage like the following code snippet:
+ * <pre>{@code
+ * Configuration config = new Configuration();
+ * config.set(CheckpointingOptions.CHECKPOINT_STORAGE, "filesystem");
+ * config.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, "file:///flink/checkpoints");
+ * StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(config);
+ * }</pre>
+ * For more details on using ConfigOption for checkpoint storage configuration, please refer
+ * to the Flink documentation: <a
+ * href="https://nightlies.apache.org/flink/flink-docs-stable/docs/ops/state/checkpoints">Checkpoints</a>
* @param checkpointDirectory The path to write checkpoint metadata to.
* @see #setCheckpointStorage(CheckpointStorage)
*/
+ @Deprecated
@PublicEvolving
public void setCheckpointStorage(String checkpointDirectory) {
Preconditions.checkNotNull(checkpointDirectory, "Checkpoint directory must not be null");
@@ -772,9 +802,24 @@ public class CheckpointConfig implements java.io.Serializable {
* Configures the application to write out checkpoint snapshots to the configured directory. See
* {@link FileSystemCheckpointStorage} for more details on checkpointing to a file system.
*
+ * @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 for configuring checkpoint storage like the following code snippet:
+ * <pre>{@code
+ * Configuration config = new Configuration();
+ * config.set(CheckpointingOptions.CHECKPOINT_STORAGE, "filesystem");
+ * config.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, "file:///flink/checkpoints");
+ * StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(config);
+ * }</pre>
+ * For more details on using ConfigOption for checkpoint storage configuration, please refer
+ * to the Flink documentation: <a
+ * href="https://nightlies.apache.org/flink/flink-docs-stable/docs/ops/state/checkpoints">Checkpoints</a>
* @param checkpointDirectory The path to write checkpoint metadata to.
* @see #setCheckpointStorage(CheckpointStorage)
*/
+ @Deprecated
@PublicEvolving
public void setCheckpointStorage(URI checkpointDirectory) {
Preconditions.checkNotNull(checkpointDirectory, "Checkpoint directory must not be null");
@@ -785,9 +830,24 @@ public class CheckpointConfig implements java.io.Serializable {
* Configures the application to write out checkpoint snapshots to the configured directory. See
* {@link FileSystemCheckpointStorage} for more details on checkpointing to a file system.
*
+ * @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 for configuring checkpoint storage like the following code snippet:
+ * <pre>{@code
+ * Configuration config = new Configuration();
+ * config.set(CheckpointingOptions.CHECKPOINT_STORAGE, "filesystem");
+ * config.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, "file:///flink/checkpoints");
+ * StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(config);
+ * }</pre>
+ * For more details on using ConfigOption for checkpoint storage configuration, please refer
+ * to the Flink documentation: <a
+ * href="https://nightlies.apache.org/flink/flink-docs-stable/docs/ops/state/checkpoints">Checkpoints</a>
* @param checkpointDirectory The path to write checkpoint metadata to.
* @see #setCheckpointStorage(String)
*/
+ @Deprecated
@PublicEvolving
public void setCheckpointStorage(Path checkpointDirectory) {
Preconditions.checkNotNull(checkpointDirectory, "Checkpoint directory must not be null");
@@ -795,10 +855,18 @@ public class CheckpointConfig implements java.io.Serializable {
}
/**
+ * @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 find which checkpoint storage is
+ * used by checkpoint storage ConfigOption. For more details on using ConfigOption for
+ * checkpoint storage configuration, please refer to the Flink documentation: <a
+ * href="https://nightlies.apache.org/flink/flink-docs-stable/docs/ops/state/checkpoints">Checkpoints</a>
* @return The {@link CheckpointStorage} that has been configured for the job. Or {@code null}
* if none has been set.
* @see #setCheckpointStorage(CheckpointStorage)
*/
+ @Deprecated
@Nullable
@PublicEvolving
public CheckpointStorage getCheckpointStorage() {
(flink) 01/03: [FLINK-33581][core] Deprecate complex Java objects and their corresponding getter/setter methods related to restart strategies.
Posted by zh...@apache.org.
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 0e0099b4eb1285929fec02326f661cba899eedcd
Author: JunRuiLee <jr...@gmail.com>
AuthorDate: Mon Nov 20 16:14:56 2023 +0800
[FLINK-33581][core] Deprecate complex Java objects and their corresponding getter/setter methods related to restart strategies.
This closes #23758.
---
.../5b9eed8a-5fb6-4373-98ac-3be2a71941b8 | 4 ----
.../apache/flink/api/common/ExecutionConfig.java | 24 +++++++++++++++++++++-
.../common/restartstrategy/RestartStrategies.java | 18 ++++++++++++++++
.../environment/StreamExecutionEnvironment.java | 14 +++++++++++++
4 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/flink-architecture-tests/flink-architecture-tests-production/archunit-violations/5b9eed8a-5fb6-4373-98ac-3be2a71941b8 b/flink-architecture-tests/flink-architecture-tests-production/archunit-violations/5b9eed8a-5fb6-4373-98ac-3be2a71941b8
index cad03129799..7510d7d0190 100644
--- a/flink-architecture-tests/flink-architecture-tests-production/archunit-violations/5b9eed8a-5fb6-4373-98ac-3be2a71941b8
+++ b/flink-architecture-tests/flink-architecture-tests-production/archunit-violations/5b9eed8a-5fb6-4373-98ac-3be2a71941b8
@@ -1,5 +1,3 @@
-org.apache.flink.api.common.ExecutionConfig.getRestartStrategy(): Returned leaf type org.apache.flink.api.common.restartstrategy.RestartStrategies$RestartStrategyConfiguration does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
-org.apache.flink.api.common.ExecutionConfig.setRestartStrategy(org.apache.flink.api.common.restartstrategy.RestartStrategies$RestartStrategyConfiguration): Argument leaf type org.apache.flink.api.common.restartstrategy.RestartStrategies$RestartStrategyConfiguration does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.api.common.eventtime.TimestampAssignerSupplier.createTimestampAssigner(org.apache.flink.api.common.eventtime.TimestampAssignerSupplier$Context): Argument leaf type org.apache.flink.api.common.eventtime.TimestampAssignerSupplier$Context does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.api.common.eventtime.WatermarkGeneratorSupplier.createWatermarkGenerator(org.apache.flink.api.common.eventtime.WatermarkGeneratorSupplier$Context): Argument leaf type org.apache.flink.api.common.eventtime.WatermarkGeneratorSupplier$Context does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.api.common.operators.Operator.getMinResources(): Returned leaf type org.apache.flink.api.common.operators.ResourceSpec does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
@@ -185,8 +183,6 @@ org.apache.flink.streaming.api.datastream.BroadcastStream.getTransformation(): R
org.apache.flink.streaming.api.datastream.DataStream.getMinResources(): Returned leaf type org.apache.flink.api.common.operators.ResourceSpec does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.streaming.api.datastream.DataStream.getPreferredResources(): Returned leaf type org.apache.flink.api.common.operators.ResourceSpec does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.streaming.api.datastream.DataStream.transform(java.lang.String, org.apache.flink.api.common.typeinfo.TypeInformation, org.apache.flink.streaming.api.operators.OneInputStreamOperatorFactory): Argument leaf type org.apache.flink.streaming.api.operators.OneInputStreamOperatorFactory does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
-org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getRestartStrategy(): Returned leaf type org.apache.flink.api.common.restartstrategy.RestartStrategies$RestartStrategyConfiguration does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
-org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.setRestartStrategy(org.apache.flink.api.common.restartstrategy.RestartStrategies$RestartStrategyConfiguration): Argument leaf type org.apache.flink.api.common.restartstrategy.RestartStrategies$RestartStrategyConfiguration does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.streaming.api.functions.KeyedProcessFunction.onTimer(long, org.apache.flink.streaming.api.functions.KeyedProcessFunction$OnTimerContext, org.apache.flink.util.Collector): Argument leaf type org.apache.flink.streaming.api.functions.KeyedProcessFunction$OnTimerContext does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.streaming.api.functions.KeyedProcessFunction.processElement(java.lang.Object, org.apache.flink.streaming.api.functions.KeyedProcessFunction$Context, org.apache.flink.util.Collector): Argument leaf type org.apache.flink.streaming.api.functions.KeyedProcessFunction$Context does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.streaming.api.functions.ProcessFunction.onTimer(long, org.apache.flink.streaming.api.functions.ProcessFunction$OnTimerContext, org.apache.flink.util.Collector): Argument leaf type org.apache.flink.streaming.api.functions.ProcessFunction$OnTimerContext does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
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 22aee331513..3b0c73eba00 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
@@ -149,6 +149,15 @@ public class ExecutionConfig implements Serializable, Archiveable<ArchivedExecut
*/
@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();
@@ -434,8 +443,15 @@ public class ExecutionConfig implements Serializable, Archiveable<ArchivedExecut
* 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) {
@@ -446,10 +462,16 @@ public class ExecutionConfig implements Serializable, Archiveable<ArchivedExecut
/**
* 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
- @SuppressWarnings("deprecation")
public RestartStrategies.RestartStrategyConfiguration getRestartStrategy() {
if (restartStrategyConfiguration
instanceof RestartStrategies.FallbackRestartStrategyConfiguration) {
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
index 54a9c212cfb..10363d77f65 100644
--- 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
@@ -35,7 +35,25 @@ import java.util.concurrent.TimeUnit;
*
* <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 {
diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java
index 4ecb9763f49..52b5e30034f 100644
--- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java
+++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java
@@ -788,8 +788,15 @@ public class StreamExecutionEnvironment implements AutoCloseable {
* 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) {
@@ -799,8 +806,15 @@ public class StreamExecutionEnvironment implements AutoCloseable {
/**
* 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();
(flink) 03/03: [FLINK-33581][core] Deprecate getter/setter methods related to state backend in the StreamExecutionEnvironment.
Posted by zh...@apache.org.
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 dae2eb5b61f71b9453a73e4f0b3c69fd28f54ebf
Author: JunRuiLee <jr...@gmail.com>
AuthorDate: Mon Nov 20 17:05:00 2023 +0800
[FLINK-33581][core] Deprecate getter/setter methods related to state backend in the StreamExecutionEnvironment.
---
.../examples/statemachine/StateMachineExample.java | 10 ++++---
.../environment/StreamExecutionEnvironment.java | 33 ++++++++++++++++++++--
2 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/statemachine/StateMachineExample.java b/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/statemachine/StateMachineExample.java
index f905043b2ee..940b836d0bf 100644
--- a/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/statemachine/StateMachineExample.java
+++ b/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/statemachine/StateMachineExample.java
@@ -30,15 +30,14 @@ import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.configuration.CheckpointingOptions;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.MemorySize;
+import org.apache.flink.configuration.StateBackendOptions;
import org.apache.flink.connector.datagen.source.DataGeneratorSource;
import org.apache.flink.connector.datagen.source.GeneratorFunction;
import org.apache.flink.connector.file.sink.FileSink;
import org.apache.flink.connector.kafka.source.KafkaSource;
import org.apache.flink.connector.kafka.source.enumerator.initializer.OffsetsInitializer;
import org.apache.flink.connector.kafka.source.reader.deserializer.KafkaRecordDeserializationSchema;
-import org.apache.flink.contrib.streaming.state.EmbeddedRocksDBStateBackend;
import org.apache.flink.core.fs.Path;
-import org.apache.flink.runtime.state.hashmap.HashMapStateBackend;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.filesystem.rollingpolicies.DefaultRollingPolicy;
@@ -89,13 +88,16 @@ public class StateMachineExample {
final String stateBackend = params.get("backend", "memory");
if ("hashmap".equals(stateBackend)) {
final String checkpointDir = params.get("checkpoint-dir");
- env.setStateBackend(new HashMapStateBackend());
+ configuration.set(StateBackendOptions.STATE_BACKEND, "hashmap");
configuration.set(CheckpointingOptions.CHECKPOINT_STORAGE, "filesystem");
configuration.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir);
} else if ("rocks".equals(stateBackend)) {
final String checkpointDir = params.get("checkpoint-dir");
boolean incrementalCheckpoints = params.getBoolean("incremental-checkpoints", false);
- env.setStateBackend(new EmbeddedRocksDBStateBackend(incrementalCheckpoints));
+ configuration.set(
+ StateBackendOptions.STATE_BACKEND,
+ "org.apache.flink.contrib.streaming.state.EmbeddedRocksDBStateBackendFactory");
+ configuration.set(CheckpointingOptions.INCREMENTAL_CHECKPOINTS, incrementalCheckpoints);
configuration.set(CheckpointingOptions.CHECKPOINT_STORAGE, "filesystem");
configuration.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir);
}
diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java
index 52b5e30034f..9069b3a0d3c 100644
--- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java
+++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java
@@ -202,8 +202,15 @@ public class StreamExecutionEnvironment implements AutoCloseable {
private boolean isChainingOfOperatorsWithDifferentMaxParallelismEnabled = true;
- /** The state backend used for storing k/v state and state snapshots. */
- private StateBackend defaultStateBackend;
+ /**
+ * The state backend used for storing k/v state and state snapshots.
+ *
+ * @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
+ * field will be removed entirely.
+ */
+ @Deprecated private StateBackend defaultStateBackend;
/** Whether to enable ChangelogStateBackend, default value is unset. */
private TernaryBoolean changelogStateBackendEnabled = TernaryBoolean.UNDEFINED;
@@ -665,10 +672,24 @@ public class StreamExecutionEnvironment implements AutoCloseable {
* org.apache.flink.runtime.state.CheckpointStorage} which configures how and where state
* backends persist during a checkpoint.
*
+ * @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 for configuring state backend like the following code snippet:
+ * <pre>{@code
+ * Configuration config = new Configuration();
+ * config.set(StateBackendOptions.STATE_BACKEND, "hashmap");
+ * StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(config);
+ * }</pre>
+ * For more details on using ConfigOption for state backend configuration, please refer to
+ * the Flink documentation: <a
+ * href="https://nightlies.apache.org/flink/flink-docs-stable/docs/ops/state/state_backends">state-backends</a>
* @return This StreamExecutionEnvironment itself, to allow chaining of function calls.
* @see #getStateBackend()
* @see CheckpointConfig#setCheckpointStorage( org.apache.flink.runtime.state.CheckpointStorage)
*/
+ @Deprecated
@PublicEvolving
public StreamExecutionEnvironment setStateBackend(StateBackend backend) {
this.defaultStateBackend = Preconditions.checkNotNull(backend);
@@ -678,8 +699,16 @@ public class StreamExecutionEnvironment implements AutoCloseable {
/**
* Gets the state backend that defines how to store and checkpoint state.
*
+ * @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 find which state backend is used by
+ * state backend ConfigOption. For more details on using ConfigOption for state backend
+ * configuration, please refer to the Flink documentation: <a
+ * href="https://nightlies.apache.org/flink/flink-docs-stable/docs/ops/state/state_backends">state-backends</a>
* @see #setStateBackend(StateBackend)
*/
+ @Deprecated
@PublicEvolving
public StateBackend getStateBackend() {
return defaultStateBackend;