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.


Nested Class Summary
static interface CompactionManager.CompactionExecutorStatsCollector
           
 
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<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 getPendingTasks()
           
 long getTotalBytesCompacted()
           
 long getTotalCompactionsCompleted()
           
 void performCleanup(ColumnFamilyStore cfStore, NodeId.OneShotRenewer renewer)
           
 void performMaximal(ColumnFamilyStore cfStore)
           
 void performScrub(ColumnFamilyStore cfStore)
           
 void performSSTableRewrite(ColumnFamilyStore cfStore)
           
 void stopCompaction(java.lang.String type)
          Stop all running compaction-like tasks having the provided type.
 void stopCompactionFor(java.util.Collection<CFMetaData> columnFamilies)
          Try to stop all of the compactions for given ColumnFamilies.
 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.concurrent.Future<?> submitMaximal(ColumnFamilyStore cfStore, int gcBefore)
           
 java.util.concurrent.Future<?> submitTruncate(ColumnFamilyStore main, long truncatedAt)
           
 java.util.concurrent.Future<?> 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.

submitBackground

public java.util.concurrent.Future<?> submitBackground(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.


performScrub

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

performSSTableRewrite

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

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

performMaximal

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

submitMaximal

public java.util.concurrent.Future<?> submitMaximal(ColumnFamilyStore cfStore,
                                                    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<?> 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(SecondaryIndexBuilder builder)
Is not scheduled, because it is performing disjoint work from sstable compaction.


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<java.util.Map<java.lang.String,java.lang.String>> 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

getTotalBytesCompacted

public long getTotalBytesCompacted()
Specified by:
getTotalBytesCompacted in interface CompactionManagerMBean
Returns:
total number of bytes compacted since server [re]start

getTotalCompactionsCompleted

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

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

stopCompaction

public void stopCompaction(java.lang.String type)
Description copied from interface: CompactionManagerMBean
Stop all running compaction-like tasks having the provided type.

Specified by:
stopCompaction in interface CompactionManagerMBean
Parameters:
type - the type of compaction to stop. Can be one of: - COMPACTION - VALIDATION - CLEANUP - SCRUB - INDEX_BUILD

stopCompactionFor

public void stopCompactionFor(java.util.Collection<CFMetaData> columnFamilies)
Try to stop all of the compactions for given ColumnFamilies. Note that this method does not wait indefinitely for all compactions to finish, maximum wait time is 30 secs.

Parameters:
columnFamilies - The ColumnFamilies to try to stop compaction upon.


Copyright © 2012 The Apache Software Foundation