org.apache.hadoop.hbase.client
Interface HConnection

All Known Subinterfaces:
ServerConnection

public interface HConnection

Cluster connection. HConnectionManager manages instances of this class.


Method Summary
 HRegionInterface getHRegionConnection(HServerAddress regionServer)
          Establishes a connection to the region server at the specified address.
 HTableDescriptor getHTableDescriptor(byte[] tableName)
           
 HMasterInterface getMaster()
           
 HRegionLocation getRegionLocation(byte[] tableName, byte[] row, boolean reload)
          Find region location hosting passed row
<T> T
getRegionServerForWithoutRetries(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.
 boolean isMasterRunning()
           
 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 processBatchOfRows(ArrayList<BatchUpdate> list, byte[] tableName)
          Process a batch of rows.
 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.
 boolean tableExists(byte[] tableName)
          Checks if tableName exists.
 

Method Detail

getMaster

HMasterInterface getMaster()
                           throws MasterNotRunningException
Returns:
proxy connection to master server for this instance
Throws:
MasterNotRunningException

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

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 -
Returns:
true if the table is enabled, false otherwise
Throws:
IOException

isTableDisabled

boolean isTableDisabled(byte[] tableName)
                        throws IOException
Parameters:
tableName -
Returns:
true if the table is disabled, false otherwise
Throws:
IOException

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

getHTableDescriptor

HTableDescriptor getHTableDescriptor(byte[] tableName)
                                     throws IOException
Parameters:
tableName -
Returns:
table metadata
Throws:
IOException

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

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

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

getRegionLocation

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

Parameters:
tableName -
row - Row to find.
reload - If true do not use cache, otherwise bypass.
Returns:
Location of row.
Throws:
IOException

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 -
Returns:
an object of type T
Throws:
IOException
RuntimeException

getRegionServerForWithoutRetries

<T> T getRegionServerForWithoutRetries(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 -
Returns:
an object of type T
Throws:
IOException
RuntimeException

processBatchOfRows

void processBatchOfRows(ArrayList<BatchUpdate> list,
                        byte[] tableName)
                        throws IOException
Process a batch of rows. Currently it only works for updates until HBASE-880 is available. Does the retries.

Parameters:
list - A batch of rows to process
tableName - The name of the table
Throws:
IOException


Copyright © 2008 The Apache Software Foundation