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:26 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 fb1064bd2 -> aa35b198e


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

Branch: refs/heads/branch-2.4
Commit: aa35b198eb7da4b3df9edd1a5d8e1c33ae5ae6da
Parents: fb1064b
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Wed Nov 9 14:18:08 2016 -0800
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Wed Nov 9 14:18:08 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/aa35b198/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