List of usage examples for org.apache.hadoop.fs TrashPolicy getInstance
@Deprecated public static TrashPolicy getInstance(Configuration conf, FileSystem fs, Path home)
From source file:com.ruizhan.hadoop.hdfs.Trash.java
License:Apache License
/** * Construct a trash can accessor for the FileSystem provided. * @param fs the FileSystem/*from w ww. ja va 2 s . co m*/ * @param conf a Configuration */ public Trash(FileSystem fs, Configuration conf) throws IOException { super(conf); trashPolicy = TrashPolicy.getInstance(conf, fs, fs.getHomeDirectory()); }
From source file:org.apache.ambari.view.filebrowser.HdfsApi.java
License:Apache License
/** * Trash directory//from ww w. j a v a2s . co m * @return trash directory * @throws Exception */ public Path getTrashDir() throws Exception { return ugi.doAs(new PrivilegedExceptionAction<Path>() { public Path run() throws IOException { TrashPolicy trashPolicy = TrashPolicy.getInstance(conf, fs, fs.getHomeDirectory()); return trashPolicy.getCurrentTrashDir().getParent(); } }); }
From source file:org.apache.ambari.view.utils.hdfs.HdfsApi.java
License:Apache License
/** * Trash directory/* w w w .j ava2 s. c o m*/ * @return trash directory * @throws Exception */ public Path getTrashDir() throws Exception { return execute(new PrivilegedExceptionAction<Path>() { public Path run() throws IOException { TrashPolicy trashPolicy = TrashPolicy.getInstance(conf, fs, fs.getHomeDirectory()); return trashPolicy.getCurrentTrashDir().getParent(); } }); }
From source file:org.apache.gobblin.util.HadoopUtilsTest.java
License:Apache License
@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);/*from w w w .ja v a2 s. c o m*/ Assert.assertTrue(fs.exists(hadoopUtilsTestDir)); trash.moveToTrash(hadoopUtilsTestDir.getParent()); Assert.assertFalse(fs.exists(hadoopUtilsTestDir)); Assert.assertTrue(fs.exists(trashPath)); }