You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vb...@apache.org on 2016/09/01 15:59:32 UTC
ambari git commit: AMBARI-18287. status commands get all the *-env
files irrespective of a service exists or not.(vbrodetskyi)
Repository: ambari
Updated Branches:
refs/heads/trunk 169d8dbbf -> 2c40528d9
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/2c40528d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2c40528d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2c40528d
Branch: refs/heads/trunk
Commit: 2c40528d9ae1e36b7bab9b5f3dd51338dd8e7366
Parents: 169d8db
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Thu Sep 1 18:51:08 2016 +0300
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Thu Sep 1 18:51:08 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/2c40528d/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/2c40528d/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 a5396d8..31e3a09 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
@@ -212,13 +212,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);
@@ -264,7 +270,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);
@@ -273,6 +279,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);