Java Code Examples for org.apache.cassandra.io.util.FileUtils#delete()

The following examples show how to use org.apache.cassandra.io.util.FileUtils#delete() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SSTable.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
/**
 * We use a ReferenceQueue to manage deleting files that have been compacted
 * and for which no more SSTable references exist.  But this is not guaranteed
 * to run for each such file because of the semantics of the JVM gc.  So,
 * we write a marker to `compactedFilename` when a file is compacted;
 * if such a marker exists on startup, the file should be removed.
 *
 * This method will also remove SSTables that are marked as temporary.
 *
 * @return true if the file was deleted
 */
public static boolean delete(Descriptor desc, Set<Component> components)
{
    // remove the DATA component first if it exists
    if (components.contains(Component.DATA))
        FileUtils.deleteWithConfirm(desc.filenameFor(Component.DATA));
    for (Component component : components)
    {
        if (component.equals(Component.DATA) || component.equals(Component.SUMMARY))
            continue;

        FileUtils.deleteWithConfirm(desc.filenameFor(component));
    }
    FileUtils.delete(desc.filenameFor(Component.SUMMARY));

    logger.debug("Deleted {}", desc);
    return true;
}
 
Example 2
Source File: SSTableIndex.java    From sasi with Apache License 2.0 5 votes vote down vote up
public void release()
{
    int n = references.decrementAndGet();
    if (n == 0)
    {
        FileUtils.closeQuietly(index);
        sstable.releaseReference();
        if (obsolete.get() || sstable.isMarkedCompacted())
            FileUtils.delete(index.getIndexPath());
    }
}
 
Example 3
Source File: MetadataSerializer.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
private void rewriteSSTableMetadata(Descriptor descriptor, Map<MetadataType, MetadataComponent> currentComponents) throws IOException
{
    Descriptor tmpDescriptor = descriptor.asType(Descriptor.Type.TEMP);

    try (DataOutputStreamAndChannel out = new DataOutputStreamAndChannel(new FileOutputStream(tmpDescriptor.filenameFor(Component.STATS))))
    {
        serialize(currentComponents, out);
        out.flush();
    }
    // we cant move a file on top of another file in windows:
    if (FBUtilities.isWindows())
        FileUtils.delete(descriptor.filenameFor(Component.STATS));
    FileUtils.renameWithConfirm(tmpDescriptor.filenameFor(Component.STATS), descriptor.filenameFor(Component.STATS));

}
 
Example 4
Source File: SchemaLoader.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
protected static void cleanupSavedCaches()
{
    File cachesDir = new File(DatabaseDescriptor.getSavedCachesLocation());

    if (!cachesDir.exists() || !cachesDir.isDirectory())
        return;

    FileUtils.delete(cachesDir.listFiles());
}
 
Example 5
Source File: StreamLockfile.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public void delete()
{
    FileUtils.delete(lockfile);
}