本文整理汇总了Java中org.apache.cassandra.io.util.FileUtils.deleteRecursive方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.deleteRecursive方法的具体用法?Java FileUtils.deleteRecursive怎么用?Java FileUtils.deleteRecursive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.io.util.FileUtils
的用法示例。
在下文中一共展示了FileUtils.deleteRecursive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearSnapshot
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
public static void clearSnapshot(String snapshotName, List<File> snapshotDirectories)
{
// If snapshotName is empty or null, we will delete the entire snapshot directory
String tag = snapshotName == null ? "" : snapshotName;
for (File dir : snapshotDirectories)
{
File snapshotDir = new File(dir, join(SNAPSHOT_SUBDIR, tag));
if (snapshotDir.exists())
{
logger.trace("Removing snapshot directory {}", snapshotDir);
try
{
FileUtils.deleteRecursive(snapshotDir);
}
catch (FSWriteError e)
{
if (FBUtilities.isWindows())
SnapshotDeletingTask.addFailedSnapshot(snapshotDir);
else
throw e;
}
}
}
}
示例2: cleanup
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
@After
public void cleanup()
{
try {
FileUtils.deleteRecursive(tmpdir);
} catch (FSWriteError e) {
/**
* Windows does not allow a mapped file to be deleted, so we probably forgot to clean the buffers somewhere.
* We force a GC here to force buffer deallocation, and then try deleting the directory again.
* For more information, see: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4715154
* If this is not the problem, the exception will be rethrown anyway.
*/
System.gc();
FileUtils.deleteRecursive(tmpdir);
}
}
示例3: failStartupIfInvalidSSTablesFound
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
@Test
public void failStartupIfInvalidSSTablesFound() throws Exception
{
startupChecks = startupChecks.withTest(StartupChecks.checkSSTablesFormat);
copyInvalidLegacySSTables(sstableDir);
verifyFailure(startupChecks, "Detected unreadable sstables");
// we should ignore invalid sstables in a snapshots directory
FileUtils.deleteRecursive(sstableDir.toFile());
Path snapshotDir = sstableDir.resolve("snapshots");
Files.createDirectories(snapshotDir);
copyInvalidLegacySSTables(snapshotDir); startupChecks.verify();
// and in a backups directory
FileUtils.deleteRecursive(sstableDir.toFile());
Path backupDir = sstableDir.resolve("backups");
Files.createDirectories(backupDir);
copyInvalidLegacySSTables(backupDir);
startupChecks.verify();
}
示例4: testSSTableSplit
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
@Test
public void testSSTableSplit() throws InterruptedException
{
Keyspace keyspace = Keyspace.open(KEYSPACE);
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
truncate(cfs);
cfs.disableAutoCompaction();
SSTableReader s = writeFile(cfs, 1000);
try (LifecycleTransaction txn = LifecycleTransaction.offline(OperationType.UNKNOWN, s))
{
SSTableSplitter splitter = new SSTableSplitter(cfs, txn, 10);
splitter.split();
assertFileCounts(s.descriptor.directory.list());
LifecycleTransaction.waitForDeletions();
for (File f : s.descriptor.directory.listFiles())
{
// we need to clear out the data dir, otherwise tests running after this breaks
FileUtils.deleteRecursive(f);
}
}
truncate(cfs);
}
示例5: delete
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
/**
* Closes the index and removes all its files.
*/
public void delete() {
try {
close();
} catch (Exception e) {
throw new FhirIndexException(e, "Error deleting %s", name);
} finally {
FileUtils.deleteRecursive(path.toFile());
}
logger.info("Deleted {}", name);
}
示例6: cleanupDirectories
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
/**
* Cleans up cassandra's temporary base directory.
*
* @throws Exception
* if an error occurs
*/
public void cleanupDirectories() throws Exception {
File dirFile = new File(baseDirectory);
if (dirFile.exists()) {
FileUtils.deleteRecursive(dirFile);
}
}
示例7: prepareWriter
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
private void prepareWriter() throws IOException
{
try
{
if (writer == null)
{
writer = CQLSSTableWriter.builder()
.forTable(schema)
.using(insertStatement)
.withPartitioner(ConfigHelper.getOutputPartitioner(conf))
.inDirectory(outputDir)
.withBufferSizeInMB(Integer.parseInt(conf.get(BUFFER_SIZE_IN_MB, "64")))
.build();
}
if (loader == null)
{
ExternalClient externalClient = new ExternalClient(conf);
externalClient.addKnownCfs(keyspace, schema);
this.loader = new SSTableLoader(outputDir, externalClient, new BulkRecordWriter.NullOutputHandler()) {
@Override
public void onSuccess(StreamState finalState)
{
if (deleteSrc)
FileUtils.deleteRecursive(outputDir);
}
};
}
}
catch (Exception e)
{
throw new IOException(e);
}
}
示例8: clearSnapshot
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
public static void clearSnapshot(String snapshotName, List<File> snapshotDirectories)
{
// If snapshotName is empty or null, we will delete the entire snapshot directory
String tag = snapshotName == null ? "" : snapshotName;
for (File dir : snapshotDirectories)
{
File snapshotDir = new File(dir, join(SNAPSHOT_SUBDIR, tag));
if (snapshotDir.exists())
{
if (logger.isDebugEnabled())
logger.debug("Removing snapshot directory {}", snapshotDir);
FileUtils.deleteRecursive(snapshotDir);
}
}
}
示例9: CfAssumptions
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
public CfAssumptions()
{
assumptions = new HashMap<String, Map<String, Map<String, String>>>();
assumptionsChanged = false;
assumptionDirectory = FBUtilities.getToolsOutputDirectory();
File oldAssumptionDir = new File(System.getProperty("user.home") + File.separator + ".cassandra-cli");
if (oldAssumptionDir.exists())
{
File oldAssumptionFile = new File(oldAssumptionDir, ASSUMPTIONS_FILENAME);
if (oldAssumptionFile.exists())
FileUtils.renameWithConfirm(oldAssumptionFile, new File(assumptionDirectory, ASSUMPTIONS_FILENAME));
FileUtils.deleteRecursive(oldAssumptionDir);
}
}
示例10: removeAllSSTables
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
private static void removeAllSSTables(String ks, List<String> tables)
{
// clean up data directory which are stored as data directory/keyspace/data files
for (File d : Directories.getKSChildDirectories(ks))
{
if (d.exists() && containsAny(d.getName(), tables))
FileUtils.deleteRecursive(d);
}
}
示例11: clearSnapshot
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
public void clearSnapshot(String snapshotName)
{
// If snapshotName is empty or null, we will delete the entire snapshot directory
String tag = snapshotName == null ? "" : snapshotName;
for (File dir : sstableDirectories)
{
File snapshotDir = new File(dir, join(SNAPSHOT_SUBDIR, tag));
if (snapshotDir.exists())
{
if (logger.isDebugEnabled())
logger.debug("Removing snapshot directory {}", snapshotDir);
FileUtils.deleteRecursive(snapshotDir);
}
}
}
示例12: removeTemporaryDirectories
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
public void removeTemporaryDirectories()
{
for (File dataDir : dataPaths)
{
File tmpDir = new File(dataDir, TMP_SUBDIR);
if (tmpDir.exists())
{
logger.debug("Removing temporary directory {}", tmpDir);
FileUtils.deleteRecursive(tmpDir);
}
}
}
示例13: tearDown
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
@After
public void tearDown()
{
FileUtils.deleteRecursive(this.testDirectory);
}
示例14: afterClass
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
@AfterClass
public static void afterClass()
{
Directories.resetDataDirectoriesAfterTest();
FileUtils.deleteRecursive(tempDataDir);
}
示例15: testAbortHelper
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
private void testAbortHelper(boolean earlyException, boolean offline) throws Exception
{
Keyspace keyspace = Keyspace.open(KEYSPACE);
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
truncate(cfs);
SSTableReader s = writeFile(cfs, 1000);
if (!offline)
cfs.addSSTable(s);
Set<SSTableReader> compacting = Sets.newHashSet(s);
try (ISSTableScanner scanner = compacting.iterator().next().getScanner();
CompactionController controller = new CompactionController(cfs, compacting, 0);
LifecycleTransaction txn = offline ? LifecycleTransaction.offline(OperationType.UNKNOWN, compacting)
: cfs.getTracker().tryModify(compacting, OperationType.UNKNOWN);
SSTableRewriter rewriter = new SSTableRewriter(txn, 1000, offline, 10000000, false);
CompactionIterator ci = new CompactionIterator(OperationType.COMPACTION, Collections.singletonList(scanner), controller, FBUtilities.nowInSeconds(), UUIDGen.getTimeUUID())
)
{
rewriter.switchWriter(getWriter(cfs, s.descriptor.directory, txn));
while (ci.hasNext())
{
rewriter.append(ci.next());
if (rewriter.currentWriter().getOnDiskFilePointer() > 25000000)
{
rewriter.switchWriter(getWriter(cfs, s.descriptor.directory, txn));
}
}
try
{
rewriter.throwDuringPrepare(earlyException);
rewriter.prepareToCommit();
}
catch (Throwable t)
{
rewriter.abort();
}
}
finally
{
if (offline)
s.selfRef().release();
}
LifecycleTransaction.waitForDeletions();
int filecount = assertFileCounts(s.descriptor.directory.list());
assertEquals(filecount, 1);
if (!offline)
{
assertEquals(1, cfs.getLiveSSTables().size());
validateCFS(cfs);
truncate(cfs);
}
else
{
assertEquals(0, cfs.getLiveSSTables().size());
cfs.truncateBlocking();
}
filecount = assertFileCounts(s.descriptor.directory.list());
if (offline)
{
// the file is not added to the CFS, therefore not truncated away above
assertEquals(1, filecount);
for (File f : s.descriptor.directory.listFiles())
{
FileUtils.deleteRecursive(f);
}
filecount = assertFileCounts(s.descriptor.directory.list());
}
assertEquals(0, filecount);
truncate(cfs);
}