cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject git commit: Add nodetool taketoken to relocate vnodes. Patch by brandonwilliams reviewed by jbellis for CASSANDRA-4445
Date Thu, 06 Feb 2014 19:25:15 GMT
Updated Branches:
  refs/heads/trunk ac666706d -> d5c5734c8


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/d5c5734c
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/d5c5734c
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/d5c5734c

Branch: refs/heads/trunk
Commit: d5c5734c89a62869ee0c207306543b7f1e9cdf27
Parents: ac66670
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Thu Feb 6 13:22:57 2014 -0600
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Thu Feb 6 13:22:57 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/service/StorageService.java       |  3 +++
 .../org/apache/cassandra/tools/NodeProbe.java   |  5 ++++
 .../org/apache/cassandra/tools/NodeTool.java    | 25 +++++++++++++++++++-
 4 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/d5c5734c/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6e1b984..86e576c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -29,6 +29,7 @@
  * Add option to use row cache with a given amount of rows (CASSANDRA-5357)
 
 2.0.6
+ * Add nodetool taketoken to relocate vnodes (CASSANDRA-4445)
  * Fix upgradesstables NPE for non-CF-based indexes (CASSANDRA-6645)
  * Expose bulk loading progress over JMX (CASSANDRA-4757)
  * Correctly handle null with IF conditions and TTL (CASSANDRA-6623)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d5c5734c/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 d891a59..4d6e13f 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -3129,6 +3129,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/d5c5734c/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 e44b576..d874ef0 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -487,6 +487,11 @@ public class NodeProbe implements AutoCloseable
         ssProxy.move(newToken);
     }
 
+    public void takeTokens(List<String> tokens) throws IOException
+    {
+        ssProxy.relocate(tokens);
+    }
+
     public void removeNode(String token)
     {
         ssProxy.removeNode(token);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d5c5734c/src/java/org/apache/cassandra/tools/NodeTool.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeTool.java b/src/java/org/apache/cassandra/tools/NodeTool.java
index cc94b35..10e581c 100644
--- a/src/java/org/apache/cassandra/tools/NodeTool.java
+++ b/src/java/org/apache/cassandra/tools/NodeTool.java
@@ -138,7 +138,8 @@ public class NodeTool
                 DisableHandoff.class,
                 Drain.class,
                 TruncateHints.class,
-                TpStats.class
+                TpStats.class,
+                TakeToken.class
         );
 
         Cli<Runnable> parser = Cli.<Runnable>builder("nodetool")
@@ -1360,6 +1361,26 @@ public class NodeTool
         }
     }
 
+    @Command(name = "taketoken", description = "Move the token(s) from the existing owner(s)
to this node.  For vnodes only.  Use \\\\ to escape negative tokens.")
+    public static class TakeToken extends NodeToolCmd
+    {
+        @Arguments(usage = "<token, ...>", description = "Token(s) to take", required
= true)
+        private List<String> tokens = new ArrayList<String>();
+
+        @Override
+        public void execute(NodeProbe probe)
+        {
+            try
+            {
+                probe.takeTokens(tokens);
+            }
+            catch (IOException e)
+            {
+                throw new RuntimeException("Error taking tokens", e);
+            }
+        }
+    }
+
     @Command(name = "join", description = "Join the ring")
     public static class Join extends NodeToolCmd
     {
@@ -1397,6 +1418,8 @@ public class NodeTool
         }
     }
 
+
+
     @Command(name = "pausehandoff", description = "Pause hints delivery process")
     public static class PauseHandoff extends NodeToolCmd
     {


Mime
View raw message