You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2014/08/15 22:09:34 UTC

git commit: AMBARI-6876. Flume: stopping agent doesn't work on host with multiple agents (ncole)

Repository: ambari
Updated Branches:
  refs/heads/trunk 6afba61c6 -> 76b801783


AMBARI-6876. Flume: stopping agent doesn't work on host with multiple agents (ncole)


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

Branch: refs/heads/trunk
Commit: 76b801783c97bb779c141d976786a6d42a6d23ea
Parents: 6afba61
Author: Nate Cole <nc...@hortonworks.com>
Authored: Fri Aug 15 11:30:05 2014 -0400
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Fri Aug 15 15:23:59 2014 -0400

----------------------------------------------------------------------
 .../AmbariManagementControllerImpl.java         | 30 +++++++++-
 .../AmbariManagementControllerTest.java         | 62 ++++++++++++++++++++
 2 files changed, 90 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/76b80178/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 59544dd..c749a26 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
@@ -1769,6 +1769,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
             RoleCommand roleCommand;
             State oldSchState = scHost.getState();
             ServiceComponentHostEvent event;
+            
             switch (newState) {
               case INSTALLED:
                 if (oldSchState == State.INIT
@@ -1902,6 +1903,28 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
             // any targeted information
             String keyName = scHost.getServiceComponentName().toLowerCase();
             if (requestProperties.containsKey(keyName)) {
+              // in the case where the command is targeted, but the states
+              // of the old and new are the same, the targeted component
+              // may still need to get the command.  This is true for Flume.
+              if (oldSchState == newState) {
+                switch (oldSchState) {
+                  case INSTALLED:
+                    roleCommand = RoleCommand.STOP;
+                    event = new ServiceComponentHostStopEvent(
+                        scHost.getServiceComponentName(), scHost.getHostName(),
+                        nowTimestamp);
+                    break;
+                  case STARTED:
+                    roleCommand = RoleCommand.START;
+                    event = new ServiceComponentHostStartEvent(
+                        scHost.getServiceComponentName(), scHost.getHostName(),
+                        nowTimestamp);
+                    break;
+                  default:
+                    break;
+                }
+              }
+              
               if (null == requestParameters) {
                 requestParameters = new HashMap<String, String>();
               }
@@ -1913,7 +1936,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
           }
         }
       }
-
+      
       for (String serviceName : smokeTestServices) { // Creates smoke test commands
         Service s = cluster.getService(serviceName);
         // find service component host
@@ -2194,7 +2217,10 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
 
       State oldSchState = sch.getState();
       // Client component reinstall allowed
-      if (newState == oldSchState && !sc.isClientComponent()) {
+      if (newState == oldSchState &&
+          !sc.isClientComponent() &&
+          !requestProperties.containsKey(sch.getServiceComponentName().toLowerCase())) {
+
         ignoredScHosts.add(sch);
         if (LOG.isDebugEnabled()) {
           LOG.debug("Ignoring ServiceComponentHost"

http://git-wip-us.apache.org/repos/asf/ambari/blob/76b80178/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 fe2023e..4e9a0f9 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
@@ -10303,6 +10303,68 @@ public class AmbariManagementControllerTest {
     Assert.assertEquals(1, resps.size());
   }
 
+  @Test
+  public void testTargetedProcessCommand() throws Exception {
+    final String host1 = "h1";
+    String clusterName = "c1";
+    setupClusterWithHosts(clusterName, "HDP-2.0.5", Arrays.asList(host1), "centos5");
+    String serviceName = "HDFS";
+    createService(clusterName, serviceName, null);
+    String componentName1 = "NAMENODE";
+
+    createServiceComponent(clusterName, serviceName, componentName1, State.INIT);
+
+    createServiceComponentHost(clusterName, serviceName, componentName1, host1, null);
+
+    // Install
+    installService(clusterName, serviceName, false, false);
+
+    // Create and attach config
+    // hdfs-site will not have config-attributes
+    Map<String, String> hdfsConfigs = new HashMap<String, String>();
+    hdfsConfigs.put("a", "b");
+    Map<String, Map<String, String>> hdfsConfigAttributes = new HashMap<String, Map<String, String>>() {
+      {
+        put("final", new HashMap<String, String>() {{put("a", "true");}});
+      }
+    };
+
+    ConfigurationRequest cr1 = new ConfigurationRequest(clusterName, "hdfs-site", "version1", hdfsConfigs, hdfsConfigAttributes);
+    ClusterRequest crReq1 = new ClusterRequest(null, clusterName, null, null);
+    crReq1.setDesiredConfig(cr1);
+
+    controller.updateClusters(Collections.singleton(crReq1), null);
+
+    // Start
+    startService(clusterName, serviceName, false, false);
+    
+    ServiceComponentHostRequest req = new ServiceComponentHostRequest(clusterName, serviceName,
+        componentName1, host1, "INSTALLED");
+
+    Map<String, String> requestProperties = new HashMap<String, String>();
+    requestProperties.put("namenode", "p1");
+    RequestStatusResponse resp = controller.updateHostComponents(Collections.singleton(req), requestProperties, false);
+
+    // succeed in creating a task
+    assertNotNull(resp);
+    
+    // manually change live state to stopped as no running action manager
+    for (ServiceComponentHost sch :
+      clusters.getCluster(clusterName).getServiceComponentHosts(host1)) {
+        sch.setState(State.INSTALLED);
+    }
+    
+    // no new commands since no targeted info
+    resp = controller.updateHostComponents(Collections.singleton(req), new HashMap<String, String>(), false);
+    assertNull(resp);
+    
+    // role commands added for targeted command
+    resp = controller.updateHostComponents(Collections.singleton(req), requestProperties, false);
+    assertNotNull(resp);
+    
+  }
+  
+  
 }