You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sm...@apache.org on 2014/02/24 05:17:02 UTC
git commit: AMBARI-4796. Do not automatically put host component in
Maintenance Mode upon decommissioning (and out of Maintenance Mode when
recommissioning)
Repository: ambari
Updated Branches:
refs/heads/trunk 64de9764f -> a2a34fa8a
AMBARI-4796. Do not automatically put host component in Maintenance Mode upon decommissioning (and out of Maintenance Mode when recommissioning)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a2a34fa8
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a2a34fa8
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a2a34fa8
Branch: refs/heads/trunk
Commit: a2a34fa8a14fb8a1b1c400120f406a399993ebc9
Parents: 64de976
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Sun Feb 23 19:26:47 2014 -0800
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Sun Feb 23 19:26:47 2014 -0800
----------------------------------------------------------------------
.../AmbariCustomCommandExecutionHelper.java | 32 ++++++++++++--------
.../AmbariManagementControllerTest.java | 7 ++++-
2 files changed, 25 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/a2a34fa8/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
index 0d83e88..7da9a9f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
@@ -64,6 +64,7 @@ import java.util.Set;
import java.util.TreeMap;
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.COMMAND_TIMEOUT;
+import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.COMPONENT_CATEGORY;
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.CUSTOM_COMMAND;
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.DB_DRIVER_FILENAME;
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.DB_NAME;
@@ -83,7 +84,6 @@ import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.SERVICE_P
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.SERVICE_REPO_INFO;
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.STACK_NAME;
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.STACK_VERSION;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.COMPONENT_CATEGORY;
/**
@@ -110,6 +110,7 @@ public class AmbariCustomCommandExecutionHelper {
private static String DECOM_SLAVE_COMPONENT = "slave_type";
private static String HBASE_MARK_DRAINING_ONLY = "mark_draining_only";
private static String UPDATE_EXCLUDE_FILE_ONLY = "update_exclude_file_only";
+ private static String ALIGN_MAINTENANCE_STATE = "align_maintenance_state";
@Inject
private ActionMetadata actionMetadata;
@Inject
@@ -125,7 +126,6 @@ public class AmbariCustomCommandExecutionHelper {
@Inject
private ConfigHelper configHelper;
-
private Boolean isServiceCheckCommand(String command, String service) {
List<String> actions = actionMetadata.getActions(service);
if (actions == null || actions.size() == 0) {
@@ -291,8 +291,8 @@ public class AmbariCustomCommandExecutionHelper {
String commandTimeout = configs.getDefaultAgentTaskTimeout();
ComponentInfo componentInfo = ambariMetaInfo.getComponent(
- stackId.getStackName(), stackId.getStackVersion(),
- serviceName, componentName);
+ stackId.getStackName(), stackId.getStackVersion(),
+ serviceName, componentName);
if (serviceInfo.getSchemaVersion().equals(AmbariMetaInfo.SCHEMA_VERSION_2)) {
// Service check command is not custom command
@@ -557,18 +557,24 @@ public class AmbariCustomCommandExecutionHelper {
}
}
+ String alignMtnStateStr = request.getParameters().get(ALIGN_MAINTENANCE_STATE);
+ boolean alignMtnState = "true".equals(alignMtnStateStr);
// Set/reset decommissioned flag on all components
List<String> listOfExcludedHosts = new ArrayList<String>();
for (ServiceComponentHost sch : svcComponents.get(slaveCompType).getServiceComponentHosts().values()) {
if (excludedHosts.contains(sch.getHostName())) {
sch.setComponentAdminState(HostComponentAdminState.DECOMMISSIONED);
listOfExcludedHosts.add(sch.getHostName());
- sch.setPassiveState(PassiveState.PASSIVE);
+ if (alignMtnState) {
+ sch.setPassiveState(PassiveState.PASSIVE);
+ }
LOG.info("Decommissioning " + slaveCompType + " and marking it PASSIVE on " + sch.getHostName());
}
if (includedHosts.contains(sch.getHostName())) {
sch.setComponentAdminState(HostComponentAdminState.INSERVICE);
- sch.setPassiveState(PassiveState.ACTIVE);
+ if (alignMtnState) {
+ sch.setPassiveState(PassiveState.ACTIVE);
+ }
LOG.info("Recommissioning " + slaveCompType + " and marking it ACTIVE on " + sch.getHostName());
}
}
@@ -679,8 +685,8 @@ public class AmbariCustomCommandExecutionHelper {
if (!scHost.getHostName().equals(jobtrackerHost)) {
if (configTags.get(Configuration.GLOBAL_CONFIG_TAG) != null) {
configHelper.applyCustomConfig(
- configurations, Configuration.GLOBAL_CONFIG_TAG,
- Configuration.RCA_ENABLED_PROPERTY, "false", false);
+ configurations, Configuration.GLOBAL_CONFIG_TAG,
+ Configuration.RCA_ENABLED_PROPERTY, "false", false);
}
}
@@ -781,7 +787,7 @@ public class AmbariCustomCommandExecutionHelper {
Map<String, String> roleParams = new TreeMap<String, String>();
execCmd.setRoleParams(roleParams);
-
+
execCmd.setPassiveInfo(PassiveStateHelper.getPassiveHostComponents(clusters, cluster));
}
@@ -789,14 +795,14 @@ public class AmbariCustomCommandExecutionHelper {
StackId stackId = cluster.getDesiredStackVersion();
Map<String, List<RepositoryInfo>> repos = ambariMetaInfo.getRepository(
- stackId.getStackName(), stackId.getStackVersion());
+ stackId.getStackName(), stackId.getStackVersion());
String repoInfo = "";
if (!repos.containsKey(host.getOsType())) {
// FIXME should this be an error?
LOG.warn("Could not retrieve repo information for host"
- + ", hostname=" + host.getHostName()
- + ", clusterName=" + cluster.getClusterName()
- + ", stackInfo=" + stackId.getStackId());
+ + ", hostname=" + host.getHostName()
+ + ", clusterName=" + cluster.getClusterName()
+ + ", stackInfo=" + stackId.getStackId());
} else {
repoInfo = gson.toJson(repos.get(host.getOsType()));
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/a2a34fa8/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 775928b..5ee94c7 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
@@ -2346,6 +2346,7 @@ public class AmbariManagementControllerTest {
// Decommission one RS
Map<String, String> params = new HashMap<String, String>() {{
put("excluded_hosts", "h2");
+ put("align_maintenance_state", "true");
}};
ExecuteActionRequest request = new ExecuteActionRequest(clusterName, "DECOMMISSION", null, "HBASE", "HBASE_MASTER",
null, params);
@@ -2387,6 +2388,7 @@ public class AmbariManagementControllerTest {
put("excluded_hosts", "h2");
put("mark_draining_only", "true");
put("slave_type", "HBASE_REGIONSERVER");
+ put("align_maintenance_state", "true");
}};
request = new ExecuteActionRequest(clusterName, "DECOMMISSION", null, "HBASE", "HBASE_MASTER", null, params);
@@ -2426,7 +2428,7 @@ public class AmbariManagementControllerTest {
Assert.assertNotNull(storedTasks);
Assert.assertEquals(1, storedTasks.size());
Assert.assertEquals(HostComponentAdminState.INSERVICE, scHost.getComponentAdminState());
- Assert.assertEquals(PassiveState.ACTIVE, scHost.getPassiveState());
+ Assert.assertEquals(PassiveState.PASSIVE, scHost.getPassiveState());
command = storedTasks.get(0);
Assert.assertTrue("DECOMMISSION, Included: h2".equals(command.getCommandDetail()));
Assert.assertTrue("DECOMMISSION".equals(command.getCustomCommandName()));
@@ -5955,6 +5957,7 @@ public class AmbariManagementControllerTest {
Map<String, String> params = new HashMap<String, String>(){{
put("test", "test");
put("excluded_hosts", "h2");
+ put("align_maintenance_state", "true");
}};
ExecuteActionRequest request = new ExecuteActionRequest(clusterName, "DECOMMISSION", null, "HDFS", "NAMENODE",
null, params);
@@ -5987,6 +5990,7 @@ public class AmbariManagementControllerTest {
params = new HashMap<String, String>(){{
put("test", "test");
put("excluded_hosts", "h1");
+ put("align_maintenance_state", "true");
}};
request = new ExecuteActionRequest(clusterName, "DECOMMISSION", null, "HDFS", "NAMENODE", null, params);
@@ -6027,6 +6031,7 @@ public class AmbariManagementControllerTest {
params = new HashMap<String, String>(){{
put("test", "test");
put("included_hosts", "h1 , h2");
+ put("align_maintenance_state", "true");
}};
request = new ExecuteActionRequest(clusterName, "DECOMMISSION", null, "HDFS", "NAMENODE", null, params);