You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ja...@apache.org on 2015/07/22 15:01:34 UTC

[3/6] cassandra git commit: checkForEndpointCollision fails for legitimate collisions, finalized list of statuses and nits, CASSANDRA-9765

checkForEndpointCollision fails for legitimate collisions, finalized list of statuses and nits, CASSANDRA-9765


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

Branch: refs/heads/cassandra-2.1
Commit: ba9a69ea21b6cf2e70408ba62522a4a58b695e3f
Parents: 54470a2
Author: Stefania Alborghetti <st...@datastax.com>
Authored: Thu Jul 16 10:04:58 2015 +0800
Committer: Stefania Alborghetti <st...@datastax.com>
Committed: Thu Jul 16 10:04:58 2015 +0800

----------------------------------------------------------------------
 src/java/org/apache/cassandra/gms/Gossiper.java | 39 ++++++++------------
 1 file changed, 15 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ba9a69ea/src/java/org/apache/cassandra/gms/Gossiper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/gms/Gossiper.java b/src/java/org/apache/cassandra/gms/Gossiper.java
index 8eecc98..8c36223 100644
--- a/src/java/org/apache/cassandra/gms/Gossiper.java
+++ b/src/java/org/apache/cassandra/gms/Gossiper.java
@@ -703,20 +703,19 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
     public boolean isSafeForBootstrap(InetAddress endpoint)
     {
         EndpointState epState = endpointStateMap.get(endpoint);
-        String state = getApplicationState(epState);
-        logger.info("{} state : {}", endpoint, state);
 
         // if there's no previous state, or the node was previously removed from the cluster, we're good
         if (epState == null || isDeadState(epState))
             return true;
 
-        // these states are not allowed to join the cluster
-        List<String> states = new ArrayList<String>() {{
+        String status = getGossipStatus(epState);
+
+        // these states are not allowed to join the cluster as it would not be safe
+        final List<String> unsafeStatuses = new ArrayList<String>() {{
             add(""); // failed bootstrap but we did start gossiping
-            add(VersionedValue.STATUS_NORMAL); // node is legit in the cluster or was stopped kill -9
-            //add(VersionedValue.STATUS_BOOTSTRAPPING); // failed bootstrap
+            add(VersionedValue.STATUS_NORMAL); // node is legit in the cluster or it was stopped with kill -9
             add(VersionedValue.SHUTDOWN); }}; // node was shutdown
-        return !states.contains(state);
+        return !unsafeStatuses.contains(status);
     }
 
     private void doStatusCheck()
@@ -1039,31 +1038,23 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
 
     public boolean isDeadState(EndpointState epState)
     {
-        String state = getApplicationState(epState);
-        if (state.isEmpty())
+        String status = getGossipStatus(epState);
+        if (status.isEmpty())
             return false;
-        for (String deadstate : DEAD_STATES)
-        {
-            if (state.equals(deadstate))
-                return true;
-        }
-        return false;
+
+        return DEAD_STATES.contains(status);
     }
 
     public boolean isSilentShutdownState(EndpointState epState)
     {
-        String state = getApplicationState(epState);
-        if (state.isEmpty())
+        String status = getGossipStatus(epState);
+        if (status.isEmpty())
             return false;
-        for (String deadstate : SILENT_SHUTDOWN_STATES)
-        {
-            if (state.equals(deadstate))
-                return true;
-        }
-        return false;
+
+        return SILENT_SHUTDOWN_STATES.contains(status);
     }
 
-    private static String getApplicationState(EndpointState epState)
+    private static String getGossipStatus(EndpointState epState)
     {
         if (epState == null || epState.getApplicationState(ApplicationState.STATUS) == null)
             return "";