Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 5a04ef2c3 -> 0d933837e


AMBARI-15184. Host with uppercased symbols was not registered during deploy via 
blueprints. (Sandor Magyari via stoader)


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

Branch: refs/heads/branch-2.2
Commit: 0d933837eef7b32b1c6920b4a61afd31291d777b
Parents: 5a04ef2
Author: Toader, Sebastian <stoa...@hortonworks.com>
Authored: Mon Feb 29 20:17:54 2016 +0100
Committer: Toader, Sebastian <stoa...@hortonworks.com>
Committed: Mon Feb 29 22:58:43 2016 +0100

----------------------------------------------------------------------
 .../ambari/server/topology/ClusterTopologyImpl.java     |  3 ++-
 .../apache/ambari/server/topology/HostGroupInfo.java    | 11 ++++++++++-
 .../internal/BlueprintConfigurationProcessorTest.java   | 12 ++++++------
 .../internal/ProvisionClusterRequestTest.java           |  4 ++--
 .../ambari/server/topology/HostGroupInfoTest.java       | 11 +++++++++++
 5 files changed, 31 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0d933837/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
index af716a0..003539c 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
@@ -360,7 +360,8 @@ public class ClusterTopologyImpl implements ClusterTopology 
{
       }
     }
     if (! duplicates.isEmpty()) {
-      throw new InvalidTopologyException("The following hosts are mapped to 
multiple host groups: " + duplicates);
+      throw new InvalidTopologyException("The following hosts are mapped to 
multiple host groups: " + duplicates + "." +
+        " Be aware that host names are converted to lowercase, case 
differences do not matter in Ambari deployments.");
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0d933837/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
index 98ad3a9..4847a11 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
@@ -26,11 +26,16 @@ import java.util.Map;
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.api.predicate.PredicateCompiler;
 import org.apache.ambari.server.controller.spi.Predicate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Host Group information specific to a cluster instance.
  */
 public class HostGroupInfo {
+
+  private final static Logger LOG = 
LoggerFactory.getLogger(HostGroupInfo.class);
+
   /**
    * predicate compiler
    */
@@ -125,7 +130,11 @@ public class HostGroupInfo {
    */
   public void addHost(String hostName) {
     synchronized(hostNames) {
-      hostNames.add(hostName);
+      String lowerHostName = hostName.toLowerCase();
+      if (!hostName.equals(lowerHostName)) {
+        LOG.warn("Host name {} contains upper case letters, will be converted 
to lowercase!", hostName );
+      }
+      hostNames.add(lowerHostName);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/0d933837/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 e70105b..ef5dc76 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
@@ -2541,7 +2541,7 @@ public class BlueprintConfigurationProcessorTest {
   public void 
testDoUpdateForClusterWithNameNodeHAEnabledSpecifyingHostNamesDirectly() throws 
Exception {
     final String expectedNameService = "mynameservice";
     final String expectedHostName = "c6401.apache.ambari.org";
-    final String expectedHostNameTwo = "serverTwo";
+    final String expectedHostNameTwo = "server-two";
     final String expectedPortNum = "808080";
     final String expectedNodeOne = "nn1";
     final String expectedNodeTwo = "nn2";
@@ -3986,7 +3986,7 @@ public class BlueprintConfigurationProcessorTest {
     hgComponents.add("FALCON_CLIENT");
     List<String> hosts = new ArrayList<String>();
     hosts.add("c6401.apache.ambari.org");
-    hosts.add("serverTwo");
+    hosts.add("server-two");
     TestHostGroup group1 = new TestHostGroup("host_group_1", hgComponents, 
hosts);
 
     Collection<TestHostGroup> hostGroups = new HashSet<TestHostGroup>();
@@ -4032,7 +4032,7 @@ public class BlueprintConfigurationProcessorTest {
     hgComponents.add("FALCON_CLIENT");
     List<String> hosts = new ArrayList<String>();
     hosts.add(expectedHostName);
-    hosts.add("serverTwo");
+    hosts.add("server-two");
     TestHostGroup group1 = new TestHostGroup(expectedHostGroupName, 
hgComponents, hosts);
 
     Collection<TestHostGroup> hostGroups = new HashSet<TestHostGroup>();
@@ -4649,7 +4649,7 @@ public class BlueprintConfigurationProcessorTest {
   public void testDoUpdateForClusterWithNameNodeHAEnabled() throws Exception {
     final String expectedNameService = "mynameservice";
     final String expectedHostName = "c6401.apache.ambari.org";
-    final String expectedHostNameTwo = "serverTwo";
+    final String expectedHostNameTwo = "server-two";
     final String expectedPortNum = "808080";
     final String expectedNodeOne = "nn1";
     final String expectedNodeTwo = "nn2";
@@ -4861,8 +4861,8 @@ public class BlueprintConfigurationProcessorTest {
   @Test
   public void testDoUpdateForClusterWithNameNodeHAEnabledAndActiveNodeSet() 
throws Exception {
     final String expectedNameService = "mynameservice";
-    final String expectedHostName = "serverThree";
-    final String expectedHostNameTwo = "serverFour";
+    final String expectedHostName = "server-three";
+    final String expectedHostNameTwo = "server-four";
     final String expectedPortNum = "808080";
     final String expectedNodeOne = "nn1";
     final String expectedNodeTwo = "nn2";

http://git-wip-us.apache.org/repos/asf/ambari/blob/0d933837/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java
index 5ace2a5..0610d10 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java
@@ -116,7 +116,7 @@ public class ProvisionClusterRequestTest {
     HostGroupInfo group1Info = hostGroupInfo.get("group1");
     assertEquals("group1", group1Info.getHostGroupName());
     assertEquals(1, group1Info.getHostNames().size());
-    assertTrue(group1Info.getHostNames().contains("host1.myDomain.com"));
+    assertTrue(group1Info.getHostNames().contains("host1.mydomain.com"));
     assertEquals(1, group1Info.getRequestedHostCount());
     assertNull(group1Info.getPredicate());
     // configuration
@@ -220,7 +220,7 @@ public class ProvisionClusterRequestTest {
     HostGroupInfo group1Info = hostGroupInfo.get("group1");
     assertEquals("group1", group1Info.getHostGroupName());
     assertEquals(1, group1Info.getHostNames().size());
-    assertTrue(group1Info.getHostNames().contains("host1.myDomain.com"));
+    assertTrue(group1Info.getHostNames().contains("host1.mydomain.com"));
     assertEquals(1, group1Info.getRequestedHostCount());
     assertNull(group1Info.getPredicate());
     // configuration

http://git-wip-us.apache.org/repos/asf/ambari/blob/0d933837/ambari-server/src/test/java/org/apache/ambari/server/topology/HostGroupInfoTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/topology/HostGroupInfoTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/topology/HostGroupInfoTest.java
index 3b15684..47ddddf 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/topology/HostGroupInfoTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/topology/HostGroupInfoTest.java
@@ -47,6 +47,15 @@ public class HostGroupInfoTest {
   }
 
   @Test
+  public void testHostName_isConvertedToLowercase() {
+    HostGroupInfo group = new HostGroupInfo("test-name");
+    // single host add
+    group.addHost("HOST1");
+    assertEquals(1, group.getHostNames().size());
+    assertTrue(group.getHostNames().contains("host1"));
+  }
+
+  @Test
   public void testSetGetHostNames() {
     HostGroupInfo group = new HostGroupInfo("test-name");
     // single host add
@@ -72,6 +81,8 @@ public class HostGroupInfoTest {
 
   }
 
+
+
   @Test
   public void testSetGetRequestedHostCount_explicit() {
     HostGroupInfo group = new HostGroupInfo("test-name");

Reply via email to