org.apache.cassandra.db.compaction
Class CompactionManager

java.lang.Object
  extended by org.apache.cassandra.db.compaction.CompactionManager
All Implemented Interfaces:
CompactionManagerMBean

public class CompactionManager
extends java.lang.Object
implements CompactionManagerMBean

A singleton which manages a private executor of ongoing compactions. A readwrite lock controls whether compactions can proceed: an external consumer can completely stop compactions by acquiring the write half of the lock via getCompactionLock(). Scheduling for compaction is accomplished by swapping sstables to be compacted into a set via DataTracker. New scheduling attempts will ignore currently compacting sstables.


Field Summary
static CompactionManager instance
           
static java.lang.String MBEAN_OBJECT_NAME
           
 
Constructor Summary
CompactionManager()
           
 
Method Summary
 void disableAutoCompaction()
           
 void forceUserDefinedCompaction(java.lang.String ksname, java.lang.String dataFiles)
          Triggers the compaction of user specified sstables.
 int getActiveCompactions()
           
 java.util.concurrent.locks.Lock getCompactionLock()
           
 java.util.List<CompactionInfo> getCompactions()
          List of running compaction objects.
 java.util.List<java.lang.String> getCompactionSummary()
          List of running compaction summary strings.
 long getCompletedTasks()
           
 int getPendingTasks()
           
 void performCleanup(ColumnFamilyStore cfStore, NodeId.OneShotRenewer renewer)
           
 void performMajor(ColumnFamilyStore cfStore)
           
 void performScrub(ColumnFamilyStore cfStore)
           
 java.util.concurrent.Future<?> submitCacheWrite(AutoSavingCache.Writer writer)
           
 java.util.concurrent.Future submitIndexBuild(ColumnFamilyStore cfs, Table.IndexBuilder builder)
          Is not scheduled, because it is performing disjoint work from sstable compaction.
 java.util.concurrent.Future<java.lang.Object> submitMajor(ColumnFamilyStore cfStore, long skip, int gcBefore)
           
 java.util.concurrent.Future<java.lang.Integer> submitMinorIfNeeded(ColumnFamilyStore cfs)
          Call this whenever a compaction might be needed on the given columnfamily.
 java.util.concurrent.Future<SSTableReader> submitSSTableBuild(Descriptor desc, OperationType type)
          Submits an sstable to be rebuilt: is not scheduled, since the sstable must not exist.
 java.util.concurrent.Future<?> submitTruncate(ColumnFamilyStore main, long truncatedAt)
           
 java.util.concurrent.Future<java.lang.Object> submitUserDefined(ColumnFamilyStore cfs, java.util.Collection<Descriptor> dataFiles, int gcBefore)
           
 java.util.concurrent.Future<java.lang.Object> submitValidation(ColumnFamilyStore cfStore, AntiEntropyService.Validator validator)
          Does not mutate data, so is not scheduled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MBEAN_OBJECT_NAME

public static final java.lang.String MBEAN_OBJECT_NAME
See Also:
Constant Field Values

instance

public static final CompactionManager instance
Constructor Detail

CompactionManager

public CompactionManager()
Method Detail

getCompactionLock

public java.util.concurrent.locks.Lock getCompactionLock()
Returns:
A lock, for which acquisition means no compactions can run.

submitMinorIfNeeded

public java.util.concurrent.Future<java.lang.Integer> submitMinorIfNeeded(ColumnFamilyStore cfs)
Call this whenever a compaction might be needed on the given columnfamily. It's okay to over-call (within reason) since the compactions are single-threaded, and if a call is unnecessary, it will just be no-oped in the bucketing phase.


performCleanup

public void performCleanup(ColumnFamilyStore cfStore,
                           NodeId.OneShotRenewer renewer)
                    throws java.lang.InterruptedException,
                           java.util.concurrent.ExecutionException
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException

performScrub

public void performScrub(ColumnFamilyStore cfStore)
                  throws java.lang.InterruptedException,
                         java.util.concurrent.ExecutionException
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException

performMajor

public void performMajor(ColumnFamilyStore cfStore)
                  throws java.lang.InterruptedException,
                         java.util.concurrent.ExecutionException
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException

submitMajor

public java.util.concurrent.Future<java.lang.Object> submitMajor(ColumnFamilyStore cfStore,
                                                                 long skip,
                                                                 int gcBefore)

forceUserDefinedCompaction

public void forceUserDefinedCompaction(java.lang.String ksname,
                                       java.lang.String dataFiles)
Description copied from interface: CompactionManagerMBean
Triggers the compaction of user specified sstables.

Specified by:
forceUserDefinedCompaction in interface CompactionManagerMBean
Parameters:
ksname - the keyspace for the sstables to compact
dataFiles - a comma separated list of sstable filename to compact

submitUserDefined

public java.util.concurrent.Future<java.lang.Object> submitUserDefined(ColumnFamilyStore cfs,
                                                                       java.util.Collection<Descriptor> dataFiles,
                                                                       int gcBefore)

submitValidation

public java.util.concurrent.Future<java.lang.Object> submitValidation(ColumnFamilyStore cfStore,
                                                                      AntiEntropyService.Validator validator)
Does not mutate data, so is not scheduled.


disableAutoCompaction

public void disableAutoCompaction()

submitIndexBuild

public java.util.concurrent.Future submitIndexBuild(ColumnFamilyStore cfs,
                                                    Table.IndexBuilder builder)
Is not scheduled, because it is performing disjoint work from sstable compaction.


submitSSTableBuild

public java.util.concurrent.Future<SSTableReader> submitSSTableBuild(Descriptor desc,
                                                                     OperationType type)
Submits an sstable to be rebuilt: is not scheduled, since the sstable must not exist.


submitCacheWrite

public java.util.concurrent.Future<?> submitCacheWrite(AutoSavingCache.Writer writer)

submitTruncate

public java.util.concurrent.Future<?> submitTruncate(ColumnFamilyStore main,
                                                     long truncatedAt)

getActiveCompactions

public int getActiveCompactions()

getCompactions

public java.util.List<CompactionInfo> getCompactions()
Description copied from interface: CompactionManagerMBean
List of running compaction objects.

Specified by:
getCompactions in interface CompactionManagerMBean

getCompactionSummary

public java.util.List<java.lang.String> getCompactionSummary()
Description copied from interface: CompactionManagerMBean
List of running compaction summary strings.

Specified by:
getCompactionSummary in interface CompactionManagerMBean

getPendingTasks

public int getPendingTasks()
Specified by:
getPendingTasks in interface CompactionManagerMBean
Returns:
estimated number of compactions remaining to perform

getCompletedTasks

public long getCompletedTasks()
Specified by:
getCompletedTasks in interface CompactionManagerMBean
Returns:
number of completed compactions since server [re]start


Copyright © 2011 The Apache Software Foundation