use of org.apache.cassandra.db.lifecycle.LifecycleTransaction in project cassandra by apache.
the class TimeWindowCompactionStrategy method getNextBackgroundTask.
@Override
// transaction is closed by AbstractCompactionTask::execute
@SuppressWarnings("resource")
public AbstractCompactionTask getNextBackgroundTask(int gcBefore) {
while (true) {
List<SSTableReader> latestBucket = getNextBackgroundSSTables(gcBefore);
if (latestBucket.isEmpty())
return null;
LifecycleTransaction modifier = cfs.getTracker().tryModify(latestBucket, OperationType.COMPACTION);
if (modifier != null)
return new CompactionTask(cfs, modifier, gcBefore);
}
}
use of org.apache.cassandra.db.lifecycle.LifecycleTransaction in project cassandra by apache.
the class TimeWindowCompactionStrategy method getMaximalTask.
@Override
// transaction is closed by AbstractCompactionTask::execute
@SuppressWarnings("resource")
public synchronized Collection<AbstractCompactionTask> getMaximalTask(int gcBefore, boolean splitOutput) {
Iterable<SSTableReader> filteredSSTables = filterSuspectSSTables(sstables);
if (Iterables.isEmpty(filteredSSTables))
return null;
LifecycleTransaction txn = cfs.getTracker().tryModify(filteredSSTables, OperationType.COMPACTION);
if (txn == null)
return null;
return Collections.singleton(new CompactionTask(cfs, txn, gcBefore));
}
use of org.apache.cassandra.db.lifecycle.LifecycleTransaction in project cassandra by apache.
the class SizeTieredCompactionStrategy method getNextBackgroundTask.
@SuppressWarnings("resource")
public AbstractCompactionTask getNextBackgroundTask(int gcBefore) {
while (true) {
List<SSTableReader> hottestBucket = getNextBackgroundSSTables(gcBefore);
if (hottestBucket.isEmpty())
return null;
LifecycleTransaction transaction = cfs.getTracker().tryModify(hottestBucket, OperationType.COMPACTION);
if (transaction != null)
return new CompactionTask(cfs, transaction, gcBefore);
}
}
use of org.apache.cassandra.db.lifecycle.LifecycleTransaction in project cassandra by apache.
the class DateTieredCompactionStrategy method getMaximalTask.
@Override
@SuppressWarnings("resource")
public synchronized Collection<AbstractCompactionTask> getMaximalTask(int gcBefore, boolean splitOutput) {
Iterable<SSTableReader> filteredSSTables = filterSuspectSSTables(sstables);
if (Iterables.isEmpty(filteredSSTables))
return null;
LifecycleTransaction txn = cfs.getTracker().tryModify(filteredSSTables, OperationType.COMPACTION);
if (txn == null)
return null;
return Collections.<AbstractCompactionTask>singleton(new CompactionTask(cfs, txn, gcBefore));
}
use of org.apache.cassandra.db.lifecycle.LifecycleTransaction in project cassandra by apache.
the class LeveledCompactionStrategy method getNextBackgroundTask.
/**
* the only difference between background and maximal in LCS is that maximal is still allowed
* (by explicit user request) even when compaction is disabled.
*/
// transaction is closed by AbstractCompactionTask::execute
@SuppressWarnings("resource")
public AbstractCompactionTask getNextBackgroundTask(int gcBefore) {
while (true) {
OperationType op;
LeveledManifest.CompactionCandidate candidate = manifest.getCompactionCandidates();
if (candidate == null) {
// if there is no sstable to compact in standard way, try compacting based on droppable tombstone ratio
SSTableReader sstable = findDroppableSSTable(gcBefore);
if (sstable == null) {
logger.trace("No compaction necessary for {}", this);
return null;
}
candidate = new LeveledManifest.CompactionCandidate(Collections.singleton(sstable), sstable.getSSTableLevel(), getMaxSSTableBytes());
op = OperationType.TOMBSTONE_COMPACTION;
} else {
op = OperationType.COMPACTION;
}
LifecycleTransaction txn = cfs.getTracker().tryModify(candidate.sstables, OperationType.COMPACTION);
if (txn != null) {
LeveledCompactionTask newTask = new LeveledCompactionTask(cfs, txn, candidate.level, gcBefore, candidate.maxSSTableBytes, false);
newTask.setCompactionType(op);
return newTask;
}
}
}
Aggregations