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 2016/01/26 22:45:25 UTC
[22/50] ambari git commit: AMBARI-14758. Desired configs cache may
become broken. (mpapirkovskyy)
AMBARI-14758. Desired configs cache may become broken. (mpapirkovskyy)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e94362c3
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e94362c3
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e94362c3
Branch: refs/heads/branch-dev-patch-upgrade
Commit: e94362c35e0a046dcd7ab802cbf258ce603780c6
Parents: 1be4be1
Author: Myroslav Papirkovskyy <mp...@hortonworks.com>
Authored: Thu Jan 21 16:58:52 2016 +0200
Committer: Myroslav Papirkovskyy <mp...@hortonworks.com>
Committed: Sat Jan 23 20:27:28 2016 +0200
----------------------------------------------------------------------
.../ambari/server/state/cluster/ClusterImpl.java | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/e94362c3/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 1d20322..50e02a5 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
@@ -270,7 +270,6 @@ public class ClusterImpl implements Cluster {
private volatile boolean svcHostsLoaded = false;
private volatile Multimap<String, String> serviceConfigTypes;
- private Map<String, DesiredConfig> cachedDesiredConfigs;
/**
* Used to publish events relating to cluster CRUD operations.
@@ -2186,7 +2185,6 @@ public class ClusterImpl implements Cluster {
if (configs == null) {
return null;
}
- cachedDesiredConfigs = null; //clear desired configs cache
Iterator<Config> configIterator = configs.iterator();
@@ -2230,14 +2228,10 @@ public class ClusterImpl implements Cluster {
*/
@Override
public Map<String, DesiredConfig> getDesiredConfigs() {
- //test desired configs caching as this method is called too frequently
- if (cachedDesiredConfigs != null) {
- return new HashMap<>(cachedDesiredConfigs);
- }
Map<String, Set<DesiredConfig>> activeConfigsByType = getDesiredConfigs(false);
- cachedDesiredConfigs = Maps.transformEntries(
+ return Maps.transformEntries(
activeConfigsByType,
new Maps.EntryTransformer<String, Set<DesiredConfig>, DesiredConfig>() {
@Override
@@ -2245,8 +2239,6 @@ public class ClusterImpl implements Cluster {
return value.iterator().next();
}
});
-
- return new HashMap<>(cachedDesiredConfigs);
}
@@ -2264,7 +2256,7 @@ public class ClusterImpl implements Cluster {
Map<String, Set<DesiredConfig>> map = new HashMap<>();
Collection<String> types = new HashSet<>();
- for (ClusterConfigMappingEntity e : clusterDAO.getClusterConfigMappingEntitiesByCluster(getClusterId())) {
+ for (ClusterConfigMappingEntity e : getClusterEntity().getConfigMappingEntities()) {
if (allVersions || e.isSelected() > 0) {
DesiredConfig c = new DesiredConfig();
c.setServiceName(null);
@@ -2425,7 +2417,6 @@ public class ClusterImpl implements Cluster {
clusterGlobalLock.writeLock().lock();
try {
- cachedDesiredConfigs = null; //clear desired configs cache
ServiceConfigVersionResponse serviceConfigVersionResponse = applyServiceConfigVersion(
serviceName, version, user, note);
configHelper.invalidateStaleConfigsCache();
@@ -2656,6 +2647,9 @@ public class ClusterImpl implements Cluster {
entity.setType(type);
entity.setTag(tag);
clusterDAO.persistConfigMapping(entity);
+
+ clusterEntity.getConfigMappingEntities().add(entity);
+ clusterDAO.merge(clusterEntity);
}
@Transactional
@@ -3309,7 +3303,6 @@ public class ClusterImpl implements Cluster {
* Caches all of the {@link ClusterConfigEntity}s in {@link #allConfigs}.
*/
private void cacheConfigurations() {
- cachedDesiredConfigs = null; //clear desired configs cache
ClusterEntity clusterEntity = getClusterEntity();
if (clusterEntity != null) {
if (null == allConfigs) {