cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1021807 - /cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
Date Tue, 12 Oct 2010 15:51:46 GMT
Author: jbellis
Date: Tue Oct 12 15:51:46 2010
New Revision: 1021807

URL: http://svn.apache.org/viewvc?rev=1021807&view=rev
Log:
clean up, mostly removal of unnecessary Latch.  patch by jbellis

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

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=1021807&r1=1021806&r2=1021807&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Tue Oct 12 15:51:46
2010
@@ -171,7 +171,6 @@ public class StorageService implements I
 
     private Set<InetAddress> replicatingNodes;
     private InetAddress removingNode;
-    private CountDownLatch replicateLatch;
 
     /* Are we starting this node in bootstrap mode? */
     private boolean isBootstrapMode;
@@ -754,7 +753,7 @@ public class StorageService implements I
      * Handle node being actively removed from the ring.
      *
      * @param endpoint node
-     * @param moveValue (token to notify of removal)<Delimiter>(token to remove)
+     * @param pieces (token to notify of removal)(token to remove)(unused)(unused)
      */
     private void handleStateRemoving(InetAddress endpoint, String[] pieces)
     {
@@ -1707,10 +1706,7 @@ public class StorageService implements I
      */
     public void finishRemoval()
     {
-        while (replicateLatch != null && replicateLatch.getCount() > 0)
-        {
-            replicateLatch.countDown();
-        }
+        replicatingNodes.clear();
     }
 
     /**
@@ -1738,7 +1734,7 @@ public class StorageService implements I
         if (tokenMetadata_.isLeaving(endpoint)) 
             throw new UnsupportedOperationException("Node " + endpoint + " is already being
removed.");
 
-        if (this.replicatingNodes != null || replicateLatch != null)
+        if (replicatingNodes != null)
             throw new UnsupportedOperationException("This node is already processing a removal.
Wait for it to complete.");
 
         // Find the endpoints that are going to become responsible for data
@@ -1757,7 +1753,6 @@ public class StorageService implements I
                     logger_.warn("Endpoint " + ep + " is down and will not receive data for
re-replication of " + endpoint);
             }
         }
-        replicateLatch = new CountDownLatch(this.replicatingNodes.size());
         removingNode = endpoint;
 
         tokenMetadata_.addLeavingEndpoint(endpoint);
@@ -1766,15 +1761,20 @@ public class StorageService implements I
         // but indicate the leaving token so that it can be dealt with.
         Gossiper.instance.addLocalApplicationState(ApplicationState.STATUS, valueFactory.removingNonlocal(localToken,
token));
 
+        // kick off streaming commands
         restoreReplicaCount(endpoint, myAddress);
 
-        try
+        // wait for ReplicationFinishedVerbHandler to signal we're done
+        while (!replicatingNodes.isEmpty())
         {
-            replicateLatch.await();
-        }
-        catch (InterruptedException e)
-        {
-            logger_.error("Interrupted while waiting for replication confirmation.");
+            try
+            {
+                Thread.sleep(100);
+            }
+            catch (InterruptedException e)
+            {
+                throw new AssertionError(e);
+            }
         }
 
         Gossiper.instance.removeEndpoint(endpoint);
@@ -1789,15 +1789,14 @@ public class StorageService implements I
         if(!this.replicatingNodes.isEmpty())
             logger_.error("Failed to recieve removal confirmation for " + StringUtils.join(this.replicatingNodes,
","));
 
-        this.replicatingNodes = null;
+        replicatingNodes = null;
         removingNode = null;
-        replicateLatch = null;
     }
 
     public void confirmReplication(InetAddress node)
     {
-        if(replicatingNodes != null && replicatingNodes.remove(node))
-            replicateLatch.countDown();
+        assert replicatingNodes != null;
+        replicatingNodes.remove(node);
     }
 
     public boolean isClientMode()
@@ -1921,7 +1920,7 @@ public class StorageService implements I
                 return migration;
             }
         };
-        Migration migration = null;
+        Migration migration;
         try
         {
             migration = StageManager.getStage(Stage.MIGRATION).submit(call).get();
@@ -2033,14 +2032,6 @@ public class StorageService implements I
     }
     
     // Never ever do this at home. Used by tests.
-    Map<String, AbstractReplicationStrategy> setReplicationStrategyUnsafe(Map<String,
AbstractReplicationStrategy> replacement)
-    {
-        Map<String, AbstractReplicationStrategy> old = replicationStrategies;
-        replicationStrategies = replacement;
-        return old;
-    }
-
-    // Never ever do this at home. Used by tests.
     IPartitioner setPartitionerUnsafe(IPartitioner newPartitioner)
     {
         IPartitioner oldPartitioner = partitioner_;



Mime
View raw message