@AfterMethod(alwaysRun = true) public void tearDown() throws IOException { FileUtils.deleteRecursively(tempDir); }
public static boolean copyRecursively(File src, File target) { if (src.isDirectory()) { return copyDirectoryContents(src, target); } else { try { Files.copy(src, target); return true; } catch (IOException e) { return false; } } }
public static boolean copyDirectoryContents(File src, File target) { Preconditions.checkArgument(src.isDirectory(), "Source dir is not a directory: %s", src); // Don't delete symbolic link directories if (isSymbolicLink(src)) { return false; } target.mkdirs(); Preconditions.checkArgument(target.isDirectory(), "Target dir is not a directory: %s", src); boolean success = true; for (File file : listFiles(src)) { success = copyRecursively(file, new File(target, file.getName())) && success; } return success; }
public static boolean deleteDirectoryContents(File directory) { Preconditions.checkArgument(directory.isDirectory(), "Not a directory: %s", directory); // Don't delete symbolic link directories if (isSymbolicLink(directory)) { return false; } boolean success = true; for (File file : listFiles(directory)) { success = deleteRecursively(file) && success; } return success; }
public static boolean deleteRecursively(File file) { boolean success = true; if (file.isDirectory()) { success = deleteDirectoryContents(file); } return file.delete() && success; }
public static File createTempDir(String prefix) { return createTempDir(new File(System.getProperty("java.io.tmpdir")), prefix); }
@AfterMethod(alwaysRun = true) public void teardown() throws Exception { FileUtils.deleteRecursively(tempDir); }
@AfterClass(alwaysRun = true) public void teardown() throws IOException { FileUtils.deleteRecursively(tempDir); }
@AfterMethod(alwaysRun = true) public void tearDown() throws IOException { FileUtils.deleteRecursively(tempDir); }
@TearDown public void tearDown() { deleteRecursively(targetDir); }
@AfterMethod(alwaysRun = true) public void teardown() throws Exception { try { if (server != null) { server.stop(); } } finally { FileUtils.deleteRecursively(tempDir); } }
public static void main(String[] args) throws IOException { String outputDirectory = requireNonNull(System.getProperty("outputDirectory"), "Must specify -DoutputDirectory=..."); File tempDir = Files.createTempDir(); try (LocalQueryRunner localQueryRunner = createLocalQueryRunner(tempDir)) { new BenchmarkSuite(localQueryRunner, outputDirectory).runAllBenchmarks(); } finally { FileUtils.deleteRecursively(tempDir); } }
@Override public void close() { if (started.get()) { kafka.shutdown(); kafka.awaitShutdown(); zookeeper.close(); deleteRecursively(kafkaDataDir); } }
@Override public void close() { if (started.get()) { cnxnFactory.shutdown(); try { cnxnFactory.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } if (zkServer.isRunning()) { zkServer.shutdown(); } deleteRecursively(zkDataDir); } }
@Override public void dropTable(String databaseName, String tableName) { List<String> locations = listAllDataPaths(this, databaseName, tableName); SchemaTableName schemaTableName = new SchemaTableName(databaseName, tableName); Table table = relations.remove(schemaTableName); if (table == null) { throw new TableNotFoundException(schemaTableName); } views.remove(schemaTableName); partitions.keySet().stream() .filter(partitionName -> partitionName.matches(databaseName, tableName)) .forEach(partitions::remove); // remove data for (String location : locations) { if (location != null) { File directory = new File(URI.create(location)); checkArgument(isParentDir(directory, baseDirectory), "Table directory must be inside of the metastore base directory"); deleteRecursively(directory); } } }
@Test public void testAllFormats() throws Exception { HiveClientConfig config = new HiveClientConfig(); File tempDir = Files.createTempDir(); try { HiveMetastore metastore = new InMemoryHiveMetastore(new File(tempDir, "metastore")); for (HiveStorageFormat format : HiveStorageFormat.values()) { config.setHiveStorageFormat(format); config.setHiveCompressionCodec(NONE); long uncompressedLength = writeTestFile(config, metastore, makeFileName(tempDir, config)); assertGreaterThan(uncompressedLength, 0L); for (HiveCompressionCodec codec : HiveCompressionCodec.values()) { if (codec == NONE) { continue; } config.setHiveCompressionCodec(codec); long length = writeTestFile(config, metastore, makeFileName(tempDir, config)); assertTrue(uncompressedLength > length, format("%s with %s compressed to %s which is not less than %s", format, codec, length, uncompressedLength)); } } } finally { FileUtils.deleteRecursively(tempDir); } }