public class CompactionManager extends java.lang.Object implements CompactionManagerMBean
A singleton which manages a private executor of ongoing compactions.
Scheduling for compaction is accomplished by swapping sstables to be compacted into a set via Tracker. New scheduling attempts will ignore currently compacting sstables.| Modifier and Type | Class and Description | 
|---|---|
| static class  | CompactionManager.AllSSTableOpStatus | 
| static interface  | CompactionManager.CompactionExecutorStatsCollector | 
| Modifier and Type | Field and Description | 
|---|---|
| static int | GC_ALL | 
| static CompactionManager | instance | 
| static io.netty.util.concurrent.FastThreadLocal<java.lang.Boolean> | isCompactionManager | 
| static java.lang.String | MBEAN_OBJECT_NAME | 
| static int | NO_GC | 
| Constructor and Description | 
|---|
| CompactionManager() | 
| Modifier and Type | Method and Description | 
|---|---|
| static SSTableWriter | createWriter(ColumnFamilyStore cfs,
            java.io.File compactionFileLocation,
            long expectedBloomFilterSize,
            long repairedAt,
            SSTableReader sstable,
            LifecycleTransaction txn) | 
| static SSTableWriter | createWriterForAntiCompaction(ColumnFamilyStore cfs,
                             java.io.File compactionFileLocation,
                             int expectedBloomFilterSize,
                             long repairedAt,
                             java.util.Collection<SSTableReader> sstables,
                             LifecycleTransaction txn) | 
| void | disableAutoCompaction() | 
| void | finishCompactionsAndShutdown(long timeout,
                            java.util.concurrent.TimeUnit unit) | 
| void | forceCompactionForTokenRange(ColumnFamilyStore cfStore,
                            java.util.Collection<Range<Token>> ranges) | 
| void | forceShutdown()Shutdowns both compaction and validation executors, cancels running compaction / validation,
 and waits for tasks to complete if tasks were not cancelable. | 
| void | forceUserDefinedCleanup(java.lang.String dataFiles)Triggers the cleanup of user specified sstables. | 
| void | forceUserDefinedCompaction(java.lang.String dataFiles)Triggers the compaction of user specified sstables. | 
| int | getActiveCompactions() | 
| javax.management.openmbean.TabularData | getCompactionHistory()compaction history | 
| java.util.List<java.util.Map<java.lang.String,java.lang.String>> | getCompactions()List of running compaction objects. | 
| java.util.List<java.lang.String> | getCompactionSummary()List of running compaction summary strings. | 
| long | getCompletedTasks() | 
| int | getCoreCompactorThreads()Returns core size of compaction thread pool | 
| int | getCoreValidationThreads()Returns core size of validation thread pool | 
| static int | getDefaultGcBefore(ColumnFamilyStore cfs,
                  int nowInSec) | 
| int | getMaximumCompactorThreads()Returns maximum size of compaction thread pool | 
| int | getMaximumValidatorThreads()Returns size of validator thread pool | 
| int | getPendingTasks() | 
| com.google.common.util.concurrent.RateLimiter | getRateLimiter()Gets compaction rate limiter. | 
| long | getTotalBytesCompacted() | 
| long | getTotalCompactionsCompleted() | 
| void | interruptCompactionFor(java.lang.Iterable<CFMetaData> columnFamilies,
                      boolean interruptValidation)Try to stop all of the compactions for given ColumnFamilies. | 
| void | interruptCompactionForCFs(java.lang.Iterable<ColumnFamilyStore> cfss,
                         boolean interruptValidation) | 
| boolean | isCompacting(java.lang.Iterable<ColumnFamilyStore> cfses) | 
| static boolean | needsCleanup(SSTableReader sstable,
            java.util.Collection<Range<Token>> ownedRanges)Determines if a cleanup would actually remove any data in this SSTable based
 on a set of owned ranges. | 
