ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-18287. status commands get all the *-env files irrespective of a service exists or not.(vbrodetskyi)
Date Thu, 15 Sep 2016 13:50:40 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 1afecc2dd -> 53b34516a


AMBARI-18287. status commands get all the *-env files irrespective of a service exists or
not.(vbrodetskyi)


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

Branch: refs/heads/branch-2.5
Commit: 53b34516a5c53cf1d6a93d1bf53f247815269d35
Parents: 1afecc2
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Thu Sep 15 16:50:07 2016 +0300
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Thu Sep 15 16:50:07 2016 +0300

----------------------------------------------------------------------
 .../ambari/server/agent/HeartbeatMonitor.java   |  7 ++++++-
 .../server/agent/TestHeartbeatMonitor.java      | 20 +++++++++++++++-----
 2 files changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/53b34516/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
index c353049..c53a73d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
@@ -31,6 +31,7 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.TreeMap;
 
 import org.apache.ambari.server.AmbariException;
@@ -256,12 +257,16 @@ public class HeartbeatMonitor implements Runnable {
     //Config clusterConfig = cluster.getDesiredConfigByType(GLOBAL);
     Collection<Config> clusterConfigs = cluster.getAllConfigs();
 
+    // creating list with desired config types to validate if cluster config actual
+    Set<String> desiredConfigTypes = cluster.getDesiredConfigs().keySet();
+
     // Apply global properties for this host from all config groups
     Map<String, Map<String, String>> allConfigTags = configHelper
         .getEffectiveDesiredTags(cluster, hostname);
 
     for(Config clusterConfig: clusterConfigs) {
-      if(!clusterConfig.getType().endsWith("-env")) {
+      String configType = clusterConfig.getType();
+      if(!configType.endsWith("-env") || !desiredConfigTypes.contains(configType)) {
         continue;
       }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/53b34516/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
index d8e8879..b6f5ec2 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
@@ -266,13 +266,19 @@ public class TestHeartbeatMonitor {
     }};
 
     ConfigFactory configFactory = injector.getInstance(ConfigFactory.class);
-    Config config = configFactory.createNew(cluster, "hadoop-env",
+    Config hadoopEnvConfig = configFactory.createNew(cluster, "hadoop-env",
       new HashMap<String, String>() {{
         put("a", "b");
       }}, new HashMap<String, Map<String,String>>());
-    config.setTag("version1");
-    cluster.addConfig(config);
-    cluster.addDesiredConfig("_test", Collections.singleton(config));
+    Config hbaseEnvConfig = configFactory.createNew(cluster, "hbase-env",
+            new HashMap<String, String>() {{
+              put("a", "b");
+            }}, new HashMap<String, Map<String,String>>());
+    hadoopEnvConfig.setTag("version1");
+    cluster.addConfig(hadoopEnvConfig);
+    hbaseEnvConfig.setTag("version1");
+    cluster.addConfig(hbaseEnvConfig);
+    cluster.addDesiredConfig("_test", Collections.singleton(hadoopEnvConfig));
 
 
     clusters.mapHostsToCluster(hostNames, clusterName);
@@ -318,7 +324,7 @@ public class TestHeartbeatMonitor {
     HostInfo hi = new HostInfo();
     hi.setOS("Centos5");
     reg.setHardwareProfile(hi);
-    handler.handleRegistration(reg);
+    RegistrationResponse registrationResponse = handler.handleRegistration(reg);
 
     HeartBeat hb = new HeartBeat();
     hb.setHostname(hostname1);
@@ -327,6 +333,10 @@ public class TestHeartbeatMonitor {
     hb.setResponseId(12);
     handler.handleHeartBeat(hb);
 
+    Map<String, Map<String, String>> statusCommandConfig = registrationResponse.getStatusCommands().get(0).getConfigurations();
+    assertEquals(statusCommandConfig.size(), 1);
+    assertTrue(statusCommandConfig.containsKey("hadoop-env"));
+
     // HeartbeatMonitor should generate StatusCommands for
     // MASTER, SLAVE or CLIENT components
     List<StatusCommand> cmds = hm.generateStatusCommands(hostname1);


Mime
View raw message