org.apache.hadoop.hbase.regionserver.compactions
Class SortedCompactionPolicy
java.lang.Object
org.apache.hadoop.hbase.regionserver.compactions.CompactionPolicy
org.apache.hadoop.hbase.regionserver.compactions.SortedCompactionPolicy
- Direct Known Subclasses:
- DateTieredCompactionPolicy, RatioBasedCompactionPolicy
@InterfaceAudience.Private
public abstract class SortedCompactionPolicy
- extends CompactionPolicy
An abstract compaction policy that select files on seq id order.
Method Summary |
protected ArrayList<StoreFile> |
checkMinFilesCriteria(ArrayList<StoreFile> candidates,
int minFiles)
|
protected ArrayList<StoreFile> |
filterBulk(ArrayList<StoreFile> candidates)
|
protected abstract CompactionRequest |
getCompactionRequest(ArrayList<StoreFile> candidateSelection,
boolean tryingMajor,
boolean isUserCompaction,
boolean mayUseOffPeak,
boolean mayBeStuck)
|
protected ArrayList<StoreFile> |
getCurrentEligibleFiles(ArrayList<StoreFile> candidateFiles,
List<StoreFile> filesCompacting)
|
long |
getNextMajorCompactTime(Collection<StoreFile> filesToCompact)
|
boolean |
needsCompaction(Collection<StoreFile> storeFiles,
List<StoreFile> filesCompacting)
A heuristic method to decide whether to schedule a compaction request |
List<StoreFile> |
preSelectCompactionForCoprocessor(Collection<StoreFile> candidates,
List<StoreFile> filesCompacting)
|
protected void |
removeExcessFiles(ArrayList<StoreFile> candidates,
boolean isUserCompaction,
boolean isMajorCompaction)
|
CompactionRequest |
selectCompaction(Collection<StoreFile> candidateFiles,
List<StoreFile> filesCompacting,
boolean isUserCompaction,
boolean mayUseOffPeak,
boolean forceMajor)
|
abstract boolean |
shouldPerformMajorCompaction(Collection<StoreFile> filesToCompact)
|
protected ArrayList<StoreFile> |
skipLargeFiles(ArrayList<StoreFile> candidates)
|
boolean |
throttleCompaction(long compactionSize)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SortedCompactionPolicy
public SortedCompactionPolicy(org.apache.hadoop.conf.Configuration conf,
StoreConfigInformation storeConfigInfo)
preSelectCompactionForCoprocessor
public List<StoreFile> preSelectCompactionForCoprocessor(Collection<StoreFile> candidates,
List<StoreFile> filesCompacting)
selectCompaction
public CompactionRequest selectCompaction(Collection<StoreFile> candidateFiles,
List<StoreFile> filesCompacting,
boolean isUserCompaction,
boolean mayUseOffPeak,
boolean forceMajor)
throws IOException
- Parameters:
candidateFiles
- candidate files, ordered from oldest to newest by seqId. We rely on
DefaultStoreFileManager to sort the files by seqId to guarantee contiguous compaction based
on seqId for data consistency.
- Returns:
- subset copy of candidate list that meets compaction criteria
- Throws:
IOException
getCompactionRequest
protected abstract CompactionRequest getCompactionRequest(ArrayList<StoreFile> candidateSelection,
boolean tryingMajor,
boolean isUserCompaction,
boolean mayUseOffPeak,
boolean mayBeStuck)
throws IOException
- Throws:
IOException
shouldPerformMajorCompaction
public abstract boolean shouldPerformMajorCompaction(Collection<StoreFile> filesToCompact)
throws IOException
- Specified by:
shouldPerformMajorCompaction
in class CompactionPolicy
- Parameters:
filesToCompact
- Files to compact. Can be null.
- Returns:
- True if we should run a major compaction.
- Throws:
IOException
getNextMajorCompactTime
public long getNextMajorCompactTime(Collection<StoreFile> filesToCompact)
throttleCompaction
public boolean throttleCompaction(long compactionSize)
- Specified by:
throttleCompaction
in class CompactionPolicy
- Parameters:
compactionSize
- Total size of some compaction
- Returns:
- whether this should be a large or small compaction
needsCompaction
public boolean needsCompaction(Collection<StoreFile> storeFiles,
List<StoreFile> filesCompacting)
- A heuristic method to decide whether to schedule a compaction request
- Parameters:
storeFiles
- files in the store.filesCompacting
- files being scheduled to compact.
- Returns:
- true to schedule a request.
getCurrentEligibleFiles
protected ArrayList<StoreFile> getCurrentEligibleFiles(ArrayList<StoreFile> candidateFiles,
List<StoreFile> filesCompacting)
skipLargeFiles
protected ArrayList<StoreFile> skipLargeFiles(ArrayList<StoreFile> candidates)
- Parameters:
candidates
- pre-filtrate
- Returns:
- filtered subset exclude all files above maxCompactSize Also save all references. We
MUST compact them
filterBulk
protected ArrayList<StoreFile> filterBulk(ArrayList<StoreFile> candidates)
- Parameters:
candidates
- pre-filtrate
- Returns:
- filtered subset exclude all bulk load files if configured
removeExcessFiles
protected void removeExcessFiles(ArrayList<StoreFile> candidates,
boolean isUserCompaction,
boolean isMajorCompaction)
- Parameters:
candidates
- pre-filtrate
checkMinFilesCriteria
protected ArrayList<StoreFile> checkMinFilesCriteria(ArrayList<StoreFile> candidates,
int minFiles)
- Parameters:
candidates
- pre-filtrate
- Returns:
- filtered subset forget the compactionSelection if we don't have enough files
Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.