|
@@ -234,7 +234,11 @@ public class SimpleCopyListing extends CopyListing {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Write a single file/directory to the sequence file.
|
|
* Write a single file/directory to the sequence file.
|
|
- * @throws IOException
|
|
|
|
|
|
+ * @param fileListWriter the list for holding processed results
|
|
|
|
+ * @param sourceRoot the source dir path for copyListing
|
|
|
|
+ * @param path add the given path to the file list.
|
|
|
|
+ * @param context The DistCp context with associated input options
|
|
|
|
+ * @throws IOException if it fails to add it to the fileList
|
|
*/
|
|
*/
|
|
private void addToFileListing(SequenceFile.Writer fileListWriter,
|
|
private void addToFileListing(SequenceFile.Writer fileListWriter,
|
|
Path sourceRoot, Path path, DistCpContext context) throws IOException {
|
|
Path sourceRoot, Path path, DistCpContext context) throws IOException {
|
|
@@ -265,7 +269,7 @@ public class SimpleCopyListing extends CopyListing {
|
|
* into the list.
|
|
* into the list.
|
|
* @param fileListWriter the list for holding processed results
|
|
* @param fileListWriter the list for holding processed results
|
|
* @param context The DistCp context with associated input options
|
|
* @param context The DistCp context with associated input options
|
|
- * @throws IOException
|
|
|
|
|
|
+ * @throws IOException if unable to construct the fileList
|
|
*/
|
|
*/
|
|
@VisibleForTesting
|
|
@VisibleForTesting
|
|
protected void doBuildListingWithSnapshotDiff(
|
|
protected void doBuildListingWithSnapshotDiff(
|
|
@@ -274,6 +278,8 @@ public class SimpleCopyListing extends CopyListing {
|
|
ArrayList<DiffInfo> diffList = distCpSync.prepareDiffListForCopyListing();
|
|
ArrayList<DiffInfo> diffList = distCpSync.prepareDiffListForCopyListing();
|
|
Path sourceRoot = context.getSourcePaths().get(0);
|
|
Path sourceRoot = context.getSourcePaths().get(0);
|
|
FileSystem sourceFS = sourceRoot.getFileSystem(getConf());
|
|
FileSystem sourceFS = sourceRoot.getFileSystem(getConf());
|
|
|
|
+ boolean traverseDirectory = getConf().getBoolean(
|
|
|
|
+ DistCpConstants.CONF_LABEL_DIFF_COPY_LISTING_TRAVERSE_DIRECTORY, true);
|
|
|
|
|
|
try {
|
|
try {
|
|
List<FileStatusInfo> fileStatuses = Lists.newArrayList();
|
|
List<FileStatusInfo> fileStatuses = Lists.newArrayList();
|
|
@@ -285,25 +291,8 @@ public class SimpleCopyListing extends CopyListing {
|
|
addToFileListing(fileListWriter,
|
|
addToFileListing(fileListWriter,
|
|
sourceRoot, diff.getTarget(), context);
|
|
sourceRoot, diff.getTarget(), context);
|
|
} else if (diff.getType() == SnapshotDiffReport.DiffType.CREATE) {
|
|
} else if (diff.getType() == SnapshotDiffReport.DiffType.CREATE) {
|
|
- addToFileListing(fileListWriter,
|
|
|
|
- sourceRoot, diff.getTarget(), context);
|
|
|
|
-
|
|
|
|
- FileStatus sourceStatus = sourceFS.getFileStatus(diff.getTarget());
|
|
|
|
- if (sourceStatus.isDirectory()) {
|
|
|
|
- LOG.debug("Adding source dir for traverse: {}",
|
|
|
|
- sourceStatus.getPath());
|
|
|
|
-
|
|
|
|
- HashSet<String> excludeList =
|
|
|
|
- distCpSync.getTraverseExcludeList(diff.getSource(),
|
|
|
|
- context.getSourcePaths().get(0));
|
|
|
|
-
|
|
|
|
- ArrayList<FileStatus> sourceDirs = new ArrayList<>();
|
|
|
|
- sourceDirs.add(sourceStatus);
|
|
|
|
-
|
|
|
|
- new TraverseDirectory(fileListWriter, sourceFS, sourceDirs,
|
|
|
|
- sourceRoot, context, excludeList, fileStatuses)
|
|
|
|
- .traverseDirectory();
|
|
|
|
- }
|
|
|
|
|
|
+ addCreateDiffsToFileListing(fileListWriter, context, sourceRoot,
|
|
|
|
+ sourceFS, fileStatuses, diff, traverseDirectory);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (randomizeFileListing) {
|
|
if (randomizeFileListing) {
|
|
@@ -316,6 +305,43 @@ public class SimpleCopyListing extends CopyListing {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Handle create Diffs and add to the copyList.
|
|
|
|
+ * If the path is a directory, iterate it recursively and add the paths
|
|
|
|
+ * to the result copyList.
|
|
|
|
+ *
|
|
|
|
+ * @param fileListWriter the list for holding processed results
|
|
|
|
+ * @param context The DistCp context with associated input options
|
|
|
|
+ * @param sourceRoot The rootDir of the source snapshot
|
|
|
|
+ * @param sourceFS the source Filesystem
|
|
|
|
+ * @param fileStatuses store the result fileStatuses to add to the copyList
|
|
|
|
+ * @param diff the SnapshotDiff report
|
|
|
|
+ * @param traverseDirectory traverse directory recursively and add paths to the copyList
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ private void addCreateDiffsToFileListing(SequenceFile.Writer fileListWriter,
|
|
|
|
+ DistCpContext context, Path sourceRoot, FileSystem sourceFS,
|
|
|
|
+ List<FileStatusInfo> fileStatuses, DiffInfo diff, boolean traverseDirectory) throws IOException {
|
|
|
|
+ addToFileListing(fileListWriter, sourceRoot, diff.getTarget(), context);
|
|
|
|
+
|
|
|
|
+ if (traverseDirectory) {
|
|
|
|
+ FileStatus sourceStatus = sourceFS.getFileStatus(diff.getTarget());
|
|
|
|
+ if (sourceStatus.isDirectory()) {
|
|
|
|
+ LOG.debug("Adding source dir for traverse: {}", sourceStatus.getPath());
|
|
|
|
+
|
|
|
|
+ HashSet<String> excludeList =
|
|
|
|
+ distCpSync.getTraverseExcludeList(diff.getSource(),
|
|
|
|
+ context.getSourcePaths().get(0));
|
|
|
|
+
|
|
|
|
+ ArrayList<FileStatus> sourceDirs = new ArrayList<>();
|
|
|
|
+ sourceDirs.add(sourceStatus);
|
|
|
|
+
|
|
|
|
+ new TraverseDirectory(fileListWriter, sourceFS, sourceDirs, sourceRoot,
|
|
|
|
+ context, excludeList, fileStatuses).traverseDirectory();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Collect the list of
|
|
* Collect the list of
|
|
* {@literal <sourceRelativePath, sourceFileStatus>}
|
|
* {@literal <sourceRelativePath, sourceFileStatus>}
|
|
@@ -332,7 +358,7 @@ public class SimpleCopyListing extends CopyListing {
|
|
* computed.
|
|
* computed.
|
|
* @param fileListWriter
|
|
* @param fileListWriter
|
|
* @param context The distcp context with associated input options
|
|
* @param context The distcp context with associated input options
|
|
- * @throws IOException
|
|
|
|
|
|
+ * @throws IOException if unable to construct the fileList
|
|
*/
|
|
*/
|
|
@VisibleForTesting
|
|
@VisibleForTesting
|
|
protected void doBuildListing(SequenceFile.Writer fileListWriter,
|
|
protected void doBuildListing(SequenceFile.Writer fileListWriter,
|