cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r883854 - /incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
Date Tue, 24 Nov 2009 20:27:03 GMT
Author: jbellis
Date: Tue Nov 24 20:27:02 2009
New Revision: 883854

URL: http://svn.apache.org/viewvc?rev=883854&view=rev
Log:
Moved leaving ring code to a separate helper function and call it right away if rangesMM is
empty.  patch by Jaakko Laine; reviewed by jbellis for CASSANDRA-573

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

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=883854&r1=883853&r2=883854&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Tue
Nov 24 20:27:02 2009
@@ -968,11 +968,39 @@
         unbootstrap(finishLeaving);
     }
 
+    private void leaveRing()
+    {
+        SystemTable.setBootstrapped(false);
+        tokenMetadata_.removeEndpoint(FBUtilities.getLocalAddress());
+        replicationStrategy_.removeObsoletePendingRanges();
+
+        if (logger_.isDebugEnabled())
+            logger_.debug("");
+        Gossiper.instance().addApplicationState(STATE_LEFT, new ApplicationState(getLocalToken().toString()));
+        try
+        {
+            Thread.sleep(2 * Gossiper.intervalInMillis_);
+        }
+        catch (InterruptedException e)
+        {
+            throw new AssertionError(e);
+        }
+    }
+
     private void unbootstrap(final Runnable onFinish)
     {
         Multimap<Range, InetAddress> rangesMM = getChangedRangesForLeaving(FBUtilities.getLocalAddress());
         if (logger_.isDebugEnabled())
             logger_.debug("Ranges needing transfer are [" + StringUtils.join(rangesMM.keySet(),
",") + "]");
+
+        if (rangesMM.isEmpty())
+        {
+            // nothing needs transfer, so leave immediately.  this can happen when replication
factor == number of nodes.
+            leaveRing();
+            onFinish.run();
+            return;
+        }
+
         final Set<Map.Entry<Range, InetAddress>> pending = new HashSet<Map.Entry<Range,
InetAddress>>(rangesMM.entries());
         for (final Map.Entry<Range, InetAddress> entry : rangesMM.entries())
         {
@@ -985,22 +1013,7 @@
                     pending.remove(entry);
                     if (pending.isEmpty())
                     {
-                        SystemTable.setBootstrapped(false);
-                        tokenMetadata_.removeEndpoint(FBUtilities.getLocalAddress());
-                        replicationStrategy_.removeObsoletePendingRanges();
-
-                        if (logger_.isDebugEnabled())
-                            logger_.debug("");
-                        Gossiper.instance().addApplicationState(STATE_LEFT, new ApplicationState(getLocalToken().toString()));
-                        try
-                        {
-                            Thread.sleep(2 * Gossiper.intervalInMillis_);
-                        }
-                        catch (InterruptedException e)
-                        {
-                            throw new AssertionError(e);
-                        }
-
+                        leaveRing();
                         onFinish.run();
                     }
                 }



Mime
View raw message