use of alluxio.underfs.UnderFileStatus in project alluxio by Alluxio.
the class Format method formatFolder.
private static boolean formatFolder(String name, String folder) throws IOException {
UnderFileSystem ufs = UnderFileSystem.Factory.get(folder);
LOG.info("Formatting {}:{}", name, folder);
if (ufs.isDirectory(folder)) {
for (UnderFileStatus p : ufs.listStatus(folder)) {
String childPath = PathUtils.concatPath(folder, p.getName());
boolean failedToDelete;
if (p.isDirectory()) {
failedToDelete = !ufs.deleteDirectory(childPath, DeleteOptions.defaults().setRecursive(true));
} else {
failedToDelete = !ufs.deleteFile(childPath);
}
if (failedToDelete) {
LOG.info("Failed to delete {}", childPath);
return false;
}
}
} else if (!ufs.mkdirs(folder)) {
LOG.info("Failed to create {}:{}", name, folder);
return false;
}
return true;
}
use of alluxio.underfs.UnderFileStatus in project alluxio by Alluxio.
the class JournalIntegrationTest method multipleFlush.
/**
* Tests flushing the journal multiple times, without writing any data.
*/
@Test
public void multipleFlush() throws Exception {
// Set the max log size to 0 to force a flush to write a new file.
String existingMax = Configuration.get(PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX);
Configuration.set(PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX, "0");
try {
String journalFolder = mLocalAlluxioCluster.getMaster().getJournalFolder();
ReadWriteJournal journal = new ReadWriteJournal(PathUtils.concatPath(journalFolder, Constants.FILE_SYSTEM_MASTER_NAME));
JournalWriter writer = journal.getNewWriter();
writer.getCheckpointOutputStream(0).close();
// Flush multiple times, without writing to the log.
writer.flushEntryStream();
writer.flushEntryStream();
writer.flushEntryStream();
UnderFileStatus[] paths = UnderFileSystem.Factory.get(journalFolder).listStatus(journal.getCompletedDirectory());
// Make sure no new empty files were created.
Assert.assertTrue(paths == null || paths.length == 0);
} finally {
// Reset the max log size.
Configuration.set(PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX, existingMax);
}
}
Aggregations