| void | performAnticompaction(ColumnFamilyStore cfs,
                     java.util.Collection<Range<Token>> ranges,
                     Refs<SSTableReader> validatedForRepair,
                     LifecycleTransaction txn,
                     long repairedAt,
                     java.util.UUID parentRepairSession)Make sure the {validatedForRepair} are marked for compaction before calling this. | 
| CompactionManager.AllSSTableOpStatus | performCleanup(ColumnFamilyStore cfStore,
              int jobs) | 
| CompactionManager.AllSSTableOpStatus | performGarbageCollection(ColumnFamilyStore cfStore,
                        CompactionParams.TombstoneOption tombstoneOption,
                        int jobs) | 
| void | performMaximal(ColumnFamilyStore cfStore,
              boolean splitOutput) | 
| CompactionManager.AllSSTableOpStatus | performScrub(ColumnFamilyStore cfs,
            boolean skipCorrupted,
            boolean checkData,
            boolean reinsertOverflowedTTL,
            int jobs) | 
| CompactionManager.AllSSTableOpStatus | performScrub(ColumnFamilyStore cfs,
            boolean skipCorrupted,
            boolean checkData,
            int jobs) | 
| CompactionManager.AllSSTableOpStatus | performSSTableRewrite(ColumnFamilyStore cfs,
                     boolean excludeCurrentVersion,
                     int jobs) | 
| CompactionManager.AllSSTableOpStatus | performVerify(ColumnFamilyStore cfs,
             boolean extendedVerify) | 
| CompactionManager.AllSSTableOpStatus | relocateSSTables(ColumnFamilyStore cfs,
                int jobs) | 
| java.util.List<SSTableReader> | runIndexSummaryRedistribution(IndexSummaryRedistribution redistribution) | 
| void | setConcurrentCompactors(int value) | 
| void | setCoreCompactorThreads(int number)Allows user to resize maximum size of the compaction thread pool. | 
| void | setCoreValidationThreads(int number)Allows user to resize maximum size of the compaction thread pool. | 
| void | setMaximumCompactorThreads(int number)Allows user to resize maximum size of the compaction thread pool. | 
| void | setMaximumValidatorThreads(int number)Allows user to resize maximum size of the validator thread pool. | 
| void | setRate(double throughPutMbPerSec)Sets the rate for the rate limiter. | 
| void | stopCompaction(java.lang.String type)Stop all running compaction-like tasks having the provided  type. | 
| void | stopCompactionById(java.lang.String compactionId)Stop an individual running compaction using the compactionId. | 
| com.google.common.util.concurrent.ListenableFuture<?> | submitAntiCompaction(ColumnFamilyStore cfs,
                    java.util.Collection<Range<Token>> ranges,
                    Refs<SSTableReader> sstables,
                    long repairedAt,
                    java.util.UUID parentRepairSession) | 
| java.util.List<java.util.concurrent.Future<?>> | submitBackground(ColumnFamilyStore cfs)Call this whenever a compaction might be needed on the given columnfamily. | 
| java.util.concurrent.Future<?> | submitCacheWrite(AutoSavingCache.Writer writer) | 
| java.util.concurrent.Future<?> | submitIndexBuild(SecondaryIndexBuilder builder)Is not scheduled, because it is performing disjoint work from sstable compaction. | 
| java.util.List<java.util.concurrent.Future<?>> | submitMaximal(ColumnFamilyStore cfStore,
             int gcBefore,
             boolean splitOutput) | 
| java.util.concurrent.Future<?> | submitUserDefined(ColumnFamilyStore cfs,
                 java.util.Collection<Descriptor> dataFiles,
                 int gcBefore) | 
| java.util.concurrent.Future<?> | submitValidation(ColumnFamilyStore cfStore,
                Validator validator)Does not mutate data, so is not scheduled. | 
