From 57cb43be50c81daad8da34d33a45f396d9c1c35b Mon Sep 17 00:00:00 2001 From: Jing Zhao Date: Mon, 8 Dec 2014 11:08:17 -0800 Subject: [PATCH] HADOOP-11354. ThrottledInputStream doesn't perform effective throttling. Contributed by Ted Yu. --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../org/apache/hadoop/tools/util/ThrottledInputStream.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 616842fa5ff..d4962766bed 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -516,6 +516,9 @@ Release 2.7.0 - UNRELEASED HADOOP-11343. Overflow is not properly handled in caclulating final iv for AES CTR. (Jerry Chen via wang) + HADOOP-11354. ThrottledInputStream doesn't perform effective throttling. + (Ted Yu via jing9) + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES diff --git a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/util/ThrottledInputStream.java b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/util/ThrottledInputStream.java index f6fe11847a2..d08a3012e27 100644 --- a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/util/ThrottledInputStream.java +++ b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/util/ThrottledInputStream.java @@ -115,7 +115,7 @@ public class ThrottledInputStream extends InputStream { } private void throttle() throws IOException { - if (getBytesPerSec() > maxBytesPerSec) { + while (getBytesPerSec() > maxBytesPerSec) { try { Thread.sleep(SLEEP_DURATION_MS); totalSleepTime += SLEEP_DURATION_MS;