You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2014/12/31 12:05:47 UTC

ambari git commit: AMBARI-8952. Adding new host fails with 500 if only zookeeper is installed (dlysnichenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk b6f3dd6b4 -> aaf84e3ac


AMBARI-8952. Adding new host fails with 500 if only zookeeper is installed (dlysnichenko)


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

Branch: refs/heads/trunk
Commit: aaf84e3ac10dcca075c85d3e2791fedfb20855a0
Parents: b6f3dd6
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Wed Dec 31 13:05:01 2014 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Wed Dec 31 13:05:01 2014 +0200

----------------------------------------------------------------------
 .../internal/HostComponentResourceProvider.java          | 11 +++++++++--
 .../controller/AmbariManagementControllerTest.java       |  7 +++++++
 2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/aaf84e3a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
index a6c95f5..7c7e280 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
@@ -402,7 +402,10 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
 
     Resource.Type reqOpLvl = determineOperationLevel(requestProperties);
 
-
+    String clusterName = requestProperties.get(RequestOperationLevel.OPERATION_CLUSTER_ID);
+    if (clusterName != null && !clusterName.isEmpty()) {
+      clusterNames.add(clusterName);
+    }
     for (ServiceComponentHostRequest request : requests) {
       validateServiceComponentHostRequest(request);
 
@@ -417,7 +420,11 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
 
       logRequestInfo("Received a updateHostComponent request", request);
 
-      clusterNames.add(request.getClusterName());
+      if((clusterName == null || clusterName.isEmpty()) 
+              && (request.getClusterName() != null 
+              && !request.getClusterName().isEmpty())) {
+        clusterNames.add(request.getClusterName());
+      }
 
       if (clusterNames.size() > 1) {
         throw new IllegalArgumentException("Updates to multiple clusters is not"

http://git-wip-us.apache.org/repos/asf/ambari/blob/aaf84e3a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index f5521f9..26e1546 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -9106,6 +9106,13 @@ public class AmbariManagementControllerTest {
       componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "DATANODE", "host2", "DISABLED"));
       updateHostComponents(amc, componentHostRequests, mapRequestProps, false);
       org.junit.Assert.assertEquals(State.DISABLED, sch.getState());
+      
+      // State should not be changed if componentHostRequests are empty
+      componentHostRequests.clear();
+      mapRequestProps.put(RequestOperationLevel.OPERATION_CLUSTER_ID,"c1");
+      updateHostComponents(amc, componentHostRequests, mapRequestProps, false);
+      org.junit.Assert.assertEquals(State.DISABLED, sch.getState());
+      mapRequestProps.clear();
 
       // ServiceComponentHost remains in disabled after service stop
       assertEquals(sch.getServiceComponentName(),"DATANODE");