Example usage for org.apache.cassandra.db.compaction CompactionController getFullyExpiredSSTables

List of usage examples for org.apache.cassandra.db.compaction CompactionController getFullyExpiredSSTables

Introduction

In this page you can find the example usage for org.apache.cassandra.db.compaction CompactionController getFullyExpiredSSTables.

Prototype

public static Set<SSTableReader> getFullyExpiredSSTables(ColumnFamilyStore cfStore,
            Iterable<SSTableReader> compacting, Iterable<SSTableReader> overlapping, int gcBefore) 

Source Link

Usage

From source file:com.jeffjirsa.cassandra.db.compaction.TimeWindowCompactionStrategy.java

License:Apache License

/**
 *
 * @param gcBefore/*from  w w  w .j a  va2  s .c o  m*/
 * @return
 */
private List<SSTableReader> getNextBackgroundSSTables(final int gcBefore) {
    if (Iterables.isEmpty(cfs.getSSTables(SSTableSet.LIVE)))
        return Collections.emptyList();

    Set<SSTableReader> uncompacting = ImmutableSet
            .copyOf(filter(cfs.getUncompactingSSTables(), sstables::contains));

    // Find fully expired SSTables. Those will be included no matter what.
    Set<SSTableReader> expired = Collections.emptySet();

    if (System.currentTimeMillis() - lastExpiredCheck > options.expiredSSTableCheckFrequency) {
        logger.debug("TWCS expired check sufficiently far in the past, checking for fully expired SSTables");
        expired = CompactionController.getFullyExpiredSSTables(cfs, uncompacting,
                cfs.getOverlappingSSTables(SSTableSet.CANONICAL, uncompacting), gcBefore);
        lastExpiredCheck = System.currentTimeMillis();
    } else {
        logger.debug("TWCS skipping check for fully expired SSTables");
    }

    Set<SSTableReader> candidates = Sets.newHashSet(filterSuspectSSTables(uncompacting));

    List<SSTableReader> compactionCandidates = new ArrayList<>(
            getNextNonExpiredSSTables(Sets.difference(candidates, expired), gcBefore));
    if (!expired.isEmpty()) {
        logger.debug("Including expired sstables: {}", expired);
        compactionCandidates.addAll(expired);
    }

    return compactionCandidates;
}