Repository: ambari Updated Branches: refs/heads/trunk ae2cd3d7a -> b6326be3a
AMBARI-8226. Export topology related properties in blueprint that have undefined hosts Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b6326be3 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b6326be3 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b6326be3 Branch: refs/heads/trunk Commit: b6326be3ae26f5b3ca9f24d2b861b2bb8bad3f18 Parents: ae2cd3d Author: John Speidel <jspei...@hortonworks.com> Authored: Fri Nov 7 20:35:40 2014 -0500 Committer: John Speidel <jspei...@hortonworks.com> Committed: Fri Nov 7 21:12:37 2014 -0500 ---------------------------------------------------------------------- .../BlueprintConfigurationProcessor.java | 19 ++++++++- .../BlueprintConfigurationProcessorTest.java | 44 +++++++++++++++++++- 2 files changed, 59 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/b6326be3/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 5af81be..f1a6110 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 @@ -342,8 +342,12 @@ public class BlueprintConfigurationProcessor { // except in the case of HA-related properties, that // can contain nameservice references instead of hostnames (Fix for Bug AMBARI-7458). // also will not remove properties that reference the special 0.0.0.0 network - // address - if (! matchedHost && ! isNameServiceProperty(propertyName) && !isSpecialNetworkAddress(propValue)) { + // address or properties with undefined hosts + if (! matchedHost && + ! isNameServiceProperty(propertyName) && + ! isSpecialNetworkAddress(propValue) && + ! isUndefinedAddress(propValue)) { + typeProperties.remove(propertyName); } } @@ -380,6 +384,17 @@ public class BlueprintConfigurationProcessor { } /** + * Determine if a property has an undefined host. + * + * @param propertyValue property value + * + * @return true if the property value contains "undefined" + */ + private static boolean isUndefinedAddress(String propertyValue) { + return propertyValue.contains("undefined"); + } + + /** * Update multi host topology configuration properties for blueprint export. * * @param hostGroups cluster host groups http://git-wip-us.apache.org/repos/asf/ambari/blob/b6326be3/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 6c00927..48b9077 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 @@ -2042,8 +2042,6 @@ public class BlueprintConfigurationProcessorTest { Map<String, String> kafkaBrokerProperties = new HashMap<String, String>(); - - configProperties.put("core-site", coreSiteProperties); configProperties.put("hbase-site", hbaseSiteProperties); configProperties.put("webhcat-site", webHCatSiteProperties); @@ -2232,6 +2230,48 @@ public class BlueprintConfigurationProcessorTest { } + @Test + public void testPropertyWithUndefinedHostisExported() throws Exception { + final String expectedHostName = "c6401.apache.ambari.org"; + final String expectedHostGroupName = "host_group_1"; + + EasyMockSupport mockSupport = new EasyMockSupport(); + + HostGroup mockHostGroupOne = mockSupport.createMock(HostGroup.class); + + expect(mockHostGroupOne.getHostInfo()).andReturn(Arrays.asList(expectedHostName, "serverTwo")).atLeastOnce(); + expect(mockHostGroupOne.getName()).andReturn(expectedHostGroupName).atLeastOnce(); + + mockSupport.replayAll(); + + Map<String, Map<String, String>> configProperties = new HashMap<String, Map<String, String>>(); + + Map<String, String> properties = new HashMap<String, String>(); + configProperties.put("storm-site", properties); + + // setup properties that include host information including undefined host properties + properties.put("storm.zookeeper.servers", expectedHostName); + properties.put("nimbus.childopts", "undefined"); + properties.put("worker.childopts", "some other info, undefined, more info"); + + + BlueprintConfigurationProcessor configProcessor = + new BlueprintConfigurationProcessor(configProperties); + + // call top-level export method + configProcessor.doUpdateForBlueprintExport(Arrays.asList(mockHostGroupOne)); + + assertEquals("Property was incorrectly exported", + "%HOSTGROUP::" + expectedHostGroupName + "%", properties.get("storm.zookeeper.servers")); + assertEquals("Property with undefined host was incorrectly exported", + "undefined", properties.get("nimbus.childopts")); + assertEquals("Property with undefined host was incorrectly exported", + "some other info, undefined, more info" , properties.get("worker.childopts")); + + mockSupport.verifyAll(); + } + + private static String createExportedAddress(String expectedPortNum, String expectedHostGroupName) { return createExportedHostName(expectedHostGroupName) + ":" + expectedPortNum; }