You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by st...@apache.org on 2016/02/29 21:43:46 UTC

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

Repository: ambari
Updated Branches:
  refs/heads/trunk ba59c242d -> 6bdc7fc7f


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/6bdc7fc7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6bdc7fc7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6bdc7fc7

Branch: refs/heads/trunk
Commit: 6bdc7fc7fe88a151116b92f1b9023780c2f219ad
Parents: ba59c24
Author: Toader, Sebastian <st...@hortonworks.com>
Authored: Mon Feb 29 20:17:54 2016 +0100
Committer: Toader, Sebastian <st...@hortonworks.com>
Committed: Mon Feb 29 21:43:33 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/6bdc7fc7/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/6bdc7fc7/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/6bdc7fc7/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 15166f7..30351d8 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
@@ -2556,7 +2556,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";
@@ -4001,7 +4001,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>();
@@ -4047,7 +4047,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>();
@@ -4664,7 +4664,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";
@@ -4876,8 +4876,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/6bdc7fc7/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/6bdc7fc7/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");