org.apache.hadoop.hbase.ipc
Interface HRegionInterface

All Superinterfaces:
Abortable, Stoppable, VersionedProtocol
All Known Implementing Classes:
HRegionServer

public interface HRegionInterface
extends VersionedProtocol, Stoppable, Abortable

Clients interact with HRegionServers using a handle to the HRegionInterface.

NOTE: if you change the interface, you must change the RPC version number in HBaseRPCProtocolVersion


Field Summary
static long VERSION
          This Interfaces' version.
 
Method Summary
 Result append(byte[] regionName, Append append)
          Appends values to one or more columns values in a row.
 boolean bulkLoadHFiles(List<Pair<byte[],String>> familyPaths, byte[] regionName)
          Atomically bulk load multiple HFiles (say from different column families) into an open region.
 boolean bulkLoadHFiles(List<Pair<byte[],String>> familyPaths, byte[] regionName, boolean assignSeqNum)
          Atomically bulk load multiple HFiles (say from different column families) into an open region.
 boolean checkAndDelete(byte[] regionName, byte[] row, byte[] family, byte[] qualifier, byte[] value, Delete delete)
          Atomically checks if a row/family/qualifier value match the expectedValue.
 boolean checkAndDelete(byte[] regionName, byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, WritableByteArrayComparable comparator, Delete delete)
          Atomically checks if a row/family/qualifier value match the expectedValue.
 boolean checkAndPut(byte[] regionName, byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put)
          Atomically checks if a row/family/qualifier value match the expectedValue.
 boolean checkAndPut(byte[] regionName, byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, WritableByteArrayComparable comparator, Put put)
          Atomically checks if a row/family/qualifier value match the expectedValue.
 void close(long scannerId)
          Close a scanner
 boolean closeRegion(byte[] encodedRegionName, boolean zk)
          Closes the region in the RS with the specified encoded regionName and will use or not use ZK during the close according to the specified flag.
 boolean closeRegion(HRegionInfo region)
          Closes the specified region.
 boolean closeRegion(HRegionInfo region, boolean zk)
          Closes the specified region and will use or not use ZK during the close according to the specified flag.
 boolean closeRegion(HRegionInfo region, int versionOfClosingNode)
          Closes the specified region.
 void compactRegion(HRegionInfo regionInfo, boolean major)
          Compacts the specified region.
 void compactRegion(HRegionInfo regionInfo, boolean major, byte[] columnFamily)
          Compacts a column-family within a specified region.
 void delete(byte[] regionName, Delete delete)
          Deletes all the KeyValues that match those found in the Delete object, if their ts <= to the Delete.
 int delete(byte[] regionName, List<Delete> deletes)
          Put an array of deletes into the specified region
 ExecResult execCoprocessor(byte[] regionName, Exec call)
          Executes a single CoprocessorProtocol method using the registered protocol handlers.
 boolean exists(byte[] regionName, Get get)
          Perform exists operation.
 void flushRegion(byte[] regionName)
          Flush the given region
 void flushRegion(byte[] regionName, long ifOlderThanTS)
          Flush the given region if lastFlushTime < ifOlderThanTS
 void flushRegion(HRegionInfo regionInfo)
          Deprecated. use flushRegion(byte[]) instead
 Result get(byte[] regionName, Get get)
          Perform Get operation.
 List<BlockCacheColumnFamilySummary> getBlockCacheColumnFamilySummaries()
          Performs a BlockCache summary and returns a List of BlockCacheColumnFamilySummary objects.
 Result getClosestRowBefore(byte[] regionName, byte[] row, byte[] family)
          Return all the data for the row that matches row exactly, or the one that immediately preceeds it.
 String getCompactionState(byte[] regionName)
          Get the current compaction state of the region.
 HServerInfo getHServerInfo()
          Deprecated.  
 long getLastFlushTime(byte[] regionName)
          Gets last flush time for the given region
 List<HRegionInfo> getOnlineRegions()
           
 HRegionInfo getRegionInfo(byte[] regionName)
          Get metainfo about an HRegion
 List<String> getStoreFileList(byte[] regionName)
          Get a list of store files for all CFs in a particular region
 List<String> getStoreFileList(byte[] regionName, byte[] columnFamily)
          Get a list of store files for a particular CF in a particular region
 List<String> getStoreFileList(byte[] regionName, byte[][] columnFamilies)
          Get a list of store files for a set of CFs in a particular region
 Result increment(byte[] regionName, Increment increment)
          Increments one or more columns values in a row.
 long incrementColumnValue(byte[] regionName, byte[] row, byte[] family, byte[] qualifier, long amount, boolean writeToWAL)
          Atomically increments a column value.
 long lockRow(byte[] regionName, byte[] row)
          Opens a remote row lock.
