hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1586030 - in /hadoop/common/trunk/hadoop-common-project/hadoop-common: CHANGES.txt src/test/java/org/apache/hadoop/ipc/TestCallQueueManager.java
Date Wed, 09 Apr 2014 16:49:32 GMT
Author: szetszwo
Date: Wed Apr  9 16:49:31 2014
New Revision: 1586030

URL: http://svn.apache.org/r1586030
Log:
HADOOP-10473. TestCallQueueManager should interrupt before counting calls.

Modified:
    hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
    hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestCallQueueManager.java

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1586030&r1=1586029&r2=1586030&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Wed Apr  9 16:49:31
2014
@@ -378,6 +378,9 @@ Release 2.4.1 - UNRELEASED
     HADOOP-10456. Bug in Configuration.java exposed by Spark
     (ConcurrentModificationException).  (Nishkam Ravi via cnauroth)
 
+    HADOOP-10473. TestCallQueueManager should interrupt before counting calls.
+    (szetszwo)
+
 Release 2.4.0 - 2014-04-07 
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestCallQueueManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestCallQueueManager.java?rev=1586030&r1=1586029&r2=1586030&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestCallQueueManager.java
(original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestCallQueueManager.java
Wed Apr  9 16:49:31 2014
@@ -19,7 +19,6 @@
 package org.apache.hadoop.ipc;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -49,7 +48,7 @@ public class TestCallQueueManager {
     public volatile int callsAdded = 0; // How many calls we added, accurate unless interrupted
     private final int maxCalls;
 
-    private boolean isRunning = true;
+    private volatile boolean isRunning = true;
 
     public Putter(CallQueueManager<FakeCall> aCq, int maxCalls, int tag) {
       this.maxCalls = maxCalls;
@@ -201,16 +200,22 @@ public class TestCallQueueManager {
 
     // Ensure no calls were dropped
     long totalCallsCreated = 0;
-    long totalCallsConsumed = 0;
-
     for (Putter p : producers) {
-      totalCallsCreated += p.callsAdded;
       threads.get(p).interrupt();
     }
+    for (Putter p : producers) {
+      threads.get(p).join();
+      totalCallsCreated += p.callsAdded;
+    }
+    
+    long totalCallsConsumed = 0;
     for (Taker t : consumers) {
-      totalCallsConsumed += t.callsTaken;
       threads.get(t).interrupt();
     }
+    for (Taker t : consumers) {
+      threads.get(t).join();
+      totalCallsConsumed += t.callsTaken;
+    }
 
     assertEquals(totalCallsConsumed, totalCallsCreated);
   }



Mime
View raw message