AMBARI-18835. Heartbeat lost for all hosts after server start. (mapirkovskyi via swagle)
(cherry picked from commit aa35b198eb7da4b3df9edd1a5d8e1c33ae5ae6da) Change-Id: Ie6637abcfa0d4651b59167801d609ce12545f528 Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/553f26bc Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/553f26bc Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/553f26bc Branch: refs/heads/AMBARI-2.4.2.16 Commit: 553f26bcd03e234c640404cd0a2653288668cc68 Parents: f6e5618 Author: Siddharth Wagle <[email protected]> Authored: Wed Nov 9 14:18:08 2016 -0800 Committer: Zuul <[email protected]> Committed: Wed Nov 9 19:28:34 2016 -0800 ---------------------------------------------------------------------- .../ambari/server/state/alert/AlertDefinitionHash.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/553f26bc/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java index b5dfcd1..57181e5 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.locks.ReentrantLock; import org.apache.ambari.server.AmbariException; @@ -119,7 +120,8 @@ public class AlertDefinitionHash { * The hashes for all hosts for any cluster. The key is the hostname and the * value is a map between cluster name and hash. */ - private Map<String, Map<String, String>> m_hashes = new HashMap<String, Map<String, String>>(); + private ConcurrentMap<String, ConcurrentMap<String, String>> m_hashes = + new ConcurrentHashMap<String, ConcurrentMap<String, String>>(); /** * Gets a unique hash value reprssenting all of the alert definitions that @@ -138,10 +140,13 @@ public class AlertDefinitionHash { * @return the unique hash or {@value #NULL_MD5_HASH} if none. */ public String getHash(String clusterName, String hostName) { - Map<String, String> clusterMapping = m_hashes.get(hostName); + ConcurrentMap<String, String> clusterMapping = m_hashes.get(hostName); if (null == clusterMapping) { clusterMapping = new ConcurrentHashMap<String, String>(); - m_hashes.put(hostName, clusterMapping); + ConcurrentMap<String, String> temp = m_hashes.putIfAbsent(hostName, clusterMapping); + if (temp != null) { + clusterMapping = temp; + } } String hash = clusterMapping.get(hostName);
