org.apache.hadoop.hbase.coprocessor.example
Class ZooKeeperScanPolicyObserver

java.lang.Object
  extended by org.apache.hadoop.hbase.coprocessor.BaseRegionObserver
      extended by org.apache.hadoop.hbase.coprocessor.example.ZooKeeperScanPolicyObserver
All Implemented Interfaces:
Coprocessor, RegionObserver

public class ZooKeeperScanPolicyObserver
extends BaseRegionObserver

This is an example showing how a RegionObserver could 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 to not delete data that was inserted since (based on wall clock time). This implements org.apache.zookeeper.Watcher directly instead of using ZooKeeperWatcher, because RegionObservers come and go and currently listeners registered with ZooKeeperWatcher cannot be removed.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.coprocessor.RegionObserver
RegionObserver.MutationType
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.Coprocessor
Coprocessor.State
 
Field Summary
static String node
           
static String zkkey
           
 
Fields inherited from interface org.apache.hadoop.hbase.Coprocessor
PRIORITY_HIGHEST, PRIORITY_LOWEST, PRIORITY_SYSTEM, PRIORITY_USER, VERSION
 
Constructor Summary
ZooKeeperScanPolicyObserver()
           
 
Method Summary
protected  ScanInfo getScanInfo(Store store, RegionCoprocessorEnvironment e)
           
 InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs, InternalScanner s)
           
 InternalScanner preFlushScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, KeyValueScanner memstoreScanner, InternalScanner s)
           
 KeyValueScanner preStoreScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, Scan scan, NavigableSet<byte[]> targetCols, KeyValueScanner s)
           
 void start(CoprocessorEnvironment e)
           
 void stop(CoprocessorEnvironment e)
           
 
Methods inherited from class org.apache.hadoop.hbase.coprocessor.BaseRegionObserver
postAppend, postBatchMutate, postBatchMutateIndispensably, postBulkLoadHFile, postCheckAndDelete, postCheckAndPut, postClose, postCloseRegionOperation, postCompact, postCompact, postCompactSelection, postCompactSelection, postCompleteSplit, postDelete, postExists, postFlush, postFlush, postGet, postGetClosestRowBefore, postGetOp, postIncrement, postIncrementColumnValue, postInstantiateDeleteTracker, postLogReplay, postMutationBeforeWAL, postOpen, postPut, postRollBackSplit, postScannerClose, postScannerFilterRow, postScannerNext, postScannerOpen, postSplit, postStartRegionOperation, postStoreFileReaderOpen, postWALRestore, preAppend, preAppendAfterRowLock, preBatchMutate, preBulkLoadHFile, preCheckAndDelete, preCheckAndDeleteAfterRowLock, preCheckAndPut, preCheckAndPutAfterRowLock, preClose, preCompact, preCompact, preCompactScannerOpen, preCompactSelection, preCompactSelection, preDelete, preExists, preFlush, preFlush, preGet, preGetClosestRowBefore, preGetOp, preIncrement, preIncrementAfterRowLock, preIncrementColumnValue, preOpen, prePrepareTimeStampForDeleteVersion, prePut, preRollBackSplit, preScannerClose, preScannerNext, preScannerOpen, preSplit, preSplit, preSplitAfterPONR, preSplitBeforePONR, preStoreFileReaderOpen, preWALRestore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

node

public static final String node
See Also:
Constant Field Values

zkkey

public static final String zkkey
See Also:
Constant Field Values
Constructor Detail

ZooKeeperScanPolicyObserver

public ZooKeeperScanPolicyObserver()
Method Detail

start

public void start(CoprocessorEnvironment e)
           throws IOException
Specified by:
start in interface Coprocessor
Overrides:
start in class BaseRegionObserver
Throws:
IOException

stop

public void stop(CoprocessorEnvironment e)
          throws IOException
Specified by:
stop in interface Coprocessor
Overrides:
stop in class BaseRegionObserver
Throws:
IOException

getScanInfo

protected ScanInfo getScanInfo(Store store,
                               RegionCoprocessorEnvironment e)

preFlushScannerOpen

public InternalScanner preFlushScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c,
                                           Store store,
                                           KeyValueScanner memstoreScanner,
                                           InternalScanner s)
                                    throws IOException
Specified by:
preFlushScannerOpen in interface RegionObserver
Overrides:
preFlushScannerOpen in class BaseRegionObserver
Throws:
IOException

preCompactScannerOpen

public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c,
                                             Store store,
                                             List<? extends KeyValueScanner> scanners,
                                             ScanType scanType,
                                             long earliestPutTs,
                                             InternalScanner s)
                                      throws IOException
Specified by:
preCompactScannerOpen in interface RegionObserver
Overrides:
preCompactScannerOpen in class BaseRegionObserver
Throws:
IOException

preStoreScannerOpen

public KeyValueScanner preStoreScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c,
                                           Store store,
                                           Scan scan,
                                           NavigableSet<byte[]> targetCols,
                                           KeyValueScanner s)
                                    throws IOException
Specified by:
preStoreScannerOpen in interface RegionObserver
Overrides:
preStoreScannerOpen in class BaseRegionObserver
Throws:
IOException


Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.