You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2013/10/11 19:48:35 UTC

git commit: AMBARI-3489. Unable to reconfigure services with client only components. (Adamos Loizou via swagle)

Updated Branches:
  refs/heads/trunk f1d232fb8 -> 4410fcce1


AMBARI-3489. Unable to reconfigure services with client only components. (Adamos Loizou via swagle)


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

Branch: refs/heads/trunk
Commit: 4410fcce1883347b9853bf9e3cd321488157d4f8
Parents: f1d232f
Author: Siddharth Wagle <sw...@hortonworks.com>
Authored: Fri Oct 11 10:48:17 2013 -0700
Committer: Siddharth Wagle <sw...@hortonworks.com>
Committed: Fri Oct 11 10:48:26 2013 -0700

----------------------------------------------------------------------
 .../AmbariManagementControllerImpl.java         | 17 +++++-
 .../AmbariManagementControllerTest.java         | 60 ++++++++++++++++++++
 2 files changed, 76 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4410fcce/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 1c0f56c..a1855b0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -1820,10 +1820,25 @@ public class AmbariManagementControllerImpl implements
   }
 
   private void addClientSchForReinstall(Cluster cluster,
+            Map<State, List<Service>> changedServices,
             Map<String, Map<State, List<ServiceComponentHost>>> changedScHosts)
             throws AmbariException {
 
     Set<String> services = new HashSet<String>();
+
+    if (changedServices != null) {
+      for (Entry<State, List<Service>> entry : changedServices.entrySet()) {
+        if (State.STARTED != entry.getKey()) {
+          continue;
+        }
+        for (Service s : entry.getValue()) {
+          if (State.INSTALLED == s.getDesiredState()) {
+            services.add(s.getName());
+          }
+        }
+      }
+    }
+
     // Flatten changed Schs that are going to be Started
     List<ServiceComponentHost> serviceComponentHosts = new
       ArrayList<ServiceComponentHost>();
@@ -2004,7 +2019,7 @@ public class AmbariManagementControllerImpl implements
     if (reconfigureClients) {
       // Re-install client only hosts to reattach changed configs on service
       // restart
-      addClientSchForReinstall(cluster, changedScHosts);
+      addClientSchForReinstall(cluster, changedServices, changedScHosts);
     }
 
     if (!changedScHosts.isEmpty()

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/4410fcce/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 96adc3c..dee74ea 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
@@ -5285,6 +5285,66 @@ public class AmbariManagementControllerTest {
   }
 
   @Test
+  public void testReInstallClientComponentFromServiceChange() throws AmbariException {
+    String clusterName = "foo1";
+    createCluster(clusterName);
+    clusters.getCluster(clusterName)
+      .setDesiredStackVersion(new StackId("HDP-2.0.6"));
+    String serviceName = "HDFS";
+    createService(clusterName, serviceName, null);
+    String componentName = "HDFS_CLIENT";
+
+    createServiceComponent(clusterName, serviceName, componentName,
+      State.INIT);
+
+    String host1 = "h1";
+    clusters.addHost(host1);
+    clusters.getHost("h1").setOsType("centos6");
+    clusters.getHost("h1").setState(HostState.HEALTHY);
+    clusters.getHost("h1").persist();
+    String host2 = "h2";
+    clusters.addHost(host2);
+    clusters.getHost("h2").setOsType("centos6");
+    clusters.getHost("h2").setState(HostState.HEALTHY);
+    clusters.getHost("h2").persist();
+
+    clusters.mapHostToCluster(host1, clusterName);
+    clusters.mapHostToCluster(host2, clusterName);
+
+    createServiceComponentHost(clusterName, serviceName, componentName,
+      host1, null);
+    createServiceComponentHost(clusterName, serviceName, componentName,
+      host2, null);
+
+    // Install
+    installService(clusterName, serviceName, false, false);
+
+    // Start Service
+    ServiceRequest sr = new ServiceRequest(
+      clusterName, serviceName, null, State.STARTED.name());
+    Set<ServiceRequest> setReqs = new HashSet<ServiceRequest>();
+    setReqs.add(sr);
+    RequestStatusResponse resp = controller.updateServices(
+      setReqs, Collections.<String, String>emptyMap(), false, true);
+
+    Assert.assertNotNull(resp);
+    Assert.assertTrue(resp.getRequestId() > 0);
+
+    List<Stage> stages = actionDB.getAllStages(resp.getRequestId());
+    Map<String, Role> hostsToRoles = new HashMap<String, Role>();
+    for (Stage stage : stages) {
+      for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
+          hostsToRoles.put(hrc.getHostName(), hrc.getRole());
+      }
+    }
+
+    Map<String, Role> expectedHostsToRoles = new HashMap<String, Role>();
+    expectedHostsToRoles.put(host1, Role.HDFS_CLIENT);
+    expectedHostsToRoles.put(host2, Role.HDFS_CLIENT);
+    Assert.assertEquals(expectedHostsToRoles, hostsToRoles);
+  }
+
+  @Test
   public void testHivePasswordAbsentInConfigs() throws AmbariException {
     String clusterName = "c1";
     String serviceName = "HIVE";