org.apache.hadoop.hbase.client
Interface HConnection

All Known Subinterfaces:
ServerConnection

public interface HConnection

Cluster connection. HConnectionManager manages instances of this class.


Method Summary
 void clearRegionCache()
          Allows flushing the region cache.
 HRegionInterface getHRegionConnection(HServerAddress regionServer)
          Establishes a connection to the region server at the specified address.
 HRegionInterface getHRegionConnection(HServerAddress regionServer, boolean getMaster)
          Establishes a connection to the region server at the specified address.
 HTableDescriptor getHTableDescriptor(byte[] tableName)
           
 HMasterInterface getMaster()
           
 boolean getRegionCachePrefetch(byte[] tableName)
          Check whether region cache prefetch is enabled or not.
 HRegionLocation getRegionLocation(byte[] tableName, byte[] row, boolean reload)
          Find region location hosting passed row
<T> T
getRegionServerWithoutRetries(ServerCallable<T> callable)
          Pass in a ServerCallable with your particular bit of logic defined and this method will pass it to the defined region server.
<T> T
getRegionServerWithRetries(ServerCallable<T> callable)
          Pass in a ServerCallable with your particular bit of logic defined and this method will manage the process of doing retries with timed waits and refinds of missing regions.
 ZooKeeperWrapper getZooKeeperWrapper()
          Retrieve ZooKeeperWrapper used by the connection.
 boolean isMasterRunning()
           
 boolean isTableAvailable(byte[] tableName)
           
 boolean isTableDisabled(byte[] tableName)
           
 boolean isTableEnabled(byte[] tableName)
          A table that isTableEnabled == false and isTableDisabled == false is possible.
 HTableDescriptor[] listTables()
          List all the userspace tables.
 HRegionLocation locateRegion(byte[] tableName, byte[] row)
          Find the location of the region of tableName that row lives in.
 void prewarmRegionCache(byte[] tableName, Map<HRegionInfo,HServerAddress> regions)
          Load the region map and warm up the global region cache for the table.
 int processBatchOfDeletes(List<Delete> list, byte[] tableName)
          Process a batch of Deletes.
 void processBatchOfPuts(List<Put> list, byte[] tableName, ExecutorService pool)
           
 int processBatchOfRows(ArrayList<Put> list, byte[] tableName)
          Process a batch of Puts.
 HRegionLocation relocateRegion(byte[] tableName, byte[] row)
          Find the location of the region of tableName that row lives in, ignoring any value that might be in the cache.
 void setRegionCachePrefetch(byte[] tableName, boolean enable)
          Enable or disable region cache prefetch for the table.
 boolean tableExists(byte[] tableName)
          Checks if tableName exists.
 

Method Detail

getZooKeeperWrapper

ZooKeeperWrapper getZooKeeperWrapper()
                                     throws IOException
Retrieve ZooKeeperWrapper used by the connection.

Returns:
ZooKeeperWrapper handle being used by the connection.
Throws:
IOException - if a remote or network exception occurs

getMaster

HMasterInterface getMaster()
                           throws MasterNotRunningException
Returns:
proxy connection to master server for this instance
Throws:
MasterNotRunningException - if the master is not running

isMasterRunning

boolean isMasterRunning()
Returns:
- true if the master server is running

tableExists

boolean tableExists(byte[] tableName)
                    throws MasterNotRunningException
Checks if tableName exists.

Parameters:
tableName - Table to check.
Returns:
True if table exists already.
Throws:
MasterNotRunningException - if the master is not running

isTableEnabled

boolean isTableEnabled(byte[] tableName)
                       throws IOException
A table that isTableEnabled == false and isTableDisabled == false is possible. This happens when a table has a lot of regions that must be processed.

Parameters:
tableName - table name
Returns:
true if the table is enabled, false otherwise
Throws:
IOException - if a remote or network exception occurs

isTableDisabled

boolean isTableDisabled(byte[] tableName)
                        throws IOException
Parameters:
tableName - table name
Returns:
true if the table is disabled, false otherwise
Throws:
IOException - if a remote or network exception occurs

isTableAvailable

boolean isTableAvailable(byte[] tableName)
                         throws IOException
Parameters:
tableName - table name
Returns:
true if all regions of the table are available, false otherwise
Throws:
IOException - if a remote or network exception occurs

listTables

HTableDescriptor[] listTables()
                              throws IOException
List all the userspace tables. In other words, scan the META table. If we wanted this to be really fast, we could implement a special catalog table that just contains table names and their descriptors. Right now, it only exists as part of the META table's region info.

Returns:
- returns an array of HTableDescriptors
Throws:
IOException - if a remote or network exception occurs

getHTableDescriptor

HTableDescriptor getHTableDescriptor(byte[] tableName)
                                     throws IOException
