You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2016/04/18 22:54:54 UTC

ambari git commit: AMBARI-15791 Blueprint based installations should automatically add dfs.internal.nameservices during cluster creation (dsen)

Repository: ambari
Updated Branches:
  refs/heads/trunk 4f487e8f8 -> c623e4270


AMBARI-15791 Blueprint based installations should automatically add dfs.internal.nameservices during cluster creation (dsen)


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

Branch: refs/heads/trunk
Commit: c623e42701c233fbd04f761b23129555c1f47945
Parents: 4f487e8
Author: Dmytro Sen <ds...@apache.org>
Authored: Mon Apr 18 23:54:41 2016 +0300
Committer: Dmytro Sen <ds...@apache.org>
Committed: Mon Apr 18 23:54:41 2016 +0300

----------------------------------------------------------------------
 .../BlueprintConfigurationProcessor.java        | 14 +++++++++++-
 .../BlueprintConfigurationProcessorTest.java    | 24 ++++++++++++++++++--
 2 files changed, 35 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c623e427/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
index 797caca..60a9263 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
@@ -298,6 +298,15 @@ public class BlueprintConfigurationProcessor {
 
     //todo: lots of hard coded HA rules included here
     if (clusterTopology.isNameNodeHAEnabled()) {
+
+      // add "dfs.internal.nameservices" if it's not specified
+      Map<String, String> hdfsSiteConfig = clusterConfig.getFullProperties().get("hdfs-site");
+      String nameservices = hdfsSiteConfig.get("dfs.nameservices");
+      String int_nameservices = hdfsSiteConfig.get("dfs.internal.nameservices");
+      if(int_nameservices == null && nameservices != null) {
+        clusterConfig.setProperty("hdfs-site", "dfs.internal.nameservices", nameservices);
+      }
+
       // if the active/stanbdy namenodes are not specified, assign them automatically
       if (! isNameNodeHAInitialActiveNodeSet(clusterProps) && ! isNameNodeHAInitialStandbyNodeSet(clusterProps)) {
         Collection<String> nnHosts = clusterTopology.getHostAssignmentsForComponent("NAMENODE");
@@ -847,7 +856,10 @@ public class BlueprintConfigurationProcessor {
    * @return array of Strings that indicate the nameservices for this cluster
    */
   static String[] parseNameServices(Map<String, String> properties) {
-    final String nameServices = properties.get("dfs.nameservices");
+    String nameServices = properties.get("dfs.internal.nameservices");
+    if (nameServices == null) {
+      nameServices = properties.get("dfs.nameservices");
+    }
     return splitAndTrimStrings(nameServices);
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c623e427/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java
index c8a77fb..0bf01b3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java
@@ -933,6 +933,7 @@ public class BlueprintConfigurationProcessorTest {
     configProperties.put("hbase-site", hbaseSiteProperties);
 
     // setup hdfs config for test
+    hdfsSiteProperties.put("dfs.internal.nameservices", expectedNameService);
     hdfsSiteProperties.put("dfs.nameservices", expectedNameService);
     hdfsSiteProperties.put("dfs.ha.namenodes.mynameservice", expectedNodeOne + ", " + expectedNodeTwo);
 
@@ -1078,6 +1079,7 @@ public class BlueprintConfigurationProcessorTest {
     configProperties.put("hdfs-site", hdfsSiteProperties);
 
     // setup hdfs config for test
+    hdfsSiteProperties.put("dfs.internal.nameservices", expectedNameServiceOne + "," + expectedNameServiceTwo);
     hdfsSiteProperties.put("dfs.nameservices", expectedNameServiceOne + "," + expectedNameServiceTwo);
     hdfsSiteProperties.put("dfs.ha.namenodes." + expectedNameServiceOne, expectedNodeOne + ", " + expectedNodeTwo);
     hdfsSiteProperties.put("dfs.ha.namenodes." + expectedNameServiceTwo, expectedNodeOne + ", " + expectedNodeTwo);
@@ -2626,6 +2628,9 @@ public class BlueprintConfigurationProcessorTest {
     BlueprintConfigurationProcessor updater = new BlueprintConfigurationProcessor(topology);
     updater.doUpdateForClusterCreate();
 
+    // verify that dfs.internal.nameservices was added
+    assertEquals("dfs.internal.nameservices wasn't added", expectedNameService, hdfsSiteProperties.get("dfs.internal.nameservices"));
+
     // verify that the expected hostname was substituted for the host group name in the config
     assertEquals("HTTPS address HA property not properly exported",
         expectedHostName + ":" + expectedPortNum, hdfsSiteProperties.get("dfs.namenode.https-address." + expectedNameService + "." + expectedNodeOne));
@@ -4832,6 +4837,9 @@ public class BlueprintConfigurationProcessorTest {
     Set<String> updatedConfigTypes =
       updater.doUpdateForClusterCreate();
 
+    // verify that dfs.internal.nameservices was added
+    assertEquals("dfs.internal.nameservices wasn't added", expectedNameService, hdfsSiteProperties.get("dfs.internal.nameservices"));
+
     // verify that the expected hostname was substituted for the host group name in the config
     assertEquals("HTTPS address HA property not properly exported",
       expectedHostName + ":" + expectedPortNum, hdfsSiteProperties.get("dfs.namenode.https-address." + expectedNameService + "." + expectedNodeOne));
@@ -5053,7 +5061,7 @@ public class BlueprintConfigurationProcessorTest {
       new HashMap<String, String>();
     hdfsSiteConfigMap.put("dfs.nameservices", "serviceOne");
 
-    // verify that a single service is parsed correctly
+    // verify that a dfs.internal.nameservices parsing falls back to dfs.nameservices
     String[] result = BlueprintConfigurationProcessor.parseNameServices(hdfsSiteConfigMap);
 
     assertNotNull("Resulting array was null",
@@ -5063,8 +5071,20 @@ public class BlueprintConfigurationProcessorTest {
     assertEquals("Incorrect value for returned name service",
       "serviceOne", result[0]);
 
+    hdfsSiteConfigMap.put("dfs.internal.nameservices", "serviceTwo");
+
+    // verify that a single service is parsed correctly
+    result = BlueprintConfigurationProcessor.parseNameServices(hdfsSiteConfigMap);
+
+    assertNotNull("Resulting array was null",
+      result);
+    assertEquals("Incorrect array size",
+      1, result.length);
+    assertEquals("Incorrect value for returned name service",
+      "serviceTwo", result[0]);
+
     // verify that multiple services are parsed correctly
-    hdfsSiteConfigMap.put("dfs.nameservices", " serviceTwo, serviceThree, serviceFour");
+    hdfsSiteConfigMap.put("dfs.internal.nameservices", " serviceTwo, serviceThree, serviceFour");
 
     String[] resultTwo = BlueprintConfigurationProcessor.parseNameServices(hdfsSiteConfigMap);