| java.util.concurrent.Future<?> | submitViewBuilder(ViewBuilder builder) | 
| void | waitForCessation(java.lang.Iterable<ColumnFamilyStore> cfss) | 
public static final java.lang.String MBEAN_OBJECT_NAME
public static final CompactionManager instance
public static final int NO_GC
public static final int GC_ALL
public static final io.netty.util.concurrent.FastThreadLocal<java.lang.Boolean> isCompactionManager
public com.google.common.util.concurrent.RateLimiter getRateLimiter()
public void setRate(double throughPutMbPerSec)
throughPutMbPerSec - throughput to set in mb per secondpublic java.util.List<java.util.concurrent.Future<?>> submitBackground(ColumnFamilyStore cfs)
public boolean isCompacting(java.lang.Iterable<ColumnFamilyStore> cfses)
public void forceShutdown()
public void finishCompactionsAndShutdown(long timeout,
                                         java.util.concurrent.TimeUnit unit)
                                  throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic CompactionManager.AllSSTableOpStatus performScrub(ColumnFamilyStore cfs, boolean skipCorrupted, boolean checkData, int jobs) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic CompactionManager.AllSSTableOpStatus performScrub(ColumnFamilyStore cfs, boolean skipCorrupted, boolean checkData, boolean reinsertOverflowedTTL, int jobs) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic CompactionManager.AllSSTableOpStatus performVerify(ColumnFamilyStore cfs, boolean extendedVerify) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic CompactionManager.AllSSTableOpStatus performSSTableRewrite(ColumnFamilyStore cfs, boolean excludeCurrentVersion, int jobs) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic CompactionManager.AllSSTableOpStatus performCleanup(ColumnFamilyStore cfStore, int jobs) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic CompactionManager.AllSSTableOpStatus performGarbageCollection(ColumnFamilyStore cfStore, CompactionParams.TombstoneOption tombstoneOption, int jobs) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic CompactionManager.AllSSTableOpStatus relocateSSTables(ColumnFamilyStore cfs, int jobs) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
java.util.concurrent.ExecutionExceptionjava.lang.InterruptedExceptionpublic com.google.common.util.concurrent.ListenableFuture<?> submitAntiCompaction(ColumnFamilyStore cfs, java.util.Collection<Range<Token>> ranges, Refs<SSTableReader> sstables, long repairedAt, java.util.UUID parentRepairSession)
public void performAnticompaction(ColumnFamilyStore cfs, java.util.Collection<Range<Token>> ranges, Refs<SSTableReader> validatedForRepair, LifecycleTransaction txn, long repairedAt, java.util.UUID parentRepairSession) throws java.lang.InterruptedException, java.io.IOException
cfs - ranges - Ranges that the repair was carried out onvalidatedForRepair - SSTables containing the repaired ranges. Should be referenced before passing them.parentRepairSession - parent repair session IDjava.lang.InterruptedExceptionjava.io.IOExceptionpublic void performMaximal(ColumnFamilyStore cfStore, boolean splitOutput)
public java.util.List<java.util.concurrent.Future<?>> submitMaximal(ColumnFamilyStore cfStore, int gcBefore, boolean splitOutput)
public void forceCompactionForTokenRange(ColumnFamilyStore cfStore, java.util.Collection<Range<Token>> ranges)
public void forceUserDefinedCompaction(java.lang.String dataFiles)
CompactionManagerMBeanforceUserDefinedCompaction in interface CompactionManagerMBeandataFiles - a comma separated list of sstable file to compact.
                  must contain keyspace and columnfamily name in path(for 2.1+) or file name itself.public void forceUserDefinedCleanup(java.lang.String dataFiles)
CompactionManagerMBeanforceUserDefinedCleanup in interface CompactionManagerMBeandataFiles - a comma separated list of sstable file to cleanup.
                  must contain keyspace and columnfamily name in path(for 2.1+) or file name itself.public java.util.concurrent.Future<?> submitUserDefined(ColumnFamilyStore cfs, java.util.Collection<Descriptor> dataFiles, int gcBefore)
