ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject ambari git commit: Revert "AMBARI-17651. Restart indicator is not shown after modifying the configs (dlysnichenko)"
Date Tue, 12 Jul 2016 02:12:16 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 f2496bb7c -> 0ee10290f


Revert "AMBARI-17651. Restart indicator is not shown after modifying the configs (dlysnichenko)"

This reverts commit 18f0a8f61b86ce4fa021333f36b3bdabf85b2a9f.


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0ee10290
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0ee10290
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0ee10290

Branch: refs/heads/branch-2.4
Commit: 0ee10290fda673b31e6a98d30df3ae7d3ca7e8c5
Parents: f2496bb
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Mon Jul 11 22:12:08 2016 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Mon Jul 11 22:12:08 2016 -0400

----------------------------------------------------------------------
 .../ambari/server/agent/HeartBeatHandler.java   |  2 +-
 .../internal/ConfigGroupResourceProvider.java   |  2 +-
 .../ambari/server/state/ConfigHelper.java       | 69 +++++++-------------
 .../server/state/cluster/ClusterImpl.java       |  8 +--
 .../svccomphost/ServiceComponentHostImpl.java   |  2 +-
 .../ConfigGroupResourceProviderTest.java        |  2 +-
 .../ambari/server/state/ConfigHelperTest.java   |  8 +--
 7 files changed, 34 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0ee10290/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
index f9ce8e6..94a8fe0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
@@ -473,7 +473,7 @@ public class HeartBeatHandler {
           now));
     }
 
-    configHelper.invalidateStaleConfigsCache(hostname, null);
+    configHelper.invalidateStaleConfigsCache(hostname);
 
     response.setStatusCommands(cmds);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ee10290/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java
index 3ba8e69..d4e3828 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java
@@ -696,9 +696,9 @@ public class ConfigGroupResourceProvider extends
         LOG.warn("Could not determine service name for config group {}, service config version
not created",
             configGroup.getId());
       }
-      getManagementController().getConfigHelper().invalidateStaleConfigsCache(cluster.getDesiredConfigs());
     }
 
+    getManagementController().getConfigHelper().invalidateStaleConfigsCache();
   }
 
   @SuppressWarnings("unchecked")

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ee10290/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 e533315..46a3f3e 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
@@ -33,7 +33,6 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 
 import org.apache.ambari.annotations.TransactionalLock;
@@ -465,7 +464,7 @@ public class ConfigHelper {
    *
    * @param sch
    *          the SCH to calcualte config staleness for (not {@code null}).
-   * @param requestDesiredConfigs
+   * @param desiredConfigs
    *          the desired configurations for the cluster. Obtaining these can be
    *          expensive and since this method operates on SCH's, it could be
    *          called 10,000's of times when generating cluster/host responses.
@@ -475,46 +474,27 @@ public class ConfigHelper {
    *
    * @return <code>true</code> if the actual configs are stale
    */
-  public boolean isStaleConfigs(ServiceComponentHost sch, Map<String, DesiredConfig>
requestDesiredConfigs)
+  public boolean isStaleConfigs(ServiceComponentHost sch, Map<String, DesiredConfig>
desiredConfigs)
       throws AmbariException {
     Boolean stale = null;
-    Lock readLock = transactionLocks.getLock(LockArea.STALE_CONFIG_CACHE).readLock();
-    readLock.lock();
-    try {
-      // try the cache
-      if (STALE_CONFIGS_CACHE_ENABLED) {
-        stale = staleConfigsCache.getIfPresent(sch);
-      }
 
-      if (stale == null) {
-        /*
-         prefer staleConfigCacheDesiredConfigs(they are supposed to be passed from thread
that updated configs) to avoid
-         population staleConfigsCache with stale data in case current thread have stale EL
caches(this can happen during
-         parallel requests)
-         */
-        Map<String, DesiredConfig> desiredConfigs = staleConfigCacheDesiredConfigs
!= null ? staleConfigCacheDesiredConfigs : requestDesiredConfigs;
-        stale = calculateIsStaleConfigs(sch, desiredConfigs);
-        staleConfigsCache.put(sch, stale);
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("Cache configuration staleness for host {} and component {} as {}",
-              sch.getHostName(), sch.getServiceComponentName(), stale);
-        }
-      }
-      return stale;
-    } finally {
-      readLock.unlock();
+    // try the cache
+    if (STALE_CONFIGS_CACHE_ENABLED) {
+      stale = staleConfigsCache.getIfPresent(sch);
     }
 
+    if (stale == null) {
+      stale = calculateIsStaleConfigs(sch, desiredConfigs);
+      staleConfigsCache.put(sch, stale);
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Cache configuration staleness for host {} and component {} as {}",
+            sch.getHostName(), sch.getServiceComponentName(), stale);
+      }
+    }
+    return stale;
   }
 
   /**
-   * Every request that updates configs or configs-groups must invalidate staleConfigCache
and update this filed
-   * with its own updated desiredConfigs(they must be passed form updater request) to avoid
any issues with EL caches
-   * during parallel requests.
-   */
-  private Map<String, DesiredConfig> staleConfigCacheDesiredConfigs = null;
-
-  /**
    * Invalidates the stale configuration cache for all
    * {@link ServiceComponentHost}s for the given host. This will execute the
    * invalidation on a separate thread. The thread will attempt to acquire the
@@ -523,13 +503,12 @@ public class ConfigHelper {
    * cluster global locks already acquired.
    *
    * @param hostname
-   * @param desiredConfigs desired cluster configs that will be used for configuration invalidation
    */
