-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-17122: Preserving Directory Attributes in DistCp with Atomic Copy #2133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
10d0fab
HADOOP-17122: Preserving Directory Attributes in DistCp with Atomic Copy
swaminathan-b 166ec38
HADOOP-17122: Addressing Review Comments for Preserving Directory At…
swaminathan-b f97e6f7
HADOOP-17122: Restoring new line at the end
swaminathan-b c4ad2f7
HADOOP-17122: Removing Whitespace from Added New line
swaminathan-b eeff2e6
HADOOP-17122: Correcting Whitespace checks
swaminathan-b 987a9aa
HADOOP-17122: Correcting Whitespace checks
swaminathan-b File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,8 @@ | |
| import java.util.*; | ||
|
|
||
| import static org.apache.hadoop.fs.contract.ContractTestUtils.*; | ||
| import static org.apache.hadoop.tools.DistCpConstants.CONF_LABEL_TARGET_FINAL_PATH; | ||
| import static org.apache.hadoop.tools.DistCpConstants.CONF_LABEL_TARGET_WORK_PATH; | ||
| import static org.apache.hadoop.tools.util.TestDistCpUtils.*; | ||
|
|
||
| public class TestCopyCommitter { | ||
|
|
@@ -160,10 +162,10 @@ public void testPreserveStatus() throws IOException { | |
| context.setTargetPathExists(false); | ||
|
|
||
| CopyListing listing = new GlobbedCopyListing(conf, CREDENTIALS); | ||
| Path listingFile = new Path("/tmp1/" + String.valueOf(rand.nextLong())); | ||
| Path listingFile = new Path("/tmp1/" + rand.nextLong()); | ||
| listing.buildListing(listingFile, context); | ||
|
|
||
| conf.set(DistCpConstants.CONF_LABEL_TARGET_WORK_PATH, targetBase); | ||
| conf.set(CONF_LABEL_TARGET_FINAL_PATH, targetBase); | ||
|
|
||
| committer.commitJob(jobContext); | ||
| checkDirectoryPermissions(fs, targetBase, sourcePerm); | ||
|
|
@@ -178,6 +180,45 @@ public void testPreserveStatus() throws IOException { | |
| } | ||
|
|
||
| } | ||
|
|
||
| @Test | ||
swamirishi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public void testPreserveStatusWithAtomicCommit() throws IOException { | ||
| TaskAttemptContext taskAttemptContext = getTaskAttemptContext(config); | ||
| JobContext jobContext = new JobContextImpl(taskAttemptContext.getConfiguration(), | ||
| taskAttemptContext.getTaskAttemptID().getJobID()); | ||
| Configuration conf = jobContext.getConfiguration(); | ||
| String sourceBase; | ||
| String workBase; | ||
| String targetBase; | ||
| FileSystem fs = null; | ||
| try { | ||
| OutputCommitter committer = new CopyCommitter(null, taskAttemptContext); | ||
| fs = FileSystem.get(conf); | ||
steveloughran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| FsPermission sourcePerm = new FsPermission((short) 511); | ||
| FsPermission initialPerm = new FsPermission((short) 448); | ||
| sourceBase = TestDistCpUtils.createTestSetup(fs, sourcePerm); | ||
| workBase = TestDistCpUtils.createTestSetup(fs, initialPerm); | ||
| targetBase = "/tmp1/" + rand.nextLong(); | ||
| final DistCpOptions options = new DistCpOptions.Builder( | ||
| Collections.singletonList(new Path(sourceBase)), new Path("/out")) | ||
| .preserve(FileAttribute.PERMISSION).build(); | ||
| options.appendToConf(conf); | ||
| final DistCpContext context = new DistCpContext(options); | ||
| context.setTargetPathExists(false); | ||
| CopyListing listing = new GlobbedCopyListing(conf, CREDENTIALS); | ||
| Path listingFile = new Path("/tmp1/" + rand.nextLong()); | ||
| listing.buildListing(listingFile, context); | ||
| conf.set(CONF_LABEL_TARGET_FINAL_PATH, targetBase); | ||
| conf.set(CONF_LABEL_TARGET_WORK_PATH, workBase); | ||
| conf.setBoolean(DistCpConstants.CONF_LABEL_ATOMIC_COPY, true); | ||
| committer.commitJob(jobContext); | ||
| checkDirectoryPermissions(fs, targetBase, sourcePerm); | ||
| } finally { | ||
| TestDistCpUtils.delete(fs, "/tmp1"); | ||
| conf.unset(DistCpConstants.CONF_LABEL_PRESERVE_STATUS); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| @Test | ||
| public void testDeleteMissing() throws IOException { | ||
|
|
@@ -207,8 +248,8 @@ public void testDeleteMissing() throws IOException { | |
| Path listingFile = new Path("/tmp1/" + String.valueOf(rand.nextLong())); | ||
| listing.buildListing(listingFile, context); | ||
|
|
||
| conf.set(DistCpConstants.CONF_LABEL_TARGET_WORK_PATH, targetBase); | ||
| conf.set(DistCpConstants.CONF_LABEL_TARGET_FINAL_PATH, targetBase); | ||
| conf.set(CONF_LABEL_TARGET_WORK_PATH, targetBase); | ||
| conf.set(CONF_LABEL_TARGET_FINAL_PATH, targetBase); | ||
|
|
||
| committer.commitJob(jobContext); | ||
| verifyFoldersAreInSync(fs, targetBase, sourceBase); | ||
|
|
@@ -256,8 +297,8 @@ public void testPreserveTimeWithDeleteMiss() throws IOException { | |
| Path listingFile = new Path("/tmp1/" + String.valueOf(rand.nextLong())); | ||
| listing.buildListing(listingFile, context); | ||
|
|
||
| conf.set(DistCpConstants.CONF_LABEL_TARGET_WORK_PATH, targetBase); | ||
| conf.set(DistCpConstants.CONF_LABEL_TARGET_FINAL_PATH, targetBase); | ||
| conf.set(CONF_LABEL_TARGET_WORK_PATH, targetBase); | ||
| conf.set(CONF_LABEL_TARGET_FINAL_PATH, targetBase); | ||
|
|
||
| Path sourceListing = new Path( | ||
| conf.get(DistCpConstants.CONF_LABEL_LISTING_FILE_PATH)); | ||
|
|
@@ -320,8 +361,8 @@ public void testDeleteMissingFlatInterleavedFiles() throws IOException { | |
| Path listingFile = new Path("/tmp1/" + String.valueOf(rand.nextLong())); | ||
| listing.buildListing(listingFile, context); | ||
|
|
||
| conf.set(DistCpConstants.CONF_LABEL_TARGET_WORK_PATH, targetBase); | ||
| conf.set(DistCpConstants.CONF_LABEL_TARGET_FINAL_PATH, targetBase); | ||
| conf.set(CONF_LABEL_TARGET_WORK_PATH, targetBase); | ||
| conf.set(CONF_LABEL_TARGET_FINAL_PATH, targetBase); | ||
|
|
||
| committer.commitJob(jobContext); | ||
| verifyFoldersAreInSync(fs, targetBase, sourceBase); | ||
|
|
@@ -353,8 +394,8 @@ public void testAtomicCommitMissingFinal() throws IOException { | |
| fs = FileSystem.get(conf); | ||
| fs.mkdirs(new Path(workPath)); | ||
|
|
||
| conf.set(DistCpConstants.CONF_LABEL_TARGET_WORK_PATH, workPath); | ||
| conf.set(DistCpConstants.CONF_LABEL_TARGET_FINAL_PATH, finalPath); | ||
| conf.set(CONF_LABEL_TARGET_WORK_PATH, workPath); | ||
| conf.set(CONF_LABEL_TARGET_FINAL_PATH, finalPath); | ||
| conf.setBoolean(DistCpConstants.CONF_LABEL_ATOMIC_COPY, true); | ||
|
|
||
| assertPathExists(fs, "Work path", new Path(workPath)); | ||
|
|
@@ -391,8 +432,8 @@ public void testAtomicCommitExistingFinal() throws IOException { | |
| fs.mkdirs(new Path(workPath)); | ||
| fs.mkdirs(new Path(finalPath)); | ||
|
|
||
| conf.set(DistCpConstants.CONF_LABEL_TARGET_WORK_PATH, workPath); | ||
| conf.set(DistCpConstants.CONF_LABEL_TARGET_FINAL_PATH, finalPath); | ||
| conf.set(CONF_LABEL_TARGET_WORK_PATH, workPath); | ||
| conf.set(CONF_LABEL_TARGET_FINAL_PATH, finalPath); | ||
| conf.setBoolean(DistCpConstants.CONF_LABEL_ATOMIC_COPY, true); | ||
|
|
||
| assertPathExists(fs, "Work path", new Path(workPath)); | ||
|
|
@@ -463,8 +504,8 @@ private void testCommitWithChecksumMismatch(boolean skipCrc) | |
| + String.valueOf(rand.nextLong())); | ||
| listing.buildListing(listingFile, context); | ||
|
|
||
| conf.set(DistCpConstants.CONF_LABEL_TARGET_WORK_PATH, targetBase); | ||
| conf.set(DistCpConstants.CONF_LABEL_TARGET_FINAL_PATH, targetBase); | ||
| conf.set(CONF_LABEL_TARGET_WORK_PATH, targetBase); | ||
| conf.set(CONF_LABEL_TARGET_FINAL_PATH, targetBase); | ||
|
|
||
| OutputCommitter committer = new CopyCommitter( | ||
| null, taskAttemptContext); | ||
|
|
@@ -612,4 +653,4 @@ public RecordReader createRecordReader(InputSplit split, | |
| return null; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.