use of org.apache.hadoop.fs.TrashPolicy in project incubator-gobblin by apache.
the class HadoopUtilsTest method testMoveToTrash.
@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));
}
use of org.apache.hadoop.fs.TrashPolicy in project hive by apache.
the class AbstractMetaStoreService method start.
/**
* Starts the MetaStoreService. Be aware, as the current MetaStore does not implement clean
* shutdown, starting MetaStoreService is possible only once per test.
*
* @throws Exception if any Exception occurs
*/
public void start() throws Exception {
warehouse = new Warehouse(configuration);
warehouseRootFs = warehouse.getFs(warehouse.getWhRoot());
TrashPolicy trashPolicy = TrashPolicy.getInstance(configuration, warehouseRootFs);
trashDir = trashPolicy.getCurrentTrashDir();
}
Aggregations