瀏覽代碼

HADOOP-11876. Refactor code to make it more readable, minor maybePrintStats bug (Zoran Dimitrijevic via raviprak)

Ravi Prakash 10 年之前
父節點
當前提交
a287d2fb77

+ 3 - 0
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

+ 5 - 5
hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/SimpleCopyListing.java

@@ -343,11 +343,12 @@ public class SimpleCopyListing extends CopyListing {
           }
         }
         result = new WorkReport<FileStatus[]>(
-            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<FileStatus[]>(new FileStatus[0], 0, true, fnf);
+        result = new WorkReport<FileStatus[]>(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 @@ public class SimpleCopyListing extends CopyListing {
 
     for (FileStatus status : sourceDirs) {
       workers.put(new WorkRequest<FileStatus>(status, 0));
-      maybePrintStats();
     }
 
     while (workers.hasWork()) {
@@ -402,7 +402,7 @@ public class SimpleCopyListing extends CopyListing {
           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 @@ public class SimpleCopyListing extends CopyListing {
                 LOG.debug("Traversing into source dir: " + child.getPath());
               }
               workers.put(new WorkRequest<FileStatus>(child, retry));
-              maybePrintStats();
             }
           } else {
             LOG.error("Giving up on " + child.getPath() +
@@ -472,5 +471,6 @@ public class SimpleCopyListing extends CopyListing {
       totalDirs++;
     }
     totalPaths++;
+    maybePrintStats();
   }
 }