-
Notifications
You must be signed in to change notification settings - Fork 9k
HDFS-16911. Distcp with snapshot diff to support Ozone filesystem. #5364
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 all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b074251
HDFS-16911.Distcp with snapshot diff to support Ozone filesystem
5aabd75
use fs.hasPathCapability to check FS compatibility with snapshots and…
fd34ce6
add javadoc
6fd1f57
fix javac warning
66a3e14
address comments
ac44e1c
remove getter
57bb1d1
throw UnsupportedOperationException instead
345eac1
throw UnsupportedOperationException instead
89da1b0
fix test
2a3a07a
address comments
a66c5f4
address comment
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 |
---|---|---|
|
@@ -23,6 +23,8 @@ | |
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.Path; | ||
import org.apache.hadoop.fs.contract.ContractTestUtils; | ||
import org.apache.hadoop.fs.RawLocalFileSystem; | ||
import org.apache.hadoop.fs.CommonPathCapabilities; | ||
import org.apache.hadoop.hdfs.DFSTestUtil; | ||
import org.apache.hadoop.hdfs.DistributedFileSystem; | ||
import org.apache.hadoop.hdfs.HdfsConfiguration; | ||
|
@@ -38,6 +40,7 @@ | |
import org.apache.hadoop.mapreduce.Mapper; | ||
import org.apache.hadoop.security.Credentials; | ||
import org.apache.hadoop.test.GenericTestUtils; | ||
import org.apache.hadoop.test.LambdaTestUtils; | ||
import org.apache.hadoop.tools.mapred.CopyMapper; | ||
import org.junit.After; | ||
import org.junit.Assert; | ||
|
@@ -47,6 +50,7 @@ | |
import java.io.IOException; | ||
import java.io.FileWriter; | ||
import java.io.BufferedWriter; | ||
import java.net.URI; | ||
import java.nio.file.Files; | ||
import java.util.Arrays; | ||
import java.util.ArrayList; | ||
|
@@ -56,6 +60,9 @@ | |
import java.util.Map; | ||
import java.util.regex.Pattern; | ||
|
||
import static org.apache.hadoop.fs.impl.PathCapabilitiesSupport.validatePathCapabilityArgs; | ||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
public class TestDistCpSync { | ||
private MiniDFSCluster cluster; | ||
private final Configuration conf = new HdfsConfiguration(); | ||
|
@@ -89,6 +96,7 @@ public void setUp() throws Exception { | |
|
||
conf.set(DistCpConstants.CONF_LABEL_TARGET_WORK_PATH, target.toString()); | ||
conf.set(DistCpConstants.CONF_LABEL_TARGET_FINAL_PATH, target.toString()); | ||
conf.setClass("fs.dummy.impl", DummyFs.class, FileSystem.class); | ||
} | ||
|
||
@After | ||
|
@@ -1276,4 +1284,63 @@ private void snapshotDiffWithPaths(Path sourceFSPath, | |
verifyCopyByFs(sourceFS, targetFS, sourceFS.getFileStatus(sourceFSPath), | ||
targetFS.getFileStatus(targetFSPath), false); | ||
} | ||
|
||
@Test | ||
public void testSyncSnapshotDiffWithLocalFileSystem() throws Exception { | ||
String[] args = new String[]{"-update", "-diff", "s1", "s2", | ||
"file:///source", "file:///target"}; | ||
LambdaTestUtils.intercept( | ||
UnsupportedOperationException.class, | ||
"The source file system file does not support snapshot", | ||
() -> new DistCp(conf, OptionsParser.parse(args)).execute()); | ||
} | ||
|
||
@Test | ||
public void testSy AE8F ncSnapshotDiffWithDummyFileSystem() { | ||
String[] args = | ||
new String[] { "-update", "-diff", "s1", "s2", "dummy:///source", | ||
"dummy:///target" }; | ||
try { | ||
FileSystem dummyFs = FileSystem.get(URI.create("dummy:///"), conf); | ||
assertThat(dummyFs).isInstanceOf(DummyFs.class); | ||
new DistCp(conf, OptionsParser.parse(args)).execute(); | ||
} catch (UnsupportedOperationException e) { | ||
throw e; | ||
} catch (Exception e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. catch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
// can expect other exceptions as source and target paths | ||
// are not created. | ||
} | ||
} | ||
|
||
public static class DummyFs extends RawLocalFileSystem { | ||
public DummyFs() { | ||
super(); | ||
} | ||
|
||
public URI getUri() { | ||
return URI.create("dummy:///"); | ||
} | ||
|
||
@Override | ||
public boolean hasPathCapability(Path path, String capability) | ||
throws IOException { | ||
switch (validatePathCapabilityArgs(makeQualified(path), capability)) { | ||
case CommonPathCapabilities.FS_SNAPSHOTS: | ||
return true; | ||
default: | ||
return super.hasPathCapability(path, capability); | ||
} | ||
} | ||
|
||
@Override | ||
public FileStatus getFileStatus(Path f) throws IOException { | ||
return new FileStatus(); | ||
} | ||
|
||
public SnapshotDiffReport getSnapshotDiffReport(final Path snapshotDir, | ||
final String fromSnapshot, final String toSnapshot) { | ||
return new SnapshotDiffReport(snapshotDir.getName(), fromSnapshot, | ||
toSnapshot, new ArrayList<SnapshotDiffReport.DiffReportEntry>()); | ||
} | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NoSuchMethod sanity check already covered looks like before calling this API. IllegalAccess should noyt happen ideally. So runtime should be ok.
Tiny Nit: Message: "Failed to ...."
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @umamaheswararao for the review.
Done. Yes the exception will likely be detected earlier but these are checked exceptions so it requires either to define in
catch
block orthrows
.