cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [6/9] git commit: cleanup
Date Mon, 30 Sep 2013 18:54:02 GMT
cleanup


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

Branch: refs/heads/trunk
Commit: 672131d97fe31a7c724a236fc4f040d4c241769d
Parents: d73380e
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Mon Sep 30 13:52:09 2013 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Mon Sep 30 13:52:09 2013 -0500

----------------------------------------------------------------------
 .../apache/cassandra/locator/TokenMetadata.java | 22 +++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/672131d9/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 7ad711f..ac9a1d0 100644
--- a/src/java/org/apache/cassandra/locator/TokenMetadata.java
+++ b/src/java/org/apache/cassandra/locator/TokenMetadata.java
@@ -45,10 +45,14 @@ public class TokenMetadata
 {
     private static final Logger logger = LoggerFactory.getLogger(TokenMetadata.class);
 
-    /* Maintains token to endpoint map of every node in the cluster. */
+    /**
+     * Maintains token to endpoint map of every node in the cluster.
+     * Each Token is associated with exactly one Address, but each Address may have
+     * multiple tokens.  Hence, the BiMultiValMap collection.
+     */
     private final BiMultiValMap<Token, InetAddress> tokenToEndpointMap;
 
-    /* Maintains endpoint to host ID map of every node in the cluster */
+    /** Maintains endpoint to host ID map of every node in the cluster */
     private final BiMap<InetAddress, UUID> endpointToHostIdMap;
 
     // Prior to CASSANDRA-603, we just had <tt>Map<Range, InetAddress> pendingRanges<tt>,
@@ -235,10 +239,10 @@ public class TokenMetadata
                                                              hostId));
                 }
             }
-    
+
             UUID storedId = endpointToHostIdMap.get(endpoint);
             if ((storedId != null) && (!storedId.equals(hostId)))
-                logger.warn("Changing {}'s host ID from {} to {}", new Object[] {endpoint,
storedId, hostId});
+                logger.warn("Changing {}'s host ID from {} to {}", endpoint, storedId, hostId);
     
             endpointToHostIdMap.forcePut(endpoint, hostId);
         }
@@ -761,7 +765,7 @@ public class TokenMetadata
         lock.readLock().lock();
         try
         {
-            return new HashSet<>(endpointToHostIdMap.keySet());
+            return ImmutableSet.copyOf(endpointToHostIdMap.keySet());
         }
         finally
         {
@@ -775,7 +779,7 @@ public class TokenMetadata
         lock.readLock().lock();
         try
         {
-            return new HashSet<>(leavingEndpoints);
+            return ImmutableSet.copyOf(leavingEndpoints);
         }
         finally
         {
@@ -792,7 +796,7 @@ public class TokenMetadata
         lock.readLock().lock();
         try
         {
-            return new HashSet<>(movingEndpoints);
+            return ImmutableSet.copyOf(movingEndpoints);
         }
         finally
         {
@@ -1004,9 +1008,7 @@ public class TokenMetadata
      */
     public Collection<InetAddress> getWriteEndpoints(Token token, String table, Collection<InetAddress>
naturalEndpoints)
     {
-        ArrayList<InetAddress> endpoints = new ArrayList<InetAddress>();
-        Iterables.addAll(endpoints, Iterables.concat(naturalEndpoints, pendingEndpointsFor(token,
table)));
-        return endpoints;
+        return ImmutableList.copyOf(Iterables.concat(naturalEndpoints, pendingEndpointsFor(token,
table)));
     }
 
     /** @return an endpoint to token multimap representation of tokenToEndpointMap (a copy)
*/


Mime
View raw message