@InterfaceAudience.Private public class WriteHeavyIncrementObserver extends Object implements RegionCoprocessor, RegionObserver
We will convert increment to put, and do aggregating when get. And of course the return value of increment is useless then.
Notice that this is only an example so we do not handle most corner cases, for example, you must provide a qualifier when doing a get.
Coprocessor.StateRegionObserver.MutationType| Modifier and Type | Field and Description |
|---|---|
private org.apache.commons.lang3.mutable.MutableLong[] |
lastTimestamps |
private int |
mask |
PRIORITY_HIGHEST, PRIORITY_LOWEST, PRIORITY_SYSTEM, PRIORITY_USER, VERSION| Constructor and Description |
|---|
WriteHeavyIncrementObserver() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBulkLoadObserver, getEndpointObservergetServices, start, stoppostAppend, postAppendBeforeWAL, postBatchMutate, postBatchMutateIndispensably, postBulkLoadHFile, postCheckAndDelete, postCheckAndDelete, postCheckAndPut, postCheckAndPut, postClose, postCloseRegionOperation, postCommitStoreFile, postCompact, postCompactSelection, postDelete, postExists, postFlush, postFlush, postGetOp, postIncrement, postIncrementBeforeWAL, postInstantiateDeleteTracker, postMemStoreCompaction, postMutationBeforeWAL, postOpen, postPut, postReplayWALs, postScannerClose, postScannerFilterRow, postScannerNext, postScannerOpen, postStartRegionOperation, postStoreFileReaderOpen, postWALRestore, preAppend, preAppendAfterRowLock, preBatchMutate, preBulkLoadHFile, preCheckAndDelete, preCheckAndDelete, preCheckAndDeleteAfterRowLock, preCheckAndDeleteAfterRowLock, preCheckAndPut, preCheckAndPut, preCheckAndPutAfterRowLock, preCheckAndPutAfterRowLock, preClose, preCommitStoreFile, preCompactSelection, preDelete, preExists, preFlush, preIncrementAfterRowLock, preMemStoreCompaction, preOpen, prePrepareTimeStampForDeleteVersion, prePut, preReplayWALs, preScannerClose, preScannerNext, preScannerOpen, preStoreFileReaderOpen, preWALAppend, preWALRestoreprivate final int mask
private final org.apache.commons.lang3.mutable.MutableLong[] lastTimestamps
public WriteHeavyIncrementObserver()
public Optional<RegionObserver> getRegionObserver()
getRegionObserver in interface RegionCoprocessorpublic void preFlushScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, ScanOptions options, FlushLifeCycleTracker tracker) throws IOException
RegionObserveroptions to change max
versions and TTL for the scanner being opened.preFlushScannerOpen in interface RegionObserverc - the environment provided by the region serverstore - the store where flush is being requestedoptions - used to change max versions and TTL for the scanner being openedIOExceptionprivate Cell createCell(byte[] row, byte[] family, byte[] qualifier, long ts, long value)
private InternalScanner wrap(byte[] family, InternalScanner scanner)
public InternalScanner preFlush(ObserverContext<RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner, FlushLifeCycleTracker tracker) throws IOException
RegionObserverpreFlush in interface RegionObserverc - the environment provided by the region serverstore - the store where flush is being requestedscanner - the scanner over existing data used in the memstoretracker - tracker used to track the life cycle of a flushnull unless the implementation
is writing new store files on its own.IOExceptionpublic void preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, ScanType scanType, ScanOptions options, CompactionLifeCycleTracker tracker, CompactionRequest request) throws IOException
RegionObserveroptions to change max
versions and TTL for the scanner being opened.preCompactScannerOpen in interface RegionObserverc - the environment provided by the region serverstore - the store being compactedscanType - type of Scanoptions - used to change max versions and TTL for the scanner being openedtracker - tracker used to track the life cycle of a compactionrequest - the requested compactionIOExceptionpublic InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner, ScanType scanType, CompactionLifeCycleTracker tracker, CompactionRequest request) throws IOException
RegionObserverStoreFiles 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 Cells from the wrapped scanner,
applying its own policy to what gets written.
preCompact in interface RegionObserverc - 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.IOExceptionpublic void preMemStoreCompactionCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, ScanOptions options) throws IOException
RegionObserveroptions
to change max versions and TTL for the scanner being opened. Notice that this method will only
be called when you use eager mode. For basic mode we will not drop any cells
thus we do not open a store scanner.preMemStoreCompactionCompactScannerOpen in interface RegionObserverc - the environment provided by the region serverstore - the store where in memory compaction is being requestedoptions - used to change max versions and TTL for the scanner being openedIOExceptionpublic InternalScanner preMemStoreCompactionCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner) throws IOException
RegionObservereager mode. For basic mode we will not drop any cells thus there is no
InternalScanner.preMemStoreCompactionCompact in interface RegionObserverc - the environment provided by the region serverstore - the store where in memory compaction is being executedscanner - the scanner over existing data used in the memstore segments being compactIOExceptionpublic void preGetOp(ObserverContext<RegionCoprocessorEnvironment> c, Get get, List<Cell> result) throws IOException
RegionObserverCall CoprocessorEnvironment#bypass to skip default actions. If 'bypass' is set, we skip out on calling any subsequent chained coprocessors.
preGetOp in interface RegionObserverc - the environment provided by the region serverget - the Get requestresult - The result to return to the client if default processing
is bypassed. Can be modified. Will not be used if default processing
is not bypassed.IOExceptionprivate long getUniqueTimestamp(byte[] row)
public Result preIncrement(ObserverContext<RegionCoprocessorEnvironment> c, Increment increment) throws IOException
RegionObserverCall CoprocessorEnvironment#bypass to skip default actions. If 'bypass' is set, we skip out on calling any subsequent chained coprocessors.
Note: Do not retain references to any Cells in 'increment' beyond the life of this invocation. If need a Cell reference for later use, copy the cell and use that.
preIncrement in interface RegionObserverc - the environment provided by the region serverincrement - increment objectIOExceptionpublic void preStoreScannerOpen(ObserverContext<RegionCoprocessorEnvironment> ctx, Store store, ScanOptions options) throws IOException
RegionObserver
This hook is called when a "user" scanner is opened. Use preFlushScannerOpen and
preCompactScannerOpen to inject flush/compaction.
Notice that, this method is used to change the inherent max versions and TTL for a Store. For
example, you can change the max versions option for a Scan object to 10 in
preScannerOpen, but if the max versions config on the Store is 1, then you still can
only read 1 version. You need also to inject here to change the max versions to 10 if you want
to get more versions.
preStoreScannerOpen in interface RegionObserverctx - the environment provided by the region serverstore - the store which we want to get scanner fromoptions - used to change max versions and TTL for the scanner being openedIOExceptionRegionObserver.preFlushScannerOpen(ObserverContext, Store, ScanOptions, FlushLifeCycleTracker),
RegionObserver.preCompactScannerOpen(ObserverContext, Store, ScanType, ScanOptions,
CompactionLifeCycleTracker, CompactionRequest)Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.