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

adoroszlai pushed a commit to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-2.6 by this push:
     new cde0c47  AMBARI-25136. Scale hosts ignores rack_info (#2800)
cde0c47 is described below

commit cde0c47195b723d0bc211c22dacf8c450d865111
Author: Doroszlai, Attila <6454655+adorosz...@users.noreply.github.com>
AuthorDate: Thu Jan 31 16:51:15 2019 +0100

    AMBARI-25136. Scale hosts ignores rack_info (#2800)
---
 .../controller/internal/ScaleClusterRequest.java      |  2 ++
 .../controller/internal/ScaleClusterRequestTest.java  | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
index 9434f3b..7a799bd 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
@@ -180,6 +180,8 @@ public class ScaleClusterRequest extends BaseClusterRequest 
{
     String rackInfo = null;
     if 
(properties.containsKey(HostResourceProvider.HOST_RACK_INFO_PROPERTY_ID)) {
       rackInfo = (String) 
properties.get(HostResourceProvider.HOST_RACK_INFO_PROPERTY_ID);
+    } else if 
(properties.containsKey(HostResourceProvider.RACK_INFO_PROPERTY_ID)) {
+      rackInfo = (String) 
properties.get(HostResourceProvider.RACK_INFO_PROPERTY_ID);
     } else {
       LOGGER.debug("No rack info provided");
     }
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java
index 3f96944..5069994 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java
@@ -50,6 +50,8 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.google.common.collect.ImmutableMap;
+
 /**
  * Unit tests for ScaleClusterRequest.
  */
@@ -64,6 +66,7 @@ public class ScaleClusterRequestTest {
   private static final String GROUP2_NAME = "group2";
   private static final String GROUP3_NAME = "group3";
   private static final String PREDICATE = "test/prop=foo";
+  private static final String RACK_A = "/rack/a";
 
   private static final BlueprintFactory blueprintFactory = 
createStrictMock(BlueprintFactory.class);
   private static final Blueprint blueprint = createNiceMock(Blueprint.class);
@@ -130,6 +133,14 @@ public class ScaleClusterRequestTest {
     assertTrue(group1Info.getHostNames().contains(HOST1_NAME));
     assertEquals(1, group1Info.getRequestedHostCount());
     assertNull(group1Info.getPredicate());
+    assertEquals(ImmutableMap.of(HOST1_NAME, RACK_A), 
group1Info.getHostRackInfo());
+  }
+
+  @Test
+  public void acceptsRackInfo() throws Exception {
+    Map<String, Object> props = 
createScaleClusterPropertiesGroup1_HostName(CLUSTER_NAME, BLUEPRINT_NAME);
+    addSingleHostByName(props);
+    addSingleHostByName(replaceWithPlainRackInfoKey(props));
   }
 
   @Test
@@ -350,6 +361,7 @@ public class ScaleClusterRequestTest {
     properties.put(HostResourceProvider.BLUEPRINT_PROPERTY_ID, blueprintName);
     properties.put(HostResourceProvider.HOST_GROUP_PROPERTY_ID, GROUP1_NAME);
     properties.put(HostResourceProvider.HOST_HOST_NAME_PROPERTY_ID, 
HOST1_NAME);
+    properties.put(HostResourceProvider.HOST_RACK_INFO_PROPERTY_ID, RACK_A);
 
     return properties;
   }
@@ -361,6 +373,13 @@ public class ScaleClusterRequestTest {
     return properties;
   }
 
+  // include rack info under "rack_info" key instead of "Hosts/rack_info"
+  private static Map<String, Object> replaceWithPlainRackInfoKey(Map<String, 
Object> properties) {
+    Object value = 
properties.remove(HostResourceProvider.HOST_RACK_INFO_PROPERTY_ID);
+    properties.put(HostResourceProvider.RACK_INFO_PROPERTY_ID, value);
+    return properties;
+  }
+
   public static Map<String, Object> 
createScaleClusterPropertiesGroup1_HostCount(String clusterName, String 
blueprintName) {
     Map<String, Object> properties = new LinkedHashMap<>();
 

Reply via email to