Author: jbellis Date: Tue Jul 20 22:03:08 2010 New Revision: 966033 URL: http://svn.apache.org/viewvc?rev=966033&view=rev Log: fix RoundRobinSchedulerTest heisenbug. patch by Nirmal Ranganathan; reviewed by jbellis for CASSANDRA-1279
Modified: cassandra/trunk/src/java/org/apache/cassandra/scheduler/RoundRobinScheduler.java cassandra/trunk/test/unit/org/apache/cassandra/scheduler/RoundRobinSchedulerTest.java Modified: cassandra/trunk/src/java/org/apache/cassandra/scheduler/RoundRobinScheduler.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/scheduler/RoundRobinScheduler.java?rev=966033&r1=966032&r2=966033&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/scheduler/RoundRobinScheduler.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/scheduler/RoundRobinScheduler.java Tue Jul 20 22:03:08 2010 @@ -123,4 +123,9 @@ public class RoundRobinScheduler impleme // another thread created the queue return queue; } + + Semaphore getTaskCount() + { + return taskCount; + } } Modified: cassandra/trunk/test/unit/org/apache/cassandra/scheduler/RoundRobinSchedulerTest.java URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/scheduler/RoundRobinSchedulerTest.java?rev=966033&r1=966032&r2=966033&view=diff ============================================================================== --- cassandra/trunk/test/unit/org/apache/cassandra/scheduler/RoundRobinSchedulerTest.java (original) +++ cassandra/trunk/test/unit/org/apache/cassandra/scheduler/RoundRobinSchedulerTest.java Tue Jul 20 22:03:08 2010 @@ -39,7 +39,7 @@ import org.junit.Test; public class RoundRobinSchedulerTest { ExecutorService executor; - IRequestScheduler scheduler; + RoundRobinScheduler scheduler; AtomicInteger counter = new AtomicInteger(0); static final String KS1 = "TestKeyspace"; static final String KS2 = "DevKeyspace"; @@ -51,7 +51,8 @@ public class RoundRobinSchedulerTest public void setUp() { RequestSchedulerOptions options = new RequestSchedulerOptions(); - options.throttle_limit = 5; + // Block the scheduler from running initially + options.throttle_limit = -1; scheduler = new RoundRobinScheduler(options); SynchronousQueue<Runnable> queue = new SynchronousQueue<Runnable>(); @@ -66,7 +67,9 @@ public class RoundRobinSchedulerTest runKs1(1, 10); runKs2(11, 13); runKs3(14, 15); - + // Release some tasks for the scheduler to run, now that the requests + // are queued in their various buckets, behavior will be more predictable + scheduler.getTaskCount().release(2); try { Thread.sleep(3000);