HDFS-4745. Merge 1475623 from trunk

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1475625 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2013-04-25 04:32:51 +00:00
parent b392a65e2e
commit 14f658bf38
2 changed files with 23 additions and 4 deletions

View File

@ -209,6 +209,9 @@ Release 2.0.5-beta - UNRELEASED
HDFS-4739. NN can miscalculate the number of extra edit log segments to HDFS-4739. NN can miscalculate the number of extra edit log segments to
retain. (atm) retain. (atm)
HDFS-4745. TestDataTransferKeepalive#testSlowReader has race condition that
causes sporadic failure. (Chris Nauroth via suresh)
Release 2.0.4-alpha - UNRELEASED Release 2.0.4-alpha - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -144,7 +144,15 @@ public class TestDataTransferKeepalive {
stm.read(); stm.read();
assertXceiverCount(1); 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 // DN should time out in sendChunks, and this should force
// the xceiver to exit. // the xceiver to exit.
assertXceiverCount(0); assertXceiverCount(0);
@ -188,9 +196,7 @@ public class TestDataTransferKeepalive {
} }
private void assertXceiverCount(int expected) { private void assertXceiverCount(int expected) {
// Subtract 1, since the DataXceiverServer int count = getXceiverCountWithoutServer();
// counts as one
int count = dn.getXceiverCount() - 1;
if (count != expected) { if (count != expected) {
ReflectionUtils.printThreadInfo( ReflectionUtils.printThreadInfo(
new PrintWriter(System.err), new PrintWriter(System.err),
@ -199,4 +205,14 @@ public class TestDataTransferKeepalive {
count); 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;
}
} }