[ambari] branch trunk updated: [AMBARI-23493] Decommission Datanode doesn't work (dsen)

2018-04-16 Thread avijayan
This is an automated email from the ASF dual-hosted git repository.

avijayan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
 new c37a739  [AMBARI-23493] Decommission Datanode doesn't work (dsen)
c37a739 is described below

commit c37a7399c2b5d873af3dff56ecf8cd416a4684ec
Author: Dmytro Sen 
AuthorDate: Mon Apr 16 17:38:17 2018 +0300

[AMBARI-23493] Decommission Datanode doesn't work (dsen)
---
 .../AmbariCustomCommandExecutionHelper.java| 16 +++
 .../org/apache/ambari/server/utils/StageUtils.java | 31 +-
 .../HDFS/2.1.0.2.0/package/scripts/params_linux.py |  5 +++-
 .../YARN/2.1.0.2.0/package/scripts/params_linux.py |  5 +++-
 .../controller/AmbariManagementControllerTest.java |  9 +++
 .../apache/ambari/server/utils/StageUtilsTest.java |  4 ---
 6 files changed, 34 insertions(+), 36 deletions(-)

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 61b14c4..d396d12 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
@@ -129,6 +129,7 @@ public class AmbariCustomCommandExecutionHelper {
 
   public final static String DECOM_INCLUDED_HOSTS = "included_hosts";
   public final static String DECOM_EXCLUDED_HOSTS = "excluded_hosts";
+  public final static String ALL_DECOMMISSIONED_HOSTS = 
"all_decommissioned_hosts";
   public final static String DECOM_SLAVE_COMPONENT = "slave_type";
   public final static String HBASE_MARK_DRAINING_ONLY = "mark_draining_only";
   public final static String UPDATE_FILES_ONLY = "update_files_only";
@@ -1056,6 +1057,10 @@ public class AmbariCustomCommandExecutionHelper {
   }
 
   Map commandParams = new HashMap<>();
+
+  commandParams.put(ALL_DECOMMISSIONED_HOSTS,
+  StringUtils.join(calculateDecommissionedNodes(service, 
slaveCompType), ','));
+
   if (serviceName.equals(Service.Type.HBASE.name())) {
 commandParams.put(DECOM_EXCLUDED_HOSTS, 
StringUtils.join(listOfExcludedHosts, ','));
 if ((isDrainOnlyRequest != null) && isDrainOnlyRequest.equals("true")) 
{
@@ -1072,6 +1077,17 @@ public class AmbariCustomCommandExecutionHelper {
 }
   }
 
+  private Set calculateDecommissionedNodes(Service service, String 
slaveCompType) throws AmbariException {
+Set decommissionedHostsSet = new HashSet<>();
+ServiceComponent serviceComponent = 
service.getServiceComponent(slaveCompType);
+for (ServiceComponentHost serviceComponentHost : 
serviceComponent.getServiceComponentHosts().values()) {
+  if (serviceComponentHost.getComponentAdminState() == 
HostComponentAdminState.DECOMMISSIONED) {
+decommissionedHostsSet.add(serviceComponentHost.getHostName());
+  }
+}
+return decommissionedHostsSet;
+  }
+
 
   private StringBuilder getReadableDecommissionCommandDetail(
   ActionExecutionContext actionExecutionContext, Set includedHosts,
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java 
b/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
index b6287e6..9abc62b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
@@ -58,10 +58,8 @@ import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.ActionExecutionContext;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.state.HostComponentAdminState;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
-import org.apache.ambari.server.state.ServiceComponentHost;
 import 
org.apache.ambari.server.state.svccomphost.ServiceComponentHostInstallEvent;
 import org.apache.ambari.server.topology.TopologyManager;
 import org.apache.commons.lang.StringUtils;
@@ -94,8 +92,6 @@ public class StageUtils {
 
   private static Map componentToClusterInfoKeyMap =
 new HashMap<>();
-  private static Map decommissionedToClusterInfoKeyMap =
-new HashMap<>();
   private volatile static Gson gson;
 
   @Inject
@@ -181,13 +177,6 @@ public class StageUtils {
 componentToClusterInfoKeyMap.put("ACCUMULO_TSERVER", 
"accumulo_tserver_hosts");
   }
 
-  static {
-decommissionedToClusterInfoKeyMap.put("DATANODE", "decom_dn_hosts");
-decommissionedToClusterInfoKeyMap.put("TASKTRACKER", "decom_tt_hosts");
-decommissionedToClusterInfoKeyMap.put("NODEMANAGER", 

[ambari] branch trunk updated: [AMBARI-23493] Decommission Datanode doesn't work (dsen)

2018-04-12 Thread dsen
This is an automated email from the ASF dual-hosted git repository.

dsen pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
 new 675ca9a  [AMBARI-23493] Decommission Datanode doesn't work (dsen)
675ca9a is described below

commit 675ca9a64f70fae517aeefcadcbab137a239922a
Author: Dmytro Sen 
AuthorDate: Thu Apr 12 11:58:51 2018 +0300

[AMBARI-23493] Decommission Datanode doesn't work (dsen)
---
 .../AmbariCustomCommandExecutionHelper.java| 16 +
 .../org/apache/ambari/server/utils/StageUtils.java | 28 --
 .../HDFS/2.1.0.2.0/package/scripts/params_linux.py |  5 +++-
 .../YARN/2.1.0.2.0/package/scripts/params_linux.py |  5 +++-
 .../controller/AmbariManagementControllerTest.java |  9 +++
 .../apache/ambari/server/utils/StageUtilsTest.java |  4 
 6 files changed, 33 insertions(+), 34 deletions(-)

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 61b14c4..d396d12 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
@@ -129,6 +129,7 @@ public class AmbariCustomCommandExecutionHelper {
 
   public final static String DECOM_INCLUDED_HOSTS = "included_hosts";
   public final static String DECOM_EXCLUDED_HOSTS = "excluded_hosts";
+  public final static String ALL_DECOMMISSIONED_HOSTS = 
"all_decommissioned_hosts";
   public final static String DECOM_SLAVE_COMPONENT = "slave_type";
   public final static String HBASE_MARK_DRAINING_ONLY = "mark_draining_only";
   public final static String UPDATE_FILES_ONLY = "update_files_only";
@@ -1056,6 +1057,10 @@ public class AmbariCustomCommandExecutionHelper {
   }
 
   Map commandParams = new HashMap<>();
+
+  commandParams.put(ALL_DECOMMISSIONED_HOSTS,
+  StringUtils.join(calculateDecommissionedNodes(service, 
slaveCompType), ','));
+
   if (serviceName.equals(Service.Type.HBASE.name())) {
 commandParams.put(DECOM_EXCLUDED_HOSTS, 
StringUtils.join(listOfExcludedHosts, ','));
 if ((isDrainOnlyRequest != null) && isDrainOnlyRequest.equals("true")) 
{
@@ -1072,6 +1077,17 @@ public class AmbariCustomCommandExecutionHelper {
 }
   }
 
+  private Set calculateDecommissionedNodes(Service service, String 
slaveCompType) throws AmbariException {
+Set decommissionedHostsSet = new HashSet<>();
+ServiceComponent serviceComponent = 
service.getServiceComponent(slaveCompType);
+for (ServiceComponentHost serviceComponentHost : 
serviceComponent.getServiceComponentHosts().values()) {
+  if (serviceComponentHost.getComponentAdminState() == 
HostComponentAdminState.DECOMMISSIONED) {
+decommissionedHostsSet.add(serviceComponentHost.getHostName());
+  }
+}
+return decommissionedHostsSet;
+  }
+
 
   private StringBuilder getReadableDecommissionCommandDetail(
   ActionExecutionContext actionExecutionContext, Set includedHosts,
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java 
b/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
index 1130e3d..f023b3a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
@@ -58,10 +58,8 @@ import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.ActionExecutionContext;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.state.HostComponentAdminState;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
-import org.apache.ambari.server.state.ServiceComponentHost;
 import 
org.apache.ambari.server.state.svccomphost.ServiceComponentHostInstallEvent;
 import org.apache.ambari.server.topology.TopologyManager;
 import org.apache.commons.lang.StringUtils;
@@ -92,8 +90,6 @@ public class StageUtils {
   protected static final String RACKS = "all_racks";
   protected static final String IPV4_ADDRESSES = "all_ipv4_ips";
 
-  private static Map decommissionedToClusterInfoKeyMap =
-new HashMap<>();
   private volatile static Gson gson;
 
   @Inject
@@ -149,12 +145,6 @@ public class StageUtils {
 StageUtils.configuration = configuration;
   }
 
-  static {
-decommissionedToClusterInfoKeyMap.put("DATANODE", "decom_dn_hosts");
-decommissionedToClusterInfoKeyMap.put("TASKTRACKER", "decom_tt_hosts");
-decommissionedToClusterInfoKeyMap.put("NODEMANAGER",