GitHub user StephanEwen opened a pull request:
https://github.com/apache/flink/pull/2605
[DISCUSS] Introduce config options
It is a bit unorthodox to start a discussion via a pull request, but this
suggestion is best motivated via some code.
I suggest to move away from the current model with `ConfigConstants` and
move to a model where an `Option` object describes a configuration option
completely, with default value, fallback keys.
## Advantages
- Much simpler / easier access to values that have deprecated keys
- Not possible to accidentally overlook deprecated keys
- Key and default values are grouped together in the definition
- Clearly states the expected type value for each config key (string,
int, etc).
- We can improve this even further to include the description and
auto-generate the config docs
## Example
Simple option:
```java
Option<String> TASK_MANAGER_TMP_DIRS = new Option<>(
"taskmanager.tmp.dirs", // config key
System.getProperty("java.io.tmpdir")); // default value
```
Option with multiple deprecated keys:
```java
Option<String> HA_CLUSTER_ID = new Option<>(
"high-availability.cluster-id", // config key
null, // no default value
"high-availability.zookeeper.path.namespace", //
latest deprecated key
"recovery.zookeeper.path.namespace"); // even
earlier deprecated key
```
Get a config value, this automatically checks deprecated keys and default
values:
```java
final String zkQuorum =
configuration.getValue(ConfigOptions.HA_ZOOKEEPER_QUORUM);
final long connTimeout =
configuration.getInteger(ConfigOptions.HA_ZOOKEEPER_CONN_TIMEOUT);
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/StephanEwen/incubator-flink config_options
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/2605.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #2605
----
commit 4cb894b25cc7558501af8d537db737c5646c752f
Author: Stephan Ewen <[email protected]>
Date: 2016-10-06T17:38:09Z
[FLINK-XXXX] [core] Introduce config options
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---