ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-14410. It failed to change the host name from Upper to Lower case for the cluster.(vbrodetskyi)
Date Tue, 22 Dec 2015 10:52:49 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 ae3593018 -> d5fe98421


AMBARI-14410. It failed to change the host name from Upper to Lower case for the cluster.(vbrodetskyi)


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

Branch: refs/heads/branch-2.2
Commit: d5fe984216b2abec7df8449a3d1344a81276d51d
Parents: ae35930
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Tue Dec 22 12:52:21 2015 +0200
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Tue Dec 22 12:52:21 2015 +0200

----------------------------------------------------------------------
 .../ambari/server/update/HostUpdateHelper.java  | 13 +++++++++-
 .../server/update/HostUpdateHelperTest.java     | 27 ++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d5fe9842/ambari-server/src/main/java/org/apache/ambari/server/update/HostUpdateHelper.java
----------------------------------------------------------------------
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 ec4921d..44a45f9 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
@@ -338,7 +338,7 @@ public class HostUpdateHelper {
   /*
   * Method initialize Map with json data from file
   * */
-  private void initHostChangesFileMap() throws AmbariException {
+  protected void initHostChangesFileMap() throws AmbariException {
     JsonObject hostChangesJsonObject = configuration.getHostChangesJson(hostChangesFile);
     hostChangesFileMap = new HashMap<>();
 
@@ -350,6 +350,17 @@ public class HostUpdateHelper {
         throw new AmbariException("Error occurred during mapping Json to Map structure. Please
check json structure in file.", e);
       }
     }
+
+    // put current host names to lower case
+    Map<String, Map<String,String>> newHostChangesFileMap = new HashMap<>();
+    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());
+      }
+      newHostChangesFileMap.put(clusterHosts.getKey(), newHostPairs);
+    }
+    hostChangesFileMap = newHostChangesFileMap;
   }
 
   /*

http://git-wip-us.apache.org/repos/asf/ambari/blob/d5fe9842/ambari-server/src/test/java/org/apache/ambari/server/update/HostUpdateHelperTest.java
----------------------------------------------------------------------
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 c59aac2..4f08a9a 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
@@ -18,11 +18,14 @@
 package org.apache.ambari.server.update;
 
 
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.orm.DBAccessor;
 import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
@@ -504,6 +507,30 @@ public class HostUpdateHelperTest {
     easyMockSupport.verifyAll();
   }
 
+  @Test
+  public void testInitHostChangesFileMap_SUCCESS() throws AmbariException {
+    EasyMockSupport easyMockSupport = new EasyMockSupport();
+    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"));
+    cluster.add("cl1", hostPairs);
+
+    expect(mockConfiguration.getHostChangesJson(null)).andReturn(cluster).once();
+
+    HostUpdateHelper hostUpdateHelper = new HostUpdateHelper(null, mockConfiguration, null);
+
+    easyMockSupport.replayAll();
+    hostUpdateHelper.initHostChangesFileMap();
+    easyMockSupport.verifyAll();
+
+    Map<String, Map<String,String>> hostChangesFileMap = hostUpdateHelper.getHostChangesFileMap();
+    Assert.assertTrue(hostChangesFileMap.get("cl1").containsKey("host1"));
+    Assert.assertTrue(hostChangesFileMap.get("cl1").containsKey("host2"));
+
+  }
+
 
 }
 


Mime
View raw message