public class CompactionStrategyManager extends java.lang.Object implements INotificationConsumer
ReentrantReadWriteLock
. This lock performs mutual exclusion on
reads and writes to the following variables: this#repaired
, this#unrepaired
, this#isActive
,
this#params
, this#currentBoundaries
. Whenever performing reads on these variables,
the this#readLock
should be acquired. Likewise, updates to these variables should be guarded by
this#writeLock
.
Whenever the DiskBoundaries
change, the compaction strategies must be reloaded, so in order to ensure
the compaction strategy placement reflect most up-to-date disk boundaries, call this#maybeReloadDiskBoundaries()
before acquiring the read lock to acess the strategies.Modifier and Type | Field and Description |
---|---|
CompactionLogger |
compactionLogger |
Constructor and Description |
---|
CompactionStrategyManager(ColumnFamilyStore cfs) |
CompactionStrategyManager(ColumnFamilyStore cfs,
java.util.function.Supplier<DiskBoundaries> boundariesSupplier,
boolean partitionSSTablesByTokenRange) |
Modifier and Type | Method and Description |
---|---|
protected AbstractCompactionStrategy |
compactionStrategyFor(SSTableReader sstable) |
SSTableMultiWriter |
createSSTableMultiWriter(Descriptor descriptor,
long keyCount,
long repairedAt,
MetadataCollector collector,
SerializationHeader header,
java.util.Collection<Index> indexes,
LifecycleNewTracker lifecycleNewTracker) |
void |
disable() |
void |
enable() |
CompactionParams |
getCompactionParams() |
protected AbstractCompactionStrategy |
getCompactionStrategyFor(SSTableReader sstable)
return the compaction strategy for the given sstable
returns differently based on the repaired status and which vnode the compaction strategy belongs to
|
AbstractCompactionTask |
getCompactionTask(LifecycleTransaction txn,
int gcBefore,
long maxSSTableBytes) |
Directories |
getDirectories() |
int |
getEstimatedRemainingTasks() |
int |
getLevelFanoutSize() |
java.util.Collection<AbstractCompactionTask> |
getMaximalTasks(int gcBefore,
boolean splitOutput) |
long |
getMaxSSTableBytes() |
java.lang.String |
getName() |
AbstractCompactionTask |
getNextBackgroundTask(int gcBefore)
Return the next background task
Returns a task for the compaction strategy that needs it the most (most estimated remaining tasks)
|
AbstractCompactionStrategy.ScannerList |
getScanners(java.util.Collection<SSTableReader> sstables) |
AbstractCompactionStrategy.ScannerList |
getScanners(java.util.Collection<SSTableReader> sstables,
java.util.Collection<Range<Token>> ranges)
Create ISSTableScanners from the given sstables
Delegates the call to the compaction strategies to allow LCS to create a scanner
|
int[] |
getSSTableCountPerLevel() |
java.util.List<java.util.List<AbstractCompactionStrategy>> |
getStrategies() |
java.util.List<java.lang.String> |
getStrategyFolders(AbstractCompactionStrategy strategy) |
int |
getUnleveledSSTables() |
AbstractCompactionTask |
getUserDefinedTask(java.util.Collection<SSTableReader> sstables,
int gcBefore)
Deprecated.
use
getUserDefinedTasks(Collection, int) instead. |
java.util.List<AbstractCompactionTask> |
getUserDefinedTasks(java.util.Collection<SSTableReader> sstables,
int gcBefore)
Return a list of compaction tasks corresponding to the sstables requested.
|
java.util.List<AbstractCompactionTask> |
getUserDefinedTasks(java.util.Collection<SSTableReader> sstables,
int gcBefore,
boolean validateForCompaction) |
java.util.Collection<java.util.Collection<SSTableReader>> |
groupSSTablesForAntiCompaction(java.util.Collection<SSTableReader> sstablesToGroup) |
void |
handleNotification(INotification notification,
java.lang.Object sender) |
boolean |
isActive() |
boolean |
isEnabled() |
boolean |
isRepaired(AbstractCompactionStrategy strategy) |
void |
maybeReload(CFMetaData metadata) |
protected void |
maybeReloadDiskBoundaries()
Checks if the disk boundaries changed and reloads the compaction strategies
to reflect the most up-to-date disk boundaries.
|
boolean |
onlyPurgeRepairedTombstones() |
void |
pause()
pause compaction while we cancel all ongoing compactions
Separate call from enable/disable to not have to save the enabled-state externally
|
void |
replaceFlushed(Memtable memtable,
java.util.Collection<SSTableReader> sstables) |
void |
resume() |
void |
setNewLocalCompactionStrategy(CompactionParams params) |
boolean |
shouldBeEnabled() |
void |
shutdown() |
boolean |
supportsEarlyOpen() |
public final CompactionLogger compactionLogger
public CompactionStrategyManager(ColumnFamilyStore cfs)
public CompactionStrategyManager(ColumnFamilyStore cfs, java.util.function.Supplier<DiskBoundaries> boundariesSupplier, boolean partitionSSTablesByTokenRange)
public AbstractCompactionTask getNextBackgroundTask(int gcBefore)
public boolean isEnabled()
public boolean isActive()
public void resume()
public void pause()
protected AbstractCompactionStrategy getCompactionStrategyFor(SSTableReader sstable)
sstable
- protected AbstractCompactionStrategy compactionStrategyFor(SSTableReader sstable)
public void shutdown()
public void maybeReload(CFMetaData metadata)
protected void maybeReloadDiskBoundaries()
this#readLock
to ensure the most up-to-date
disk locations and boundaries are used.
This should *never* be called inside by a thread holding the this#readLock
, since it
will potentially acquire the this#writeLock
to update the compaction strategies
what can cause a deadlock.public void replaceFlushed(Memtable memtable, java.util.Collection<SSTableReader> sstables)
public int getUnleveledSSTables()
public int getLevelFanoutSize()
public int[] getSSTableCountPerLevel()
public Directories getDirectories()
public void handleNotification(INotification notification, java.lang.Object sender)
handleNotification
in interface INotificationConsumer
public void enable()
public void disable()
public AbstractCompactionStrategy.ScannerList getScanners(java.util.Collection<SSTableReader> sstables, java.util.Collection<Range<Token>> ranges)
sstables
- ranges
- public AbstractCompactionStrategy.ScannerList getScanners(java.util.Collection<SSTableReader> sstables)
public java.util.Collection<java.util.Collection<SSTableReader>> groupSSTablesForAntiCompaction(java.util.Collection<SSTableReader> sstablesToGroup)
public long getMaxSSTableBytes()
public AbstractCompactionTask getCompactionTask(LifecycleTransaction txn, int gcBefore, long maxSSTableBytes)
public java.util.Collection<AbstractCompactionTask> getMaximalTasks(int gcBefore, boolean splitOutput)
public java.util.List<AbstractCompactionTask> getUserDefinedTasks(java.util.Collection<SSTableReader> sstables, int gcBefore)
sstables
- the sstables to compactgcBefore
- gc grace period, throw away tombstones older than thispublic java.util.List<AbstractCompactionTask> getUserDefinedTasks(java.util.Collection<SSTableReader> sstables, int gcBefore, boolean validateForCompaction)
@Deprecated public AbstractCompactionTask getUserDefinedTask(java.util.Collection<SSTableReader> sstables, int gcBefore)
getUserDefinedTasks(Collection, int)
instead.public int getEstimatedRemainingTasks()
public boolean shouldBeEnabled()
public java.lang.String getName()
public java.util.List<java.util.List<AbstractCompactionStrategy>> getStrategies()
public void setNewLocalCompactionStrategy(CompactionParams params)
public CompactionParams getCompactionParams()
public boolean onlyPurgeRepairedTombstones()
public SSTableMultiWriter createSSTableMultiWriter(Descriptor descriptor, long keyCount, long repairedAt, MetadataCollector collector, SerializationHeader header, java.util.Collection<Index> indexes, LifecycleNewTracker lifecycleNewTracker)
public boolean isRepaired(AbstractCompactionStrategy strategy)
public java.util.List<java.lang.String> getStrategyFolders(AbstractCompactionStrategy strategy)
public boolean supportsEarlyOpen()
Copyright © 2009-2022 The Apache Software Foundation