From a287d2fb77d9873b61c6ab24134993d784ae8475 Mon Sep 17 00:00:00 2001 From: Ravi Prakash Date: Fri, 24 Apr 2015 13:39:07 -0700 Subject: [PATCH] HADOOP-11876. Refactor code to make it more readable, minor maybePrintStats bug (Zoran Dimitrijevic via raviprak) --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../org/apache/hadoop/tools/SimpleCopyListing.java | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 80c8a54c5a..826c77e413 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -561,6 +561,9 @@ Release 2.8.0 - UNRELEASED HADOOP-11864. JWTRedirectAuthenticationHandler breaks java8 javadocs. (Larry McCay via stevel) + HADOOP-11876. Refactor code to make it more readable, minor + maybePrintStats bug (Zoran Dimitrijevic via raviprak) + Release 2.7.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/SimpleCopyListing.java b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/SimpleCopyListing.java index b9ba099d8e..4ea1dc9abc 100644 --- a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/SimpleCopyListing.java +++ b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/SimpleCopyListing.java @@ -343,11 +343,12 @@ public WorkReport processItem( } } result = new WorkReport( - fileSystem.listStatus(parent.getPath()), 0, true); + fileSystem.listStatus(parent.getPath()), retry, true); } catch (FileNotFoundException fnf) { LOG.error("FileNotFoundException exception in listStatus: " + fnf.getMessage()); - result = new WorkReport(new FileStatus[0], 0, true, fnf); + result = new WorkReport(new FileStatus[0], retry, true, + fnf); } catch (Exception e) { LOG.error("Exception in listStatus. Will send for retry."); FileStatus[] parentList = new FileStatus[1]; @@ -391,7 +392,6 @@ private void traverseDirectory(SequenceFile.Writer fileListWriter, for (FileStatus status : sourceDirs) { workers.put(new WorkRequest(status, 0)); - maybePrintStats(); } while (workers.hasWork()) { @@ -402,7 +402,7 @@ private void traverseDirectory(SequenceFile.Writer fileListWriter, if (LOG.isDebugEnabled()) { LOG.debug("Recording source-path: " + child.getPath() + " for copy."); } - if (retry == 0) { + if (workResult.getSuccess()) { CopyListingFileStatus childCopyListingStatus = DistCpUtils.toCopyListingFileStatus(sourceFS, child, preserveAcls && child.isDirectory(), @@ -417,7 +417,6 @@ private void traverseDirectory(SequenceFile.Writer fileListWriter, LOG.debug("Traversing into source dir: " + child.getPath()); } workers.put(new WorkRequest(child, retry)); - maybePrintStats(); } } else { LOG.error("Giving up on " + child.getPath() + @@ -472,5 +471,6 @@ private void writeToFileListing(SequenceFile.Writer fileListWriter, totalDirs++; } totalPaths++; + maybePrintStats(); } }