HADOOP-10473. TestCallQueueManager should interrupt before counting calls.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1586030 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
58d49cecd5
commit
f13a0fd2ad
@ -378,6 +378,9 @@ Release 2.4.1 - UNRELEASED
|
|||||||
HADOOP-10456. Bug in Configuration.java exposed by Spark
|
HADOOP-10456. Bug in Configuration.java exposed by Spark
|
||||||
(ConcurrentModificationException). (Nishkam Ravi via cnauroth)
|
(ConcurrentModificationException). (Nishkam Ravi via cnauroth)
|
||||||
|
|
||||||
|
HADOOP-10473. TestCallQueueManager should interrupt before counting calls.
|
||||||
|
(szetszwo)
|
||||||
|
|
||||||
Release 2.4.0 - 2014-04-07
|
Release 2.4.0 - 2014-04-07
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package org.apache.hadoop.ipc;
|
package org.apache.hadoop.ipc;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -49,7 +48,7 @@ public class Putter implements Runnable {
|
|||||||
public volatile int callsAdded = 0; // How many calls we added, accurate unless interrupted
|
public volatile int callsAdded = 0; // How many calls we added, accurate unless interrupted
|
||||||
private final int maxCalls;
|
private final int maxCalls;
|
||||||
|
|
||||||
private boolean isRunning = true;
|
private volatile boolean isRunning = true;
|
||||||
|
|
||||||
public Putter(CallQueueManager<FakeCall> aCq, int maxCalls, int tag) {
|
public Putter(CallQueueManager<FakeCall> aCq, int maxCalls, int tag) {
|
||||||
this.maxCalls = maxCalls;
|
this.maxCalls = maxCalls;
|
||||||
@ -201,16 +200,22 @@ public void testSwapUnderContention() throws InterruptedException {
|
|||||||
|
|
||||||
// Ensure no calls were dropped
|
// Ensure no calls were dropped
|
||||||
long totalCallsCreated = 0;
|
long totalCallsCreated = 0;
|
||||||
long totalCallsConsumed = 0;
|
|
||||||
|
|
||||||
for (Putter p : producers) {
|
for (Putter p : producers) {
|
||||||
totalCallsCreated += p.callsAdded;
|
|
||||||
threads.get(p).interrupt();
|
threads.get(p).interrupt();
|
||||||
}
|
}
|
||||||
|
for (Putter p : producers) {
|
||||||
|
threads.get(p).join();
|
||||||
|
totalCallsCreated += p.callsAdded;
|
||||||
|
}
|
||||||
|
|
||||||
|
long totalCallsConsumed = 0;
|
||||||
for (Taker t : consumers) {
|
for (Taker t : consumers) {
|
||||||
totalCallsConsumed += t.callsTaken;
|
|
||||||
threads.get(t).interrupt();
|
threads.get(t).interrupt();
|
||||||
}
|
}
|
||||||
|
for (Taker t : consumers) {
|
||||||
|
threads.get(t).join();
|
||||||
|
totalCallsConsumed += t.callsTaken;
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals(totalCallsConsumed, totalCallsCreated);
|
assertEquals(totalCallsConsumed, totalCallsCreated);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user