hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From su...@apache.org
Subject hadoop git commit: YARN-5833. Add validation to ensure default ports are unique in Configuration. (Konstantinos Karanasos via Subru).
Date Tue, 08 Nov 2016 22:41:15 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 8bb264c70 -> 797c7bfab


YARN-5833. Add validation to ensure default ports are unique in Configuration. (Konstantinos
Karanasos via Subru).

(cherry picked from commit 29e3b3417c16c83dc8e753f94d7ca9957dddbedd)


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

Branch: refs/heads/branch-2
Commit: 797c7bfab9b1d7c39151a71e53f4290134a5033c
Parents: 8bb264c
Author: Subru Krishnan <subru@apache.org>
Authored: Tue Nov 8 14:38:18 2016 -0800
Committer: Subru Krishnan <subru@apache.org>
Committed: Tue Nov 8 14:39:09 2016 -0800

----------------------------------------------------------------------
 .../conf/TestConfigurationFieldsBase.java       | 47 ++++++++++++++++++++
 .../hadoop/yarn/conf/YarnConfiguration.java     |  2 +-
 .../yarn/conf/TestYarnConfigurationFields.java  | 11 +++++
 3 files changed, 59 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/797c7bfa/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationFieldsBase.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationFieldsBase.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationFieldsBase.java
index eab0161..9007c20 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationFieldsBase.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigurationFieldsBase.java
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.conf;
 
+import org.apache.commons.lang.StringUtils;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -147,6 +148,14 @@ public abstract class TestConfigurationFieldsBase {
   private Set<String> xmlFieldsMissingInConfiguration = null;
 
   /**
+   * A set of strings used to check for collision of default values.
+   * For each of the set's strings, the default values containing that string
+   * in their name should not coincide.
+   */
+  @SuppressWarnings("checkstyle:visibilitymodifier")
+  protected Set<String> filtersForDefaultValueCollisionCheck = new HashSet<>();
+
+  /**
    * Member variable for debugging base class operation
    */
   protected boolean configDebug = false;
@@ -719,4 +728,42 @@ public abstract class TestConfigurationFieldsBase {
     System.out.println("=====");
     System.out.println();
   }
+
+  /**
+   * For each specified string, get the default parameter values whose names
+   * contain the string. Then check whether any of these default values collide.
+   * This is, for example, useful to make sure there is no collision of default
+   * ports across different services.
+   */
+  @Test
+  public void testDefaultValueCollision() {
+    for (String filter : filtersForDefaultValueCollisionCheck) {
+      System.out.println("Checking if any of the default values whose name " +
+          "contains string \"" + filter + "\" collide.");
+
+      // Map from filtered default value to name of the corresponding parameter.
+      Map<String, String> filteredValues = new HashMap<>();
+
+      int valuesChecked = 0;
+      for (Map.Entry<String, String> ent :
+          configurationDefaultVariables.entrySet()) {
+        // Apply the name filter to the default parameters.
+        if (ent.getKey().contains(filter)) {
+          // Check only for numerical values.
+          if (StringUtils.isNumeric(ent.getValue())) {
+            String crtValue =
+                filteredValues.putIfAbsent(ent.getValue(), ent.getKey());
+            assertTrue("Parameters " + ent.getKey() + " and " + crtValue +
+                " are using the same default value!", crtValue == null);
+          }
+          valuesChecked++;
+        }
+      }
+
+      System.out.println(
+          "Checked " + valuesChecked + " default values for collision.");
+    }
+
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/797c7bfa/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
index 5716e3a..6599a02 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
@@ -1700,7 +1700,7 @@ public class YarnConfiguration extends Configuration {
 
   public static final String AMRM_PROXY_ADDRESS = NM_PREFIX
       + "amrmproxy.address";
-  public static final int DEFAULT_AMRM_PROXY_PORT = 8048;
+  public static final int DEFAULT_AMRM_PROXY_PORT = 8049;
   public static final String DEFAULT_AMRM_PROXY_ADDRESS = "0.0.0.0:"
       + DEFAULT_AMRM_PROXY_PORT;
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/797c7bfa/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/conf/TestYarnConfigurationFields.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/conf/TestYarnConfigurationFields.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/conf/TestYarnConfigurationFields.java
index 818f4e0..6320483 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/conf/TestYarnConfigurationFields.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/conf/TestYarnConfigurationFields.java
@@ -144,5 +144,16 @@ public class TestYarnConfigurationFields extends TestConfigurationFieldsBase
{
 
     // Currently defined in RegistryConstants/core-site.xml
     xmlPrefixToSkipCompare.add("hadoop.registry");
+
+    // Add the filters used for checking for collision of default values.
+    initDefaultValueCollisionCheck();
+  }
+
+  /**
+   * Add filters used to perform the check of default values collision by
+   * {@link TestConfigurationFieldsBase#filtersForDefaultValueCollisionCheck}.
+   */
+  private void initDefaultValueCollisionCheck() {
+    filtersForDefaultValueCollisionCheck.add("_PORT");
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message