org.apache.hadoop.fs.TestTrash Java Examples

The following examples show how to use org.apache.hadoop.fs.TestTrash. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestHDFSTrash.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonDefaultFS() throws IOException {
  FileSystem fs = cluster.getFileSystem();
  Configuration conf = fs.getConf();
  conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, fs.getUri().toString());
  TestTrash.trashNonDefaultFS(conf);
}
 
Example #2
Source File: TestHDFSTrash.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonDefaultFS() throws IOException {
  FileSystem fs = cluster.getFileSystem();
  Configuration conf = fs.getConf();
  conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, fs.getUri().toString());
  TestTrash.trashNonDefaultFS(conf);
}
 
Example #3
Source File: TestFileDeleteWhitelist.java    From RDFS with Apache License 2.0 5 votes vote down vote up
public void testFileDeleteWithTrash() throws IOException {
  Configuration conf = new Configuration();
  conf.set("fs.trash.interval", "10"); // 10 minute

  // create cluster
  MiniDFSCluster cluster = new MiniDFSCluster(conf, 1, true, null);
  FileSystem fs = null;
  try {
    cluster.waitActive();
    fs = cluster.getFileSystem();

    // create file1.
    Path dir = new Path("/foo");
    Path file1 = new Path(dir, "file1");
    createFile(fs, file1);
    System.out.println("testFileCreationDeleteParent: "
        + "Created file " + file1);
    fs.delete(file1, true);

    // create file2.
    Path file2 = new Path("/tmp", "file2");
    createFile(fs, file2);
    System.out.println("testFileCreationDeleteParent: "
        + "Created file " + file2);
    fs.delete(file2, true);

    TrashPolicy trashPolicy = TrashPolicy.getInstance(conf, fs, fs.getHomeDirectory());
    Path trashRoot = trashPolicy.getCurrentTrashDir();
    TestTrash.checkTrash(fs, trashRoot, file1);
    TestTrash.checkNotInTrash(fs, trashRoot, file2.toString());
  } finally {
    fs.close();
    cluster.shutdown();
  }
}
 
Example #4
Source File: TestHDFSTrash.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testTrash() throws IOException {
  TestTrash.trashShell(cluster.getFileSystem(), new Path("/"));
}
 
Example #5
Source File: TestViewFsTrash.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testTrash() throws IOException {
  TestTrash.trashShell(conf, fileSystemTestHelper.getTestRootPath(fsView),
      fsTarget, new Path(fsTarget.getHomeDirectory(), ".Trash/Current"));
}
 
Example #6
Source File: TestHDFSTrash.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testTrash() throws IOException {
  TestTrash.trashShell(cluster.getFileSystem(), new Path("/"));
}
 
Example #7
Source File: TestViewFsTrash.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testTrash() throws IOException {
  TestTrash.trashShell(conf, fileSystemTestHelper.getTestRootPath(fsView),
      fsTarget, new Path(fsTarget.getHomeDirectory(), ".Trash/Current"));
}