().getExecutionCommand();
Assert.assertNotNull(storedTasks);
Assert.assertEquals(1, storedTasks.size());
Assert.assertEquals(HostComponentAdminState.DECOMMISSIONED, scHost.getComponentAdminState());
Assert.assertEquals(MaintenanceState.ON, scHost.getMaintenanceState());
HostRoleCommand command = storedTasks.get(0);
Assert.assertTrue("DECOMMISSION, Excluded: h2".equals(command.getCommandDetail()));
Assert.assertTrue("DECOMMISSION".equals(command.getCustomCommandName()));
Map<String, String> cmdParams = command.getExecutionCommandWrapper().getExecutionCommand().getCommandParams();
Assert.assertTrue(cmdParams.containsKey("mark_draining_only"));
Assert.assertEquals("false", cmdParams.get("mark_draining_only"));
Assert.assertEquals(Role.HBASE_MASTER, command.getRole());
Assert.assertEquals(RoleCommand.CUSTOM_COMMAND, command.getRoleCommand());
Map<String, Set<String>> cInfo = execCmd.getClusterHostInfo();
Assert.assertTrue(cInfo.containsKey("decom_hbase_rs_hosts"));
Assert.assertTrue(cInfo.get("decom_hbase_rs_hosts").size() == 1);
Assert.assertEquals("h2",
cInfo.get("all_hosts").toArray()[Integer.parseInt(cInfo.get("decom_hbase_rs_hosts").iterator().next())]);
Assert.assertEquals("DECOMMISSION", execCmd.getHostLevelParams().get("custom_command"));
// RS stops
s.getServiceComponent("HBASE_REGIONSERVER").getServiceComponentHost("h2").setState(State.INSTALLED);
// Remove RS from draining
params = new
HashMap<String, String>() {{
put("excluded_hosts", "h2");
put("mark_draining_only", "true");
put("slave_type", "HBASE_REGIONSERVER");
put("align_maintenance_state", "true");
}};
request = new ExecuteActionRequest(clusterName, "DECOMMISSION", params);
resourceFilter = new RequestResourceFilter("HBASE", "HBASE_MASTER", null);
request.getResourceFilters().add(resourceFilter);
response = controller.createAction(request, requestProperties);
storedTasks = actionDB.getRequestTasks(response.getRequestId());
execCmd = storedTasks.get(0).getExecutionCommandWrapper
().getExecutionCommand();
Assert.assertNotNull(storedTasks);
Assert.assertEquals(1, storedTasks.size());
Assert.assertEquals(HostComponentAdminState.DECOMMISSIONED, scHost.getComponentAdminState());
Assert.assertEquals(MaintenanceState.ON, scHost.getMaintenanceState());
cInfo = execCmd.getClusterHostInfo();
Assert.assertTrue(cInfo.containsKey("decom_hbase_rs_hosts"));
command = storedTasks.get(0);
Assert.assertEquals("DECOMMISSION", execCmd.getHostLevelParams().get("custom_command"));
Assert.assertTrue("DECOMMISSION, Excluded: h2".equals(command.getCommandDetail()));
Assert.assertTrue("DECOMMISSION".equals(command.getCustomCommandName()));
cmdParams = command.getExecutionCommandWrapper().getExecutionCommand().getCommandParams();
Assert.assertTrue(cmdParams.containsKey("mark_draining_only"));
Assert.assertEquals("true", cmdParams.get("mark_draining_only"));
//Recommission
params = new HashMap<String, String>() {{
put("included_hosts", "h2");
}};
request = new ExecuteActionRequest(clusterName, "DECOMMISSION", null,
resourceFilters, params);
response = controller.createAction(request,
requestProperties);
storedTasks = actionDB.getRequestTasks(response.getRequestId());
execCmd = storedTasks.get(0).getExecutionCommandWrapper
().getExecutionCommand();
Assert.assertNotNull(storedTasks);
Assert.assertEquals(1, storedTasks.size());
Assert.assertEquals(HostComponentAdminState.INSERVICE, scHost.getComponentAdminState());
Assert.assertEquals(MaintenanceState.ON, scHost.getMaintenanceState());
command = storedTasks.get(0);
Assert.assertTrue("DECOMMISSION, Included: h2".equals(command.getCommandDetail()));
Assert.assertTrue("DECOMMISSION".equals(command.getCustomCommandName()));
cmdParams = command.getExecutionCommandWrapper().getExecutionCommand().getCommandParams();
Assert.assertTrue(cmdParams.containsKey("mark_draining_only"));
Assert.assertEquals("false", cmdParams.get("mark_draining_only"));
Assert.assertTrue(cmdParams.containsKey("excluded_hosts"));
Assert.assertEquals("", cmdParams.get("excluded_hosts"));
Assert.assertEquals(Role.HBASE_MASTER, command.getRole());
Assert.assertEquals(RoleCommand.CUSTOM_COMMAND, command.getRoleCommand());
cInfo = execCmd.getClusterHostInfo();
Assert.assertFalse(cInfo.containsKey("decom_hbase_rs_hosts"));
Assert.assertEquals("DECOMMISSION", execCmd.getHostLevelParams().get("custom_command"));
}