ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject ambari git commit: AMBARI-18835. Heartbeat lost for all hosts after server start. (mapirkovskyi via swagle)
Date Wed, 09 Nov 2016 22:18:58 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 7beb04d25 -> 8b8460d7d


AMBARI-18835. Heartbeat lost for all hosts after server start. (mapirkovskyi via swagle)


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

Branch: refs/heads/branch-2.5
Commit: 8b8460d7dc573f1f0de135f861a492cb0ec2d7ea
Parents: 7beb04d
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Wed Nov 9 14:18:52 2016 -0800
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Wed Nov 9 14:18:52 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/8b8460d7/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);


Mime
View raw message