Class ZooKeeperScanPolicyObserver
java.lang.Object
org.apache.hadoop.hbase.coprocessor.example.ZooKeeperScanPolicyObserver
- All Implemented Interfaces:
Coprocessor
,RegionCoprocessor
,RegionObserver
@Private
public class ZooKeeperScanPolicyObserver
extends Object
implements RegionCoprocessor, RegionObserver
This is an example showing how a RegionObserver could be configured via ZooKeeper in order to
control a Region compaction, flush, and scan policy. This also demonstrated the use of shared
RegionObserver
state. See
RegionCoprocessorEnvironment.getSharedData()
.
This would be useful for an incremental backup tool, which would indicate the last time of a successful backup via ZK and instruct HBase that to safely delete the data which has already been backup.
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static final class
Internal watcher that keep "data" up to date asynchronously.Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.Coprocessor
Coprocessor.State
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.coprocessor.RegionObserver
RegionObserver.MutationType
-
Field Summary
Modifier and TypeFieldDescriptionprivate org.apache.curator.framework.recipes.cache.NodeCache
static final String
static final String
static final int
static final String
private static final String
Fields inherited from interface org.apache.hadoop.hbase.Coprocessor
PRIORITY_HIGHEST, PRIORITY_LOWEST, PRIORITY_SYSTEM, PRIORITY_USER, VERSION
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate OptionalLong
void
preCompactScannerOpen
(ObserverContext<? extends RegionCoprocessorEnvironment> c, Store store, ScanType scanType, ScanOptions options, CompactionLifeCycleTracker tracker, CompactionRequest request) Called before we open store scanner for compaction.void
preFlushScannerOpen
(ObserverContext<? extends RegionCoprocessorEnvironment> c, Store store, ScanOptions options, FlushLifeCycleTracker tracker) Called before we open store scanner for flush.private void
resetTTL
(ScanOptions options) void
Called by theCoprocessorEnvironment
during it's own startup to initialize the coprocessor.void
Called by theCoprocessorEnvironment
during it's own shutdown to stop the coprocessor.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.Coprocessor
getServices
Methods inherited from interface org.apache.hadoop.hbase.coprocessor.RegionCoprocessor
getBulkLoadObserver, getEndpointObserver
Methods 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, preAppend, preAppend, preAppendAfterRowLock, preBatchMutate, preBulkLoadHFile, preCheckAndDelete, preCheckAndDelete, preCheckAndDeleteAfterRowLock, preCheckAndDeleteAfterRowLock, preCheckAndMutate, preCheckAndMutateAfterRowLock, preCheckAndPut, preCheckAndPut, preCheckAndPutAfterRowLock, preCheckAndPutAfterRowLock, preClose, preCommitStoreFile, preCompact, preCompactSelection, preDelete, preDelete, preExists, preFlush, preFlush, preGetOp, preIncrement, preIncrement, preIncrementAfterRowLock, preMemStoreCompaction, preMemStoreCompactionCompact, preMemStoreCompactionCompactScannerOpen, preOpen, prePrepareTimeStampForDeleteVersion, prePut, prePut, preReplayWALs, preScannerClose, preScannerNext, preScannerOpen, preStoreFileReaderOpen, preStoreScannerOpen, preWALAppend
-
Field Details
-
ZK_ENSEMBLE_KEY
- See Also:
-
ZK_SESSION_TIMEOUT_KEY
- See Also:
-
ZK_SESSION_TIMEOUT_DEFAULT
- See Also:
-
NODE
- See Also:
-
ZKKEY
- See Also:
-
cache
-
-
Constructor Details
-
ZooKeeperScanPolicyObserver
public ZooKeeperScanPolicyObserver()
-
-
Method Details
-
getRegionObserver
- Specified by:
getRegionObserver
in interfaceRegionCoprocessor
-
start
Description copied from interface:Coprocessor
Called by theCoprocessorEnvironment
during it's own startup to initialize the coprocessor.- Specified by:
start
in interfaceCoprocessor
- Throws:
IOException
-
stop
Description copied from interface:Coprocessor
Called by theCoprocessorEnvironment
during it's own shutdown to stop the coprocessor.- Specified by:
stop
in interfaceCoprocessor
- Throws:
IOException
-
getExpireBefore
-
resetTTL
-
preFlushScannerOpen
public void preFlushScannerOpen(ObserverContext<? extends RegionCoprocessorEnvironment> c, Store store, ScanOptions options, FlushLifeCycleTracker tracker) throws IOException Description copied from interface:RegionObserver
Called before we open store scanner for flush. You can use theoptions
to change max versions and TTL for the scanner being opened.- Specified by:
preFlushScannerOpen
in 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
-
preCompactScannerOpen
public void preCompactScannerOpen(ObserverContext<? extends RegionCoprocessorEnvironment> c, Store store, ScanType scanType, ScanOptions options, CompactionLifeCycleTracker tracker, CompactionRequest request) throws IOException Description copied from interface:RegionObserver
Called before we open store scanner for compaction. You can use theoptions
to change max versions and TTL for the scanner being opened.- Specified by:
preCompactScannerOpen
in 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
-