public java.util.concurrent.Future<?> submitValidation(ColumnFamilyStore cfStore, Validator validator)
public void disableAutoCompaction()
public static boolean needsCleanup(SSTableReader sstable, java.util.Collection<Range<Token>> ownedRanges)
public static SSTableWriter createWriter(ColumnFamilyStore cfs, java.io.File compactionFileLocation, long expectedBloomFilterSize, long repairedAt, SSTableReader sstable, LifecycleTransaction txn)
public static SSTableWriter createWriterForAntiCompaction(ColumnFamilyStore cfs, java.io.File compactionFileLocation, int expectedBloomFilterSize, long repairedAt, java.util.Collection<SSTableReader> sstables, LifecycleTransaction txn)
public java.util.concurrent.Future<?> submitIndexBuild(SecondaryIndexBuilder builder)
public java.util.concurrent.Future<?> submitCacheWrite(AutoSavingCache.Writer writer)
public java.util.List<SSTableReader> runIndexSummaryRedistribution(IndexSummaryRedistribution redistribution) throws java.io.IOException
java.io.IOExceptionpublic static int getDefaultGcBefore(ColumnFamilyStore cfs, int nowInSec)
public java.util.concurrent.Future<?> submitViewBuilder(ViewBuilder builder)
public int getActiveCompactions()
public java.util.List<java.util.Map<java.lang.String,java.lang.String>> getCompactions()
CompactionManagerMBeangetCompactions in interface CompactionManagerMBeanpublic java.util.List<java.lang.String> getCompactionSummary()
CompactionManagerMBeangetCompactionSummary in interface CompactionManagerMBeanpublic javax.management.openmbean.TabularData getCompactionHistory()
CompactionManagerMBeangetCompactionHistory in interface CompactionManagerMBeanpublic long getTotalBytesCompacted()
public long getTotalCompactionsCompleted()
public int getPendingTasks()
public long getCompletedTasks()
public void stopCompaction(java.lang.String type)
CompactionManagerMBeantype.stopCompaction in interface CompactionManagerMBeantype - the type of compaction to stop. Can be one of:
   - COMPACTION
   - VALIDATION
   - CLEANUP
   - SCRUB
   - INDEX_BUILDpublic void stopCompactionById(java.lang.String compactionId)
CompactionManagerMBeanstopCompactionById in interface CompactionManagerMBeancompactionId - Compaction ID of compaction to stop. Such IDs can be found in
                     the transaction log files whose name starts with compaction_,
                     located in the table transactions folder.public void setConcurrentCompactors(int value)
public int getCoreCompactorThreads()
CompactionManagerMBeangetCoreCompactorThreads in interface CompactionManagerMBeanpublic void setCoreCompactorThreads(int number)
CompactionManagerMBeansetCoreCompactorThreads in interface CompactionManagerMBeannumber - New maximum of compaction threadspublic int getMaximumCompactorThreads()
CompactionManagerMBeangetMaximumCompactorThreads in interface CompactionManagerMBeanpublic void setMaximumCompactorThreads(int number)
CompactionManagerMBeansetMaximumCompactorThreads in interface CompactionManagerMBeannumber - New maximum of compaction threadspublic int getCoreValidationThreads()
CompactionManagerMBeangetCoreValidationThreads in interface CompactionManagerMBeanpublic void setCoreValidationThreads(int number)
CompactionManagerMBeansetCoreValidationThreads in interface CompactionManagerMBeannumber - New maximum of compaction threadspublic int getMaximumValidatorThreads()
CompactionManagerMBeangetMaximumValidatorThreads in interface CompactionManagerMBeanpublic void setMaximumValidatorThreads(int number)
CompactionManagerMBeansetMaximumValidatorThreads in interface CompactionManagerMBeannumber - New maximum of validator threadspublic void interruptCompactionFor(java.lang.Iterable<CFMetaData> columnFamilies, boolean interruptValidation)
columnFamilies - The ColumnFamilies to try to stop compaction upon.interruptValidation - true if validation operations for repair should also be interruptedpublic void interruptCompactionForCFs(java.lang.Iterable<ColumnFamilyStore> cfss, boolean interruptValidation)
public void waitForCessation(java.lang.Iterable<ColumnFamilyStore> cfss)
Copyright © 2018 The Apache Software Foundation