Search in sources :

Example 1 with SnapshotDiff

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);
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) SnapshotDiffReport(org.apache.hadoop.hdfs.protocol.SnapshotDiffReport) SnapshotDiff(org.apache.hadoop.hdfs.tools.snapshot.SnapshotDiff) Test(org.junit.Test)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 SnapshotDiffReport (org.apache.hadoop.hdfs.protocol.SnapshotDiffReport)1 SnapshotDiff (org.apache.hadoop.hdfs.tools.snapshot.SnapshotDiff)1 Test (org.junit.Test)1