org.apache.hadoop.hbase.client
Class CoprocessorHConnection

java.lang.Object
  extended by org.apache.hadoop.hbase.client.CoprocessorHConnection
All Implemented Interfaces:
Closeable, Abortable, HConnection

@InterfaceAudience.Private
@InterfaceStability.Evolving
public class CoprocessorHConnection
extends Object
implements HConnection

Connection to an HTable from within a Coprocessor. We can do some nice tricks since we know we are on a regionserver, for instance skipping the full serialization/deserialization of objects when talking to the server.

You should not use this class from any client - its an internal class meant for use by the coprocessor framework.


Field Summary
 
Fields inherited from interface org.apache.hadoop.hbase.client.HConnection
HBASE_CLIENT_CONNECTION_IMPL
 
Constructor Summary
CoprocessorHConnection(HConnection delegate, HRegionServer server)
           
 
Method Summary
 void abort(String why, Throwable e)
           
 void clearCaches(ServerName sn)
           
 void clearRegionCache()
           
 void clearRegionCache(byte[] tableName)
           
 void clearRegionCache(TableName tableName)
           
 void close()
           
 void deleteCachedRegionLocation(HRegionLocation location)
           
 AdminProtos.AdminService.BlockingInterface getAdmin(ServerName serverName)
           
 AdminProtos.AdminService.BlockingInterface getAdmin(ServerName serverName, boolean getMaster)
           
 ClientProtos.ClientService.BlockingInterface getClient(ServerName serverName)
           
 org.apache.hadoop.conf.Configuration getConfiguration()
           
static HConnection getConnectionForEnvironment(CoprocessorEnvironment env)
          Create an unmanaged HConnection based on the environment in which we are running the coprocessor.
 int getCurrentNrHRS()
           
 HTableDescriptor getHTableDescriptor(byte[] tableName)
           
 HTableDescriptor getHTableDescriptor(TableName tableName)
           
 HTableDescriptor[] getHTableDescriptors(List<String> tableNames)
           
 HTableDescriptor[] getHTableDescriptorsByTableName(List<TableName> tableNames)
           
 org.apache.hadoop.hbase.client.MasterKeepAliveConnection getKeepAliveMasterService()
           
 MasterProtos.MasterService.BlockingInterface getMaster()
           
 boolean getRegionCachePrefetch(byte[] tableName)
           
 boolean getRegionCachePrefetch(TableName tableName)
           
 HRegionLocation getRegionLocation(byte[] tableName, byte[] row, boolean reload)
           
 HRegionLocation getRegionLocation(TableName tableName, byte[] row, boolean reload)
           
 HTableInterface getTable(byte[] tableName)
           
 HTableInterface getTable(byte[] tableName, ExecutorService pool)
           
 HTableInterface getTable(String tableName)
           
 HTableInterface getTable(String tableName, ExecutorService pool)
           
 HTableInterface getTable(TableName tableName)
           
 HTableInterface getTable(TableName tableName, ExecutorService pool)
           
 String[] getTableNames()
           
 boolean isAborted()
           
 boolean isClosed()
           
 boolean isDeadServer(ServerName serverName)
           
 boolean isMasterRunning()
           
 boolean isTableAvailable(byte[] tableName)
           
 boolean isTableAvailable(byte[] tableName, byte[][] splitKeys)
           
 boolean isTableAvailable(TableName tableName)
           
 boolean isTableAvailable(TableName tableName, byte[][] splitKeys)
           
 boolean isTableDisabled(byte[] tableName)
           
 boolean isTableDisabled(TableName tableName)
           
 boolean isTableEnabled(byte[] tableName)
           
 boolean isTableEnabled(TableName tableName)
           
 TableName[] listTableNames()
           
 HTableDescriptor[] listTables()
           
 HRegionLocation locateRegion(byte[] regionName)
           
 HRegionLocation locateRegion(byte[] tableName, byte[] row)
           
 HRegionLocation locateRegion(TableName tableName, byte[] row)
           
 List<HRegionLocation> locateRegions(byte[] tableName)
           
 List<HRegionLocation> locateRegions(byte[] tableName, boolean useCache, boolean offlined)
           
 List<HRegionLocation> locateRegions(TableName tableName)
           
 List<HRegionLocation> locateRegions(TableName tableName, boolean useCache, boolean offlined)
           
 void processBatch(List<? extends Row> actions, byte[] tableName, ExecutorService pool, Object[] results)
           
 void processBatch(List<? extends Row> actions, TableName tableName, ExecutorService pool, Object[] results)
           
