You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2010/10/13 17:56:59 UTC

svn commit: r1022158 - in /cassandra/trunk: CHANGES.txt src/java/org/apache/cassandra/service/StorageService.java

Author: jbellis
Date: Wed Oct 13 15:56:58 2010
New Revision: 1022158

URL: http://svn.apache.org/viewvc?rev=1022158&view=rev
Log:
fix removing tokens from SystemTable on decommission and removetoken.
patch by jbellis; reviewed by Nick Bailey for CASSANDRA-1609

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1022158&r1=1022157&r2=1022158&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Wed Oct 13 15:56:58 2010
@@ -31,6 +31,8 @@ dev
  * remove ConsistencyLevel.ZERO (CASSANDRA-1607)
  * expose in-progress compaction type in jmx (CASSANDRA-1586)
  * removed IClock & related classes from internals (CASSANDRA-1502)
+ * fix removing tokens from SystemTable on decommission and removetoken
+   (CASSANDRA-1609)
 
 
 0.7-beta2

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=1022158&r1=1022157&r2=1022158&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Wed Oct 13 15:56:58 2010
@@ -732,23 +732,10 @@ public class StorageService implements I
         assert pieces.length == 2;
         Token token = getPartitioner().getTokenFactory().fromString(pieces[1]);
 
-        // endpoint itself is leaving
         if (logger_.isDebugEnabled())
             logger_.debug("Node " + endpoint + " state left, token " + token);
 
-        // If the node is member, remove all references to it. If not, call
-        // removeBootstrapToken just in case it is there (very unlikely chain of events)
-        if (tokenMetadata_.isMember(endpoint))
-        {
-            if (!tokenMetadata_.getToken(endpoint).equals(token))
-                logger_.warn("Node " + endpoint + " 'left' token mismatch. Long network partition?");
-            tokenMetadata_.removeEndpoint(endpoint);
-            HintedHandOffManager.deleteHintsForEndPoint(endpoint);
-        }
-
-        // remove token from bootstrap tokens just in case it is still there
-        tokenMetadata_.removeBootstrapToken(token);
-        calculatePendingRanges();
+        excise(token, endpoint);
     }
 
     /**
@@ -771,10 +758,7 @@ public class StorageService implements I
 
         if (VersionedValue.REMOVED_TOKEN.equals(state))
         {
-            Gossiper.instance.removeEndpoint(removeEndpoint);
-            tokenMetadata_.removeEndpoint(removeEndpoint);
-            HintedHandOffManager.deleteHintsForEndPoint(removeEndpoint);
-            tokenMetadata_.removeBootstrapToken(removeToken);
+            excise(removeToken, removeEndpoint);
         }
         else if (VersionedValue.REMOVING_TOKEN.equals(state))
         {
@@ -788,10 +772,19 @@ public class StorageService implements I
             // grab any data we are now responsible for and notify responsible node
             restoreReplicaCount(removeEndpoint, endpoint);
         }
+    }
+
+    private void excise(Token token, InetAddress endpoint)
+    {
+        Gossiper.instance.removeEndpoint(endpoint);
+        tokenMetadata_.removeEndpoint(endpoint);
+        HintedHandOffManager.deleteHintsForEndPoint(endpoint);
+        tokenMetadata_.removeBootstrapToken(token);
+        calculatePendingRanges();
         if (!isClientMode)
         {
-            logger_.info("Removing token " + removeToken + " for " + removeEndpoint);
-            SystemTable.removeToken(removeToken);
+            logger_.info("Removing token " + token + " for " + endpoint);
+            SystemTable.removeToken(token);
         }
     }
 
@@ -1778,13 +1771,9 @@ public class StorageService implements I
             }
         }
 
-        Gossiper.instance.removeEndpoint(endpoint);
-        tokenMetadata_.removeBootstrapToken(token);
-        tokenMetadata_.removeEndpoint(endpoint);
-        HintedHandOffManager.deleteHintsForEndPoint(endpoint);
+        excise(token, endpoint);
 
         // indicate the token has left
-        calculatePendingRanges();
         Gossiper.instance.addLocalApplicationState(ApplicationState.STATUS, valueFactory.removedNonlocal(localToken, token));
 
         replicatingNodes = null;