ソースを参照

AMBARI-14696. It failed to change the host name from lower to upper case for the cluster.(vbrodetskyi)

Vitaly Brodetskyi 9 年 前
コミット
9e4708876d

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/update/HostUpdateHelper.java

@@ -356,7 +356,7 @@ public class HostUpdateHelper {
     for (Map.Entry<String, Map<String,String>> clusterHosts : hostChangesFileMap.entrySet()) {
       Map<String,String> newHostPairs = new HashMap<>();
       for (Map.Entry<String, String> hostPair : clusterHosts.getValue().entrySet()) {
-        newHostPairs.put(hostPair.getKey().toLowerCase(), hostPair.getValue());
+        newHostPairs.put(hostPair.getKey().toLowerCase(), hostPair.getValue().toLowerCase());
       }
       newHostChangesFileMap.put(clusterHosts.getKey(), newHostPairs);
     }

+ 4 - 3
ambari-server/src/test/java/org/apache/ambari/server/update/HostUpdateHelperTest.java

@@ -513,8 +513,8 @@ public class HostUpdateHelperTest {
     final Configuration mockConfiguration = easyMockSupport.createNiceMock(Configuration.class);
     JsonObject cluster = new JsonObject();
     JsonObject hostPairs = new JsonObject();
-    hostPairs.add("Host1", new JsonPrimitive("hos11"));
-    hostPairs.add("Host2", new JsonPrimitive("hos22"));
+    hostPairs.add("Host1", new JsonPrimitive("Host11"));
+    hostPairs.add("Host2", new JsonPrimitive("Host22"));
     cluster.add("cl1", hostPairs);
 
     expect(mockConfiguration.getHostChangesJson(null)).andReturn(cluster).once();
@@ -528,7 +528,8 @@ public class HostUpdateHelperTest {
     Map<String, Map<String,String>> hostChangesFileMap = hostUpdateHelper.getHostChangesFileMap();
     Assert.assertTrue(hostChangesFileMap.get("cl1").containsKey("host1"));
     Assert.assertTrue(hostChangesFileMap.get("cl1").containsKey("host2"));
-
+    Assert.assertTrue(hostChangesFileMap.get("cl1").get("host1").equals("host11"));
+    Assert.assertTrue(hostChangesFileMap.get("cl1").get("host2").equals("host22"));
   }