Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
* Note: The SimpleCopyListing doesn't handle wild-cards in the input-paths.
*/
public class SimpleCopyListing extends CopyListing {
private static final Logger LOG = LoggerFactory.getLogger(SimpleCopyListing.class);
public static final Logger LOG =
LoggerFactory.getLogger(SimpleCopyListing.class);

public static final int DEFAULT_FILE_STATUS_SIZE = 1000;
public static final boolean DEFAULT_RANDOMIZE_FILE_LISTING = true;
Expand Down Expand Up @@ -601,7 +602,7 @@ public WorkReport<FileStatus[]> processItem(
}

private void printStats() {
LOG.info("Paths (files+dirs) cnt = {}; dirCnt = ", totalPaths, totalDirs);
LOG.info("Paths (files+dirs) cnt = {}; dirCnt = {}", totalPaths, totalDirs);
}

private void maybePrintStats() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,15 @@ private Path listTargetFiles(final Configuration conf,
// thread count is picked up from the job
int threads = conf.getInt(DistCpConstants.CONF_LABEL_LISTSTATUS_THREADS,
DistCpConstants.DEFAULT_LISTSTATUS_THREADS);
boolean useIterator =
conf.getBoolean(DistCpConstants.CONF_LABEL_USE_ITERATOR, false);
LOG.info("Scanning destination directory {} with thread count: {}",
targetFinalPath, threads);
DistCpOptions options = new DistCpOptions.Builder(targets, resultNonePath)
.withOverwrite(overwrite)
.withSyncFolder(syncFolder)
.withNumListstatusThreads(threads)
.withUseIterator(useIterator)
.build();
DistCpContext distCpContext = new DistCpContext(options);
distCpContext.setTargetPathExists(targetPathExists);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.apache.hadoop.tools.DistCp;
import org.apache.hadoop.tools.DistCpConstants;
import org.apache.hadoop.tools.DistCpOptions;
import org.apache.hadoop.tools.SimpleCopyListing;
import org.apache.hadoop.tools.mapred.CopyMapper;
import org.apache.hadoop.tools.util.DistCpTestUtils;
import org.apache.hadoop.util.functional.RemoteIterators;
Expand Down Expand Up @@ -628,11 +629,17 @@ public void testDistCpWithIterator() throws Exception {
GenericTestUtils
.createFiles(remoteFS, source, getDepth(), getWidth(), getWidth());

GenericTestUtils.LogCapturer log =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not over-enamoured of this test strategy. As well as being brittle, every use of this is going to complicate our move to Log4J2.

Is there any other way we could do this?

If the distcp test collected the IOStatistics of iteration, then those stores which returned it from iterators (s3a currently, abfs is still WiP) could count it and actually assert on real invocations. HDFS Doesn't do this.

Copy link
Member Author

@ayushtkn ayushtkn Apr 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanx @steveloughran, do you suggest that we should have two options like -useiteratorforsource and -useiteratorfortarget. Do you think in that case we would be able to save out on memory? since the target list is being build as part of CopyCommitter, so even if one takes the normal path, We would get OOM, just when will differ?

Regarding the log stuff, That was the only thing I could think of, to confirm if iterator was used. And during migration to Log4J2, Will moving to something like this will be of any help instead:
https://github.com/apache/hive/blob/master/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java#L285

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • hive code looks great!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, Are you Ok with the other changes? This logger change we can not do now itself in the code, need to do during the migration itself, Was just trying to find a solution to the problem you told, or if there isn't any

GenericTestUtils.LogCapturer.captureLogs(SimpleCopyListing.LOG);

DistCpTestUtils.assertRunDistCp(DistCpConstants.SUCCESS, source.toString(),
dest.toString(), "-useiterator", conf);
dest.toString(), "-useiterator -update -delete", conf);

// Check the target listing was also done using iterator.
Assertions.assertThat(log.getOutput()).contains(
"Building listing using iterator mode for " + dest.toString());

Assertions
.assertThat(RemoteIterators.toList(localFS.listFiles(dest, true)))
Assertions.assertThat(RemoteIterators.toList(localFS.listFiles(dest, true)))
.describedAs("files").hasSize(getTotalFiles());
}

Expand Down