org.apache.cassandra.db.compaction

## Class CompactionTask

- java.lang.Object
- - org.apache.cassandra.utils.WrappedRunnable
  - - org.apache.cassandra.db.compaction.AbstractCompactionTask
    - - org.apache.cassandra.db.compaction.CompactionTask

All Implemented Interfaces:
  java.lang.Runnable

Direct Known Subclasses:
  LeveledCompactionTask, SSTableSplitter.SplittingCompactionTask, TimeWindowCompactionTask

    public class CompactionTask
    extends AbstractCompactionTask

### Field Summary

Fields
`protected int` `gcBefore`
`protected boolean` `keepOriginals`
`protected static org.slf4j.Logger` `logger`
`protected static long` `totalBytesCompacted`

### Fields inherited from class org.apache.cassandra.db.compaction.AbstractCompactionTask

`cfs, compactionType, isUserDefined, transaction`

### Constructor Summary

Constructors
Constructor and Description
`CompactionTask(ColumnFamilyStore cfs, LifecycleTransaction txn, int gcBefore)`
`CompactionTask(ColumnFamilyStore cfs, LifecycleTransaction txn, int gcBefore, boolean keepOriginals)`
`CompactionTask(ColumnFamilyStore cfs, LifecycleTransaction txn, int gcBefore, boolean offline, boolean keepOriginals)` Deprecated.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static long` `addToTotalBytesCompacted(long bytesCompacted)`
`protected void` `checkAvailableDiskSpace()`
`protected int` `executeInternal(CompactionManager.CompactionExecutorStatsCollector collector)`
`CompactionAwareWriter` `getCompactionAwareWriter(ColumnFamilyStore cfs, Directories directories, LifecycleTransaction transaction, java.util.Set<SSTableReader> nonExpiredSSTables)`
`protected CompactionController` `getCompactionController(java.util.Set<SSTableReader> toCompact)`
`protected Directories` `getDirectories()`
`protected int` `getLevel()`
`static long` `getMaxDataAge(java.util.Collection<SSTableReader> sstables)`
`static long` `getMinRepairedAt(java.util.Set<SSTableReader> actuallyCompact)`
`protected boolean` `partialCompactionsAcceptable()`
`boolean` `reduceScopeForLimitedSpace(long expectedSize)`
`protected void` `runMayThrow()` For internal use and testing only.
`static java.lang.String` `updateCompactionHistory(java.lang.String keyspaceName, java.lang.String columnFamilyName, long[] mergedRowCounts, long startSize, long endSize)`

### Methods inherited from class org.apache.cassandra.db.compaction.AbstractCompactionTask

`execute, setCompactionType, setUserDefined, toString`

### Methods inherited from class org.apache.cassandra.utils.WrappedRunnable

`run`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### logger

    protected static final org.slf4j.Logger logger

#### gcBefore

    protected final int gcBefore

#### keepOriginals

    protected final boolean keepOriginals

#### totalBytesCompacted

    protected static long totalBytesCompacted

### Constructor Detail

#### CompactionTask

    public CompactionTask(ColumnFamilyStore cfs,
                          LifecycleTransaction txn,
                          int gcBefore)

#### CompactionTask

    @Deprecated
    public CompactionTask(ColumnFamilyStore cfs,
                                      LifecycleTransaction txn,
                                      int gcBefore,
                                      boolean offline,
                                      boolean keepOriginals)

Deprecated.

#### CompactionTask

    public CompactionTask(ColumnFamilyStore cfs,
                          LifecycleTransaction txn,
                          int gcBefore,
                          boolean keepOriginals)

### Method Detail

#### addToTotalBytesCompacted

    public static long addToTotalBytesCompacted(long bytesCompacted)

#### executeInternal

    protected int executeInternal(CompactionManager.CompactionExecutorStatsCollector collector)

Specified by:
  `executeInternal` in class `AbstractCompactionTask`

#### reduceScopeForLimitedSpace

    public boolean reduceScopeForLimitedSpace(long expectedSize)

#### runMayThrow

    protected void runMayThrow()
                        throws java.lang.Exception

For internal use and testing only. The rest of the system should go through the submit* methods, which are properly serialized. Caller is in charge of marking/unmarking the sstables as compacting.

Specified by:
  `runMayThrow` in class `WrappedRunnable`
Throws:
  `java.lang.Exception`

#### getCompactionAwareWriter

    public CompactionAwareWriter getCompactionAwareWriter(ColumnFamilyStore cfs,
                                                          Directories directories,
                                                          LifecycleTransaction transaction,
                                                          java.util.Set<SSTableReader> nonExpiredSSTables)

Specified by:
  `getCompactionAwareWriter` in class `AbstractCompactionTask`

#### updateCompactionHistory

    public static java.lang.String updateCompactionHistory(java.lang.String keyspaceName,
                                                           java.lang.String columnFamilyName,
                                                           long[] mergedRowCounts,
                                                           long startSize,
                                                           long endSize)

#### getDirectories

    protected Directories getDirectories()

#### getMinRepairedAt

    public static long getMinRepairedAt(java.util.Set<SSTableReader> actuallyCompact)

#### checkAvailableDiskSpace

    protected void checkAvailableDiskSpace()

#### getLevel

    protected int getLevel()

#### getCompactionController

    protected CompactionController getCompactionController(java.util.Set<SSTableReader> toCompact)

#### partialCompactionsAcceptable

    protected boolean partialCompactionsAcceptable()

#### getMaxDataAge

    public static long getMaxDataAge(java.util.Collection<SSTableReader> sstables)