You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2016/02/25 17:18:21 UTC
ambari git commit: AMBARI-15160. YARN restart icon appeared after 5
minutes after reconfig (aonishuk)
Repository: ambari
Updated Branches:
refs/heads/branch-2.2 42b08a65c -> 5edef8a68
AMBARI-15160. YARN restart icon appeared after 5 minutes after reconfig (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/5edef8a6
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/5edef8a6
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/5edef8a6
Branch: refs/heads/branch-2.2
Commit: 5edef8a68c41fedaee171f40afd0fe204890aca5
Parents: 42b08a6
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Thu Feb 25 18:17:25 2016 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Thu Feb 25 18:18:13 2016 +0200
----------------------------------------------------------------------
.../ambari/server/state/ConfigHelper.java | 43 +++++++++++++++++++-
.../ambari/server/state/ConfigHelperTest.java | 2 +-
2 files changed, 42 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/5edef8a6/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 aa30b48..30e4157 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
@@ -19,6 +19,8 @@ package org.apache.ambari.server.state;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.RemovalListener;
+import com.google.common.cache.RemovalNotification;
import com.google.common.collect.Maps;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -33,6 +35,7 @@ import org.apache.ambari.server.orm.entities.ClusterConfigEntity;
import org.apache.ambari.server.state.PropertyInfo.PropertyType;
import org.apache.ambari.server.state.configgroup.ConfigGroup;
import org.apache.ambari.server.upgrade.UpgradeCatalog170;
+import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -83,6 +86,30 @@ public class ConfigHelper {
public static final String HTTP_ONLY = "HTTP_ONLY";
public static final String HTTPS_ONLY = "HTTPS_ONLY";
+ /**
+ * Used to debug stale config cache changes.
+ */
+ private class StaleConfigRemovalListener implements RemovalListener {
+
+ @Override
+ public void onRemoval(RemovalNotification removalNotification) {
+ ServiceComponentHost sch;
+ if(removalNotification.getKey() instanceof ServiceComponentHost)
+ {
+ sch = (ServiceComponentHost)removalNotification.getKey();
+ } else {
+ return;
+ }
+ String message = String.format(
+ "Removed stale config flag for:\n\thost:component=%s:%s\n\treason=%s",
+ sch.getHostName(),
+ sch.getServiceComponentName(),
+ removalNotification.getCause().toString()
+ );
+ LOG.info(message);
+ }
+ }
+
@Inject
public ConfigHelper(Clusters c, AmbariMetaInfo metaInfo, Configuration configuration, ClusterDAO clusterDAO) {
clusters = c;
@@ -90,7 +117,8 @@ public class ConfigHelper {
this.clusterDAO = clusterDAO;
STALE_CONFIGS_CACHE_ENABLED = configuration.isStaleConfigCacheEnabled();
staleConfigsCache = CacheBuilder.newBuilder().
- expireAfterWrite(STALE_CONFIGS_CACHE_EXPIRATION_TIME, TimeUnit.SECONDS).build();
+ expireAfterWrite(STALE_CONFIGS_CACHE_EXPIRATION_TIME, TimeUnit.SECONDS).
+ removalListener(new StaleConfigRemovalListener()).build();
}
/**
@@ -977,6 +1005,17 @@ public class ConfigHelper {
Map<String, Map<String, String>> desired = getEffectiveDesiredTags(cluster,
sch.getHostName());
+ ArrayList<String> configs = new ArrayList<>();
+ Iterator<Entry<String, Map<String, String>>> configIterator = desired.entrySet().iterator();
+ while (configIterator.hasNext()) {
+ Entry<String, Map<String, String>> desiredEntry = configIterator.next();
+ configs.add(desiredEntry.getKey() + ":" + desiredEntry.getValue());
+ }
+ LOG.info(String.format(
+ "Calculating stale configs for \n\tcomponent:%s\n\twith configs:%s",
+ sch.getHostName() + ":" + sch.getServiceComponentName(),
+ StringUtils.join(configs, ';')));
+
ServiceInfo serviceInfo = ambariMetaInfo.getService(stackId.getStackName(),
stackId.getStackVersion(), sch.getServiceName());
ComponentInfo componentInfo = serviceInfo.getComponentByName(sch.getServiceComponentName());
@@ -1179,4 +1218,4 @@ public class ConfigHelper {
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/5edef8a6/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 4c9bd2e..eaf35f5 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
@@ -661,7 +661,7 @@ public class ConfigHelperTest {
// set up mocks
ServiceComponentHost sch = createNiceMock(ServiceComponentHost.class);
// set up expectations
- expect(sch.getActualConfigs()).andReturn(schReturn).times(6);
+ expect(sch.getActualConfigs()).andReturn(schReturn).anyTimes();
expect(sch.getHostName()).andReturn("h1").anyTimes();
expect(sch.getClusterId()).andReturn(1l).anyTimes();
expect(sch.getServiceName()).andReturn("FLUME").anyTimes();