<R> MultiResponse
multi(MultiAction<R> multi)
          Method used for doing multiple actions(Deletes, Gets and Puts) in one call
 void mutateRow(byte[] regionName, RowMutations rm)
           
 Result next(long scannerId)
          Get the next set of values
 Result[] next(long scannerId, int numberOfRows)
          Get the next set of values
 RegionOpeningState openRegion(HRegionInfo region)
          Opens the specified region.
 RegionOpeningState openRegion(HRegionInfo region, int versionOfOfflineNode)
          Opens the specified region.
 void openRegions(List<HRegionInfo> regions)
          Opens the specified regions.
 long openScanner(byte[] regionName, Scan scan)
          Opens a remote scanner with a RowFilter.
 int put(byte[] regionName, List<Put> puts)
          Put an array of puts into the specified region
 void put(byte[] regionName, Put put)
          Put data into the specified region
 void replicateLogEntries(HLog.Entry[] entries)
          Replicates the given entries.
 byte[][] rollHLogWriter()
          Roll the log writer.
 Result[] scan(byte[] regionName, Scan scan, int numberOfRows)
          Perform scan operation.
 void splitRegion(HRegionInfo regionInfo)
          Splits the specified region.
 void splitRegion(HRegionInfo regionInfo, byte[] splitPoint)
          Splits the specified region.
 void stop(String why)
          Stop this service.
 void unlockRow(byte[] regionName, long lockId)
          Releases a remote row lock.
 
Methods inherited from interface org.apache.hadoop.hbase.ipc.VersionedProtocol
getProtocolSignature, getProtocolVersion
 
Methods inherited from interface org.apache.hadoop.hbase.Stoppable
isStopped
 
Methods inherited from interface org.apache.hadoop.hbase.Abortable
abort, isAborted
 

Field Detail

VERSION

static final long VERSION
This Interfaces' version. Version changes when the Interface changes.

See Also:
Constant Field Values
Method Detail

getRegionInfo

HRegionInfo getRegionInfo(byte[] regionName)
                          throws NotServingRegionException,
                                 ConnectException,
                                 IOException
Get metainfo about an HRegion

Parameters:
regionName - name of the region
Returns:
HRegionInfo object for region
Throws:
NotServingRegionException
ConnectException
IOException - This can manifest as an Hadoop ipc RemoteException

flushRegion

void flushRegion(byte[] regionName)
                 throws IllegalArgumentException,
                        IOException
Flush the given region

Parameters:
region - name
Throws:
IllegalArgumentException
IOException

flushRegion

void flushRegion(byte[] regionName,
                 long ifOlderThanTS)
                 throws IllegalArgumentException,
                        IOException
Flush the given region if lastFlushTime < ifOlderThanTS

Parameters:
region - name
timestamp -
Throws:
IllegalArgumentException
IOException

getLastFlushTime

long getLastFlushTime(byte[] regionName)
Gets last flush time for the given region

Returns:
the last flush time for a region

getStoreFileList

List<String> getStoreFileList(byte[] regionName,
                              byte[] columnFamily)
                              throws IllegalArgumentException
Get a list of store files for a particular CF in a particular region

Parameters:
region - name
CF - name
Returns:
the list of store files
Throws:
IllegalArgumentException

