ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpapirkovs...@apache.org
Subject ambari git commit: AMBARI-14758. Desired configs cache may become broken. (mpapirkovskyy)
Date Sat, 23 Jan 2016 18:28:09 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 bfea8026a -> 9d413a29b


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/9d413a29
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9d413a29
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9d413a29

Branch: refs/heads/branch-2.2
Commit: 9d413a29b044a5eb454487ab391598cf2f572ecd
Parents: bfea802
Author: Myroslav Papirkovskyy <mpapyrkovskyy@hortonworks.com>
Authored: Thu Jan 21 16:58:52 2016 +0200
Committer: Myroslav Papirkovskyy <mpapyrkovskyy@hortonworks.com>
Committed: Sat Jan 23 20:27:14 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/9d413a29/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 e0900e1..a1e1919 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
@@ -268,7 +268,6 @@ public class ClusterImpl implements Cluster {
   private volatile boolean svcHostsLoaded = false;
 
   private volatile Multimap<String, String> serviceConfigTypes;
-  private Map<String, DesiredConfig> cachedDesiredConfigs;
 
 
   @Inject
@@ -2152,7 +2151,6 @@ public class ClusterImpl implements Cluster {
       if (configs == null) {
         return null;
       }
-      cachedDesiredConfigs = null; //clear desired configs cache
 
       Iterator<Config> configIterator = configs.iterator();
 
@@ -2196,14 +2194,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
@@ -2211,8 +2205,6 @@ public class ClusterImpl implements Cluster {
             return value.iterator().next();
           }
         });
-
-    return new HashMap<>(cachedDesiredConfigs);
   }
 
 
@@ -2230,7 +2222,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);
@@ -2391,7 +2383,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();
@@ -2622,6 +2613,9 @@ public class ClusterImpl implements Cluster {
     entity.setType(type);
     entity.setTag(tag);
     clusterDAO.persistConfigMapping(entity);
+
+    clusterEntity.getConfigMappingEntities().add(entity);
+    clusterDAO.merge(clusterEntity);
   }
 
   @Transactional
@@ -3276,7 +3270,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) {


Mime
View raw message