cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r945912 - /cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterShardStrategy.java
Date Tue, 18 May 2010 21:53:22 GMT
Author: jbellis
Date: Tue May 18 21:53:21 2010
New Revision: 945912

URL: http://svn.apache.org/viewvc?rev=945912&view=rev
Log:
simplify out doneDataCenterIter variable
patch by jbellis; reviewed by Jeremy Hanna for CASSANDRA-1103

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterShardStrategy.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterShardStrategy.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterShardStrategy.java?rev=945912&r1=945911&r2=945912&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterShardStrategy.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterShardStrategy.java Tue
May 18 21:53:21 2010
@@ -135,11 +135,11 @@ public class DatacenterShardStrategy ext
             int replicas = getReplicationFactor(dc, table);
             List<Token> tokens = dcTokens.get(dc);
             boolean bOtherRack = false;
-            boolean doneDataCenterItr;
             // Add the node at the index by default
             Iterator<Token> iter = TokenMetadata.ringIterator(tokens, searchToken);
-            InetAddress primaryHost = metadata.getEndpoint(iter.next());
-            endpoints.add(primaryHost);
+            InetAddress initialDCHost = metadata.getEndpoint(iter.next());
+            assert initialDCHost != null;
+            endpoints.add(initialDCHost);
 
             while (endpoints.size() < replicas && iter.hasNext())
             {
@@ -150,22 +150,18 @@ public class DatacenterShardStrategy ext
                     endpoints.add(endPointOfInterest);
                     continue;
                 }
-                else
-                {
-                    doneDataCenterItr = true;
-                }
 
                 // Now try to find one on a different rack
                 if (!bOtherRack)
                 {
-                    if (!snitch.getRack(primaryHost).equals(snitch.getRack(endPointOfInterest)))
+                    if (!snitch.getRack(initialDCHost).equals(snitch.getRack(endPointOfInterest)))
                     {
                         endpoints.add(metadata.getEndpoint(t));
                         bOtherRack = true;
                     }
                 }
                 // If both already found exit loop.
-                if (doneDataCenterItr && bOtherRack)
+                if (bOtherRack)
                     break;
             }
 



Mime
View raw message