[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hadoop-commits
Subject:    git commit: HADOOP-11145. TestFairCallQueue fails. Contributed by Akira AJISAKA.
From:       cnauroth () apache ! org
Date:       2014-09-30 15:59:41
Message-ID: 0848f4f394624ede917adc2bd2e606a1 () git ! apache ! org
[Download RAW message or body]

Repository: hadoop
Updated Branches:
  refs/heads/branch-2 781833f55 -> 57b145c3a


HADOOP-11145. TestFairCallQueue fails. Contributed by Akira AJISAKA.

(cherry picked from commit b9158697a4f2d345b681a9b6ed982dae558338bc)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/57b145c3
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/57b145c3
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/57b145c3

Branch: refs/heads/branch-2
Commit: 57b145c3aba9063e230458873440bab11a536e3e
Parents: 781833f
Author: cnauroth <cnauroth@apache.org>
Authored: Tue Sep 30 08:57:05 2014 -0700
Committer: cnauroth <cnauroth@apache.org>
Committed: Tue Sep 30 08:58:39 2014 -0700

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  2 ++
 .../apache/hadoop/ipc/TestFairCallQueue.java    | 23 +++++++++++++++-----
 2 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/57b145c3/hadoop-common-project/hadoop-common/CHANGES.txt
                
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt \
b/hadoop-common-project/hadoop-common/CHANGES.txt index 07227b8..fdc785d 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -560,6 +560,8 @@ Release 2.6.0 - UNRELEASED
     HADOOP-11154. Update BUILDING.txt to state that CMake 3.0 or newer is
     required on Mac. (cnauroth)
 
+    HADOOP-11145. TestFairCallQueue fails. (Akira AJISAKA via cnauroth)
+
 Release 2.5.1 - 2014-09-05
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/57b145c3/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestFairCallQueue.java
                
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestFairCallQueue.java \
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestFairCallQueue.java
 index acbedc5..2694ba3 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestFairCallQueue.java
                
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestFairCallQueue.java
 @@ -29,6 +29,7 @@ import static org.mockito.Mockito.when;
 
 import junit.framework.TestCase;
 
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.BlockingQueue;
 
@@ -243,11 +244,14 @@ public class TestFairCallQueue extends TestCase {
     public final String tag;
     public volatile int callsAdded = 0; // How many calls we added, accurate unless \
interrupted  private final int maxCalls;
+    private final CountDownLatch latch;
 
-    public Putter(BlockingQueue<Schedulable> aCq, int maxCalls, String tag) {
+    public Putter(BlockingQueue<Schedulable> aCq, int maxCalls, String tag,
+                  CountDownLatch latch) {
       this.maxCalls = maxCalls;
       this.cq = aCq;
       this.tag = tag;
+      this.latch = latch;
     }
 
     private String getTag() {
@@ -262,6 +266,7 @@ public class TestFairCallQueue extends TestCase {
         while (callsAdded < maxCalls || maxCalls < 0) {
           cq.put(mockCall(getTag()));
           callsAdded++;
+          latch.countDown();
         }
       } catch (InterruptedException e) {
         return;
@@ -280,14 +285,17 @@ public class TestFairCallQueue extends TestCase {
     public volatile int callsTaken = 0; // total calls taken, accurate if we aren't \
                interrupted
     public volatile Schedulable lastResult = null; // the last thing we took
     private final int maxCalls; // maximum calls to take
+    private final CountDownLatch latch;
 
     private IdentityProvider uip;
 
-    public Taker(BlockingQueue<Schedulable> aCq, int maxCalls, String tag) {
+    public Taker(BlockingQueue<Schedulable> aCq, int maxCalls, String tag,
+                 CountDownLatch latch) {
       this.maxCalls = maxCalls;
       this.cq = aCq;
       this.tag = tag;
       this.uip = new UserIdentityProvider();
+      this.latch = latch;
     }
 
     @Override
@@ -303,6 +311,7 @@ public class TestFairCallQueue extends TestCase {
             cq.put(res);
           } else {
             callsTaken++;
+            latch.countDown();
             lastResult = res;
           }
         }
@@ -316,10 +325,11 @@ public class TestFairCallQueue extends TestCase {
   public void assertCanTake(BlockingQueue<Schedulable> cq, int numberOfTakes,
     int takeAttempts) throws InterruptedException {
 
-    Taker taker = new Taker(cq, takeAttempts, "default");
+    CountDownLatch latch = new CountDownLatch(numberOfTakes);
+    Taker taker = new Taker(cq, takeAttempts, "default", latch);
     Thread t = new Thread(taker);
     t.start();
-    t.join(100);
+    latch.await();
 
     assertEquals(numberOfTakes, taker.callsTaken);
     t.interrupt();
@@ -329,10 +339,11 @@ public class TestFairCallQueue extends TestCase {
   public void assertCanPut(BlockingQueue<Schedulable> cq, int numberOfPuts,
     int putAttempts) throws InterruptedException {
 
-    Putter putter = new Putter(cq, putAttempts, null);
+    CountDownLatch latch = new CountDownLatch(numberOfPuts);
+    Putter putter = new Putter(cq, putAttempts, null, latch);
     Thread t = new Thread(putter);
     t.start();
-    t.join(100);
+    latch.await();
 
     assertEquals(numberOfPuts, putter.callsAdded);
     t.interrupt();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic