Repository: ambari Updated Branches: refs/heads/trunk 6d7d82ce4 -> d87bfc07c
AMBARI-9733. Exported HDFS HA Blueprint not deploying when used for new cluster. (rnettleton) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d87bfc07 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d87bfc07 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d87bfc07 Branch: refs/heads/trunk Commit: d87bfc07cc2c6f047d773bee3fb2b8b17e07abb2 Parents: 6d7d82c Author: Bob Nettleton <[email protected]> Authored: Fri Feb 20 21:36:12 2015 -0500 Committer: Bob Nettleton <[email protected]> Committed: Fri Feb 20 21:37:01 2015 -0500 ---------------------------------------------------------------------- .../BlueprintConfigurationProcessor.java | 25 +++++++++++++++++++- .../BlueprintConfigurationProcessorTest.java | 15 ++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/d87bfc07/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 d2af1d7..a6d4da7 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 @@ -665,12 +665,24 @@ public class BlueprintConfigurationProcessor { if (isNameNodeHAEnabled(properties) && isComponentNameNode() && (matchingGroups.size() == 2)) { // if this is the defaultFS property, it should reflect the nameservice name, // rather than a hostname (used in non-HA scenarios) - if (properties.get("core-site").get("fs.defaultFS").equals(origValue)) { + if (properties.containsKey("core-site") && properties.get("core-site").get("fs.defaultFS").equals(origValue)) { + return origValue; + } + + if (properties.containsKey("hbase-site") && properties.get("hbase-site").get("hbase.rootdir").equals(origValue)) { + // hbase-site's reference to the namenode is handled differently in HA mode, since the + // reference must point to the logical nameservice, rather than an individual namenode return origValue; } } + if (isNameNodeHAEnabled(properties) && isComponentSecondaryNameNode() && (matchingGroups.isEmpty())) { + // if HDFS HA is enabled, then no replacement is necessary for properties that refer to the SECONDARY_NAMENODE + // eventually this type of information should be encoded in the stacks + return origValue; + } + throw new IllegalArgumentException("Unable to update configuration property with topology information. " + "Component '" + component + "' is not mapped to any host group or is mapped to multiple groups."); } @@ -690,6 +702,17 @@ public class BlueprintConfigurationProcessor { } /** + * Utility method to determine if the component associated with this updater + * instance is an HDFS Secondary NameNode + * + * @return true if the component associated is a Secondary NameNode + * false if the component is not a Secondary NameNode + */ + private boolean isComponentSecondaryNameNode() { + return component.equals("SECONDARY_NAMENODE"); + } + + /** * Provides access to the name of the component associated * with this updater instance. * http://git-wip-us.apache.org/repos/asf/ambari/blob/d87bfc07/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 cac1602..d8794ac 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 @@ -1532,6 +1532,7 @@ public class BlueprintConfigurationProcessorTest { expect(mockHostGroupOne.getComponents()).andReturn(Collections.singleton("NAMENODE")).atLeastOnce(); expect(mockHostGroupTwo.getComponents()).andReturn(Collections.singleton("NAMENODE")).atLeastOnce(); expect(mockStack.getCardinality("NAMENODE")).andReturn(new Cardinality("1-2")).atLeastOnce(); + expect(mockStack.getCardinality("SECONDARY_NAMENODE")).andReturn(new Cardinality("1")).atLeastOnce(); mockSupport.replayAll(); @@ -1540,6 +1541,8 @@ public class BlueprintConfigurationProcessorTest { Map<String, String> hdfsSiteProperties = new HashMap<String, String>(); + Map<String, String> hbaseSiteProperties = + new HashMap<String, String>(); Map<String, String> hadoopEnvProperties = new HashMap<String, String>(); Map<String, String> coreSiteProperties = @@ -1549,6 +1552,7 @@ public class BlueprintConfigurationProcessorTest { configProperties.put("hdfs-site", hdfsSiteProperties); configProperties.put("hadoop-env", hadoopEnvProperties); configProperties.put("core-site", coreSiteProperties); + configProperties.put("hbase-site", hbaseSiteProperties); // setup hdfs HA config for test hdfsSiteProperties.put("dfs.nameservices", expectedNameService); @@ -1563,9 +1567,17 @@ public class BlueprintConfigurationProcessorTest { hdfsSiteProperties.put("dfs.namenode.rpc-address." + expectedNameService + "." + expectedNodeOne, createExportedAddress(expectedPortNum, expectedHostGroupName)); hdfsSiteProperties.put("dfs.namenode.rpc-address." + expectedNameService + "." + expectedNodeTwo, createExportedAddress(expectedPortNum, expectedHostGroupName)); + // add properties that require the SECONDARY_NAMENODE, which + // is not included in this test + hdfsSiteProperties.put("dfs.secondary.http.address", "localhost:8080"); + hdfsSiteProperties.put("dfs.namenode.secondary.http-address", "localhost:8080"); + // configure the defaultFS to use the nameservice URL coreSiteProperties.put("fs.defaultFS", "hdfs://" + expectedNameService); + // configure the hbase rootdir to use the nameservice URL + hbaseSiteProperties.put("hbase.rootdir", "hdfs://" + expectedNameService + "/hbase/test/root/dir"); + BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(configProperties); @@ -1602,6 +1614,9 @@ public class BlueprintConfigurationProcessorTest { assertEquals("fs.defaultFS should not be modified by cluster update when NameNode HA is enabled.", "hdfs://" + expectedNameService, coreSiteProperties.get("fs.defaultFS")); + assertEquals("hbase.rootdir should not be modified by cluster update when NameNode HA is enabled.", + "hdfs://" + expectedNameService + "/hbase/test/root/dir", hbaseSiteProperties.get("hbase.rootdir")); + mockSupport.verifyAll(); }