getStoreFileList

List<String> getStoreFileList(byte[] regionName,
                              byte[][] columnFamilies)
                              throws IllegalArgumentException
Get a list of store files for a set of CFs in a particular region

Parameters:
region - name
CF - names
Returns:
the list of store files
Throws:
IllegalArgumentException

getStoreFileList

List<String> getStoreFileList(byte[] regionName)
                              throws IllegalArgumentException
Get a list of store files for all CFs in a particular region

Parameters:
region - name
Returns:
the list of store files
Throws:
IllegalArgumentException

getClosestRowBefore

Result getClosestRowBefore(byte[] regionName,
                           byte[] row,
                           byte[] family)
                           throws IOException
Return all the data for the row that matches row exactly, or the one that immediately preceeds it.

Parameters:
regionName - region name
row - row key
family - Column family to look for row in.
Returns:
map of values
Throws:
IOException - e

get

Result get(byte[] regionName,
           Get get)
           throws IOException
Perform Get operation.

Parameters:
regionName - name of region to get from
get - Get operation
Returns:
Result
Throws:
IOException - e

exists

boolean exists(byte[] regionName,
               Get get)
               throws IOException
Perform exists operation.

Parameters:
regionName - name of region to get from
get - Get operation describing cell to test
Returns:
true if exists
Throws:
IOException - e

put

void put(byte[] regionName,
         Put put)
         throws IOException
Put data into the specified region

Parameters:
regionName - region name
put - the data to be put
Throws:
IOException - e

put

int put(byte[] regionName,
        List<Put> puts)
        throws IOException
Put an array of puts into the specified region

Parameters:
regionName - region name
puts - List of puts to execute
Returns:
The number of processed put's. Returns -1 if all Puts processed successfully.
Throws:
IOException - e

delete

void delete(byte[] regionName,
            Delete delete)
            throws IOException
Deletes all the KeyValues that match those found in the Delete object, if their ts <= to the Delete. In case of a delete with a specific ts it only deletes that specific KeyValue.

Parameters:
regionName - region name
delete - delete object
Throws:
IOException - e

delete

int delete(byte[] regionName,
           List<Delete> deletes)
           throws IOException
Put an array of deletes into the specified region

Parameters:
regionName - region name
deletes - delete List to execute
Returns:
The number of processed deletes. Returns -1 if all Deletes processed successfully.
Throws:
IOException - e

checkAndPut

boolean checkAndPut(byte[] regionName,
                    byte[] row,
                    byte[] family,
                    byte[] qualifier,
                    byte[] value,
                    Put put)
                    throws IOException
Atomically checks if a row/family/qualifier value match the expectedValue. If it does, it adds the put. If passed expected value is null, then the check is for non-existance of the row/column.

Parameters:
regionName - region name
row - row to check
family - column family
qualifier - column qualifier
value - the expected value
put - data to put if check succeeds
Returns:
true if the new put was execute, false otherwise
Throws:
IOException - e

checkAndDelete

boolean checkAndDelete(byte[] regionName,
                       byte[] row,
                       byte[] family,
                       byte[] qualifier,
                       byte[] value,
                       Delete delete)
                       throws IOException
Atomically checks if a row/family/qualifier value match the expectedValue. If it does, it adds the delete. If passed expected value is null, then the check is for non-existance of the row/column.

Parameters:
regionName - region name
row - row to check
family - column family
qualifier - column qualifier
value - the expected value
delete - data to delete if check succeeds
Returns:
true if the new delete was execute, false otherwise
Throws:
IOException - e

incrementColumnValue

long incrementColumnValue(byte[] regionName,
                          byte[] row,
                          byte[] family,
                          byte[] qualifier,
                          long amount,
                          boolean writeToWAL)
                          throws IOException
Atomically increments a column value. If the column value isn't long-like, this could throw an exception. If passed expected value is null, then the check is for non-existance of the row/column.

Parameters:
regionName - region name
row - row to check
family - column family
qualifier - column qualifier
amount - long amount to increment
writeToWAL - whether to write the increment to the WAL
Returns:
new incremented column value
Throws:
IOException - e

