cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject git commit: Simplify TokenMetadata.cachedOnlyTokenMap()
Date Tue, 17 Dec 2013 15:25:48 GMT
Updated Branches:
  refs/heads/cassandra-1.2 829047af5 -> 13348c47a


Simplify TokenMetadata.cachedOnlyTokenMap()


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/13348c47
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/13348c47
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/13348c47

Branch: refs/heads/cassandra-1.2
Commit: 13348c47a415bb0887ee722af33384cf18362497
Parents: 829047a
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Tue Dec 17 18:25:31 2013 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Tue Dec 17 18:25:31 2013 +0300

----------------------------------------------------------------------
 .../apache/cassandra/locator/TokenMetadata.java   | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/13348c47/src/java/org/apache/cassandra/locator/TokenMetadata.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/TokenMetadata.java b/src/java/org/apache/cassandra/locator/TokenMetadata.java
index cf0c472..22a9042 100644
--- a/src/java/org/apache/cassandra/locator/TokenMetadata.java
+++ b/src/java/org/apache/cassandra/locator/TokenMetadata.java
@@ -620,25 +620,15 @@ public class TokenMetadata
         if (tm != null)
             return tm;
 
-        // synchronize is to prevent thundering herd (CASSANDRA-6345); lock.readLock is for
correctness vs updates to our internals
+        // synchronize to prevent thundering herd (CASSANDRA-6345)
         synchronized (this)
         {
             if ((tm = cachedTokenMap.get()) != null)
                 return tm;
 
-            lock.readLock().lock();
-            try
-            {
-                tm = new TokenMetadata(SortedBiMultiValMap.<Token, InetAddress>create(tokenToEndpointMap,
null, inetaddressCmp),
-                                       HashBiMap.create(endpointToHostIdMap),
-                                       new Topology(topology));
-                cachedTokenMap.set(tm);
-                return tm;
-            }
-            finally
-            {
-                lock.readLock().unlock();
-            }
+            tm = cloneOnlyTokenMap();
+            cachedTokenMap.set(tm);
+            return tm;
         }
     }
 


Mime
View raw message