Repository: ambari Updated Branches: refs/heads/trunk 8098350a4 -> db7f25505
AMBARI-17082 Ambari server failed to start METRICS_COLLECTOR via BP (dsen) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/db7f2550 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/db7f2550 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/db7f2550 Branch: refs/heads/trunk Commit: db7f25505349c3a12688fc893676f84c3d7c4d59 Parents: 8098350 Author: Dmytro Sen <[email protected]> Authored: Tue Jun 7 19:39:48 2016 +0300 Committer: Dmytro Sen <[email protected]> Committed: Tue Jun 7 19:39:48 2016 +0300 ---------------------------------------------------------------------- .../BlueprintConfigurationProcessor.java | 7 ++-- .../BlueprintConfigurationProcessorTest.java | 37 ++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/db7f2550/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 a0af813..43ac1e9 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 @@ -2627,10 +2627,13 @@ public class BlueprintConfigurationProcessor { if (isSpecialNetworkAddress(origValue)) { value = origValue.replace(BIND_ALL_IP_ADDRESS, "localhost"); } - return super.updateForClusterCreate(propertyName, value, properties, topology); + int metricsCollectorsCount = topology.getHostAssignmentsForComponent("METRICS_COLLECTOR").size(); + if (metricsCollectorsCount == 1) { + return super.updateForClusterCreate(propertyName, value, properties, topology); + } + return origValue; } }); - } /** http://git-wip-us.apache.org/repos/asf/ambari/blob/db7f2550/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 8b1a9a6..21083ef 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 @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -7533,6 +7534,42 @@ public class BlueprintConfigurationProcessorTest { assertEquals("host1:6188", clusterConfig.getPropertyValue("ams-site", "timeline.metrics.service.webapp.address")); } + + @Test + public void testAmsPropertiesSpecialAddressMultipleCollectors() throws Exception { + Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>(); + + Map<String, String> amsSite = new HashMap<String, String>(); + //default + amsSite.put("timeline.metrics.service.webapp.address", "0.0.0.0:6188"); + properties.put("ams-site", amsSite); + + Map<String, Map<String, String>> parentProperties = new HashMap<String, Map<String, String>>(); + Configuration parentClusterConfig = new Configuration(parentProperties, + Collections.<String, Map<String, Map<String, String>>>emptyMap()); + Configuration clusterConfig = new Configuration(properties, + Collections.<String, Map<String, Map<String, String>>>emptyMap(), parentClusterConfig); + + Collection<String> hgComponents1 = new HashSet<String>(); + Collection<String> hgComponents2 = new HashSet<String>(); + hgComponents1.add("METRICS_COLLECTOR"); + hgComponents2.add("METRICS_COLLECTOR"); + TestHostGroup group1 = new TestHostGroup("group1", hgComponents1, Collections.singleton("host1")); + TestHostGroup group2 = new TestHostGroup("group2", hgComponents1, Collections.singleton("host2")); + + Collection<TestHostGroup> hostGroups = new LinkedList<>(); + hostGroups.add(group1); + hostGroups.add(group2); + + ClusterTopology topology = createClusterTopology(bp, clusterConfig, hostGroups); + BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology); + + configProcessor.doUpdateForClusterCreate(); + + assertEquals("0.0.0.0:6188", + clusterConfig.getPropertyValue("ams-site", "timeline.metrics.service.webapp.address")); + } + @Test public void testStackPasswordPropertyFilter() throws Exception{ Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>();
