cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r967183 - /cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java
Date Fri, 23 Jul 2010 18:03:13 GMT
Author: jbellis
Date: Fri Jul 23 18:03:13 2010
New Revision: 967183

URL: http://svn.apache.org/viewvc?rev=967183&view=rev
Log:
Double flush AE_SERVICE_STAGE to ensure that tasks triggered by existing tasks are cleared.
 patch by Stu Hood; reviewed by jbellis for CASSANDRA-1028

Modified:
    cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java

Modified: cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java?rev=967183&r1=967182&r2=967183&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java Fri
Jul 23 18:03:13 2010
@@ -23,6 +23,7 @@ import java.util.*;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.ThreadPoolExecutor;
 
 import org.junit.After;
 import org.junit.Before;
@@ -90,11 +91,7 @@ public class AntiEntropyServiceTest exte
     @After
     public void teardown() throws Exception
     {
-        // block for AES to clear before we teardown the token metadata for the next test.
-        StageManager.getStage(StageManager.AE_SERVICE_STAGE).submit(new Runnable()
-        {
-            public void run() { /* no-op */ }
-        }).get();
+        flushAES();
     }
 
     @Test
@@ -130,7 +127,7 @@ public class AntiEntropyServiceTest exte
         assert null != validator.tree.hash(new Range(min, min));
 
         // wait for queued operations to be flushed
-        flushAES().get(5000, TimeUnit.MILLISECONDS);
+        flushAES();
     }
 
     @Test
@@ -242,14 +239,20 @@ public class AntiEntropyServiceTest exte
         return endpoints;
     }
 
-    Future<Object> flushAES()
+    void flushAES() throws Exception
     {
-        return StageManager.getStage(StageManager.AE_SERVICE_STAGE).submit(new Callable<Object>()
+        final ThreadPoolExecutor stage = StageManager.getStage(StageManager.AE_SERVICE_STAGE);
+        final Callable noop = new Callable<Object>()
         {
             public Boolean call()
             {
                 return true;
             }
-        });
+        };
+        
+        // send two tasks through the stage: one to follow existing tasks and a second to
follow tasks created by
+        // those existing tasks: tasks won't recursively create more tasks
+        stage.submit(noop).get(5000, TimeUnit.MILLISECONDS);
+        stage.submit(noop).get(5000, TimeUnit.MILLISECONDS);
     }
 }



Mime
View raw message