cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [2/3] git commit: Add nodetool taketoken to relocate vnodes. Patch by brandonwilliams reviewed by jbellis for CASSANDRA-4445
Date Thu, 06 Feb 2014 19:13:42 GMT
Add nodetool taketoken to relocate vnodes.
Patch by brandonwilliams reviewed by jbellis for CASSANDRA-4445


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

Branch: refs/heads/trunk
Commit: 5f64af63ae063c055c214d8925098f34f4111474
Parents: 2103646
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Thu Feb 6 13:00:24 2014 -0600
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Thu Feb 6 13:00:24 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                                | 1 +
 src/java/org/apache/cassandra/service/StorageService.java  | 3 +++
 src/java/org/apache/cassandra/tools/NodeCmd.java           | 6 ++++++
 src/java/org/apache/cassandra/tools/NodeProbe.java         | 5 +++++
 src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml | 3 +++
 5 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5f64af63/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index ceb25c3..6e3c2c2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.6
+ * Add nodetool taketoken to relocate vnodes (CASSANDRA-4445)
  * Fix upgradesstables NPE for non-CF-based indexes (CASSANDRA-6645)
  * Improve nodetool cfhistograms formatting (CASSANDRA-6360)
  * Expose bulk loading progress over JMX (CASSANDRA-4757)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5f64af63/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 26846e7..e181c44 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -3098,6 +3098,9 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
             for (String srcT : srcTokens)
             {
                 getPartitioner().getTokenFactory().validate(srcT);
+                Token token = getPartitioner().getTokenFactory().fromString(srcT);
+                if (tokenMetadata.getTokens(tokenMetadata.getEndpoint(token)).size() <
2)
+                    throw new IOException("Cannot relocate " + srcT + "; source node would
have no tokens left");
                 tokens.add(getPartitioner().getTokenFactory().fromString(srcT));
             }
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5f64af63/src/java/org/apache/cassandra/tools/NodeCmd.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeCmd.java b/src/java/org/apache/cassandra/tools/NodeCmd.java
index fd7b69b..f3cd563 100644
--- a/src/java/org/apache/cassandra/tools/NodeCmd.java
+++ b/src/java/org/apache/cassandra/tools/NodeCmd.java
@@ -169,6 +169,7 @@ public class NodeCmd
         STATUSTHRIFT,
         STOP,
         STOPDAEMON,
+        TAKETOKEN,
         TPSTATS,
         TRUNCATEHINTS,
         UPGRADESSTABLES,
@@ -1315,6 +1316,11 @@ public class NodeCmd
                     probe.setTraceProbability(Double.parseDouble(arguments[0]));
                     break;
 
+                case TAKETOKEN:
+                    if (arguments.length < 1) { badUse("Must supply at least one token
to take"); }
+                    probe.takeTokens(arguments);
+                    break;
+
                 case REBUILD :
                     if (arguments.length > 1) { badUse("Too many arguments."); }
                     probe.rebuild(arguments.length == 1 ? arguments[0] : null);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5f64af63/src/java/org/apache/cassandra/tools/NodeProbe.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeProbe.java b/src/java/org/apache/cassandra/tools/NodeProbe.java
index 0fbb12a..ffd6203 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -471,6 +471,11 @@ public class NodeProbe
         ssProxy.move(newToken);
     }
 
+    public void takeTokens(String[] tokens) throws IOException
+    {
+        ssProxy.relocate(Arrays.asList(tokens));
+    }
+
     public void removeNode(String token)
     {
         ssProxy.removeNode(token);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5f64af63/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
----------------------------------------------------------------------
diff --git a/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml b/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
index b28e300..8eacf2f 100644
--- a/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
+++ b/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
@@ -115,6 +115,9 @@ commands:
   - name: move <new token>
     help: |
       Move node on the token ring to a new token. (for negative tokens, use \\ to escape,
Example: move \\-123)
+  - name: taketoken <token, ...>
+    help: |
+      Move the token(s) from the existing owner(s) to this node.  For vnodes only.  Use \\
to escape negative tokens.
   - name: removenode status|force|<ID>
     help: |
       Show status of current node removal, force completion of pending removal or remove
provided ID


Mime
View raw message