You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sm...@apache.org on 2016/01/18 17:37:27 UTC
ambari git commit: AMBARI-14705. nodes in non default config group do
no get prompted for restart to update stale configs (smohanty)
Repository: ambari
Updated Branches:
refs/heads/branch-2.2 2473e1a30 -> 950c676cb
AMBARI-14705. nodes in non default config group do no get prompted for restart to update stale configs (smohanty)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/950c676c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/950c676c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/950c676c
Branch: refs/heads/branch-2.2
Commit: 950c676cbf1cc942f5b93402284979549cfa8586
Parents: 2473e1a
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Mon Jan 18 08:32:14 2016 -0800
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Mon Jan 18 08:32:14 2016 -0800
----------------------------------------------------------------------
.../ambari/server/state/ConfigHelper.java | 7 ++-
.../server/state/cluster/ClusterImpl.java | 11 ++++-
.../ambari/server/state/ConfigHelperTest.java | 52 +++++++++++++++++---
3 files changed, 62 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/950c676c/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
index 57d4db4..aa30b48 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
@@ -378,6 +378,10 @@ public class ConfigHelper {
if (stale == null) {
stale = calculateIsStaleConfigs(sch);
staleConfigsCache.put(sch, stale);
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Config staleness for " +
+ sch.getServiceComponentName() + " on host " + sch.getHostName() + " - " + stale);
+ }
}
return stale;
}
@@ -1134,10 +1138,11 @@ public class ConfigHelper {
* @return true if the tags are different in any way, even if not-specified
*/
private boolean isTagChanged(Map<String, String> desiredTags, Map<String, String> actualTags, boolean groupSpecificConfigs) {
- if (!actualTags.get(CLUSTER_DEFAULT_TAG).equals(desiredTags.get(CLUSTER_DEFAULT_TAG)) && !groupSpecificConfigs) {
+ if (!actualTags.get(CLUSTER_DEFAULT_TAG).equals(desiredTags.get(CLUSTER_DEFAULT_TAG))) {
return true;
}
+ // cluster level configs are already compared for staleness, now they match
// if the host has group specific configs for type we should ignore the cluster level configs and compare specifics
if (groupSpecificConfigs) {
actualTags.remove(CLUSTER_DEFAULT_TAG);
http://git-wip-us.apache.org/repos/asf/ambari/blob/950c676c/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 19f5863..e0900e1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -477,9 +477,18 @@ public class ClusterImpl implements Cluster {
loadConfigGroups();
clusterGlobalLock.writeLock().lock();
try {
+ String hostList = "";
+ if(LOG.isDebugEnabled()) {
+ if (configGroup.getHosts() != null) {
+ for (Host host : configGroup.getHosts().values()) {
+ hostList += host.getHostName() + ", ";
+ }
+ }
+ }
+
LOG.debug("Adding a new Config group" + ", clusterName = "
+ getClusterName() + ", groupName = " + configGroup.getName()
- + ", tag = " + configGroup.getTag());
+ + ", tag = " + configGroup.getTag() + " with hosts " + hostList);
if (clusterConfigGroups.containsKey(configGroup.getId())) {
// The loadConfigGroups will load all groups to memory
http://git-wip-us.apache.org/repos/asf/ambari/blob/950c676c/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
index bdb5156..0cdf50a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
@@ -61,6 +61,8 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
@@ -72,6 +74,7 @@ import com.google.inject.persist.Transactional;
@RunWith(Enclosed.class)
public class ConfigHelperTest {
public static class RunWithInMemoryDefaultTestModule {
+ private final static Logger LOG = LoggerFactory.getLogger(ConfigHelperTest.class);
private Clusters clusters;
private Injector injector;
private String clusterName;
@@ -211,6 +214,8 @@ public class ConfigHelperTest {
ConfigGroup configGroup = configGroupFactory.createNew(cluster, name,
tag, "", configMap, hostMap);
+ LOG.info("Config group created with tag " + tag);
+ configGroup.setTag(tag);
configGroup.persist();
cluster.addConfigGroup(configGroup);
@@ -651,17 +656,19 @@ public class ConfigHelperTest {
// Put a different version to check for change
hc.setDefaultVersionTag("version2");
schReturn.put("flume-conf", hc);
+
// set up mocks
ServiceComponentHost sch = createNiceMock(ServiceComponentHost.class);
// set up expectations
- expect(sch.getActualConfigs()).andReturn(schReturn).times(3);
- expect(sch.getHostName()).andReturn("h1").times(6);
- expect(sch.getClusterId()).andReturn(1l).times(3);
- expect(sch.getServiceName()).andReturn("FLUME").times(3);
- expect(sch.getServiceComponentName()).andReturn("FLUME_HANDLER").times(3);
+ expect(sch.getActualConfigs()).andReturn(schReturn).times(6);
+ expect(sch.getHostName()).andReturn("h1").anyTimes();
+ expect(sch.getClusterId()).andReturn(1l).anyTimes();
+ expect(sch.getServiceName()).andReturn("FLUME").anyTimes();
+ expect(sch.getServiceComponentName()).andReturn("FLUME_HANDLER").anyTimes();
replay(sch);
// Cluster level config changes
Assert.assertTrue(configHelper.isStaleConfigs(sch));
+
HostConfig hc2 = new HostConfig();
hc2.setDefaultVersionTag("version1");
schReturn.put("flume-conf", hc2);
@@ -669,13 +676,46 @@ public class ConfigHelperTest {
configHelper.invalidateStaleConfigsCache();
// Cluster level same configs
Assert.assertFalse(configHelper.isStaleConfigs(sch));
+
// Cluster level same configs but group specific configs for host have been updated
List<String> hosts = new ArrayList<String>();
hosts.add("h1");
List<Config> configs = new ArrayList<Config>();
- configs.add(new ConfigImpl("flume-conf"));
+ ConfigImpl configImpl = new ConfigImpl("flume-conf");
+ configImpl.setTag("FLUME1");
+ configs.add(configImpl);
addConfigGroup("configGroup1", "FLUME", hosts, configs);
+
+ // config group added for host - expect staleness
Assert.assertTrue(configHelper.isStaleConfigs(sch));
+
+ HostConfig hc3 = new HostConfig();
+ hc3.setDefaultVersionTag("version1");
+ hc3.getConfigGroupOverrides().put(1l, "FLUME1");
+ schReturn.put("flume-conf", hc3);
+ configHelper.invalidateStaleConfigsCache();
+
+ // version1 and FLUME1 - stale=false
+ Assert.assertFalse(configHelper.isStaleConfigs(sch));
+
+ HostConfig hc4 = new HostConfig();
+ hc4.setDefaultVersionTag("version1");
+ hc4.getConfigGroupOverrides().put(1l, "FLUME2");
+ schReturn.put("flume-conf", hc4);
+ configHelper.invalidateStaleConfigsCache();
+
+ // version1 and FLUME2 - stale=true
+ Assert.assertTrue(configHelper.isStaleConfigs(sch));
+
+ HostConfig hc5 = new HostConfig();
+ hc5.setDefaultVersionTag("version3");
+ hc5.getConfigGroupOverrides().put(1l, "FLUME1");
+ schReturn.put("flume-conf", hc5);
+ configHelper.invalidateStaleConfigsCache();
+
+ // version3 and FLUME1 - stale=true
+ Assert.assertTrue(configHelper.isStaleConfigs(sch));
+
verify(sch);
}
}