mutateRow

void mutateRow(byte[] regionName,
               RowMutations rm)
               throws IOException
Throws:
IOException

append

Result append(byte[] regionName,
              Append append)
              throws IOException
Appends values to one or more columns values in a row. Optionally Returns the updated keys after the append.

This operation does not appear atomic to readers. Appends are done under a row lock but readers do not take row locks.

Parameters:
regionName - region name
append - Append operation
Returns:
changed cells (maybe null)
Throws:
IOException

increment

Result increment(byte[] regionName,
                 Increment increment)
                 throws IOException
Increments one or more columns values in a row. Returns the updated keys after the increment.

This operation does not appear atomic to readers. Increments are done under a row lock but readers do not take row locks.

Parameters:
regionName - region name
increment - increment operation
Returns:
incremented cells
Throws:
IOException

openScanner

long openScanner(byte[] regionName,
                 Scan scan)
                 throws IOException
Opens a remote scanner with a RowFilter.

Parameters:
regionName - name of region to scan
scan - configured scan object
Returns:
scannerId scanner identifier used in other calls
Throws:
IOException - e

next

Result next(long scannerId)
            throws IOException
Get the next set of values

Parameters:
scannerId - clientId passed to openScanner
Returns:
map of values; returns null if no results.
Throws:
IOException - e

next

Result[] next(long scannerId,
              int numberOfRows)
              throws IOException
Get the next set of values

Parameters:
scannerId - clientId passed to openScanner
numberOfRows - the number of rows to fetch
Returns:
Array of Results (map of values); array is empty if done with this region and null if we are NOT to go to the next region (happens when a filter rules that the scan is done).
Throws:
IOException - e

close

void close(long scannerId)
           throws IOException
Close a scanner

Parameters:
scannerId - the scanner id returned by openScanner
Throws:
IOException - e

lockRow

long lockRow(byte[] regionName,
             byte[] row)
             throws IOException
Opens a remote row lock.

Parameters:
regionName - name of region
row - row to lock
Returns:
lockId lock identifier
Throws:
IOException - e

unlockRow

void unlockRow(byte[] regionName,
               long lockId)
               throws IOException
Releases a remote row lock.

Parameters:
regionName - region name
lockId - the lock id returned by lockRow
Throws:
IOException - e

getOnlineRegions

List<HRegionInfo> getOnlineRegions()
                                   throws IOException
Returns:
All regions online on this region server
Throws:
IOException - e

getHServerInfo

HServerInfo getHServerInfo()
                           throws IOException
Deprecated. 

Method used when a master is taking the place of another failed one.

Returns:
This servers HServerInfo; it has RegionServer POV on the hostname which may not agree w/ how the Master sees this server.
Throws:
IOException - e

multi

<R> MultiResponse multi(MultiAction<R> multi)
                    throws IOException
Method used for doing multiple actions(Deletes, Gets and Puts) in one call

Parameters:
multi -
Returns:
MultiResult
Throws:
IOException

bulkLoadHFiles

boolean bulkLoadHFiles(List<Pair<byte[],String>> familyPaths,
                       byte[] regionName)
                       throws IOException
Atomically bulk load multiple HFiles (say from different column families) into an open region.

Parameters:
familyPaths - List of (family, hfile path) pairs
regionName - name of region to load hfiles into
Returns:
true if successful, false if failed recoverably
Throws:
IOException - if fails unrecoverably

bulkLoadHFiles

boolean bulkLoadHFiles(List<Pair<byte[],String>> familyPaths,
                       byte[] regionName,
                       boolean assignSeqNum)
                       throws IOException
Atomically bulk load multiple HFiles (say from different column families) into an open region.

Parameters:
familyPaths - List of (family, hfile path) pairs
regionName - name of region to load hfiles into
assignSeqNum - should we assign sequence numbers
Returns:
true if successful, false if failed recoverably
Throws:
IOException - if fails unrecoverably

