HDFS-4745. TestDataTransferKeepalive#testSlowReader has race condition that causes sporadic failure. Contributed by Chris Nauroth.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1475623 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e96077aaf4
commit
16ef8dd3a5
@ -588,6 +588,9 @@ Release 2.0.5-beta - UNRELEASED
|
||||
HDFS-4739. NN can miscalculate the number of extra edit log segments to
|
||||
retain. (atm)
|
||||
|
||||
HDFS-4745. TestDataTransferKeepalive#testSlowReader has race condition that
|
||||
causes sporadic failure. (Chris Nauroth via suresh)
|
||||
|
||||
Release 2.0.4-alpha - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
@ -146,7 +146,15 @@ public void testSlowReader() throws Exception {
|
||||
stm.read();
|
||||
assertXceiverCount(1);
|
||||
|
||||
Thread.sleep(WRITE_TIMEOUT + 1000);
|
||||
// Poll for 0 running xceivers. Allow up to 5 seconds for some slack.
|
||||
long totalSleepTime = 0;
|
||||
long sleepTime = WRITE_TIMEOUT + 100;
|
||||
while (getXceiverCountWithoutServer() > 0 && totalSleepTime < 5000) {
|
||||
Thread.sleep(sleepTime);
|
||||
totalSleepTime += sleepTime;
|
||||
sleepTime = 100;
|
||||
}
|
||||
|
||||
// DN should time out in sendChunks, and this should force
|
||||
// the xceiver to exit.
|
||||
assertXceiverCount(0);
|
||||
@ -190,9 +198,7 @@ public void testManyClosedSocketsInCache() throws Exception {
|
||||
}
|
||||
|
||||
private void assertXceiverCount(int expected) {
|
||||
// Subtract 1, since the DataXceiverServer
|
||||
// counts as one
|
||||
int count = dn.getXceiverCount() - 1;
|
||||
int count = getXceiverCountWithoutServer();
|
||||
if (count != expected) {
|
||||
ReflectionUtils.printThreadInfo(
|
||||
new PrintWriter(System.err),
|
||||
@ -201,4 +207,14 @@ private void assertXceiverCount(int expected) {
|
||||
count);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the datanode's xceiver count, but subtracts 1, since the
|
||||
* DataXceiverServer counts as one.
|
||||
*
|
||||
* @return int xceiver count, not including DataXceiverServer
|
||||
*/
|
||||
private int getXceiverCountWithoutServer() {
|
||||
return dn.getXceiverCount() - 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user