[FLINK-7383] Remove ConfigurationUtil

This closes #4489.


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

Branch: refs/heads/master
Commit: ff70cc3afd004aad4016f94485b95a3ced1639c9
Parents: a570aa5
Author: Till Rohrmann <trohrm...@apache.org>
Authored: Mon Aug 7 14:37:04 2017 +0200
Committer: Till Rohrmann <trohrm...@apache.org>
Committed: Wed Aug 9 11:57:09 2017 +0200

----------------------------------------------------------------------
 .../apache/flink/util/ConfigurationUtil.java    | 101 ----------------
 .../flink/util/ConfigurationUtilTest.java       | 115 -------------------
 2 files changed, 216 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/ff70cc3a/flink-core/src/main/java/org/apache/flink/util/ConfigurationUtil.java
----------------------------------------------------------------------
diff --git 
a/flink-core/src/main/java/org/apache/flink/util/ConfigurationUtil.java 
b/flink-core/src/main/java/org/apache/flink/util/ConfigurationUtil.java
deleted file mode 100644
index 44f098b..0000000
--- a/flink-core/src/main/java/org/apache/flink/util/ConfigurationUtil.java
+++ /dev/null
@@ -1,101 +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.util;
-
-import org.apache.flink.annotation.Internal;
-import org.apache.flink.configuration.Configuration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Utility for accessing deprecated {@link Configuration} values.
- */
-@Internal
-public class ConfigurationUtil {
-
-       private static final Logger LOG = 
LoggerFactory.getLogger(ConfigurationUtil.class);
-
-       /**
-        * Returns the value associated with the given key as an Integer in the
-        * given Configuration.
-        *
-        * <p>The regular key has precedence over any deprecated keys. The
-        * precedence of deprecated keys depends on the argument order, first
-        * deprecated keys have higher precedence than later ones.
-        *
-        * @param config Configuration to access
-        * @param key Configuration key (highest precedence)
-        * @param defaultValue Default value (if no key is set)
-        * @param deprecatedKeys Optional deprecated keys in precedence order
-        * @return Integer value associated with first found key or the default 
value
-        */
-       public static int getIntegerWithDeprecatedKeys(
-                       Configuration config,
-                       String key,
-                       int defaultValue,
-                       String... deprecatedKeys) {
-
-               if (config.containsKey(key)) {
-                       return config.getInteger(key, defaultValue);
-               } else {
-                       // Check deprecated keys
-                       for (String deprecatedKey : deprecatedKeys) {
-                               if (config.containsKey(deprecatedKey)) {
-                                       LOG.warn("Configuration key '{}' has 
been deprecated. Please use '{}' instead.", deprecatedKey, key);
-                                       return config.getInteger(deprecatedKey, 
defaultValue);
-                               }
-                       }
-                       return defaultValue;
-               }
-       }
-
-       /**
-        * Returns the value associated with the given key as a String in the
-        * given Configuration.
-        *
-        * <p>The regular key has precedence over any deprecated keys. The
-        * precedence of deprecated keys depends on the argument order, first
-        * deprecated keys have higher precedence than later ones.
-        *
-        * @param config Configuration to access
-        * @param key Configuration key (highest precedence)
-        * @param defaultValue Default value (if no key is set)
-        * @param deprecatedKeys Optional deprecated keys in precedence order
-        * @return String associated with first found key or the default value
-        */
-       public static String getStringWithDeprecatedKeys(
-                       Configuration config,
-                       String key,
-                       String defaultValue,
-                       String... deprecatedKeys) {
-
-               if (config.containsKey(key)) {
-                       return config.getString(key, defaultValue);
-               } else {
-                       // Check deprecated keys
-                       for (String deprecatedKey : deprecatedKeys) {
-                               if (config.containsKey(deprecatedKey)) {
-                                       LOG.warn("Configuration key {} has been 
deprecated. Please use {} instead.", deprecatedKey, key);
-                                       return config.getString(deprecatedKey, 
defaultValue);
-                               }
-                       }
-                       return defaultValue;
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/flink/blob/ff70cc3a/flink-core/src/test/java/org/apache/flink/util/ConfigurationUtilTest.java
----------------------------------------------------------------------
diff --git 
a/flink-core/src/test/java/org/apache/flink/util/ConfigurationUtilTest.java 
b/flink-core/src/test/java/org/apache/flink/util/ConfigurationUtilTest.java
deleted file mode 100644
index 7ecbd3f..0000000
--- a/flink-core/src/test/java/org/apache/flink/util/ConfigurationUtilTest.java
+++ /dev/null
@@ -1,115 +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.util;
-
-import org.apache.flink.configuration.Configuration;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class ConfigurationUtilTest {
-
-       /**
-        * Tests getInteger without any deprecated keys.
-        */
-       @Test
-       public void testGetIntegerNoDeprecatedKeys() throws Exception {
-               Configuration config = new Configuration();
-               String key = "asdasd";
-               int value = 1223239;
-               int defaultValue = 272770;
-
-               assertEquals(defaultValue, 
ConfigurationUtil.getIntegerWithDeprecatedKeys(config, key, defaultValue));
-
-               config.setInteger(key, value);
-               assertEquals(value, 
ConfigurationUtil.getIntegerWithDeprecatedKeys(config, key, defaultValue));
-       }
-
-       /**
-        * Tests getInteger with deprecated keys and checks precedence.
-        */
-       @Test
-       public void testGetIntegerWithDeprecatedKeys() throws Exception {
-               Configuration config = new Configuration();
-               String key = "asdasd";
-               int value = 1223239;
-               int defaultValue = 272770;
-
-               String[] deprecatedKey = new String[] { "deprecated-0", 
"deprecated-1" };
-               int[] deprecatedValue = new int[] { 99192, 7727 };
-
-               assertEquals(defaultValue, 
ConfigurationUtil.getIntegerWithDeprecatedKeys(config, key, defaultValue));
-
-               // Set 2nd deprecated key
-               config.setInteger(deprecatedKey[1], deprecatedValue[1]);
-               assertEquals(deprecatedValue[1], 
ConfigurationUtil.getIntegerWithDeprecatedKeys(config, key, defaultValue, 
deprecatedKey[1]));
-
-               // Set 1st deprecated key (precedence)
-               config.setInteger(deprecatedKey[0], deprecatedValue[0]);
-               assertEquals(deprecatedValue[0], 
ConfigurationUtil.getIntegerWithDeprecatedKeys(config, key, defaultValue, 
deprecatedKey[0]));
-
-               // Set current key
-               config.setInteger(key, value);
-               assertEquals(value, 
ConfigurationUtil.getIntegerWithDeprecatedKeys(config, key, defaultValue));
-       }
-
-       /**
-        * Tests getString without any deprecated keys.
-        */
-       @Test
-       public void testGetStringNoDeprecatedKeys() throws Exception {
-               Configuration config = new Configuration();
-               String key = "asdasd";
-               String value = "1223239";
-               String defaultValue = "272770";
-
-               assertEquals(defaultValue, 
ConfigurationUtil.getStringWithDeprecatedKeys(config, key, defaultValue));
-
-               config.setString(key, value);
-               assertEquals(value, 
ConfigurationUtil.getStringWithDeprecatedKeys(config, key, defaultValue));
-       }
-
-       /**
-        * Tests getString with deprecated keys and checks precedence.
-        */
-       @Test
-       public void testGetStringWithDeprecatedKeys() throws Exception {
-               Configuration config = new Configuration();
-               String key = "asdasd";
-               String value = "1223239";
-               String defaultValue = "272770";
-
-               String[] deprecatedKey = new String[] { "deprecated-0", 
"deprecated-1" };
-               String[] deprecatedValue = new String[] { "99192", "7727" };
-
-               assertEquals(defaultValue, 
ConfigurationUtil.getStringWithDeprecatedKeys(config, key, defaultValue));
-
-               // Set 2nd deprecated key
-               config.setString(deprecatedKey[1], deprecatedValue[1]);
-               assertEquals(deprecatedValue[1], 
ConfigurationUtil.getStringWithDeprecatedKeys(config, key, defaultValue, 
deprecatedKey[1]));
-
-               // Set 1st deprecated key (precedence)
-               config.setString(deprecatedKey[0], deprecatedValue[0]);
-               assertEquals(deprecatedValue[0], 
ConfigurationUtil.getStringWithDeprecatedKeys(config, key, defaultValue, 
deprecatedKey[0]));
-
-               // Set current key
-               config.setString(key, value);
-               assertEquals(value, 
ConfigurationUtil.getStringWithDeprecatedKeys(config, key, defaultValue));
-       }
-}

Reply via email to