@InterfaceAudience.Private public class ValueRewritingObserver extends Object implements RegionObserver, RegionCoprocessor
RegionObserver.MutationType
Coprocessor.State
Modifier and Type | Field and Description |
---|---|
private CellBuilder |
cellBuilder |
private Bytes.ByteArrayComparator |
comparator |
static String |
ORIGINAL_VALUE_KEY |
static String |
REPLACED_VALUE_KEY |
private byte[] |
replacedValue |
private byte[] |
sourceValue |
PRIORITY_HIGHEST, PRIORITY_LOWEST, PRIORITY_SYSTEM, PRIORITY_USER, VERSION
Constructor and Description |
---|
ValueRewritingObserver() |
Modifier and Type | Method and Description |
---|---|
Optional<RegionObserver> |
getRegionObserver() |
InternalScanner |
preCompact(ObserverContext<RegionCoprocessorEnvironment> c,
Store store,
InternalScanner scanner,
ScanType scanType,
CompactionLifeCycleTracker tracker,
CompactionRequest request)
Called prior to writing the
StoreFile s selected for compaction into a new
StoreFile . |
void |
start(CoprocessorEnvironment env)
Called by the
CoprocessorEnvironment during it's own startup to initialize the
coprocessor. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
postAppend, postAppend, postAppendBeforeWAL, postBatchMutate, postBatchMutateIndispensably, postBulkLoadHFile, postCheckAndDelete, postCheckAndDelete, postCheckAndMutate, postCheckAndPut, postCheckAndPut, postClose, postCloseRegionOperation, postCommitStoreFile, postCompact, postCompactSelection, postDelete, postDelete, postExists, postFlush, postFlush, postGetOp, postIncrement, postIncrement, postIncrementBeforeWAL, postInstantiateDeleteTracker, postMemStoreCompaction, postMutationBeforeWAL, postOpen, postPut, postPut, postReplayWALs, postScannerClose, postScannerFilterRow, postScannerNext, postScannerOpen, postStartRegionOperation, postStoreFileReaderOpen, postWALRestore, preAppend, preAppend, preAppendAfterRowLock, preBatchMutate, preBulkLoadHFile, preCheckAndDelete, preCheckAndDelete, preCheckAndDeleteAfterRowLock, preCheckAndDeleteAfterRowLock, preCheckAndMutate, preCheckAndMutateAfterRowLock, preCheckAndPut, preCheckAndPut, preCheckAndPutAfterRowLock, preCheckAndPutAfterRowLock, preClose, preCommitStoreFile, preCompactScannerOpen, preCompactSelection, preDelete, preDelete, preExists, preFlush, preFlush, preFlushScannerOpen, preGetOp, preIncrement, preIncrement, preIncrementAfterRowLock, preMemStoreCompaction, preMemStoreCompactionCompact, preMemStoreCompactionCompactScannerOpen, preOpen, prePrepareTimeStampForDeleteVersion, prePut, prePut, preReplayWALs, preScannerClose, preScannerNext, preScannerOpen, preStoreFileReaderOpen, preStoreScannerOpen, preWALAppend, preWALRestore
getBulkLoadObserver, getEndpointObserver
getServices, stop
public static final String ORIGINAL_VALUE_KEY
public static final String REPLACED_VALUE_KEY
private byte[] sourceValue
private byte[] replacedValue
private Bytes.ByteArrayComparator comparator
private CellBuilder cellBuilder
public ValueRewritingObserver()
public Optional<RegionObserver> getRegionObserver()
getRegionObserver
in interface RegionCoprocessor
public void start(CoprocessorEnvironment env) throws IOException
Coprocessor
CoprocessorEnvironment
during it's own startup to initialize the
coprocessor.start
in interface Coprocessor
IOException
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner, ScanType scanType, CompactionLifeCycleTracker tracker, CompactionRequest request)
RegionObserver
StoreFile
s selected for compaction into a new
StoreFile
.
To override or modify the compaction process, implementing classes can wrap the provided
InternalScanner
with a custom implementation that is returned from this method. The
custom scanner can then inspect Cell
s from the wrapped scanner,
applying its own policy to what gets written.
If implementations are wrapping the passed in InternalScanner
, they can also have their
implementation implement Shipper
and delegate to the original scanner. This will cause
compactions to free up memory as they progress, which is especially important for people using
off-heap memory pools.
Keep in mind that when Shipper.shipped()
is called, any cell references you maintain in
your implementation may get corrupted. As such you should make sure to deep clone any cells
that you need to keep reference to across invocations of shipped.
preCompact
in interface RegionObserver
c
- the environment provided by the region serverstore
- the store being compactedscanner
- the scanner over existing data used in the store file rewritingscanType
- type of Scantracker
- tracker used to track the life cycle of a compactionrequest
- the requested compactionnull
unless the
implementation is writing new store files on its own.Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.