openRegion

RegionOpeningState openRegion(HRegionInfo region)
                              throws IOException
Opens the specified region.

Parameters:
region - region to open
Returns:
RegionOpeningState OPENED - if region open request was successful. ALREADY_OPENED - if the region was already opened. FAILED_OPENING - if region opening failed.
Throws:
IOException

openRegion

RegionOpeningState openRegion(HRegionInfo region,
                              int versionOfOfflineNode)
                              throws IOException
Opens the specified region.

Parameters:
region - region to open
versionOfOfflineNode - the version of znode to compare when RS transitions the znode from OFFLINE state.
Returns:
RegionOpeningState OPENED - if region open request was successful. ALREADY_OPENED - if the region was already opened. FAILED_OPENING - if region opening failed.
Throws:
IOException

openRegions

void openRegions(List<HRegionInfo> regions)
                 throws IOException
Opens the specified regions.

Parameters:
regions - regions to open
Throws:
IOException

closeRegion

boolean closeRegion(HRegionInfo region)
                    throws IOException
Closes the specified region.

Parameters:
region - region to close
Returns:
true if closing region, false if not
Throws:
IOException

closeRegion

boolean closeRegion(HRegionInfo region,
                    int versionOfClosingNode)
                    throws IOException
Closes the specified region.

Parameters:
region - region to close
versionOfClosingNode - the version of znode to compare when RS transitions the znode from CLOSING state.
Returns:
true if closing region, false if not
Throws:
IOException

closeRegion

boolean closeRegion(HRegionInfo region,
                    boolean zk)
                    throws IOException
Closes the specified region and will use or not use ZK during the close according to the specified flag.

Parameters:
region - region to close
zk - true if transitions should be done in ZK, false if not
Returns:
true if closing region, false if not
Throws:
IOException

closeRegion

boolean closeRegion(byte[] encodedRegionName,
                    boolean zk)
                    throws IOException
Closes the region in the RS with the specified encoded regionName and will use or not use ZK during the close according to the specified flag. Note that the encoded region name is in byte format.

Parameters:
encodedRegionName - in bytes
zk - true if to use zookeeper, false if need not.
Returns:
true if region is closed, false if not.
Throws:
IOException

flushRegion

void flushRegion(HRegionInfo regionInfo)
                 throws NotServingRegionException,
                        IOException
Deprecated. use flushRegion(byte[]) instead

Flushes the MemStore of the specified region.

This method is synchronous.

Parameters:
regionInfo - region to flush
Throws:
NotServingRegionException
IOException

splitRegion

void splitRegion(HRegionInfo regionInfo)
                 throws NotServingRegionException,
                        IOException
Splits the specified region.

This method currently flushes the region and then forces a compaction which will then trigger a split. The flush is done synchronously but the compaction is asynchronous.

Parameters:
regionInfo - region to split
Throws:
NotServingRegionException
IOException

splitRegion

void splitRegion(HRegionInfo regionInfo,
                 byte[] splitPoint)
                 throws NotServingRegionException,
                        IOException
Splits the specified region.

This method currently flushes the region and then forces a compaction which will then trigger a split. The flush is done synchronously but the compaction is asynchronous.

Parameters:
regionInfo - region to split
splitPoint - the explicit row to split on
Throws:
NotServingRegionException
IOException

compactRegion

void compactRegion(HRegionInfo regionInfo,
                   boolean major)
                   throws NotServingRegionException,
                          IOException
Compacts the specified region. Performs a major compaction if specified.

This method is asynchronous.

Parameters:
regionInfo - region to compact
major - true to force major compaction
Throws:
NotServingRegionException
IOException

compactRegion

void compactRegion(HRegionInfo regionInfo,
                   boolean major,
                   byte[] columnFamily)
                   throws NotServingRegionException,
                          IOException
Compacts a column-family within a specified region. Performs a major compaction if specified.

This method is asynchronous.

Parameters:
regionInfo - region to compact
major - true to force major compaction
columnFamily - column family within a region to compact
Throws:
NotServingRegionException
IOException

