cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [03/10] git commit: Remove ability to change num_tokens once set.
Date Wed, 30 Jul 2014 21:55:40 GMT
Remove ability to change num_tokens once set.

Patch by brandonwilliams, reviewed by thobbs for CASSANDRA-7649


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

Branch: refs/heads/cassandra-2.1
Commit: b40cb0507ccf229e0f5017f865771a1540d38199
Parents: 440d236
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Wed Jul 30 16:53:31 2014 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Wed Jul 30 16:53:31 2014 -0500

----------------------------------------------------------------------
 .../cassandra/service/StorageService.java       | 45 +-------------------
 1 file changed, 2 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b40cb050/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 8a1b3dc..97ae908 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -821,49 +821,8 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
             }
             else
             {
-                // if we were already bootstrapped with 1 token but num_tokens is set higher
in the config,
-                // then we need to migrate to multi-token
-                if (bootstrapTokens.size() == 1 && DatabaseDescriptor.getNumTokens()
> 1)
-                {
-                    // wait for ring info
-                    logger.info("Sleeping for ring delay (" + delay + "ms)");
-                    Uninterruptibles.sleepUninterruptibly(delay, TimeUnit.MILLISECONDS);
-                    logger.info("Calculating new tokens");
-                    // calculate num_tokens tokens evenly spaced in the range (left, right]
-                    Token right = bootstrapTokens.iterator().next();
-                    TokenMetadata clone = tokenMetadata.cloneOnlyTokenMap();
-                    clone.updateNormalToken(right, FBUtilities.getBroadcastAddress());
-                    Token left = clone.getPredecessor(right);
-
-                    // get (num_tokens - 1) tokens spaced evenly, and the last token will
be our current token (right)
-                    for (int tok = 1; tok < DatabaseDescriptor.getNumTokens(); ++tok)
-                    {
-                        Token l = left;
-                        Token r = right;
-                        // iteratively calculate the location of the token using midpoint
-                        // num iterations is number of bits in IEE754 mantissa (including
implicit leading 1)
-                        // we stop early for terminating fractions
-                        // TODO: alternatively we could add an interpolate() method to IPartitioner
-                        double frac = (double)tok / (double)DatabaseDescriptor.getNumTokens();
-                        Token midpoint = getPartitioner().midpoint(l, r);
-                        for (int i = 0; i < 53; ++i)
-                        {
-                            frac *= 2;
-                            if (frac == 1.0) /* not a bug */
-                                break;
-                            else if (frac > 1.0)
-                            {
-                                l = midpoint;
-                                frac -= 1.0;
-                            }
-                            else
-                                r = midpoint;
-                            midpoint = getPartitioner().midpoint(l, r);
-                        }
-                        bootstrapTokens.add(midpoint);
-                    }
-                    logger.info("Split previous range (" + left + ", " + right + "] into
" + bootstrapTokens);
-                }
+                if (bootstrapTokens.size() != DatabaseDescriptor.getNumTokens())
+                    throw new ConfigurationException("Cannot change the number of tokens
from " + bootstrapTokens.size() + " to " + DatabaseDescriptor.getNumTokens());
                 else
                     logger.info("Using saved tokens " + bootstrapTokens);
             }


Mime
View raw message