org.apache.hadoop.fs.TrashPolicy的实例源码

项目:incubator-gobblin    文件HadoopUtilsTest.java   
@Test
public void testMovetoTrash() throws IOException {
  Path hadoopUtilsTestDir = new Path(Files.createTempDir().getAbsolutePath(),"HadoopUtilsTestDir");
  Configuration conf = new Configuration();
  // Set the time to keep it in trash to 10 minutes.
  // 0 means object will be deleted instantly.
  conf.set("fs.trash.interval","10");
  FileSystem fs = FileSystem.getLocal(conf);
  Trash trash = new Trash(fs,conf);
  TrashPolicy trashPolicy = TrashPolicy.getInstance(conf,fs,fs.getHomeDirectory());
  Path trashPath = trashPolicy.getCurrentTrashDir();

  fs.mkdirs(hadoopUtilsTestDir);
  Assert.assertTrue(fs.exists(hadoopUtilsTestDir));
  trash.movetoTrash(hadoopUtilsTestDir.getParent());
  Assert.assertFalse(fs.exists(hadoopUtilsTestDir));
  Assert.assertTrue(fs.exists(trashPath));
}
项目:hadoop-EAR    文件TestFileDeleteWhitelist.java   
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.getHomeDirectory());
    Path trashRoot = trashPolicy.getCurrentTrashDir();
    TestTrash.checkTrash(fs,trashRoot,file1);
    TestTrash.checknotinTrash(fs,file2.toString());
  } finally {
    fs.close();
    cluster.shutdown();
  }
}
项目:RDFS    文件TestFileDeleteWhitelist.java   
public void testFileDeleteWithTrash() throws IOException {
  Configuration conf = new Configuration();
  conf.set("fs.trash.interval",file2.toString());
  } finally {
    fs.close();
    cluster.shutdown();
  }
}

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...