replicateLogEntries

void replicateLogEntries(HLog.Entry[] entries)
                         throws IOException
Replicates the given entries. The guarantee is that the given entries will be durable on the slave cluster if this method returns without any exception. hbase.replication has to be set to true for this to work.

Parameters:
entries - entries to replicate
Throws:
IOException

execCoprocessor

ExecResult execCoprocessor(byte[] regionName,
                           Exec call)
                           throws IOException
Executes a single CoprocessorProtocol method using the registered protocol handlers. CoprocessorProtocol implementations must be registered via the HRegion.registerProtocol(Class, org.apache.hadoop.hbase.ipc.CoprocessorProtocol) method before they are available.

Parameters:
regionName - name of the region against which the invocation is executed
call - an Exec instance identifying the protocol, method name, and parameters for the method invocation
Returns:
an ExecResult instance containing the region name of the invocation and the return value
Throws:
IOException - if no registered protocol handler is found or an error occurs during the invocation
See Also:
HRegion.registerProtocol(Class, org.apache.hadoop.hbase.ipc.CoprocessorProtocol)

checkAndPut

boolean checkAndPut(byte[] regionName,
                    byte[] row,
                    byte[] family,
                    byte[] qualifier,
                    CompareFilter.CompareOp compareOp,
                    WritableByteArrayComparable comparator,
                    Put put)
                    throws IOException
Atomically checks if a row/family/qualifier value match the expectedValue. If it does, it adds the put. If passed expected value is null, then the check is for non-existance of the row/column.

Parameters:
regionName -
row -
family -
qualifier -
compareOp -
comparator -
put -
Returns:
true if the new put was execute, false otherwise
Throws:
IOException

checkAndDelete

boolean checkAndDelete(byte[] regionName,
                       byte[] row,
                       byte[] family,
                       byte[] qualifier,
                       CompareFilter.CompareOp compareOp,
                       WritableByteArrayComparable comparator,
                       Delete delete)
                       throws IOException
Atomically checks if a row/family/qualifier value match the expectedValue. If it does, it adds the delete. If passed expected value is null, then the check is for non-existance of the row/column.

Parameters:
regionName -
row -
family -
qualifier -
compareOp -
comparator -
delete -
Returns:
true if the new put was execute, false otherwise
Throws:
IOException

getBlockCacheColumnFamilySummaries

List<BlockCacheColumnFamilySummary> getBlockCacheColumnFamilySummaries()
                                                                       throws IOException
Performs a BlockCache summary and returns a List of BlockCacheColumnFamilySummary objects. This method could be fairly heavyweight in that it evaluates the entire HBase file-system against what is in the RegionServer BlockCache.

Returns:
BlockCacheColumnFamilySummary
Throws:
IOException - exception

rollHLogWriter

byte[][] rollHLogWriter()
                        throws IOException,
                               FailedLogCloseException
Roll the log writer. That is, start writing log messages to a new file.

Returns:
If lots of logs, flush the returned regions so next time through we can clean logs. Returns null if nothing to flush. Names are actual region names as returned by HRegionInfo.getEncodedName()
Throws:
IOException
FailedLogCloseException

getCompactionState

String getCompactionState(byte[] regionName)
                          throws IOException
Get the current compaction state of the region.

Parameters:
regionName - the name of the region to check compaction statte.
Returns:
the compaction state name.
Throws:
IOException - exception

stop

void stop(String why)
Description copied from interface: Stoppable
Stop this service.

Specified by:
stop in interface Stoppable
Parameters:
why - Why we're stopping.

scan

Result[] scan(byte[] regionName,
              Scan scan,
              int numberOfRows)
              throws IOException
Perform scan operation.

Parameters:
regionName - name of region to get from
Scan - scan operation
numberOfRows - the maximum number of rows to fetch
Returns:
Array of Results;array is empty if done with this region and null if we are NOT to go to the next region (happens when a filter rules that the scan is done).
Throws:
IOException - e


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