From da9aa9c90964a60bef320e8786f3f767ca3e443d Mon Sep 17 00:00:00 2001 From: prabhujoseph Date: Thu, 5 Dec 2019 12:32:55 +0530 Subject: [PATCH] MAPREDUCE-7250. FrameworkUploader skip replication check if timeout is 0. Contributed by Peter Bacsko. --- .../mapred/uploader/FrameworkUploader.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-uploader/src/main/java/org/apache/hadoop/mapred/uploader/FrameworkUploader.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-uploader/src/main/java/org/apache/hadoop/mapred/uploader/FrameworkUploader.java index 6f914f742c1..3dea023ea7b 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-uploader/src/main/java/org/apache/hadoop/mapred/uploader/FrameworkUploader.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-uploader/src/main/java/org/apache/hadoop/mapred/uploader/FrameworkUploader.java @@ -298,20 +298,24 @@ public class FrameworkUploader implements Runnable { fileSystem.setReplication(targetPath, finalReplication); LOG.info("Set replication to " + finalReplication + " for path: " + targetPath); - long startTime = System.currentTimeMillis(); - long endTime = startTime; - long currentReplication = 0; - while(endTime - startTime < timeout * 1000 && - currentReplication < acceptableReplication) { - Thread.sleep(1000); - endTime = System.currentTimeMillis(); - currentReplication = getSmallestReplicatedBlockCount(); - } - if (endTime - startTime >= timeout * 1000) { - LOG.error(String.format( - "Timed out after %d seconds while waiting for acceptable" + - " replication of %d (current replication is %d)", - timeout, acceptableReplication, currentReplication)); + if (timeout == 0) { + LOG.info("Timeout is set to 0. Skipping replication check."); + } else { + long startTime = System.currentTimeMillis(); + long endTime = startTime; + long currentReplication = 0; + while(endTime - startTime < timeout * 1000 && + currentReplication < acceptableReplication) { + Thread.sleep(1000); + endTime = System.currentTimeMillis(); + currentReplication = getSmallestReplicatedBlockCount(); + } + if (endTime - startTime >= timeout * 1000) { + LOG.error(String.format( + "Timed out after %d seconds while waiting for acceptable" + + " replication of %d (current replication is %d)", + timeout, acceptableReplication, currentReplication)); + } } } else { LOG.info("Cannot set replication to " +