Class UnifiedCompactionStrategy
- java.lang.Object
-
- org.apache.cassandra.db.compaction.AbstractCompactionStrategy
-
- org.apache.cassandra.db.compaction.UnifiedCompactionStrategy
-
public class UnifiedCompactionStrategy extends AbstractCompactionStrategy
The design of the unified compaction strategy is described in the accompanying UnifiedCompactionStrategy.md. See CEP-26: https://cwiki.apache.org/confluence/display/CASSANDRA/CEP-26%3A+Unified+Compaction+Strategy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UnifiedCompactionStrategy.Level
A level: index, sstables and some properties.static class
UnifiedCompactionStrategy.MultiSetBucket
static class
UnifiedCompactionStrategy.SimpleBucket
-
Nested classes/interfaces inherited from class org.apache.cassandra.db.compaction.AbstractCompactionStrategy
AbstractCompactionStrategy.ScannerList
-
-
Field Summary
Fields Modifier and Type Field Description protected int
estimatedRemainingTasks
protected java.util.Set<SSTableReader>
sstables
-
Fields inherited from class org.apache.cassandra.db.compaction.AbstractCompactionStrategy
cfs, COMPACTION_ENABLED, DEFAULT_LOG_ALL_OPTION, DEFAULT_TOMBSTONE_COMPACTION_INTERVAL, DEFAULT_TOMBSTONE_THRESHOLD, DEFAULT_UNCHECKED_TOMBSTONE_COMPACTION_OPTION, disableTombstoneCompactions, isActive, LOG_ALL_OPTION, logAll, ONLY_PURGE_REPAIRED_TOMBSTONES, options, TOMBSTONE_COMPACTION_INTERVAL_OPTION, TOMBSTONE_THRESHOLD_OPTION, tombstoneCompactionInterval, tombstoneThreshold, UNCHECKED_TOMBSTONE_COMPACTION_OPTION, uncheckedTombstoneCompaction
-
-
Constructor Summary
Constructors Constructor Description UnifiedCompactionStrategy(ColumnFamilyStore cfs, java.util.Map<java.lang.String,java.lang.String> options)
UnifiedCompactionStrategy(ColumnFamilyStore cfs, java.util.Map<java.lang.String,java.lang.String> options, Controller controller)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSSTable(SSTableReader added)
Adds sstable, note that implementations must handle duplicate notifications here (added already being in the compaction strategy)SSTableMultiWriter
createSSTableMultiWriter(Descriptor descriptor, long keyCount, long repairedAt, TimeUUID pendingRepair, boolean isTransient, IntervalSet<CommitLogPosition> commitLogPositions, int sstableLevel, SerializationHeader header, java.util.Collection<Index.Group> indexGroups, LifecycleNewTracker lifecycleNewTracker)
Create the sstable writer used for flushing.static int
fanoutFromScalingParameter(int w)
Controller
getController()
int
getEstimatedRemainingTasks()
java.util.List<UnifiedCompactionStrategy.Level>
getLevels(java.util.Collection<SSTableReader> sstables, com.google.common.base.Predicate<SSTableReader> compactionFilter)
Groups the sstables passed in into levels.java.util.Collection<AbstractCompactionTask>
getMaximalTask(long gcBefore, boolean splitOutput)
long
getMaxSSTableBytes()
TableMetadata
getMetadata()
UnifiedCompactionTask
getNextBackgroundTask(long gcBefore)
Returns a compaction task to run next.protected java.util.Set<SSTableReader>
getSSTables()
Returns the sstables managed by this strategy instanceAbstractCompactionTask
getUserDefinedTask(java.util.Collection<SSTableReader> sstables, long gcBefore)
static boolean
isSuitableForCompaction(SSTableReader rdr)
static int
parseScalingParameter(java.lang.String value)
static java.lang.String
printScalingParameter(int w)
void
removeSSTable(SSTableReader sstable)
Removes sstable from the strategy, implementations must be able to handle the sstable having already been removed.static int
thresholdFromScalingParameter(int w)
java.lang.String
toString()
static java.util.Map<java.lang.String,java.lang.String>
validateOptions(java.util.Map<java.lang.String,java.lang.String> options)
-
Methods inherited from class org.apache.cassandra.db.compaction.AbstractCompactionStrategy
addSSTables, filterSuspectSSTables, getCompactionTask, getDirectories, getName, getScanners, getScanners, getScanners, groupSSTablesForAntiCompaction, metadataChanged, pause, removeSSTables, replaceSSTables, resume, shutdown, startup, strategyLogger, supportsEarlyOpen, worthDroppingTombstones
-
-
-
-
Field Detail
-
estimatedRemainingTasks
protected volatile int estimatedRemainingTasks
-
sstables
protected final java.util.Set<SSTableReader> sstables
-
-
Constructor Detail
-
UnifiedCompactionStrategy
public UnifiedCompactionStrategy(ColumnFamilyStore cfs, java.util.Map<java.lang.String,java.lang.String> options)
-
UnifiedCompactionStrategy
public UnifiedCompactionStrategy(ColumnFamilyStore cfs, java.util.Map<java.lang.String,java.lang.String> options, Controller controller)
-
-
Method Detail
-
validateOptions
public static java.util.Map<java.lang.String,java.lang.String> validateOptions(java.util.Map<java.lang.String,java.lang.String> options) throws ConfigurationException
- Throws:
ConfigurationException
-
fanoutFromScalingParameter
public static int fanoutFromScalingParameter(int w)
-
thresholdFromScalingParameter
public static int thresholdFromScalingParameter(int w)
-
parseScalingParameter
public static int parseScalingParameter(java.lang.String value)
-
printScalingParameter
public static java.lang.String printScalingParameter(int w)
-
getMaximalTask
public java.util.Collection<AbstractCompactionTask> getMaximalTask(long gcBefore, boolean splitOutput)
- Specified by:
getMaximalTask
in classAbstractCompactionStrategy
- Parameters:
gcBefore
- throw away tombstones older than this- Returns:
- a compaction task that should be run to compact this columnfamilystore as much as possible. Null if nothing to do. Is responsible for marking its sstables as compaction-pending.
-
getUserDefinedTask
public AbstractCompactionTask getUserDefinedTask(java.util.Collection<SSTableReader> sstables, long gcBefore)
- Specified by:
getUserDefinedTask
in classAbstractCompactionStrategy
- Parameters:
sstables
- SSTables to compact. Must be marked as compacting.gcBefore
- throw away tombstones older than this- Returns:
- a compaction task corresponding to the requested sstables. Will not be null. (Will throw if user requests an invalid compaction.) Is responsible for marking its sstables as compaction-pending.
-
getNextBackgroundTask
public UnifiedCompactionTask getNextBackgroundTask(long gcBefore)
Returns a compaction task to run next. This method is synchronized because task creation is significantly more expensive in UCS; the strategy is stateless, therefore it has to compute the shard/bucket structure on each call.- Specified by:
getNextBackgroundTask
in classAbstractCompactionStrategy
- Parameters:
gcBefore
- throw away tombstones older than this- Returns:
- the next background/minor compaction task to run; null if nothing to do. Is responsible for marking its sstables as compaction-pending.
-
createSSTableMultiWriter
public SSTableMultiWriter createSSTableMultiWriter(Descriptor descriptor, long keyCount, long repairedAt, TimeUUID pendingRepair, boolean isTransient, IntervalSet<CommitLogPosition> commitLogPositions, int sstableLevel, SerializationHeader header, java.util.Collection<Index.Group> indexGroups, LifecycleNewTracker lifecycleNewTracker)
Create the sstable writer used for flushing.- Overrides:
createSSTableMultiWriter
in classAbstractCompactionStrategy
- Returns:
- an sstable writer that will split sstables into a number of shards as calculated by the controller for the expected flush density.
-
getEstimatedRemainingTasks
public int getEstimatedRemainingTasks()
- Specified by:
getEstimatedRemainingTasks
in classAbstractCompactionStrategy
- Returns:
- the number of background tasks estimated to still be needed for this columnfamilystore
-
getMaxSSTableBytes
public long getMaxSSTableBytes()
- Specified by:
getMaxSSTableBytes
in classAbstractCompactionStrategy
- Returns:
- size in bytes of the largest sstables for this strategy
-
getController
public Controller getController()
-
isSuitableForCompaction
public static boolean isSuitableForCompaction(SSTableReader rdr)
-
addSSTable
public void addSSTable(SSTableReader added)
Description copied from class:AbstractCompactionStrategy
Adds sstable, note that implementations must handle duplicate notifications here (added already being in the compaction strategy)- Specified by:
addSSTable
in classAbstractCompactionStrategy
-
removeSSTable
public void removeSSTable(SSTableReader sstable)
Description copied from class:AbstractCompactionStrategy
Removes sstable from the strategy, implementations must be able to handle the sstable having already been removed.- Specified by:
removeSSTable
in classAbstractCompactionStrategy
-
getSSTables
protected java.util.Set<SSTableReader> getSSTables()
Description copied from class:AbstractCompactionStrategy
Returns the sstables managed by this strategy instance- Specified by:
getSSTables
in classAbstractCompactionStrategy
-
getLevels
public java.util.List<UnifiedCompactionStrategy.Level> getLevels(java.util.Collection<SSTableReader> sstables, com.google.common.base.Predicate<SSTableReader> compactionFilter)
Groups the sstables passed in into levels. This is used by the strategy to determine new compactions, and by external tools to analyze the strategy decisions.- Parameters:
sstables
- a collection of the sstables to be assigned to levelscompactionFilter
- a filter to exclude CompactionSSTables, e.g.,isSuitableForCompaction(org.apache.cassandra.io.sstable.format.SSTableReader)
- Returns:
- a list of the levels in the compaction hierarchy
-
getMetadata
public TableMetadata getMetadata()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-