cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject cassandra git commit: Decommissioned nodes will not rejoin the cluster.
Date Tue, 19 May 2015 15:47:07 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 77f0d99fa -> a53a6ceda


Decommissioned nodes will not rejoin the cluster.

Patch by brandonwilliams, reviewed by carlyeks for CASSANDRA-8801


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

Branch: refs/heads/trunk
Commit: a53a6cedac2cae622937fe8118d2cf20abcf247a
Parents: 77f0d99
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Tue May 19 10:46:14 2015 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Tue May 19 10:46:14 2015 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  3 +++
 .../org/apache/cassandra/db/SystemKeyspace.java |  8 ++++++-
 .../cassandra/service/StorageService.java       | 23 +++++++++++++++-----
 3 files changed, 28 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a53a6ced/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 0ce90ce..127b7bf 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,6 @@
+3.0:
+ * Decommissioned nodes will not rejoin the cluster (CASSANDRA-8801)
+
 2.2
 Merged from 2.1:
  * Use configured gcgs in anticompaction (CASSANDRA-9397)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a53a6ced/src/java/org/apache/cassandra/db/SystemKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SystemKeyspace.java b/src/java/org/apache/cassandra/db/SystemKeyspace.java
index 6e754a4..baf6446 100644
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@ -281,7 +281,8 @@ public final class SystemKeyspace
     {
         NEEDS_BOOTSTRAP,
         COMPLETED,
-        IN_PROGRESS
+        IN_PROGRESS,
+        DECOMMISSIONED
     }
 
     private static DecoratedKey decorate(ByteBuffer key)
@@ -811,6 +812,11 @@ public final class SystemKeyspace
         return getBootstrapState() == BootstrapState.IN_PROGRESS;
     }
 
+    public static boolean wasDecommissioned()
+    {
+        return getBootstrapState() == BootstrapState.DECOMMISSIONED;
+    }
+
     public static void setBootstrapState(BootstrapState state)
     {
         String req = "INSERT INTO system.%s (key, bootstrapped) VALUES ('%s', ?)";

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a53a6ced/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 bfbf1a8..d547680 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -22,6 +22,7 @@ import static java.nio.charset.StandardCharsets.ISO_8859_1;
 import java.io.ByteArrayInputStream;
 import java.io.DataInputStream;
 import java.io.File;
+import java.io.IOError;
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.net.InetAddress;
@@ -64,10 +65,7 @@ import org.apache.cassandra.auth.AuthMigrationListener;
 import org.apache.cassandra.concurrent.ScheduledExecutors;
 import org.apache.cassandra.concurrent.Stage;
 import org.apache.cassandra.concurrent.StageManager;
-import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.config.KSMetaData;
-import org.apache.cassandra.config.Schema;
+import org.apache.cassandra.config.*;
 import org.apache.cassandra.db.BatchlogManager;
 import org.apache.cassandra.db.ColumnFamilyStore;
 import org.apache.cassandra.db.CounterMutationVerbHandler;
@@ -733,6 +731,16 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
         {
             Map<ApplicationState, VersionedValue> appStates = new HashMap<>();
 
+            if (SystemKeyspace.wasDecommissioned())
+            {
+                if (Boolean.getBoolean("cassandra.override_decommission"))
+                {
+                    logger.warn("This node was decommissioned, but overriding by operator
request.");
+                    SystemKeyspace.setBootstrapState(SystemKeyspace.BootstrapState.COMPLETED);
+                }
+                else
+                    throw new ConfigurationException("This node was decommissioned and will
not rejoin the ring unless cassandra.override_decommission=true has been set, or all existing
data is removed and the node is bootstrapped again");
+            }
             if (replacing && !(Boolean.parseBoolean(System.getProperty("cassandra.join_ring",
"true"))))
                 throw new ConfigurationException("Cannot set both join_ring=false and attempt
to replace a node");
             if (DatabaseDescriptor.getReplaceTokens().size() > 0 || DatabaseDescriptor.getReplaceNode()
!= null)
@@ -3288,8 +3296,13 @@ public class StorageService extends NotificationBroadcasterSupport
implements IE
             {
                 shutdownClientServers();
                 Gossiper.instance.stop();
-                MessagingService.instance().shutdown();
+                try {
+                    MessagingService.instance().shutdown();
+                } catch (IOError ioe) {
+                    logger.info("failed to shutdown message service: {}", ioe);
+                }
                 StageManager.shutdownNow();
+                SystemKeyspace.setBootstrapState(SystemKeyspace.BootstrapState.DECOMMISSIONED);
                 setMode(Mode.DECOMMISSIONED, true);
                 // let op be responsible for killing the process
             }


Mime
View raw message