cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject svn commit: r1152876 - /cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/service/StorageService.java
Date Mon, 01 Aug 2011 17:54:50 GMT
Author: brandonwilliams
Date: Mon Aug  1 17:54:50 2011
New Revision: 1152876

URL: http://svn.apache.org/viewvc?rev=1152876&view=rev
Log:
Don't sample the system table keys when choosing a bootstrap token.
Patch by brandonwilliams, reviewed by jbellis for CASSANDRA-2825

Modified:
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/service/StorageService.java

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/service/StorageService.java?rev=1152876&r1=1152875&r2=1152876&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/service/StorageService.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/service/StorageService.java
Mon Aug  1 17:54:50 2011
@@ -1759,6 +1759,8 @@ public class StorageService implements I
         List<DecoratedKey> keys = new ArrayList<DecoratedKey>();
         for (ColumnFamilyStore cfs : ColumnFamilyStore.all())
         {
+            if (cfs.table.name.equals(Table.SYSTEM_TABLE))
+                continue;
             for (DecoratedKey key : cfs.allKeySamples())
             {
                 if (range.contains(key.token))
@@ -1767,9 +1769,19 @@ public class StorageService implements I
         }
         FBUtilities.sortSampledKeys(keys, range);
 
-        Token token = keys.size() < 3
-                    ? partitioner.midpoint(range.left, range.right)
-                    : keys.get(keys.size() / 2).token;
+        Token token;
+        if (keys.size() < 3)
+        {
+            token = partitioner.midpoint(range.left, range.right);
+            logger_.debug("Used midpoint to assign token " + token);
+        }
+        else
+        {
+            token = keys.get(keys.size() / 2).token;
+            logger_.debug("Used key sample of size " + keys.size() + " to assign token "
+ token);
+        }
+        if (tokenMetadata_.getEndpoint(token) != null && tokenMetadata_.isMember(tokenMetadata_.getEndpoint(token)))
+            throw new RuntimeException("Chose token " + token + " which is already in use
by " + tokenMetadata_.getEndpoint(token) + " -- specify one manually with initial_token");
         // Hack to prevent giving nodes tokens with DELIMITER_STR in them (which is fine
in a row key/token)
         if (token instanceof StringToken)
         {



Mime
View raw message