org.apache.hadoop.hbase.regionserver
Class RegionCoprocessorHost

java.lang.Object
  extended by org.apache.hadoop.hbase.coprocessor.CoprocessorHost<org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.RegionEnvironment>
      extended by org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost

public class RegionCoprocessorHost
extends CoprocessorHost<org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.RegionEnvironment>

Implements the coprocessor environment and runtime support for coprocessors loaded within a HRegion.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.coprocessor.CoprocessorHost
CoprocessorHost.Environment
 
Field Summary
 
Fields inherited from class org.apache.hadoop.hbase.coprocessor.CoprocessorHost
conf, coprocessors, loadSequence, MASTER_COPROCESSOR_CONF_KEY, pathPrefix, REGION_COPROCESSOR_CONF_KEY, USER_REGION_COPROCESSOR_CONF_KEY, WAL_COPROCESSOR_CONF_KEY
 
Constructor Summary
RegionCoprocessorHost(HRegion region, RegionServerServices rsServices, org.apache.hadoop.conf.Configuration conf)
          Constructor
 
Method Summary
protected  void abortServer(CoprocessorEnvironment env, Throwable e)
           
 org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.RegionEnvironment createEnvironment(Class<?> implClass, Coprocessor instance, int priority, int seq, org.apache.hadoop.conf.Configuration conf)
          Called when a new Coprocessor class is loaded
 boolean postCheckAndDelete(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, WritableByteArrayComparable comparator, Delete delete, boolean result)
           
 boolean postCheckAndPut(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, WritableByteArrayComparable comparator, Put put, boolean result)
           
 void postClose(boolean abortRequested)
          Invoked after a region is closed
 void postCompact(Store store, StoreFile resultFile)
          Called after the store compaction has completed.
 void postCompactSelection(Store store, com.google.common.collect.ImmutableList<StoreFile> selected)
          Called after the StoreFiles to be compacted have been selected from the available candidates.
 void postDelete(Delete delete, WALEdit edit, boolean writeToWAL)
           
 boolean postExists(Get get, boolean exists)
           
 void postFlush()
          Invoked after a memstore flush
 void postGet(Get get, List<KeyValue> results)
           
 void postGetClosestRowBefore(byte[] row, byte[] family, Result result)
           
 Result postIncrement(Increment increment, Result result)
           
 long postIncrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount, boolean writeToWAL, long result)
           
 void postOpen()
          Invoked after a region open
 void postPut(Put put, WALEdit edit, boolean writeToWAL)
           
 void postScannerClose(InternalScanner s)
           
 boolean postScannerNext(InternalScanner s, List<Result> results, int limit, boolean hasMore)
           
 RegionScanner postScannerOpen(Scan scan, RegionScanner s)
           
 void postSplit(HRegion l, HRegion r)
          Invoked just after a split
 void postWALRestore(HRegionInfo info, HLogKey logKey, WALEdit logEdit)
           
 Boolean preCheckAndDelete(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, WritableByteArrayComparable comparator, Delete delete)
           
 Boolean preCheckAndPut(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, WritableByteArrayComparable comparator, Put put)
           
 void preClose(boolean abortRequested)
          Invoked before a region is closed
 InternalScanner preCompact(Store store, InternalScanner scanner)
          Called prior to rewriting the store files selected for compaction
 boolean preCompactSelection(Store store, List<StoreFile> candidates)
          Called prior to selecting the StoreFiles for compaction from the list of currently available candidates.
 boolean preDelete(Delete delete, WALEdit edit, boolean writeToWAL)
           
 Boolean preExists(Get get)
           
 void preFlush()
          Invoked before a memstore flush
 boolean preGet(Get get, List<KeyValue> results)
           
 boolean preGetClosestRowBefore(byte[] row, byte[] family, Result result)
           
 Result preIncrement(Increment increment)
           
 Long preIncrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount, boolean writeToWAL)
           
 void preOpen()
          Invoked before a region open
 boolean prePut(Put put, WALEdit edit, boolean writeToWAL)
           
 boolean preScannerClose(InternalScanner s)
           
 Boolean preScannerNext(InternalScanner s, List<Result> results, int limit)
           
 RegionScanner preScannerOpen(Scan scan)
           
 void preSplit()
          Invoked just before a split
 boolean preWALRestore(HRegionInfo info, HLogKey logKey, WALEdit logEdit)
           
 
Methods inherited from class org.apache.hadoop.hbase.coprocessor.CoprocessorHost
abortServer, findCoprocessor, findCoprocessorEnvironment, getCoprocessors, getLoadedCoprocessors, handleCoprocessorThrowable, load, load, loadInstance, loadSystemCoprocessors, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegionCoprocessorHost

public RegionCoprocessorHost(HRegion region,
                             RegionServerServices rsServices,
                             org.apache.hadoop.conf.Configuration conf)
Constructor

Parameters:
region - the region
rsServices - interface to available region server functionality
conf - the configuration
Method Detail

createEnvironment

public org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.RegionEnvironment createEnvironment(Class<?> implClass,
                                                                                                      Coprocessor instance,
                                                                                                      int priority,
                                                                                                      int seq,
                                                                                                      org.apache.hadoop.conf.Configuration conf)
