public abstract class CompactionStrategy extends Object
The tablet server has one thread to ask many tablets if they should compact. When the strategy
returns true, then tablet is added to the queue of tablets waiting for a compaction thread. Once
a thread is available, the gatherInformation(MajorCompactionRequest)
method is called
outside the tablets' lock. This gives the strategy the ability to read information that maybe
expensive to fetch. Once the gatherInformation returns, the tablet lock is grabbed and the
compactionPlan computed. This should *not* do expensive operations, especially not I/O. Note that
the number of files may change between calls to
gatherInformation(MajorCompactionRequest)
and
getCompactionPlan(MajorCompactionRequest)
.
Note: the strategy object used for the shouldCompact(MajorCompactionRequest)
call
is going to be different from the one used in the compaction thread.
Constructor and Description |
---|
CompactionStrategy() |
Modifier and Type | Method and Description |
---|---|
void |
gatherInformation(MajorCompactionRequest request)
Called prior to obtaining the tablet lock, useful for examining metadata or indexes.
|
abstract CompactionPlan |
getCompactionPlan(MajorCompactionRequest request)
Get the plan for compacting a tablets files.
|
void |
init(Map<String,String> options)
The settings for the compaction strategy pulled from zookeeper.
|
abstract boolean |
shouldCompact(MajorCompactionRequest request)
Determine if this tablet is eligible for a major compaction.
|
public void init(Map<String,String> options)
public abstract boolean shouldCompact(MajorCompactionRequest request) throws IOException
gatherInformation(MajorCompactionRequest)
and
getCompactionPlan(MajorCompactionRequest)
) that it does not need to. Any state stored
during shouldCompact will no longer exist when
gatherInformation(MajorCompactionRequest)
and
getCompactionPlan(MajorCompactionRequest)
are called.
Called while holding the tablet lock, so it should not be doing any blocking.
Since no blocking should be done in this method, then its unexpected that this method will throw IOException. However since its in the API, it can not be easily removed.
IOException
public void gatherInformation(MajorCompactionRequest request) throws IOException
getCompactionPlan(MajorCompactionRequest)
.request
- basic details about the tabletIOException
public abstract CompactionPlan getCompactionPlan(MajorCompactionRequest request) throws IOException
Since no blocking should be done in this method, then its unexpected that this method will throw IOException. However since its in the API, it can not be easily removed.
request
- basic details about the tabletIOException
Copyright © 2011–2019 The Apache Software Foundation. All rights reserved.