This is an automated email from the ASF dual-hosted git repository.

dmitriusan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 89de44a  AMBARI-24840. Change Hostname does not honor uppercase hosts 
(dlisnic… (#2553)
89de44a is described below

commit 89de44acf2106c4c70631db4dc253b940539f6dc
Author: Lisnichenko Dmitro <dmitriu...@apache.org>
AuthorDate: Tue Oct 30 18:10:20 2018 +0200

    AMBARI-24840. Change Hostname does not honor uppercase hosts (dlisnic… 
(#2553)
    
    * AMBARI-24840. Change Hostname does not honor uppercase hosts 
(dlisnichenko)
    
    * AMBARI-24840. Change Hostname does not honor uppercase hosts. Add unit 
tests (dlisnichenko)
---
 .../main/java/org/apache/ambari/server/update/HostUpdateHelper.java | 5 +++--
 .../java/org/apache/ambari/server/update/HostUpdateHelperTest.java  | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/update/HostUpdateHelper.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/update/HostUpdateHelper.java
index 27b4678..2b7129b 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/update/HostUpdateHelper.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/update/HostUpdateHelper.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 import org.apache.ambari.server.AmbariException;
@@ -292,7 +293,7 @@ public class HostUpdateHelper {
       for (String hostName : hostListForReplace) {
         String code = String.format("{replace_code_%d}", counter++);
         hostNameCode.put(hostName, code);
-        updatedPropertyValue = updatedPropertyValue.replace(hostName, code);
+        updatedPropertyValue = updatedPropertyValue.replaceAll("(?i)"+ 
Pattern.quote(hostName), code);
       }
 
       // replace codes with new host names according to ald host names
@@ -314,7 +315,7 @@ public class HostUpdateHelper {
 
     if (value != null && hostNames != null && !value.isEmpty()) {
       for (String host : hostNames) {
-        if (value.contains(host)) {
+        if (StringUtils.containsIgnoreCase(value, host)) {
           includedHostNames.add(host);
         }
       }
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/update/HostUpdateHelperTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/update/HostUpdateHelperTest.java
index 028f888..7029cbf 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/update/HostUpdateHelperTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/update/HostUpdateHelperTest.java
@@ -269,7 +269,7 @@ public class HostUpdateHelperTest {
     });
 
     hosts.put("host11","host55");
-    hosts.put("host5","host1");
+    hosts.put("HOST5","host1");
     hosts.put("host1","host5");
     hosts.put("host55","host11");
 
@@ -295,7 +295,7 @@ public class HostUpdateHelperTest {
     expect(mockClusterConfigEntity1.getConfigId()).andReturn(1L).atLeastOnce();
     
expect(mockClusterConfigEntity1.getStack()).andReturn(mockStackEntity).atLeastOnce();
     expect(mockClusterConfigEntity1.getData()).andReturn("{\"testProperty1\" : 
\"testValue_host1\", " +
-            "\"testProperty2\" : \"testValue_host5\", \"testProperty3\" : 
\"testValue_host11\", " +
+            "\"testProperty2\" : \"testValue_HOST5\", \"testProperty3\" : 
\"testValue_host11\", " +
             "\"testProperty4\" : \"testValue_host55\"}").atLeastOnce();
     
expect(mockClusterConfigEntity1.getTag()).andReturn("testTag1").atLeastOnce();
     
expect(mockClusterConfigEntity1.getType()).andReturn("testType1").atLeastOnce();
@@ -305,7 +305,7 @@ public class HostUpdateHelperTest {
     
expect(mockClusterConfigEntity2.getClusterId()).andReturn(1L).atLeastOnce();
     expect(mockClusterConfigEntity2.getConfigId()).andReturn(2L).anyTimes();
     
expect(mockClusterConfigEntity2.getStack()).andReturn(mockStackEntity).atLeastOnce();
-    expect(mockClusterConfigEntity2.getData()).andReturn("{\"testProperty5\" : 
\"test_host1_test_host5_test_host11_test_host55\"}").atLeastOnce();
+    expect(mockClusterConfigEntity2.getData()).andReturn("{\"testProperty5\" : 
\"test_host1_test_HOST5_test_host11_test_host55\"}").atLeastOnce();
     
expect(mockClusterConfigEntity2.getTag()).andReturn("testTag2").atLeastOnce();
     
expect(mockClusterConfigEntity2.getType()).andReturn("testType2").atLeastOnce();
     expect(mockClusterConfigEntity2.getVersion()).andReturn(2L).atLeastOnce();

Reply via email to