src/java/org/apache/cassandra/db/ColumnFamilyStore.java
/**
     * Removes unnecessary files from the cf directory at startup: these include temp files, orphans, zero-length files
     * and compacted sstables. Files that cannot be recognized will be ignored.
     */
Removes unnecessary files from the cf directory at startup: these include temp files, orphans, zero-length files
and compacted sstables. Files that cannot be recognized will be ignored.
Removes unnecessary files from the cf directory at startup : these include temp files orphans zero - length files and compacted sstables . Files that cannot be recognized will be ignored .
public static void scrubDataDirectories(String table, String columnFamily)
    {
        logger.debug("Removing compacted SSTable files from {} (see http://wiki.apache.org/cassandra/MemtableSSTable)", columnFamily);
        Directories directories = Directories.create(table, columnFamily);
        for (Map.Entry<Descriptor,Set<Component>> sstableFiles : directories.sstableLister().list().entrySet())
        {
            Descriptor desc = sstableFiles.getKey();
            Set<Component> components = sstableFiles.getValue();
            if (components.contains(Component.COMPACTED_MARKER) || desc.temporary)
            {
                try
                {
                    SSTable.delete(desc, components);
                }
                catch (IOException e)
                {
                    throw new IOError(e);
                }
                continue;
            }
            File dataFile = new File(desc.filenameFor(Component.DATA));
            if (components.contains(Component.DATA) && dataFile.length() > 0)
                continue;
            logger.warn("Removing orphans for {}: {}", desc, components);
            for (Component component : components)
            {
                try
                {
                    FileUtils.deleteWithConfirm(desc.filenameFor(component));
                }
                catch (IOException e)
                {
                    throw new IOError(e);
                }
            }
        }
        Pattern tmpCacheFilePattern = Pattern.compile(table + "-" + columnFamily + "-(Key|Row)Cache.*\\.tmp$");
        File dir = new File(DatabaseDescriptor.getSavedCachesLocation());
        if (dir.exists())
        {
            assert dir.isDirectory();
            for (File file : dir.listFiles())
                if (tmpCacheFilePattern.matcher(file.getName()).matches())
                    if (!file.delete())
                        logger.warn("could not delete " + file.getAbsolutePath());
        }
        CFMetaData cfm = Schema.instance.getCFMetaData(table, columnFamily);
        if (cfm != null) 
        {
            for (ColumnDefinition def : cfm.getColumn_metadata().values())
                scrubDataDirectories(table, cfm.indexColumnFamilyName(def));
        }
    }
public static void scrubDataDirectories ( String table , String columnFamily ) { logger . debug ( "Removing compacted SSTable files from {} (see http://wiki.apache.org/cassandra/MemtableSSTable)" , columnFamily ) ; Directories directories = Directories . create ( table , columnFamily ) ; for ( Map . Entry < Descriptor , Set < Component > > sstableFiles : directories . sstableLister ( ) . list ( ) . entrySet ( ) ) { Descriptor desc = sstableFiles . getKey ( ) ; Set < Component > components = sstableFiles . getValue ( ) ; if ( components . contains ( Component . COMPACTED_MARKER ) || desc . temporary ) { try { SSTable . delete ( desc , components ) ; } catch ( IOException e ) { throw new IOError ( e ) ; } continue ; } File dataFile = new File ( desc . filenameFor ( Component . DATA ) ) ; if ( components . contains ( Component . DATA ) && dataFile . length ( ) > 0 ) continue ; logger . warn ( "Removing orphans for {}: {}" , desc , components ) ; for ( Component component : components ) { try { FileUtils . deleteWithConfirm ( desc . filenameFor ( component ) ) ; } catch ( IOException e ) { throw new IOError ( e ) ; } } } Pattern tmpCacheFilePattern = Pattern . compile ( table + "-" + columnFamily + "-(Key|Row)Cache.*\\.tmp$" ) ; File dir = new File ( DatabaseDescriptor . getSavedCachesLocation ( ) ) ; if ( dir . exists ( ) ) { assert dir . isDirectory ( ) ; for ( File file : dir . listFiles ( ) ) if ( tmpCacheFilePattern . matcher ( file . getName ( ) ) . matches ( ) ) if ( ! file . delete ( ) ) logger . warn ( "could not delete " + file . getAbsolutePath ( ) ) ; } CFMetaData cfm = Schema . instance . getCFMetaData ( table , columnFamily ) ; if ( cfm != null ) { for ( ColumnDefinition def : cfm . getColumn_metadata ( ) . values ( ) ) scrubDataDirectories ( table , cfm . indexColumnFamilyName ( def ) ) ; } }
Removes unnecessary files from the cf directory at startup: these include temp files, orphans, zero-length files
 and compacted sstables.
Removes unnecessary files from the cf directory at startup : these include temp files orphans zero - length files and compacted sstables .
// everything appears to be in order... moving on. // missing the DATA file! all components are orphaned // cleanup incomplete saved caches // also clean out any index leftovers. // secondary indexes aren't stored in DD.