<R> void
processBatchCallback(List<? extends Row> list, byte[] tableName, ExecutorService pool, Object[] results, Batch.Callback<R> callback)
           
<R> void
processBatchCallback(List<? extends Row> list, TableName tableName, ExecutorService pool, Object[] results, Batch.Callback<R> callback)
           
 HRegionLocation relocateRegion(byte[] tableName, byte[] row)
           
 HRegionLocation relocateRegion(TableName tableName, byte[] row)
           
 void setRegionCachePrefetch(byte[] tableName, boolean enable)
           
 void setRegionCachePrefetch(TableName tableName, boolean enable)
           
 void updateCachedLocations(byte[] tableName, byte[] rowkey, Object exception, HRegionLocation source)
           
 void updateCachedLocations(TableName tableName, byte[] rowkey, Object exception, HRegionLocation source)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoprocessorHConnection

public CoprocessorHConnection(HConnection delegate,
                              HRegionServer server)
Method Detail

getConnectionForEnvironment

public static HConnection getConnectionForEnvironment(CoprocessorEnvironment env)
                                               throws IOException
Create an unmanaged HConnection based on the environment in which we are running the coprocessor. The HConnection must be externally cleaned up (we bypass the usual HTable cleanup mechanisms since we own everything).

Parameters:
env - environment hosting the HConnection
Returns:
an unmanaged HConnection.
Throws:
IOException - if we cannot create the basic connection

getClient

public ClientProtos.ClientService.BlockingInterface getClient(ServerName serverName)
                                                       throws IOException
Specified by:
getClient in interface HConnection
Throws:
IOException

abort

public void abort(String why,
                  Throwable e)
Specified by:
abort in interface Abortable

isAborted

public boolean isAborted()
Specified by:
isAborted in interface Abortable

getConfiguration

public org.apache.hadoop.conf.Configuration getConfiguration()
Specified by:
getConfiguration in interface HConnection

getTable

public HTableInterface getTable(String tableName)
                         throws IOException
Specified by:
getTable in interface HConnection
Throws:
IOException

getTable

public HTableInterface getTable(byte[] tableName)
                         throws IOException
Specified by:
getTable in interface HConnection
Throws:
IOException

getTable

public HTableInterface getTable(TableName tableName)
                         throws IOException
Specified by:
getTable in interface HConnection
Throws:
IOException

getTable

public HTableInterface getTable(String tableName,
                                ExecutorService pool)
                         throws IOException
Specified by:
getTable in interface HConnection
Throws:
IOException

getTable

public HTableInterface getTable(byte[] tableName,
                                ExecutorService pool)
                         throws IOException
Specified by:
getTable in interface HConnection
Throws:
IOException

getTable

public HTableInterface getTable(TableName tableName,
                                ExecutorService pool)
                         throws IOException
Specified by:
getTable in interface HConnection
Throws:
IOException

isMasterRunning

public boolean isMasterRunning()
                        throws MasterNotRunningException,
                               ZooKeeperConnectionException
Specified by:
isMasterRunning in interface HConnection
Throws:
MasterNotRunningException
ZooKeeperConnectionException

isTableEnabled

public boolean isTableEnabled(TableName tableName)
                       throws IOException
Specified by:
isTableEnabled in interface HConnection
Throws:
IOException

isTableEnabled

public boolean isTableEnabled(byte[] tableName)
                       throws IOException
Specified by:
isTableEnabled in interface HConnection
Throws:
IOException

isTableDisabled

public boolean isTableDisabled(TableName tableName)
                        throws IOException
Specified by:
isTableDisabled in interface HConnection
Throws:
IOException

isTableDisabled

public boolean isTableDisabled(byte[] tableName)
                        throws IOException
Specified by:
isTableDisabled in interface HConnection
Throws:
IOException

isTableAvailable

