Class UnifiedCompactionStrategy
java.lang.Object
org.apache.cassandra.db.compaction.AbstractCompactionStrategy
org.apache.cassandra.db.compaction.UnifiedCompactionStrategy
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 ClassesModifier and TypeClassDescriptionstatic classA level: index, sstables and some properties.static classstatic classNested classes/interfaces inherited from class org.apache.cassandra.db.compaction.AbstractCompactionStrategy
AbstractCompactionStrategy.ScannerList -
Field Summary
FieldsFields 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
ConstructorsConstructorDescriptionUnifiedCompactionStrategy(ColumnFamilyStore cfs, Map<String, String> options) UnifiedCompactionStrategy(ColumnFamilyStore cfs, Map<String, String> options, Controller controller) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSSTable(SSTableReader added) Adds sstable, note that implementations must handle duplicate notifications here (added already being in the compaction strategy)createSSTableMultiWriter(Descriptor descriptor, long keyCount, long repairedAt, TimeUUID pendingRepair, boolean isTransient, IntervalSet<CommitLogPosition> commitLogPositions, int sstableLevel, SerializationHeader header, Collection<Index.Group> indexGroups, LifecycleNewTracker lifecycleNewTracker) Create the sstable writer used for flushing.static intfanoutFromScalingParameter(int w) intgetLevels(Collection<SSTableReader> sstables, com.google.common.base.Predicate<SSTableReader> compactionFilter) Groups the sstables passed in into levels.getMaximalTask(long gcBefore, boolean splitOutput) longgetNextBackgroundTask(long gcBefore) Returns a compaction task to run next.protected Set<SSTableReader>Returns the sstables managed by this strategy instancegetUserDefinedTask(Collection<SSTableReader> sstables, long gcBefore) static booleanstatic intparseScalingParameter(String value) static StringprintScalingParameter(int w) voidremoveSSTable(SSTableReader sstable) Removes sstable from the strategy, implementations must be able to handle the sstable having already been removed.static inttoString()validateOptions(Map<String, 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 Details
-
estimatedRemainingTasks
protected volatile int estimatedRemainingTasks -
sstables
-
-
Constructor Details
-
UnifiedCompactionStrategy
-
UnifiedCompactionStrategy
public UnifiedCompactionStrategy(ColumnFamilyStore cfs, Map<String, String> options, Controller controller)
-
-
Method Details
-
validateOptions
public static Map<String,String> validateOptions(Map<String, String> options) throws ConfigurationException- Throws:
ConfigurationException
-
fanoutFromScalingParameter
public static int fanoutFromScalingParameter(int w) -
thresholdFromScalingParameter
public static int thresholdFromScalingParameter(int w) -
parseScalingParameter
-
printScalingParameter
-
getMaximalTask
- Specified by:
getMaximalTaskin 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
- Specified by:
getUserDefinedTaskin 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
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:
getNextBackgroundTaskin 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, Collection<Index.Group> indexGroups, LifecycleNewTracker lifecycleNewTracker) Create the sstable writer used for flushing.- Overrides:
createSSTableMultiWriterin 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:
getEstimatedRemainingTasksin classAbstractCompactionStrategy- Returns:
- the number of background tasks estimated to still be needed for this columnfamilystore
-
getMaxSSTableBytes
public long getMaxSSTableBytes()- Specified by:
getMaxSSTableBytesin classAbstractCompactionStrategy- Returns:
- size in bytes of the largest sstables for this strategy
-
getController
-
isSuitableForCompaction
-
addSSTable
Description copied from class:AbstractCompactionStrategyAdds sstable, note that implementations must handle duplicate notifications here (added already being in the compaction strategy)- Specified by:
addSSTablein classAbstractCompactionStrategy
-
removeSSTable
Description copied from class:AbstractCompactionStrategyRemoves sstable from the strategy, implementations must be able to handle the sstable having already been removed.- Specified by:
removeSSTablein classAbstractCompactionStrategy
-
getSSTables
Description copied from class:AbstractCompactionStrategyReturns the sstables managed by this strategy instance- Specified by:
getSSTablesin classAbstractCompactionStrategy
-
getLevels
public List<UnifiedCompactionStrategy.Level> getLevels(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
-
toString
-