You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2017/07/31 14:10:27 UTC

[12/25] ambari git commit: AMBARI-21587 Don't set restart indicators for NN/RM during DN/NM deletion (dsen)

AMBARI-21587 Don't set restart indicators for NN/RM during DN/NM deletion (dsen)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0f426c16
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0f426c16
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0f426c16

Branch: refs/heads/branch-feature-AMBARI-21450
Commit: 0f426c16c0e788d162fd2d6c1ae0c4bc1400e1e7
Parents: d9e8f4f
Author: Dmytro Sen <ds...@apache.org>
Authored: Thu Jul 27 20:18:44 2017 +0300
Committer: Dmytro Sen <ds...@apache.org>
Committed: Thu Jul 27 20:18:44 2017 +0300

----------------------------------------------------------------------
 .../AmbariManagementControllerImpl.java         | 38 ++---------
 .../AmbariManagementControllerTest.java         | 69 ++++++++++++++++++++
 2 files changed, 73 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0f426c16/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 13526c4..36cfb0f 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
@@ -165,7 +165,6 @@ import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.DesiredConfig;
 import org.apache.ambari.server.state.ExtensionInfo;
 import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.state.HostComponentAdminState;
 import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.MaintenanceState;
 import org.apache.ambari.server.state.OperatingSystemInfo;
@@ -3664,8 +3663,9 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     for (Entry<ServiceComponent, Set<ServiceComponentHost>> entry : safeToRemoveSCHs.entrySet()) {
       for (ServiceComponentHost componentHost : entry.getValue()) {
         try {
-          deleteHostComponent(entry.getKey(), componentHost);
-          deleteStatusMetaData.addDeletedKey(componentHost.getHostName() + "/" + componentHost.getServiceComponentName());
+          //actually delete the component
+          entry.getKey().deleteServiceComponentHosts(componentHost.getHostName());
+
           //create cluster-master-service map to update all include/exclude files in one action
           String componentName = componentHost.getServiceComponentName();
           if (masterToSlaveMappingForDecom.containsValue(componentName)) {
@@ -3692,6 +3692,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
               clusterMasterSlaveHostsMap.put(componentHost.getClusterName(), masterSlaveHostsMap);
             }
           }
+          deleteStatusMetaData.addDeletedKey(componentHost.getHostName() + "/" + componentHost.getServiceComponentName());
         } catch (Exception ex) {
           deleteStatusMetaData.addException(componentHost.getHostName() + "/" + componentHost.getServiceComponentName(), ex);
         }
@@ -3723,37 +3724,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     return deleteStatusMetaData;
   }
 