public boolean isTableAvailable(TableName tableName)
                         throws IOException
Specified by:
isTableAvailable in interface HConnection
Throws:
IOException

isTableAvailable

public boolean isTableAvailable(byte[] tableName)
                         throws IOException
Specified by:
isTableAvailable in interface HConnection
Throws:
IOException

isTableAvailable

public boolean isTableAvailable(TableName tableName,
                                byte[][] splitKeys)
                         throws IOException
Specified by:
isTableAvailable in interface HConnection
Throws:
IOException

isTableAvailable

public boolean isTableAvailable(byte[] tableName,
                                byte[][] splitKeys)
                         throws IOException
Specified by:
isTableAvailable in interface HConnection
Throws:
IOException

listTables

public HTableDescriptor[] listTables()
                              throws IOException
Specified by:
listTables in interface HConnection
Throws:
IOException

getTableNames

public String[] getTableNames()
                       throws IOException
Specified by:
getTableNames in interface HConnection
Throws:
IOException

listTableNames

public TableName[] listTableNames()
                           throws IOException
Specified by:
listTableNames in interface HConnection
Throws:
IOException

getHTableDescriptor

public HTableDescriptor getHTableDescriptor(TableName tableName)
                                     throws IOException
Specified by:
getHTableDescriptor in interface HConnection
Throws:
IOException

getHTableDescriptor

public HTableDescriptor getHTableDescriptor(byte[] tableName)
                                     throws IOException
Specified by:
getHTableDescriptor in interface HConnection
Throws:
IOException

locateRegion

public HRegionLocation locateRegion(TableName tableName,
                                    byte[] row)
                             throws IOException
Specified by:
locateRegion in interface HConnection
Throws:
IOException

locateRegion

public HRegionLocation locateRegion(byte[] tableName,
                                    byte[] row)
                             throws IOException
Specified by:
locateRegion in interface HConnection
Throws:
IOException

clearRegionCache

public void clearRegionCache()
Specified by:
clearRegionCache in interface HConnection

clearRegionCache

public void clearRegionCache(TableName tableName)
Specified by:
clearRegionCache in interface HConnection

clearRegionCache

public void clearRegionCache(byte[] tableName)
Specified by:
clearRegionCache in interface HConnection

relocateRegion

public HRegionLocation relocateRegion(TableName tableName,
                                      byte[] row)
                               throws IOException
Specified by:
relocateRegion in interface HConnection
Throws:
IOException

relocateRegion

public HRegionLocation relocateRegion(byte[] tableName,
                                      byte[] row)
                               throws IOException
Specified by:
relocateRegion in interface HConnection
Throws:
IOException

updateCachedLocations

public void updateCachedLocations(TableName tableName,
                                  byte[] rowkey,
                                  Object exception,
                                  HRegionLocation source)
Specified by:
updateCachedLocations in interface HConnection

updateCachedLocations

public void updateCachedLocations(byte[] tableName,
                                  byte[] rowkey,
                                  Object exception,
                                  HRegionLocation source)
Specified by:
updateCachedLocations in interface HConnection

locateRegion

public HRegionLocation locateRegion(byte[] regionName)
                             throws IOException
Specified by:
locateRegion in interface HConnection
Throws:
IOException

locateRegions

public List<HRegionLocation> locateRegions(TableName tableName)
                                    throws IOException
Specified by:
locateRegions in interface HConnection
Throws:
IOException

locateRegions

public List<HRegionLocation> locateRegions(byte[] tableName)
                                    throws IOException
Specified by:
locateRegions in interface HConnection
Throws:
IOException

locateRegions

public List<HRegionLocation> locateRegions(TableName tableName,
                                           boolean useCache,
                                           boolean offlined)
                                    throws IOException
Specified by:
locateRegions in interface HConnection
Throws:
IOException

locateRegions

public List<HRegionLocation> locateRegions(byte[] tableName,
                                           boolean useCache,
                                           boolean offlined)
                                    throws IOException
Specified by:
locateRegions in interface HConnection
Throws:
IOException

getMaster

public MasterProtos.MasterService.BlockingInterface getMaster()
                                                       throws IOException
Specified by:
getMaster in interface HConnection
Throws:
IOException

