flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fhue...@apache.org
Subject [07/11] flink git commit: [FLINK-6270] extend Configuration with contains(configOption)
Date Thu, 06 Apr 2017 21:08:49 GMT
[FLINK-6270] extend Configuration with contains(configOption)


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/d1d761ed
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/d1d761ed
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/d1d761ed

Branch: refs/heads/table-retraction
Commit: d1d761ed6b4de050402905b8c196e781479245a0
Parents: 2cb6004
Author: Nico Kruber <nico@data-artisans.com>
Authored: Wed Apr 5 10:59:00 2017 +0200
Committer: zentol <chesnay@apache.org>
Committed: Thu Apr 6 19:35:50 2017 +0200

----------------------------------------------------------------------
 .../flink/configuration/Configuration.java      | 30 ++++++++++++++++++++
 .../configuration/DelegatingConfiguration.java  |  5 ++++
 2 files changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/d1d761ed/flink-core/src/main/java/org/apache/flink/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/configuration/Configuration.java b/flink-core/src/main/java/org/apache/flink/configuration/Configuration.java
index 8f23435..ea0c419 100644
--- a/flink-core/src/main/java/org/apache/flink/configuration/Configuration.java
+++ b/flink-core/src/main/java/org/apache/flink/configuration/Configuration.java
@@ -595,6 +595,36 @@ public class Configuration extends ExecutionConfig.GlobalJobParameters
 		}
 	}
 
+	/**
+	 * Checks whether there is an entry for the given config option
+	 *
+	 * @param configOption The configuration option
+	 *
+	 * @return <tt>true</tt> if a valid (current or deprecated) key of the config
option is stored,
+	 * <tt>false</tt> otherwise
+	 */
+	@PublicEvolving
+	public boolean contains(ConfigOption<?> configOption) {
+		synchronized (this.confData){
+			// first try the current key
+			if (this.confData.containsKey(configOption.key())) {
+				return true;
+			}
+			else if (configOption.hasDeprecatedKeys()) {
+				// try the deprecated keys
+				for (String deprecatedKey : configOption.deprecatedKeys()) {
+					if (this.confData.containsKey(deprecatedKey)) {
+						LOG.warn("Config uses deprecated configuration key '{}' instead of proper key '{}'",
+							deprecatedKey, configOption.key());
+						return true;
+					}
+				}
+			}
+
+			return false;
+		}
+	}
+
 	// --------------------------------------------------------------------------------------------
 
 	@Override

http://git-wip-us.apache.org/repos/asf/flink/blob/d1d761ed/flink-core/src/main/java/org/apache/flink/configuration/DelegatingConfiguration.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/configuration/DelegatingConfiguration.java
b/flink-core/src/main/java/org/apache/flink/configuration/DelegatingConfiguration.java
index bd9a962..1b14e9e 100644
--- a/flink-core/src/main/java/org/apache/flink/configuration/DelegatingConfiguration.java
+++ b/flink-core/src/main/java/org/apache/flink/configuration/DelegatingConfiguration.java
@@ -290,6 +290,11 @@ public final class DelegatingConfiguration extends Configuration {
 		return backingConfig.containsKey(prefix + key);
 	}
 
+	@Override
+	public boolean contains(ConfigOption<?> configOption) {
+		return backingConfig.contains(prefixOption(configOption, prefix));
+	}
+
 	// --------------------------------------------------------------------------------------------
 
 	@Override


Mime
View raw message