-  public void invalidateStaleConfigsCache(String hostname, Map<String, DesiredConfig>
desiredConfigs) {
+  public void invalidateStaleConfigsCache(String hostname) {
     try {
       for (Cluster cluster : clusters.getClustersForHost(hostname)) {
         List<ServiceComponentHost> serviceComponentHosts = cluster.getServiceComponentHosts(hostname);
-        Runnable invalidationRunnable = new StaleConfigInvalidationRunnable(serviceComponentHosts,
desiredConfigs);
+        Runnable invalidationRunnable = new StaleConfigInvalidationRunnable(serviceComponentHosts);
         cacheInvalidationExecutor.execute(invalidationRunnable);
       }
     } catch (AmbariException e) {
@@ -544,8 +523,8 @@ public class ConfigHelper {
    * performed on a separate thread. This way, it won't interfere with any
    * cluster global locks already acquired.
    */
-  public void invalidateStaleConfigsCache(Map<String, DesiredConfig> desiredConfigs)
{
-    Runnable invalidationRunnable = new StaleConfigInvalidationRunnable(desiredConfigs);
+  public void invalidateStaleConfigsCache() {
+    Runnable invalidationRunnable = new StaleConfigInvalidationRunnable();
     cacheInvalidationExecutor.execute(invalidationRunnable);
   }
 
@@ -557,8 +536,8 @@ public class ConfigHelper {
    * performed on a separate thread. This way, it won't interfere with any
    * cluster global locks already acquired.
    */
-  public void invalidateStaleConfigsCache(ServiceComponentHost sch, Map<String, DesiredConfig>
desiredConfigs) {
-    Runnable invalidationRunnable = new StaleConfigInvalidationRunnable(Collections.singletonList(sch),
desiredConfigs);
+  public void invalidateStaleConfigsCache(ServiceComponentHost sch) {
+    Runnable invalidationRunnable = new StaleConfigInvalidationRunnable(Collections.singletonList(sch));
     cacheInvalidationExecutor.execute(invalidationRunnable);
   }
 
@@ -1352,15 +1331,13 @@ public class ConfigHelper {
   private final class StaleConfigInvalidationRunnable implements Runnable {
 
     private final List<ServiceComponentHost> m_keysToInvalidate;
-    private final Map<String, DesiredConfig> m_desiredConfigs;
 
     /**
      * Constructor.
      *
      */
-    private StaleConfigInvalidationRunnable(Map<String, DesiredConfig> desiredConfigs)
{
+    private StaleConfigInvalidationRunnable() {
       m_keysToInvalidate = null;
-      m_desiredConfigs = desiredConfigs;
     }
 
     /**
@@ -1369,9 +1346,8 @@ public class ConfigHelper {
      * @param keysToInvalidate
      *          the keys to invalidate in the cache.
      */
-    private StaleConfigInvalidationRunnable(List<ServiceComponentHost> keysToInvalidate,
Map<String, DesiredConfig> desiredConfigs) {
+    private StaleConfigInvalidationRunnable(List<ServiceComponentHost> keysToInvalidate)
{
       m_keysToInvalidate = keysToInvalidate;
-      m_desiredConfigs = desiredConfigs;
     }
 
     /**
@@ -1382,7 +1358,6 @@ public class ConfigHelper {
       ReadWriteLock lock = transactionLocks.getLock(LockArea.STALE_CONFIG_CACHE);
       lock.writeLock().lock();
       try {
-        ConfigHelper.this.staleConfigCacheDesiredConfigs = m_desiredConfigs;
         if (null == m_keysToInvalidate || m_keysToInvalidate.isEmpty()) {
           staleConfigsCache.invalidateAll();
         } else {

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ee10290/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 53059dc..fdb997b 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
@@ -534,7 +534,7 @@ public class ClusterImpl implements Cluster {
             + configGroup.getTag());
       } else {
         clusterConfigGroups.put(configGroup.getId(), configGroup);
-        configHelper.invalidateStaleConfigsCache(getDesiredConfigs());
+        configHelper.invalidateStaleConfigsCache();
       }
 
     } finally {
@@ -646,7 +646,7 @@ public class ClusterImpl implements Cluster {
 
       configGroup.delete();
       clusterConfigGroups.remove(id);
-      configHelper.invalidateStaleConfigsCache(getDesiredConfigs());
+      configHelper.invalidateStaleConfigsCache();
     } finally {
       clusterGlobalLock.writeLock().unlock();
     }
@@ -2337,7 +2337,7 @@ public class ClusterImpl implements Cluster {
       ServiceConfigVersionResponse serviceConfigVersionResponse = applyConfigs(
           configs, user, serviceConfigVersionNote);
 
-      configHelper.invalidateStaleConfigsCache(getDesiredConfigs());
+      configHelper.invalidateStaleConfigsCache();
       return serviceConfigVersionResponse;
     } finally {
       clusterGlobalLock.writeLock().unlock();
@@ -2556,7 +2556,7 @@ public class ClusterImpl implements Cluster {
     try {
       ServiceConfigVersionResponse serviceConfigVersionResponse = applyServiceConfigVersion(
           serviceName, version, user, note);
-      configHelper.invalidateStaleConfigsCache(getDesiredConfigs());
+      configHelper.invalidateStaleConfigsCache();
       return serviceConfigVersionResponse;
     } finally {
       clusterGlobalLock.writeLock().unlock();

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ee10290/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
index 78f3751..666111b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
@@ -1797,7 +1797,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost
{
       if (desiredStateEntity != null) {
         desiredStateEntity.setRestartRequired(restartRequired);
         saveComponentDesiredStateEntityIfPersisted();
-        helper.invalidateStaleConfigsCache(this, null);
+        helper.invalidateStaleConfigsCache(this);
       } else {
         LOG.warn("Setting a member on an entity object that may have been " +
           "previously deleted, serviceName = " + getServiceName() + ", " +

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ee10290/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProviderTest.java
index 2a4b949..dc8017a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProviderTest.java
@@ -515,7 +515,7 @@ public class ConfigGroupResourceProviderTest {
       }
     });
     expect(managementController.getConfigHelper()).andReturn(configHelper).once();
-    configHelper.invalidateStaleConfigsCache(null);
+    configHelper.invalidateStaleConfigsCache();
     expectLastCall().once();
 
     replay(managementController, clusters, cluster,

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ee10290/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 73fb6ca..0ff143c 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
@@ -737,7 +737,7 @@ public class ConfigHelperTest {
       hc2.setDefaultVersionTag("version1");
       schReturn.put("flume-conf", hc2);
       // invalidate cache to test new sch
-      configHelper.invalidateStaleConfigsCache(null);
+      configHelper.invalidateStaleConfigsCache();
       // Cluster level same configs
       Assert.assertFalse(configHelper.isStaleConfigs(sch, null));
 
@@ -757,7 +757,7 @@ public class ConfigHelperTest {
       hc3.setDefaultVersionTag("version1");
       hc3.getConfigGroupOverrides().put(1l, "FLUME1");
       schReturn.put("flume-conf", hc3);
-      configHelper.invalidateStaleConfigsCache(null);
+      configHelper.invalidateStaleConfigsCache();
 
       // version1 and FLUME1 - stale=false
       Assert.assertFalse(configHelper.isStaleConfigs(sch, null));
@@ -766,7 +766,7 @@ public class ConfigHelperTest {
       hc4.setDefaultVersionTag("version1");
       hc4.getConfigGroupOverrides().put(1l, "FLUME2");
       schReturn.put("flume-conf", hc4);
-      configHelper.invalidateStaleConfigsCache(null);
+      configHelper.invalidateStaleConfigsCache();
 
       // version1 and FLUME2 - stale=true
       Assert.assertTrue(configHelper.isStaleConfigs(sch, null));
@@ -775,7 +775,7 @@ public class ConfigHelperTest {
       hc5.setDefaultVersionTag("version3");
       hc5.getConfigGroupOverrides().put(1l, "FLUME1");
       schReturn.put("flume-conf", hc5);
-      configHelper.invalidateStaleConfigsCache(null);
+      configHelper.invalidateStaleConfigsCache();
 
       // version3 and FLUME1 - stale=true
       Assert.assertTrue(configHelper.isStaleConfigs(sch, null));


Mime
View raw message