Skip to content

Commit ade3af6

Browse files
noslowerdnasteveloughran
authored andcommitted
HADOOP-16147. Allow CopyListing sequence file keys and values to be more easily customized.
Author: Andrew Olson (cherry picked from commit faba359)
1 parent 397b63a commit ade3af6

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/CopyListing.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,29 @@ protected Credentials getCredentials() {
248248
return credentials;
249249
}
250250

251+
/**
252+
* Returns the key for an entry in the copy listing sequence file.
253+
* @param sourcePathRoot the root source path for determining the relative
254+
* target path
255+
* @param fileStatus the copy listing file status
256+
* @return the key for the sequence file entry
257+
*/
258+
protected Text getFileListingKey(Path sourcePathRoot,
259+
CopyListingFileStatus fileStatus) {
260+
return new Text(DistCpUtils.getRelativePath(sourcePathRoot,
261+
fileStatus.getPath()));
262+
}
263+
264+
/**
265+
* Returns the value for an entry in the copy listing sequence file.
266+
* @param fileStatus the copy listing file status
267+
* @return the value for the sequence file entry
268+
*/
269+
protected CopyListingFileStatus getFileListingValue(
270+
CopyListingFileStatus fileStatus) {
271+
return fileStatus;
272+
}
273+
251274
/**
252275
* Public Factory method with which the appropriate CopyListing implementation may be retrieved.
253276
* @param configuration The input configuration.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,8 +718,8 @@ private void writeToFileListing(SequenceFile.Writer fileListWriter,
718718
return;
719719
}
720720

721-
fileListWriter.append(new Text(DistCpUtils.getRelativePath(sourcePathRoot,
722-
fileStatus.getPath())), fileStatus);
721+
fileListWriter.append(getFileListingKey(sourcePathRoot, fileStatus),
722+
getFileListingValue(fileStatus));
723723
fileListWriter.sync();
724724

725725
if (!fileStatus.isDirectory()) {

0 commit comments

Comments
 (0)