Parameters:
tableName - table name
Returns:
table metadata
Throws:
IOException - if a remote or network exception occurs

locateRegion

HRegionLocation locateRegion(byte[] tableName,
                             byte[] row)
                             throws IOException
Find the location of the region of tableName that row lives in.

Parameters:
tableName - name of the table row is in
row - row key you're trying to find the region of
Returns:
HRegionLocation that describes where to find the reigon in question
Throws:
IOException - if a remote or network exception occurs

clearRegionCache

void clearRegionCache()
Allows flushing the region cache.


relocateRegion

HRegionLocation relocateRegion(byte[] tableName,
                               byte[] row)
                               throws IOException
Find the location of the region of tableName that row lives in, ignoring any value that might be in the cache.

Parameters:
tableName - name of the table row is in
row - row key you're trying to find the region of
Returns:
HRegionLocation that describes where to find the reigon in question
Throws:
IOException - if a remote or network exception occurs

getHRegionConnection

HRegionInterface getHRegionConnection(HServerAddress regionServer)
                                      throws IOException
Establishes a connection to the region server at the specified address.

Parameters:
regionServer - - the server to connect to
Returns:
proxy for HRegionServer
Throws:
IOException - if a remote or network exception occurs

getHRegionConnection

HRegionInterface getHRegionConnection(HServerAddress regionServer,
                                      boolean getMaster)
                                      throws IOException
Establishes a connection to the region server at the specified address.

Parameters:
regionServer - - the server to connect to
getMaster - - do we check if master is alive
Returns:
proxy for HRegionServer
Throws:
IOException - if a remote or network exception occurs

getRegionLocation

HRegionLocation getRegionLocation(byte[] tableName,
                                  byte[] row,
                                  boolean reload)
                                  throws IOException
Find region location hosting passed row

Parameters:
tableName - table name
row - Row to find.
reload - If true do not use cache, otherwise bypass.
Returns:
Location of row.
Throws:
IOException - if a remote or network exception occurs

getRegionServerWithRetries

<T> T getRegionServerWithRetries(ServerCallable<T> callable)
                             throws IOException,
                                    RuntimeException
Pass in a ServerCallable with your particular bit of logic defined and this method will manage the process of doing retries with timed waits and refinds of missing regions.

Type Parameters:
T - the type of the return value
Parameters:
callable - callable to run
Returns:
an object of type T
Throws:
IOException - if a remote or network exception occurs
RuntimeException - other unspecified error

getRegionServerWithoutRetries

<T> T getRegionServerWithoutRetries(ServerCallable<T> callable)
                                throws IOException,
                                       RuntimeException
Pass in a ServerCallable with your particular bit of logic defined and this method will pass it to the defined region server.

Type Parameters:
T - the type of the return value
Parameters:
callable - callable to run
Returns:
an object of type T
Throws:
IOException - if a remote or network exception occurs
RuntimeException - other unspecified error

processBatchOfRows

int processBatchOfRows(ArrayList<Put> list,
                       byte[] tableName)
                       throws IOException
Process a batch of Puts. Does the retries.

Parameters:
list - A batch of Puts to process.
tableName - The name of the table
Returns:
Count of committed Puts. On fault, < list.size().
Throws:
IOException - if a remote or network exception occurs

processBatchOfDeletes

int processBatchOfDeletes(List<Delete> list,
                          byte[] tableName)
                          throws IOException
Process a batch of Deletes. Does the retries.

Parameters:
list - A batch of Deletes to process.
tableName - The name of the table
Returns:
Count of committed Deletes. On fault, < list.size().
Throws:
IOException - if a remote or network exception occurs

processBatchOfPuts

void processBatchOfPuts(List<Put> list,
                        byte[] tableName,
                        ExecutorService pool)
                        throws IOException
Throws:
IOException

setRegionCachePrefetch

void setRegionCachePrefetch(byte[] tableName,
                            boolean enable)
Enable or disable region cache prefetch for the table. It will be applied for the given table's all HTable instances within this connection. By default, the cache prefetch is enabled.

Parameters:
tableName - name of table to configure.
enable - Set to true to enable region cache prefetch.

getRegionCachePrefetch

boolean getRegionCachePrefetch(byte[] tableName)
Check whether region cache prefetch is enabled or not.

Parameters:
tableName - name of table to check
Returns:
true if table's region cache prefecth is enabled. Otherwise it is disabled.

prewarmRegionCache

void prewarmRegionCache(byte[] tableName,
                        Map<HRegionInfo,HServerAddress> regions)
Load the region map and warm up the global region cache for the table.

Parameters:
tableName - name of the table to perform region cache prewarm.
regions - a region map.


Copyright © 2010 Apache Software Foundation. All Rights Reserved.