浏览代码

AMBARI-4445. Mark decommissioned host components as PASSIVE

Sumit Mohanty 11 年之前
父节点
当前提交
4a008bdc6b

+ 5 - 3
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java

@@ -36,6 +36,7 @@ import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.HostComponentAdminState;
+import org.apache.ambari.server.state.PassiveState;
 import org.apache.ambari.server.state.RepositoryInfo;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
@@ -421,7 +422,6 @@ public class AmbariCustomCommandExecutionHelper {
     if (actionParameters != null) { // If defined
       execCmd.setRoleParams(actionParameters);
     }
-
   }
 
   private Set<String> getHostList(Map<String, String> cmdParameters, String key) {
@@ -508,11 +508,13 @@ public class AmbariCustomCommandExecutionHelper {
       if (excludedHosts.contains(sch.getHostName())) {
         sch.setComponentAdminState(HostComponentAdminState.DECOMMISSIONED);
         listOfExcludedHosts.add(sch.getHostName());
-        LOG.info("Adding " + slaveCompType + " host to decommissioned list : " + sch.getHostName());
+        sch.setPassiveState(PassiveState.PASSIVE);
+        LOG.info("Decommissioning " + slaveCompType + " and marking it PASSIVE on " + sch.getHostName());
       }
       if (includedHosts.contains(sch.getHostName())) {
         sch.setComponentAdminState(HostComponentAdminState.INSERVICE);
-        LOG.info("Removing " + slaveCompType + " host from the decommissioned list: " + sch.getHostName());
+        sch.setPassiveState(PassiveState.ACTIVE);
+        LOG.info("Recommissioning " + slaveCompType + " and marking it ACTIVE on " + sch.getHostName());
       }
     }
 

+ 4 - 0
ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java

@@ -5715,6 +5715,7 @@ public class AmbariManagementControllerTest {
     Assert.assertNotNull(execCmd.getConfigurationTags().get("hdfs-site"));
     Assert.assertEquals(1, storedTasks.size());
     Assert.assertEquals(HostComponentAdminState.DECOMMISSIONED, scHost.getComponentAdminState());
+    Assert.assertEquals(PassiveState.PASSIVE, scHost.getPassiveState());
     HostRoleCommand command =  storedTasks.get(0);
     Assert.assertEquals(Role.NAMENODE, command.getRole());
     Assert.assertEquals(RoleCommand.CUSTOM_COMMAND, command.getRoleCommand());
@@ -5741,6 +5742,7 @@ public class AmbariManagementControllerTest {
     Assert.assertNotNull(storedTasks);
     Assert.assertEquals(1, storedTasks.size());
     Assert.assertEquals(HostComponentAdminState.DECOMMISSIONED, scHost.getComponentAdminState());
+    Assert.assertEquals(PassiveState.PASSIVE, scHost.getPassiveState());
     cInfo = execCmd.getClusterHostInfo();
     Assert.assertTrue(cInfo.containsKey("decom_dn_hosts"));
     Assert.assertEquals("0,1", cInfo.get("decom_dn_hosts").iterator().next());
@@ -5775,6 +5777,7 @@ public class AmbariManagementControllerTest {
     Assert.assertNotNull(storedTasks);
     scHost = s.getServiceComponent("DATANODE").getServiceComponentHost("h2");
     Assert.assertEquals(HostComponentAdminState.INSERVICE, scHost.getComponentAdminState());
+    Assert.assertEquals(PassiveState.ACTIVE, scHost.getPassiveState());
     execCmd = storedTasks.get(0).getExecutionCommandWrapper
         ().getExecutionCommand();
     Assert.assertNotNull(storedTasks);
@@ -5785,6 +5788,7 @@ public class AmbariManagementControllerTest {
     // Slave components will have admin state as INSERVICE even if the state in DB is null
     scHost.setComponentAdminState(null);
     Assert.assertEquals(HostComponentAdminState.INSERVICE, scHost.getComponentAdminState());
+    Assert.assertEquals(PassiveState.ACTIVE, scHost.getPassiveState());
   }
 
   @Test