Merge branch 'cassandra-2.0' into cassandra-2.1 Conflicts: src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategy.java
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/755a6b24 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/755a6b24 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/755a6b24 Branch: refs/heads/cassandra-2.1 Commit: 755a6b244c7c0db34044f03b9a62c2070e033a78 Parents: 26ff150 17042f1 Author: Marcus Eriksson <marc...@apache.org> Authored: Tue Aug 18 10:51:38 2015 +0200 Committer: Marcus Eriksson <marc...@apache.org> Committed: Tue Aug 18 10:51:38 2015 +0200 ---------------------------------------------------------------------- .../DateTieredCompactionStrategy.java | 7 +++---- .../DateTieredCompactionStrategyOptions.java | 21 ++++++++++++++++++++ .../DateTieredCompactionStrategyTest.java | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/755a6b24/src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategy.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategy.java index 41c304b,2e43352..a8e2aff --- a/src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategy.java +++ b/src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategy.java @@@ -36,11 -36,9 +36,10 @@@ public class DateTieredCompactionStrate { private static final Logger logger = LoggerFactory.getLogger(DateTieredCompactionStrategy.class); - protected DateTieredCompactionStrategyOptions options; + private final DateTieredCompactionStrategyOptions options; protected volatile int estimatedRemainingTasks; + private final Set<SSTableReader> sstables = new HashSet<>(); - @VisibleForTesting - long lastExpiredCheck; + private long lastExpiredCheck; public DateTieredCompactionStrategy(ColumnFamilyStore cfs, Map<String, String> options) { @@@ -79,14 -80,14 +78,14 @@@ */ private List<SSTableReader> getNextBackgroundSSTables(final int gcBefore) { - if (!isEnabled() || cfs.getSSTables().isEmpty()) + if (cfs.getSSTables().isEmpty()) return Collections.emptyList(); - Set<SSTableReader> uncompacting = cfs.getUncompactingSSTables(); + Set<SSTableReader> uncompacting = Sets.intersection(sstables, cfs.getUncompactingSSTables()); Set<SSTableReader> expired = Collections.emptySet(); - // we only check for expired sstables every 10 minutes due to it being an expensive operation - if (System.currentTimeMillis() - lastExpiredCheck > TimeUnit.MINUTES.toMillis(10)) + // we only check for expired sstables every 10 minutes (by default) due to it being an expensive operation + if (System.currentTimeMillis() - lastExpiredCheck > options.expiredSSTableCheckFrequency) { // Find fully expired SSTables. Those will be included no matter what. expired = CompactionController.getFullyExpiredSSTables(cfs, uncompacting, cfs.getOverlappingSSTables(uncompacting), gcBefore); http://git-wip-us.apache.org/repos/asf/cassandra/blob/755a6b24/test/unit/org/apache/cassandra/db/compaction/DateTieredCompactionStrategyTest.java ---------------------------------------------------------------------- diff --cc test/unit/org/apache/cassandra/db/compaction/DateTieredCompactionStrategyTest.java index cea835f,6d9bfc2..f05bf44 --- a/test/unit/org/apache/cassandra/db/compaction/DateTieredCompactionStrategyTest.java +++ b/test/unit/org/apache/cassandra/db/compaction/DateTieredCompactionStrategyTest.java @@@ -305,12 -305,10 +305,12 @@@ public class DateTieredCompactionStrate options.put(DateTieredCompactionStrategyOptions.BASE_TIME_KEY, "30"); options.put(DateTieredCompactionStrategyOptions.TIMESTAMP_RESOLUTION_KEY, "MILLISECONDS"); options.put(DateTieredCompactionStrategyOptions.MAX_SSTABLE_AGE_KEY, Double.toString((1d / (24 * 60 * 60)))); + options.put(DateTieredCompactionStrategyOptions.EXPIRED_SSTABLE_CHECK_FREQUENCY_SECONDS_KEY, "0"); DateTieredCompactionStrategy dtcs = new DateTieredCompactionStrategy(cfs, options); + for (SSTableReader sstable : cfs.getSSTables()) + dtcs.addSSTable(sstable); dtcs.startup(); assertNull(dtcs.getNextBackgroundTask((int) (System.currentTimeMillis() / 1000))); - dtcs.lastExpiredCheck = 0; Thread.sleep(2000); AbstractCompactionTask t = dtcs.getNextBackgroundTask((int) (System.currentTimeMillis()/1000)); assertNotNull(t);