Description copied from class: CoprocessorHost
Called when a new Coprocessor class is loaded

Specified by:
createEnvironment in class CoprocessorHost<org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.RegionEnvironment>

abortServer

protected void abortServer(CoprocessorEnvironment env,
                           Throwable e)
Overrides:
abortServer in class CoprocessorHost<org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.RegionEnvironment>

preOpen

public void preOpen()
Invoked before a region open


postOpen

public void postOpen()
Invoked after a region open


preClose

public void preClose(boolean abortRequested)
Invoked before a region is closed

Parameters:
abortRequested - true if the server is aborting

postClose

public void postClose(boolean abortRequested)
Invoked after a region is closed

Parameters:
abortRequested - true if the server is aborting

preCompactSelection

public boolean preCompactSelection(Store store,
                                   List<StoreFile> candidates)
Called prior to selecting the StoreFiles for compaction from the list of currently available candidates.

Parameters:
store - The store where compaction is being requested
candidates - The currently available store files
Returns:
If true, skip the normal selection process and use the current list

postCompactSelection

public void postCompactSelection(Store store,
                                 com.google.common.collect.ImmutableList<StoreFile> selected)
Called after the StoreFiles to be compacted have been selected from the available candidates.

Parameters:
store - The store where compaction is being requested
selected - The store files selected to compact

preCompact

public InternalScanner preCompact(Store store,
                                  InternalScanner scanner)
Called prior to rewriting the store files selected for compaction

Parameters:
store - the store being compacted
scanner - the scanner used to read store data during compaction

postCompact

public void postCompact(Store store,
                        StoreFile resultFile)
Called after the store compaction has completed.

Parameters:
store - the store being compacted
resultFile - the new store file written during compaction

preFlush

public void preFlush()
Invoked before a memstore flush


postFlush

public void postFlush()
Invoked after a memstore flush


preSplit

public void preSplit()
Invoked just before a split


postSplit

public void postSplit(HRegion l,
                      HRegion r)
Invoked just after a split

Parameters:
l - the new left-hand daughter region
r - the new right-hand daughter region

preGetClosestRowBefore

public boolean preGetClosestRowBefore(byte[] row,
                                      byte[] family,
                                      Result result)
                               throws IOException
Parameters:
row - the row key
family - the family
result - the result set from the region
Returns:
true if default processing should be bypassed
Throws:
IOException - Exception

postGetClosestRowBefore

public void postGetClosestRowBefore(byte[] row,
                                    byte[] family,
                                    Result result)
                             throws IOException
Parameters:
row - the row key
family - the family
result - the result set from the region
Throws:
IOException - Exception

preGet

public boolean preGet(Get get,
                      List<KeyValue> results)
               throws IOException
Parameters:
get - the Get request
Returns:
true if default processing should be bypassed
Throws:
IOException - Exception

postGet

public void postGet(Get get,
                    List<KeyValue> results)
             throws IOException
Parameters:
get - the Get request
results - the result set
Throws:
IOException - Exception

preExists

public Boolean preExists(Get get)
                  throws IOException
Parameters:
get - the Get request
Returns:
true or false to return to client if bypassing normal operation, or null otherwise
Throws:
IOException - Exception

postExists

public boolean postExists(Get get,
                          boolean exists)
                   throws IOException
Parameters:
get - the Get request
exists - the result returned by the region server
Returns:
the result to return to the client
Throws:
IOException - Exception

prePut

public boolean prePut(Put put,
                      WALEdit edit,
                      boolean writeToWAL)
               throws IOException
Parameters:
put - The Put object
edit - The WALEdit object.
writeToWAL - true if the change should be written to the WAL
Returns:
true if default processing should be bypassed
Throws:
IOException - Exception

postPut

public void postPut(Put put,
                    WALEdit edit,
                    boolean writeToWAL)
             throws IOException
Parameters:
put - The Put object
edit - The WALEdit object.
writeToWAL - true if the change should be written to the WAL
Throws:
IOException - Exception

preDelete

public boolean preDelete(Delete delete,
                         WALEdit edit,
                         boolean writeToWAL)
                  throws IOException
Parameters:
delete - The Delete object
edit - The WALEdit object.
writeToWAL - true if the change should be written to the WAL
Returns:
true if default processing should be bypassed
Throws:
IOException - Exception

postDelete

public void postDelete(Delete delete,
                       WALEdit edit,
                       boolean writeToWAL)
                throws IOException
Parameters:
delete - The Delete object
edit - The WALEdit object.
writeToWAL - true if the change should be written to the WAL
Throws:
IOException - Exception

preCheckAndPut

public Boolean preCheckAndPut(byte[] row,
                              byte[] family,
                              byte[] qualifier,
                              CompareFilter.CompareOp compareOp,
                              WritableByteArrayComparable comparator,
                              Put put)
                       throws IOException
Parameters:
row - row to check
family - column family
qualifier - column qualifier
compareOp - the comparison operation
comparator - the comparator
put - data to put if check succeeds
Returns:
true or false to return to client if default processing should be bypassed, or null otherwise
Throws:
IOException - e