getAdmin

public AdminProtos.AdminService.BlockingInterface getAdmin(ServerName serverName)
                                                    throws IOException
Specified by:
getAdmin in interface HConnection
Throws:
IOException

getAdmin

public AdminProtos.AdminService.BlockingInterface getAdmin(ServerName serverName,
                                                           boolean getMaster)
                                                    throws IOException
Specified by:
getAdmin in interface HConnection
Throws:
IOException

getRegionLocation

public HRegionLocation getRegionLocation(TableName tableName,
                                         byte[] row,
                                         boolean reload)
                                  throws IOException
Specified by:
getRegionLocation in interface HConnection
Throws:
IOException

getRegionLocation

public HRegionLocation getRegionLocation(byte[] tableName,
                                         byte[] row,
                                         boolean reload)
                                  throws IOException
Specified by:
getRegionLocation in interface HConnection
Throws:
IOException

processBatch

public void processBatch(List<? extends Row> actions,
                         TableName tableName,
                         ExecutorService pool,
                         Object[] results)
                  throws IOException,
                         InterruptedException
Specified by:
processBatch in interface HConnection
Throws:
IOException
InterruptedException

processBatch

public void processBatch(List<? extends Row> actions,
                         byte[] tableName,
                         ExecutorService pool,
                         Object[] results)
                  throws IOException,
                         InterruptedException
Specified by:
processBatch in interface HConnection
Throws:
IOException
InterruptedException

processBatchCallback

public <R> void processBatchCallback(List<? extends Row> list,
                                     TableName tableName,
                                     ExecutorService pool,
                                     Object[] results,
                                     Batch.Callback<R> callback)
                          throws IOException,
                                 InterruptedException
Specified by:
processBatchCallback in interface HConnection
Throws:
IOException
InterruptedException

processBatchCallback

public <R> void processBatchCallback(List<? extends Row> list,
                                     byte[] tableName,
                                     ExecutorService pool,
                                     Object[] results,
                                     Batch.Callback<R> callback)
                          throws IOException,
                                 InterruptedException
Specified by:
processBatchCallback in interface HConnection
Throws:
IOException
InterruptedException

setRegionCachePrefetch

public void setRegionCachePrefetch(TableName tableName,
                                   boolean enable)
Specified by:
setRegionCachePrefetch in interface HConnection

setRegionCachePrefetch

public void setRegionCachePrefetch(byte[] tableName,
                                   boolean enable)
Specified by:
setRegionCachePrefetch in interface HConnection

getRegionCachePrefetch

public boolean getRegionCachePrefetch(TableName tableName)
Specified by:
getRegionCachePrefetch in interface HConnection

getRegionCachePrefetch

public boolean getRegionCachePrefetch(byte[] tableName)
Specified by:
getRegionCachePrefetch in interface HConnection

getCurrentNrHRS

public int getCurrentNrHRS()
                    throws IOException
Specified by:
getCurrentNrHRS in interface HConnection
Throws:
IOException

getHTableDescriptorsByTableName

public HTableDescriptor[] getHTableDescriptorsByTableName(List<TableName> tableNames)
                                                   throws IOException
Specified by:
getHTableDescriptorsByTableName in interface HConnection
Throws:
IOException

getHTableDescriptors

public HTableDescriptor[] getHTableDescriptors(List<String> tableNames)
                                        throws IOException
Specified by:
getHTableDescriptors in interface HConnection
Throws:
IOException

isClosed

public boolean isClosed()
Specified by:
isClosed in interface HConnection

clearCaches

public void clearCaches(ServerName sn)
Specified by:
clearCaches in interface HConnection

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

deleteCachedRegionLocation

public void deleteCachedRegionLocation(HRegionLocation location)
Specified by:
deleteCachedRegionLocation in interface HConnection

getKeepAliveMasterService

public org.apache.hadoop.hbase.client.MasterKeepAliveConnection getKeepAliveMasterService()
                                                                                   throws MasterNotRunningException
Specified by:
getKeepAliveMasterService in interface HConnection
Throws:
MasterNotRunningException

isDeadServer

public boolean isDeadServer(ServerName serverName)
Specified by:
isDeadServer in interface HConnection


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