-  private void deleteHostComponent(ServiceComponent serviceComponent, ServiceComponentHost componentHost) throws AmbariException {
-    String serviceName = serviceComponent.getServiceName();
-    String master_component_name = null;
-    String slave_component_name = componentHost.getServiceComponentName();
-    HostComponentAdminState desiredAdminState = componentHost.getComponentAdminState();
-    State slaveState = componentHost.getState();
-    //Delete hostcomponents
-    serviceComponent.deleteServiceComponentHosts(componentHost.getHostName());
-    // If deleted hostcomponents support decomission and were decommited and stopped or in unknown state
-    if (masterToSlaveMappingForDecom.containsValue(slave_component_name)
-            && desiredAdminState.equals(HostComponentAdminState.DECOMMISSIONED)
-            && (slaveState.equals(State.INSTALLED) || slaveState.equals(State.UNKNOWN))) {
-      for (Entry<String, String> entrySet : masterToSlaveMappingForDecom.entrySet()) {
-        if (entrySet.getValue().equals(slave_component_name)) {
-          master_component_name = entrySet.getKey();
-        }
-      }
-
-      //Mark master component as needed to restart for remove host info from components UI
-      Cluster cluster = clusters.getCluster(serviceComponent.getClusterName());
-      Service service = cluster.getService(serviceName);
-      ServiceComponent sc = service.getServiceComponent(master_component_name);
-
-      if (sc != null && sc.isMasterComponent()) {
-        for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
-          sch.setRestartRequired(true);
-        }
-      }
-    }
-  }
-
   /**
    * Creates and triggers an action to update include and exclude files for the master components depending on current cluster topology and components state
    * @param serviceMasterMap

http://git-wip-us.apache.org/repos/asf/ambari/blob/0f426c16/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 81b3580..8afa0ef 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
@@ -10165,6 +10165,75 @@ public class AmbariManagementControllerTest {
   }
 
   @Test
+  public void testRestartIndicatorsAndSlaveFilesUpdateAtComponentsDelete() throws Exception {
+    String cluster1 = getUniqueName();
+    createCluster(cluster1);
+    Cluster cluster = clusters.getCluster(cluster1);
+    StackId stackId = new StackId("HDP-2.0.7");
+    cluster.setDesiredStackVersion(stackId);
+    cluster.setCurrentStackVersion(stackId);
+
+    String hdfsService = "HDFS";
+    String zookeeperService = "ZOOKEEPER";
+    createService(cluster1, hdfsService, null);
+    createService(cluster1, zookeeperService, null);
+
+    String namenode = "NAMENODE";
+    String datanode = "DATANODE";
+    String zookeeperServer = "ZOOKEEPER_SERVER";
+    String zookeeperClient = "ZOOKEEPER_CLIENT";
+
+    createServiceComponent(cluster1, hdfsService, namenode,
+        State.INIT);
+    createServiceComponent(cluster1, hdfsService, datanode,
+        State.INIT);
+    createServiceComponent(cluster1, zookeeperService, zookeeperServer,
+        State.INIT);
+    createServiceComponent(cluster1, zookeeperService, zookeeperClient,
+        State.INIT);
+
+    String host1 = getUniqueName();
+    String host2 = getUniqueName();
+
+    addHostToCluster(host1, cluster1);
+    createServiceComponentHost(cluster1, hdfsService, namenode, host1, null);
+    createServiceComponentHost(cluster1, hdfsService, datanode, host1, null);
+    createServiceComponentHost(cluster1, zookeeperService, zookeeperServer, host1,
+        null);
+    createServiceComponentHost(cluster1, zookeeperService, zookeeperClient, host1,
+        null);
+
+    ServiceComponentHost nameNodeSch = null;
+    for (ServiceComponentHost sch : cluster.getServiceComponentHosts(host1)) {
+      if (sch.getServiceComponentName().equals(namenode)) {
+        nameNodeSch = sch;
+      }
+    }
+
+    assertFalse(nameNodeSch.isRestartRequired());
+
+    addHostToCluster(host2, cluster1);
+
+    createServiceComponentHost(cluster1, hdfsService, datanode, host2, null);
+    assertFalse(nameNodeSch.isRestartRequired());  //No restart required if adding host
+
+    deleteServiceComponentHost(cluster1, hdfsService, datanode, host2, null);
+    deleteHost(host2);
+
+    assertFalse(nameNodeSch.isRestartRequired());   //NameNode doesn't need to be restarted!
+
+    List<Long> requestIDs = actionDB.getRequestsByStatus(null, 1, false);
+    Request request = actionDB.getRequest(requestIDs.get(0));
+    assertEquals("Update Include and Exclude Files for [HDFS]", request.getRequestContext());
+    assertEquals("{\"multi_services_decom_request\":\"true\",\"update_files_only\":\"false\"}", request.getInputs());
+    assertEquals(1, request.getResourceFilters().size());
+    RequestResourceFilter resourceFilter = request.getResourceFilters().get(0);
+    assertEquals(resourceFilter.getServiceName(), hdfsService);
+    assertEquals(resourceFilter.getComponentName(), namenode);
+    assertEquals(resourceFilter.getHostNames(), new ArrayList<String>());
+  }
+
+  @Test
   public void testMaintenanceState() throws Exception {
     String cluster1 = getUniqueName();
     createCluster(cluster1);