use of org.apache.hadoop.hdfs.tools.snapshot.SnapshotDiff in project hadoop by apache.
the class TestSnapshotCommands method testSnapshotCommandsWithURI.
@Test(timeout = 60000)
public void testSnapshotCommandsWithURI() throws Exception {
Configuration config = new HdfsConfiguration();
//fs.defaultFS should not be used, when path is fully qualified.
config.set("fs.defaultFS", "hdfs://127.0.0.1:1024");
String path = fs.getUri() + "/Fully/QPath";
DFSTestUtil.DFSAdminRun("-allowSnapshot " + path, 0, "Allowing snaphot on " + path + " succeeded", config);
DFSTestUtil.FsShellRun("-createSnapshot " + path + " sn1", config);
// create file1
DFSTestUtil.createFile(fs, new Path(fs.getUri() + "/Fully/QPath/File1"), 1024, (short) 1, 100);
// create file2
DFSTestUtil.createFile(fs, new Path(fs.getUri() + "/Fully/QPath/File2"), 1024, (short) 1, 100);
DFSTestUtil.FsShellRun("-createSnapshot " + path + " sn2", config);
// verify the snapshotdiff using api and command line
SnapshotDiffReport report = fs.getSnapshotDiffReport(new Path(path), "sn1", "sn2");
DFSTestUtil.toolRun(new SnapshotDiff(config), path + " sn1 sn2", 0, report.toString());
DFSTestUtil.FsShellRun("-renameSnapshot " + path + " sn2 sn3", config);
DFSTestUtil.FsShellRun("-deleteSnapshot " + path + " sn1", config);
DFSTestUtil.FsShellRun("-deleteSnapshot " + path + " sn3", config);
DFSTestUtil.DFSAdminRun("-disallowSnapshot " + path, 0, "Disallowing snaphot on " + path + " succeeded", config);
fs.delete(new Path("/Fully/QPath"), true);
}
Aggregations