ソースを参照

AMBARI-4960. Transition to INIT state on 800 node cluster takes too long. (swagle)

Siddharth Wagle 11 年 前
コミット
41b194064f

+ 4 - 1
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java

@@ -293,6 +293,9 @@ public class AmbariActionExecutionHelper {
       }
     }
 
+    Set<Map<String, String>> maintenanceSCHs =
+      MaintenanceStateHelper.getMaintenanceHostComponents(clusters, cluster);
+
     //create tasks for each host
     for (String hostName : targetHosts) {
       stage.addHostRoleExecutionCommand(hostName,
@@ -344,7 +347,7 @@ public class AmbariActionExecutionHelper {
         StageUtils.getClusterHostInfo(clusters.getHostsForCluster(clusterName), cluster));
 
       // cluster passive map
-      execCmd.setPassiveInfo(MaintenanceStateHelper.getMaintenanceHostCompoments(clusters, cluster));
+      execCmd.setPassiveInfo(maintenanceSCHs);
     }
   }
 }

+ 9 - 4
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java

@@ -1133,8 +1133,9 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
                                 Map<String, Map<String, String>> configTags,
                                 RoleCommand roleCommand,
                                 Map<String, String> commandParams,
-                                ServiceComponentHostEvent event)
-    throws AmbariException {
+                                ServiceComponentHostEvent event
+                                )
+                                throws AmbariException {
 
     stage.addHostRoleExecutionCommand(scHost.getHostName(), Role.valueOf(scHost
       .getServiceComponentName()), roleCommand,
@@ -1271,7 +1272,11 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     Map<String, String> roleParams = new TreeMap<String, String>();
     execCmd.setRoleParams(roleParams);
 
-    execCmd.setPassiveInfo(MaintenanceStateHelper.getMaintenanceHostCompoments(clusters, cluster));
+    // Send passive host info to the Nagios host role
+    if (execCmd.getRole().equals(Role.NAGIOS_SERVER.name())) {
+      execCmd.setPassiveInfo(
+        MaintenanceStateHelper.getMaintenanceHostComponents(clusters, cluster));
+    }
   }
 
   private ActionExecutionContext getActionExecutionContext
@@ -1342,7 +1347,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
           clusters.getHostsForCluster(cluster.getClusterName()), cluster);
 
       String clusterHostInfoJson = StageUtils.getGson().toJson(clusterHostInfo);
-      
+
       Stage stage = createNewStage(cluster, requestId, requestContext, clusterHostInfoJson);
 
       //HACK

+ 1 - 2
ambari-server/src/main/java/org/apache/ambari/server/controller/MaintenanceStateHelper.java

@@ -101,8 +101,7 @@ public class MaintenanceStateHelper {
    * maintenance state (either {@link MaintenanceState#ON} or
    * {@link MaintenanceState#IMPLIED})
    */
-  public static Set<Map<String, String>> getMaintenanceHostCompoments(Clusters clusters,
-      Cluster cluster) throws AmbariException {
+  public static Set<Map<String, String>> getMaintenanceHostComponents(Clusters clusters, Cluster cluster) throws AmbariException {
     
     Set<Map<String, String>> set = new HashSet<Map<String, String>>();
     

+ 39 - 20
ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java

@@ -9468,18 +9468,24 @@ public class AmbariManagementControllerTest {
     String clusterName = "c1";
     createCluster(clusterName);
     clusters.getCluster(clusterName)
-        .setDesiredStackVersion(new StackId("HDP-0.1"));
+        .setDesiredStackVersion(new StackId("HDP-1.2.0"));
     String serviceName = "HDFS";
+    String nagiosService = "NAGIOS";
     createService(clusterName, serviceName, null);
+    createService(clusterName, nagiosService, null);
+
     String componentName1 = "NAMENODE";
     String componentName2 = "DATANODE";
     String componentName3 = "HDFS_CLIENT";
+    String componentName4 = "NAGIOS_SERVER";
     createServiceComponent(clusterName, serviceName, componentName1,
         State.INIT);
     createServiceComponent(clusterName, serviceName, componentName2,
         State.INIT);
     createServiceComponent(clusterName, serviceName, componentName3,
         State.INIT);
+    createServiceComponent(clusterName, nagiosService, componentName4,
+        State.INIT);
 
     String host1 = "h1";
     clusters.addHost(host1);
@@ -9498,6 +9504,7 @@ public class AmbariManagementControllerTest {
     createServiceComponentHost(clusterName, serviceName, componentName1, host1, null);
     createServiceComponentHost(clusterName, serviceName, componentName2, host1, null);
     createServiceComponentHost(clusterName, serviceName, componentName2, host2, null);
+    createServiceComponentHost(clusterName, nagiosService, componentName4, host1, null);
 
     Map<String, String> requestProperties = new HashMap<String, String>();
     requestProperties.put("context", "Called from a test");
@@ -9642,27 +9649,39 @@ public class AmbariManagementControllerTest {
         Assert.assertEquals(State.INIT, sch.getState());
       }
     }    
-    
-    // attempt install on DATANODE only
-    ServiceComponentRequest scr = new ServiceComponentRequest(clusterName,
-        serviceName, componentName2, State.INSTALLED.name());
-    RequestStatusResponse rsr = ComponentResourceProviderTest.updateComponents(
-        controller, Collections.singleton(scr), requestProperties, false);
-    
-    if (rsr != null) {
-      // manually change live state to stopped as no running action manager
-      List<HostRoleCommand> commands = actionDB.getRequestTasks(rsr.getRequestId());
-      for (HostRoleCommand cmd : commands) {
-        Assert.assertNotNull(cmd.getExecutionCommandWrapper().getExecutionCommand().getPassiveInfo());
-        Assert.assertEquals(Integer.valueOf(1),
-            Integer.valueOf(
-                cmd.getExecutionCommandWrapper().getExecutionCommand().getPassiveInfo().size()));
-        
-        clusters.getCluster(clusterName).getService(serviceName).getServiceComponent(cmd.getRole().name())
-            .getServiceComponentHost(cmd.getHostName()).setState(State.INSTALLED);
+
+    long id1 = installService(clusterName, serviceName, false, false);
+    long id2 = installService(clusterName, nagiosService, false, false);
+
+    List<HostRoleCommand> hdfsCmds = actionDB.getRequestTasks(id1);
+    List<HostRoleCommand> nagiosCmds = actionDB.getRequestTasks(id2);
+
+    Assert.assertNotNull(hdfsCmds);
+    Assert.assertNotNull(nagiosCmds);
+
+    HostRoleCommand datanodeCmd = null;
+    HostRoleCommand nagiosCmd = null;
+
+    for (HostRoleCommand cmd : hdfsCmds) {
+      if (cmd.getRole().equals(Role.DATANODE)) {
+        datanodeCmd = cmd;
       }
     }
-    
+
+    for (HostRoleCommand cmd : nagiosCmds) {
+      if (cmd.getRole().equals(Role.NAGIOS_SERVER)) {
+        nagiosCmd = cmd;
+      }
+    }
+
+    Assert.assertNotNull(datanodeCmd);
+    Assert.assertNotNull(nagiosCmd);
+    Assert.assertNotNull(nagiosCmd.getExecutionCommandWrapper()
+      .getExecutionCommand().getPassiveInfo());
+    Assert.assertEquals(Integer.valueOf(1),
+      Integer.valueOf(nagiosCmd.getExecutionCommandWrapper()
+        .getExecutionCommand().getPassiveInfo().size()));
+
     // verify passive sch was skipped
     for (ServiceComponent sc : service.getServiceComponents().values()) {
       if (!sc.getName().equals(componentName2))