incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject git commit: AMBARI-2738. Allow Client component to be re-installed. (swagle)
Date Thu, 25 Jul 2013 22:00:18 GMT
Updated Branches:
  refs/heads/trunk fb69284e6 -> 23ea7ee55


AMBARI-2738. Allow Client component to be re-installed. (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/23ea7ee5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/23ea7ee5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/23ea7ee5

Branch: refs/heads/trunk
Commit: 23ea7ee55bb8d6b952a71d4fbdda6a42771c8784
Parents: fb69284
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Thu Jul 25 15:00:02 2013 -0700
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Thu Jul 25 15:00:02 2013 -0700

----------------------------------------------------------------------
 .../AmbariManagementControllerImpl.java         |  3 +-
 .../AmbariManagementControllerTest.java         | 77 ++++++++++++++++++++
 2 files changed, 79 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/23ea7ee5/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 9380420..9534d61 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
@@ -3246,7 +3246,8 @@ public class AmbariManagementControllerImpl implements
       }
 
       State oldSchState = sch.getState();
-      if (newState == oldSchState) {
+      // Client component reinstall allowed
+      if (newState == oldSchState && !sc.isClientComponent()) {
         sch.setDesiredState(newState);
         if (LOG.isDebugEnabled()) {
           LOG.debug("Ignoring ServiceComponentHost"

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/23ea7ee5/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 7ab7d0b..676a954 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
@@ -5184,6 +5184,83 @@ public class AmbariManagementControllerTest {
   }
 
   @Test
+  public void testReInstallClientComponent() throws AmbariException {
+    String clusterName = "foo1";
+    createCluster(clusterName);
+    clusters.getCluster(clusterName)
+      .setDesiredStackVersion(new StackId("HDP-0.1"));
+    String serviceName = "HDFS";
+    createService(clusterName, serviceName, null);
+    String componentName1 = "NAMENODE";
+    String componentName2 = "DATANODE";
+    String componentName3 = "HDFS_CLIENT";
+
+    createServiceComponent(clusterName, serviceName, componentName1,
+      State.INIT);
+    createServiceComponent(clusterName, serviceName, componentName2,
+      State.INIT);
+    createServiceComponent(clusterName, serviceName, componentName3,
+      State.INIT);
+
+    String host1 = "h1";
+    clusters.addHost(host1);
+    clusters.getHost("h1").setOsType("centos5");
+    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();
+    String host3 = "h3";
+    clusters.addHost(host3);
+    clusters.getHost("h3").setOsType("centos6");
+    clusters.getHost("h3").setState(HostState.HEALTHY);
+    clusters.getHost("h3").persist();
+
+    clusters.mapHostToCluster(host1, clusterName);
+    clusters.mapHostToCluster(host2, clusterName);
+    clusters.mapHostToCluster(host3, clusterName);
+
+    createServiceComponentHost(clusterName, serviceName, componentName1,
+      host1, null);
+    createServiceComponentHost(clusterName, serviceName, componentName2,
+      host1, null);
+    createServiceComponentHost(clusterName, serviceName, componentName3,
+      host2, null);
+    createServiceComponentHost(clusterName, serviceName, componentName3,
+      host3, null);
+
+    // Install
+    installService(clusterName, serviceName, false, false);
+
+    // Reinstall SCH
+    ServiceComponentHostRequest schr = new ServiceComponentHostRequest
+      (clusterName, serviceName, componentName3, host3, null,
+        State.INSTALLED.name());
+    Set<ServiceComponentHostRequest> setReqs = new
+      HashSet<ServiceComponentHostRequest>();
+    setReqs.add(schr);
+    RequestStatusResponse resp = controller.updateHostComponents(setReqs,
+      Collections.<String, String>emptyMap(), false);
+
+    Assert.assertNotNull(resp);
+    Assert.assertTrue(resp.getRequestId() > 0);
+    List<Stage> stages = actionDB.getAllStages(resp.getRequestId());
+    HostRoleCommand clientReinstallCmd = null;
+    for (Stage stage : stages) {
+      for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
+        if (hrc.getHostName().equals(host3) && hrc.getRole().toString()
+          .equals("HDFS_CLIENT")) {
+          clientReinstallCmd = hrc;
+          break;
+        }
+      }
+    }
+    Assert.assertNotNull(clientReinstallCmd);
+  }
+
+  @Test
   public void testHivePasswordAbsentInConfigs() throws AmbariException {
     String clusterName = "c1";
     String serviceName = "HIVE";


Mime
View raw message