postCheckAndPut

public boolean postCheckAndPut(byte[] row,
                               byte[] family,
                               byte[] qualifier,
                               CompareFilter.CompareOp compareOp,
                               WritableByteArrayComparable comparator,
                               Put put,
                               boolean result)
                        throws IOException
Parameters:
row - row to check
family - column family
qualifier - column qualifier
compareOp - the comparison operation
comparator - the comparator
put - data to put if check succeeds
Throws:
IOException - e

preCheckAndDelete

public Boolean preCheckAndDelete(byte[] row,
                                 byte[] family,
                                 byte[] qualifier,
                                 CompareFilter.CompareOp compareOp,
                                 WritableByteArrayComparable comparator,
                                 Delete delete)
                          throws IOException
Parameters:
row - row to check
family - column family
qualifier - column qualifier
compareOp - the comparison operation
comparator - the comparator
delete - delete to commit if check succeeds
Returns:
true or false to return to client if default processing should be bypassed, or null otherwise
Throws:
IOException - e

postCheckAndDelete

public boolean postCheckAndDelete(byte[] row,
                                  byte[] family,
                                  byte[] qualifier,
                                  CompareFilter.CompareOp compareOp,
                                  WritableByteArrayComparable comparator,
                                  Delete delete,
                                  boolean result)
                           throws IOException
Parameters:
row - row to check
family - column family
qualifier - column qualifier
compareOp - the comparison operation
comparator - the comparator
delete - delete to commit if check succeeds
Throws:
IOException - e

preIncrementColumnValue

public Long preIncrementColumnValue(byte[] row,
                                    byte[] family,
                                    byte[] qualifier,
                                    long amount,
                                    boolean writeToWAL)
                             throws IOException
Parameters:
row - row to check
family - column family
qualifier - column qualifier
amount - long amount to increment
writeToWAL - true if the change should be written to the WAL
Returns:
return value for client if default operation should be bypassed, or null otherwise
Throws:
IOException - if an error occurred on the coprocessor

postIncrementColumnValue

public long postIncrementColumnValue(byte[] row,
                                     byte[] family,
                                     byte[] qualifier,
                                     long amount,
                                     boolean writeToWAL,
                                     long result)
                              throws IOException
Parameters:
row - row to check
family - column family
qualifier - column qualifier
amount - long amount to increment
writeToWAL - true if the change should be written to the WAL
result - the result returned by incrementColumnValue
Returns:
the result to return to the client
Throws:
IOException - if an error occurred on the coprocessor

preIncrement

public Result preIncrement(Increment increment)
                    throws IOException
Parameters:
increment - increment object
Returns:
result to return to client if default operation should be bypassed, null otherwise
Throws:
IOException - if an error occurred on the coprocessor

postIncrement

public Result postIncrement(Increment increment,
                            Result result)
                     throws IOException
Parameters:
increment - increment object
result - the result returned by postIncrement
Throws:
IOException - if an error occurred on the coprocessor

preScannerOpen

public RegionScanner preScannerOpen(Scan scan)
                             throws IOException
Parameters:
scan - the Scan specification
Returns:
scanner id to return to client if default operation should be bypassed, false otherwise
Throws:
IOException - Exception

postScannerOpen

public RegionScanner postScannerOpen(Scan scan,
                                     RegionScanner s)
                              throws IOException
Parameters:
scan - the Scan specification
s - the scanner
Returns:
the scanner instance to use
Throws:
IOException - Exception

preScannerNext

public Boolean preScannerNext(InternalScanner s,
                              List<Result> results,
                              int limit)
                       throws IOException
Parameters:
s - the scanner
results - the result set returned by the region server
limit - the maximum number of results to return
Returns:
'has next' indication to client if bypassing default behavior, or null otherwise
Throws:
IOException - Exception

postScannerNext

public boolean postScannerNext(InternalScanner s,
                               List<Result> results,
                               int limit,
                               boolean hasMore)
                        throws IOException
Parameters:
s - the scanner
results - the result set returned by the region server
limit - the maximum number of results to return
hasMore -
Returns:
'has more' indication to give to client
Throws:
IOException - Exception

preScannerClose

public boolean preScannerClose(InternalScanner s)
                        throws IOException
Parameters:
s - the scanner
Returns:
true if default behavior should be bypassed, false otherwise
Throws:
IOException - Exception

postScannerClose

public void postScannerClose(InternalScanner s)
                      throws IOException
Parameters:
s - the scanner
Throws:
IOException - Exception

preWALRestore

public boolean preWALRestore(HRegionInfo info,
                             HLogKey logKey,
                             WALEdit logEdit)
                      throws IOException
Parameters:
info -
logKey -
logEdit -
Returns:
true if default behavior should be bypassed, false otherwise
Throws:
IOException

postWALRestore

public void postWALRestore(HRegionInfo info,
                           HLogKey logKey,
                           WALEdit logEdit)
                    throws IOException
Parameters:
info -
logKey -
logEdit -
Throws:
IOException


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.