Example usage for org.apache.cassandra.db.lifecycle SSTableSet LIVE

List of usage examples for org.apache.cassandra.db.lifecycle SSTableSet LIVE

Introduction

In this page you can find the example usage for org.apache.cassandra.db.lifecycle SSTableSet LIVE.

Prototype

SSTableSet LIVE

To view the source code for org.apache.cassandra.db.lifecycle SSTableSet LIVE.

Click Source Link

Usage

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

License:Apache License

/**
 *
 * @param gcBefore// ww  w  .j a  v  a2 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;
}