Class WriteHeavyIncrementObserver
- All Implemented Interfaces:
Coprocessor,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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.Coprocessor
Coprocessor.StateNested classes/interfaces inherited from interface org.apache.hadoop.hbase.coprocessor.RegionObserver
RegionObserver.MutationType -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.commons.lang3.mutable.MutableLong[]private final intFields inherited from interface org.apache.hadoop.hbase.Coprocessor
PRIORITY_HIGHEST, PRIORITY_LOWEST, PRIORITY_SYSTEM, PRIORITY_USER, VERSION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate CellcreateCell(byte[] row, byte[] family, byte[] qualifier, long ts, long value) private longgetUniqueTimestamp(byte[] row) preCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner, ScanType scanType, CompactionLifeCycleTracker tracker, CompactionRequest request) Called prior to writing theStoreFiles selected for compaction into a newStoreFile.voidpreCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, ScanType scanType, ScanOptions options, CompactionLifeCycleTracker tracker, CompactionRequest request) Called before we open store scanner for compaction.preFlush(ObserverContext<RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner, FlushLifeCycleTracker tracker) Called before a Store's memstore is flushed to disk.voidpreFlushScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, ScanOptions options, FlushLifeCycleTracker tracker) Called before we open store scanner for flush.voidpreGetOp(ObserverContext<RegionCoprocessorEnvironment> c, Get get, List<Cell> result) Called before the client performs a GetpreIncrement(ObserverContext<RegionCoprocessorEnvironment> c, Increment increment) Called before Increment.preMemStoreCompactionCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner) Called before we do in memory compaction.voidpreMemStoreCompactionCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, ScanOptions options) Called before we open store scanner for in memory compaction.voidpreStoreScannerOpen(ObserverContext<RegionCoprocessorEnvironment> ctx, Store store, ScanOptions options) Called before a store opens a new scanner.private InternalScannerwrap(byte[] family, InternalScanner scanner) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.hbase.Coprocessor
getServices, start, stopMethods inherited from interface org.apache.hadoop.hbase.coprocessor.RegionCoprocessor
getBulkLoadObserver, getEndpointObserverMethods inherited from interface org.apache.hadoop.hbase.coprocessor.RegionObserver
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, preCompactSelection, preDelete, preDelete, preExists, preFlush, preIncrement, preIncrementAfterRowLock, preMemStoreCompaction, preOpen, prePrepareTimeStampForDeleteVersion, prePut, prePut, preReplayWALs, preScannerClose, preScannerNext, preScannerOpen, preStoreFileReaderOpen, preWALAppend, preWALRestore
-
Field Details
-
mask
-
lastTimestamps
-
-
Constructor Details
-
WriteHeavyIncrementObserver
public WriteHeavyIncrementObserver()
-
-
Method Details
-
getRegionObserver
- Specified by:
getRegionObserverin interfaceRegionCoprocessor
-
preFlushScannerOpen
public void preFlushScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, ScanOptions options, FlushLifeCycleTracker tracker) throws IOException Description copied from interface:RegionObserverCalled before we open store scanner for flush. You can use theoptionsto change max versions and TTL for the scanner being opened.- Specified by:
preFlushScannerOpenin interfaceRegionObserver- Parameters:
c- 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 opened- Throws:
IOException
-
createCell
-
wrap
-
preFlush
public InternalScanner preFlush(ObserverContext<RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner, FlushLifeCycleTracker tracker) throws IOException Description copied from interface:RegionObserverCalled before a Store's memstore is flushed to disk.- Specified by:
preFlushin interfaceRegionObserver- Parameters:
c- 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 flush- Returns:
- the scanner to use during flush. Should not be
nullunless the implementation is writing new store files on its own. - Throws:
IOException
-
preCompactScannerOpen
public void preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, ScanType scanType, ScanOptions options, CompactionLifeCycleTracker tracker, CompactionRequest request) throws IOException Description copied from interface:RegionObserverCalled before we open store scanner for compaction. You can use theoptionsto change max versions and TTL for the scanner being opened.- Specified by:
preCompactScannerOpenin interfaceRegionObserver- Parameters:
c- 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 compaction- Throws:
IOException
-
preCompact
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner, ScanType scanType, CompactionLifeCycleTracker tracker, CompactionRequest request) throws IOException Description copied from interface:RegionObserverCalled prior to writing theStoreFiles selected for compaction into a newStoreFile.To override or modify the compaction process, implementing classes can wrap the provided
InternalScannerwith a custom implementation that is returned from this method. The custom scanner can then inspectCells 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 implementShipperand 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.- Specified by:
preCompactin interfaceRegionObserver- Parameters:
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 compaction- Returns:
- the scanner to use during compaction. Should not be
nullunless the implementation is writing new store files on its own. - Throws:
IOException
-
preMemStoreCompactionCompactScannerOpen
public void preMemStoreCompactionCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, ScanOptions options) throws IOException Description copied from interface:RegionObserverCalled before we open store scanner for in memory compaction. You can use theoptionsto change max versions and TTL for the scanner being opened. Notice that this method will only be called when you useeagermode. Forbasicmode we will not drop any cells thus we do not open a store scanner.- Specified by:
preMemStoreCompactionCompactScannerOpenin interfaceRegionObserver- Parameters:
c- 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 opened- Throws:
IOException
-
preMemStoreCompactionCompact
public InternalScanner preMemStoreCompactionCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner) throws IOException Description copied from interface:RegionObserverCalled before we do in memory compaction. Notice that this method will only be called when you useeagermode. Forbasicmode we will not drop any cells thus there is noInternalScanner.- Specified by:
preMemStoreCompactionCompactin interfaceRegionObserver- Parameters:
c- 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 compact- Returns:
- the scanner to use during in memory compaction. Must be non-null.
- Throws:
IOException
-
preGetOp
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> c, Get get, List<Cell> result) throws IOException Description copied from interface:RegionObserverCalled before the client performs a GetCall CoprocessorEnvironment#bypass to skip default actions. If 'bypass' is set, we skip out on calling any subsequent chained coprocessors.
- Specified by:
preGetOpin interfaceRegionObserver- Parameters:
c- 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.- Throws:
IOException
-
getUniqueTimestamp
-
preIncrement
public Result preIncrement(ObserverContext<RegionCoprocessorEnvironment> c, Increment increment) throws IOException Description copied from interface:RegionObserverCalled before Increment.Call 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.
- Specified by:
preIncrementin interfaceRegionObserver- Parameters:
c- the environment provided by the region serverincrement- increment object- Returns:
- result to return to the client if bypassing default processing
- Throws:
IOException
-
preStoreScannerOpen
public void preStoreScannerOpen(ObserverContext<RegionCoprocessorEnvironment> ctx, Store store, ScanOptions options) throws IOException Description copied from interface:RegionObserverCalled before a store opens a new scanner.This hook is called when a "user" scanner is opened. Use
preFlushScannerOpenandpreCompactScannerOpento 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
Scanobject to 10 inpreScannerOpen, 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.- Specified by:
preStoreScannerOpenin interfaceRegionObserver- Parameters:
ctx- 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 opened- Throws:
IOException- See Also:
-