cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r998722 - /cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
Date Sun, 19 Sep 2010 20:11:06 GMT
Author: jbellis
Date: Sun Sep 19 20:11:06 2010
New Revision: 998722

URL: http://svn.apache.org/viewvc?rev=998722&view=rev
Log:
improve assert for RF <= generated endpoint count.  patch by jbellis for CASSANDRA-1412

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

Modified: cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java?rev=998722&r1=998721&r2=998722&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
Sun Sep 19 20:11:06 2010
@@ -40,6 +40,7 @@ import org.apache.cassandra.dht.Token;
 import org.apache.cassandra.gms.FailureDetector;
 import org.apache.cassandra.thrift.ConsistencyLevel;
 import org.apache.cassandra.utils.FBUtilities;
+import org.apache.hadoop.util.StringUtils;
 import org.cliffc.high_scale_lib.NonBlockingHashMap;
 
 /**
@@ -76,7 +77,6 @@ public abstract class AbstractReplicatio
      */
     public ArrayList<InetAddress> getNaturalEndpoints(Token searchToken) throws IllegalStateException
     {
-        int replicas = getReplicationFactor();
         Token keyToken = TokenMetadata.firstToken(tokenMetadata.sortedTokens(), searchToken);
         ArrayList<InetAddress> endpoints = snitch.getCachedEndpoints(keyToken);
         if (endpoints == null)
@@ -85,11 +85,12 @@ public abstract class AbstractReplicatio
             keyToken = TokenMetadata.firstToken(tokenMetadataClone.sortedTokens(), searchToken);
             endpoints = new ArrayList<InetAddress>(calculateNaturalEndpoints(searchToken,
tokenMetadataClone));
             snitch.cacheEndpoint(keyToken, endpoints);
+            // calculateNaturalEndpoints should have checked this already, this is a safety
+            assert getReplicationFactor() <= endpoints.size() : String.format("endpoints
%s generated for RF of %s",
+                                                                              Arrays.toString(endpoints.toArray()),
+                                                                              getReplicationFactor());
         }
 
-        // calculateNaturalEndpoints should have checked this already, this is a safety
-        assert replicas <= endpoints.size();
-
         return new ArrayList<InetAddress>(endpoints);
     }
 



Mime
View raw message