Repository: ambari Updated Branches: refs/heads/trunk 8da4ca1b4 -> ac508b8df
AMBARI-11959. Remove Tez UI property from exported Blueprint. (rnettleton) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ac508b8d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ac508b8d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ac508b8d Branch: refs/heads/trunk Commit: ac508b8dffb923b717bf66572b0bc14ba9f2ff3f Parents: 8da4ca1 Author: Bob Nettleton <rnettle...@hortonworks.com> Authored: Tue Jun 16 16:34:52 2015 -0400 Committer: Bob Nettleton <rnettle...@hortonworks.com> Committed: Tue Jun 16 16:35:39 2015 -0400 ---------------------------------------------------------------------- .../BlueprintConfigurationProcessor.java | 28 ++++++++++++++- .../BlueprintConfigurationProcessorTest.java | 36 ++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ac508b8d/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 9d49714..af3b331 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 @@ -125,7 +125,9 @@ public class BlueprintConfigurationProcessor { * This will initially be used to filter out the Ranger Passwords, but * could be extended in the future for more generic purposes. */ - private static final PropertyFilter[] exportPropertyFilters = { new PasswordPropertyFilter() }; + private static final PropertyFilter[] exportPropertyFilters = + { new PasswordPropertyFilter(), + new SimplePropertyNameExportFilter("tez.tez-ui.history-url.base", "tez-site")}; /** * Statically-defined list of filters to apply on cluster config @@ -2161,6 +2163,30 @@ public class BlueprintConfigurationProcessor { } } + /** + * Simple filter implementation used to remove named properties from + * a Blueprint export. Some properties with hostname information set + * by the UI do not have straightforward mappings to hosts, so these properties + * cannot be exported via the default HOSTGROUP mechanism. + */ + private static class SimplePropertyNameExportFilter implements PropertyFilter { + + private final String propertyName; + + private final String propertyConfigType; + + SimplePropertyNameExportFilter(String propertyName, String propertyConfigType) { + this.propertyName = propertyName; + this.propertyConfigType = propertyConfigType; + } + + @Override + public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType, ClusterTopology topology) { + return !(this.propertyConfigType.equals(configType) && + this.propertyName.equals(propertyName)); + } + } + /** * Filter implementation that determines if a property should be included in http://git-wip-us.apache.org/repos/asf/ambari/blob/ac508b8d/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 a0c29e8..abf5675 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 @@ -679,6 +679,42 @@ public class BlueprintConfigurationProcessorTest { } @Test + public void testTezConfigExport() throws Exception { + final String expectedHostName = "c6401.apache.ambari.org"; + final String expectedHostGroupName = "host_group_1"; + + Map<String, Map<String, String>> configProperties = new HashMap<String, Map<String, String>>(); + Map<String, String> tezSiteProperties = new HashMap<String, String>(); + configProperties.put("tez-site", tezSiteProperties); + + // set the UI property, to simulate the case of a UI-created cluster with TEZ + tezSiteProperties.put("tez.tez-ui.history-url.base", "http://host:port/TEZ/TEZ_VIEW"); + + Configuration clusterConfig = new Configuration(configProperties, + Collections.<String, Map<String, Map<String, String>>>emptyMap()); + + // note: test hostgroups may not accurately reflect the required components for the config properties + // which are mapped to them. Only the hostgroup name is used for hostgroup resolution an the components + // are not validated + Collection<String> groupComponents = new HashSet<String>(); + groupComponents.add("TEZ_CLIENT"); + Collection<String> hosts = new ArrayList<String>(); + hosts.add(expectedHostName); + hosts.add("serverTwo"); + TestHostGroup group = new TestHostGroup(expectedHostGroupName, groupComponents, hosts); + + Collection<TestHostGroup> hostGroups = new HashSet<TestHostGroup>(); + hostGroups.add(group); + + ClusterTopology topology = createClusterTopology(bp, clusterConfig, hostGroups); + BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology); + configProcessor.doUpdateForBlueprintExport(); + + assertFalse("tez.tez-ui.history-url.base should not be present in exported blueprint in tez-site", + tezSiteProperties.containsKey("tez.tez-ui.history-url.base")); + } + + @Test public void testDoNameNodeHighAvailabilityExportWithHAEnabled() throws Exception { final String expectedNameService = "mynameservice"; final String expectedHostName = "c6401.apache.ambari.org";