@InterfaceAudience.Private @InterfaceStability.Evolving public class CoprocessorHConnection extends Object implements HConnection
You should not use this class from any client - its an internal class meant for use by the coprocessor framework.
HBASE_CLIENT_CONNECTION_IMPL
Constructor and Description |
---|
CoprocessorHConnection(HConnection delegate,
HRegionServer server) |
Modifier and Type | Method and Description |
---|---|
void |
abort(String why,
Throwable e)
Abort the server or client.
|
void |
clearCaches(ServerName sn)
Clear any caches that pertain to server name
sn . |
void |
clearRegionCache()
Allows flushing the region cache.
|
void |
clearRegionCache(byte[] tableName) |
void |
clearRegionCache(TableName tableName)
Allows flushing the region cache of all locations that pertain to
tableName |
void |
close() |
void |
deleteCachedRegionLocation(HRegionLocation location)
Deletes cached locations for the specific region.
|
AdminProtos.AdminService.BlockingInterface |
getAdmin(ServerName serverName)
Establishes a connection to the region server at the specified address.
|
AdminProtos.AdminService.BlockingInterface |
getAdmin(ServerName serverName,
boolean getMaster)
Establishes a connection to the region server at the specified address.
|
ClientProtos.ClientService.BlockingInterface |
getClient(ServerName serverName)
Establishes a connection to the region server at the specified address, and returns
a region client protocol.
|
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()
This function allows HBaseAdmin and potentially others to get a shared MasterService
connection.
|
MasterProtos.MasterService.BlockingInterface |
getMaster()
Returns a
MasterKeepAliveConnection to the active master |
NonceGenerator |
getNonceGenerator() |
boolean |
getRegionCachePrefetch(byte[] tableName) |
boolean |
getRegionCachePrefetch(TableName tableName)
Check whether region cache prefetch is enabled or not.
|
HRegionLocation |
getRegionLocation(byte[] tableName,
byte[] row,
boolean reload) |
HRegionLocation |
getRegionLocation(TableName tableName,
byte[] row,
boolean reload)
Find region location hosting passed row
|
HTableInterface |
getTable(byte[] tableName)
Retrieve an HTableInterface implementation for access to a table.
|
HTableInterface |
getTable(byte[] tableName,
ExecutorService pool)
Retrieve an HTableInterface implementation for access to a table.
|
HTableInterface |
getTable(String tableName)
Retrieve an HTableInterface implementation for access to a table.
|
HTableInterface |
getTable(String tableName,
ExecutorService pool)
Retrieve an HTableInterface implementation for access to a table.
|
HTableInterface |
getTable(TableName tableName)
Retrieve an HTableInterface implementation for access to a table.
|
HTableInterface |
getTable(TableName tableName,
ExecutorService pool)
Retrieve an HTableInterface implementation for access to a table.
|
String[] |
getTableNames() |
boolean |
isAborted()
Check if the server or client was aborted.
|
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)
Use this api to check if the table has been created with the specified number of
splitkeys which was used while creating the given table.
|
boolean |
isTableDisabled(byte[] tableName) |
boolean |
isTableDisabled(TableName tableName) |
boolean |
isTableEnabled(byte[] tableName) |
boolean |
isTableEnabled(TableName tableName)
A table that isTableEnabled == false and isTableDisabled == false
is possible.
|
TableName[] |
listTableNames() |
HTableDescriptor[] |
listTables()
List all the userspace tables.
|
HRegionLocation |
locateRegion(byte[] regionName)
Gets the location of the region of regionName.
|
HRegionLocation |
locateRegion(byte[] tableName,
byte[] row) |
HRegionLocation |
locateRegion(TableName tableName,
byte[] row)
Find the location of the region of tableName that row
lives in.
|
List<HRegionLocation> |
locateRegions(byte[] tableName) |
List<HRegionLocation> |
locateRegions(byte[] tableName,
boolean useCache,
boolean offlined) |
List<HRegionLocation> |
locateRegions(TableName tableName)
Gets the locations of all regions in the specified table, tableName.
|
List<HRegionLocation> |
locateRegions(TableName tableName,
boolean useCache,
boolean offlined)
Gets the locations of all regions in the specified table, tableName.
|
void |
processBatch(List<? extends Row> actions,
byte[] tableName,
ExecutorService pool,
Object[] results) |
void |
processBatch(List<? extends Row> actions,
TableName tableName,
ExecutorService pool,
Object[] results)
Process a mixed batch of Get, Put and Delete actions.
|
<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)
Parameterized batch processing, allowing varying return types for different
Row implementations. |
HRegionLocation |
relocateRegion(byte[] tableName,
byte[] row) |
HRegionLocation |
relocateRegion(TableName 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) |
void |
setRegionCachePrefetch(TableName tableName,
boolean enable)
Enable or disable region cache prefetch for the table.
|
void |
updateCachedLocations(byte[] tableName,
byte[] rowkey,
Object exception,
HRegionLocation source) |
void |
updateCachedLocations(TableName tableName,
byte[] rowkey,
Object exception,
HRegionLocation source)
Update the location cache.
|
public CoprocessorHConnection(HConnection delegate, HRegionServer server)
public static HConnection getConnectionForEnvironment(CoprocessorEnvironment env) throws IOException
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).env
- environment hosting the HConnection
HConnection
.IOException
- if we cannot create the basic connectionpublic ClientProtos.ClientService.BlockingInterface getClient(ServerName serverName) throws IOException
HConnection
getClient
in interface HConnection
IOException
- if a remote or network exception occurspublic void abort(String why, Throwable e)
Abortable
public boolean isAborted()
Abortable
public org.apache.hadoop.conf.Configuration getConfiguration()
getConfiguration
in interface HConnection
public HTableInterface getTable(String tableName) throws IOException
HConnection
HConnectionManager.createConnection(Configuration)
).getTable
in interface HConnection
IOException
public HTableInterface getTable(byte[] tableName) throws IOException
HConnection
HConnectionManager.createConnection(Configuration)
).getTable
in interface HConnection
IOException
public HTableInterface getTable(TableName tableName) throws IOException
HConnection
HConnectionManager.createConnection(Configuration)
).getTable
in interface HConnection
IOException
public HTableInterface getTable(String tableName, ExecutorService pool) throws IOException
HConnection
HConnectionManager.createConnection(Configuration)
).getTable
in interface HConnection
pool
- The thread pool to use for batch operations, null to use a default pool.IOException
public HTableInterface getTable(byte[] tableName, ExecutorService pool) throws IOException
HConnection
HConnectionManager.createConnection(Configuration)
).getTable
in interface HConnection
pool
- The thread pool to use for batch operations, null to use a default pool.IOException
public HTableInterface getTable(TableName tableName, ExecutorService pool) throws IOException
HConnection
HConnectionManager.createConnection(Configuration)
).getTable
in interface HConnection
pool
- The thread pool to use for batch operations, null to use a default pool.IOException
public boolean isMasterRunning() throws MasterNotRunningException, ZooKeeperConnectionException
isMasterRunning
in interface HConnection
MasterNotRunningException
ZooKeeperConnectionException
public boolean isTableEnabled(TableName tableName) throws IOException
HConnection
isTableEnabled
in interface HConnection
tableName
- table nameIOException
- if a remote or network exception occurspublic boolean isTableEnabled(byte[] tableName) throws IOException
isTableEnabled
in interface HConnection
IOException
public boolean isTableDisabled(TableName tableName) throws IOException
isTableDisabled
in interface HConnection
tableName
- table nameIOException
- if a remote or network exception occurspublic boolean isTableDisabled(byte[] tableName) throws IOException
isTableDisabled
in interface HConnection
IOException
public boolean isTableAvailable(TableName tableName) throws IOException
isTableAvailable
in interface HConnection
tableName
- table nameIOException
- if a remote or network exception occurspublic boolean isTableAvailable(byte[] tableName) throws IOException
isTableAvailable
in interface HConnection
IOException
public boolean isTableAvailable(TableName tableName, byte[][] splitKeys) throws IOException
HConnection
isTableAvailable
in interface HConnection
tableName
- tableNamesplitKeys
- splitKeys used while creating tableIOException
- if a remote or network exception occurspublic boolean isTableAvailable(byte[] tableName, byte[][] splitKeys) throws IOException
isTableAvailable
in interface HConnection
IOException
public HTableDescriptor[] listTables() throws IOException
HConnection
listTables
in interface HConnection
IOException
- if a remote or network exception occurspublic String[] getTableNames() throws IOException
getTableNames
in interface HConnection
IOException
public TableName[] listTableNames() throws IOException
listTableNames
in interface HConnection
IOException
public HTableDescriptor getHTableDescriptor(TableName tableName) throws IOException
getHTableDescriptor
in interface HConnection
tableName
- table nameIOException
- if a remote or network exception occurspublic HTableDescriptor getHTableDescriptor(byte[] tableName) throws IOException
getHTableDescriptor
in interface HConnection
IOException
public HRegionLocation locateRegion(TableName tableName, byte[] row) throws IOException
HConnection
locateRegion
in interface HConnection
tableName
- name of the table row is inrow
- row key you're trying to find the region ofIOException
- if a remote or network exception occurspublic HRegionLocation locateRegion(byte[] tableName, byte[] row) throws IOException
locateRegion
in interface HConnection
IOException
public void clearRegionCache()
HConnection
clearRegionCache
in interface HConnection
public void clearRegionCache(TableName tableName)
HConnection
tableName
clearRegionCache
in interface HConnection
tableName
- Name of the table whose regions we are to remove from
cache.public void clearRegionCache(byte[] tableName)
clearRegionCache
in interface HConnection
public HRegionLocation relocateRegion(TableName tableName, byte[] row) throws IOException
HConnection
relocateRegion
in interface HConnection
tableName
- name of the table row is inrow
- row key you're trying to find the region ofIOException
- if a remote or network exception occurspublic HRegionLocation relocateRegion(byte[] tableName, byte[] row) throws IOException
relocateRegion
in interface HConnection
IOException
public void updateCachedLocations(TableName tableName, byte[] rowkey, Object exception, HRegionLocation source)
HConnection
updateCachedLocations
in interface HConnection
tableName
- the table namerowkey
- the rowexception
- the exception if any. Can be null.source
- the previous locationpublic void updateCachedLocations(byte[] tableName, byte[] rowkey, Object exception, HRegionLocation source)
updateCachedLocations
in interface HConnection
public HRegionLocation locateRegion(byte[] regionName) throws IOException
HConnection
locateRegion
in interface HConnection
regionName
- name of the region to locateIOException
- if a remote or network exception occurspublic List<HRegionLocation> locateRegions(TableName tableName) throws IOException
HConnection
locateRegions
in interface HConnection
tableName
- table to get regions ofIOException
public List<HRegionLocation> locateRegions(byte[] tableName) throws IOException
locateRegions
in interface HConnection
IOException
public List<HRegionLocation> locateRegions(TableName tableName, boolean useCache, boolean offlined) throws IOException
HConnection
locateRegions
in interface HConnection
tableName
- table to get regions ofuseCache
- Should we use the cache to retrieve the region information.offlined
- True if we are to include offlined regions, false and we'll leave out offlined
regions from returned list.IOException
public List<HRegionLocation> locateRegions(byte[] tableName, boolean useCache, boolean offlined) throws IOException
locateRegions
in interface HConnection
IOException
public MasterProtos.MasterService.BlockingInterface getMaster() throws IOException
HConnection
MasterKeepAliveConnection
to the active mastergetMaster
in interface HConnection
IOException
public AdminProtos.AdminService.BlockingInterface getAdmin(ServerName serverName) throws IOException
HConnection
getAdmin
in interface HConnection
IOException
- if a remote or network exception occurspublic AdminProtos.AdminService.BlockingInterface getAdmin(ServerName serverName, boolean getMaster) throws IOException
HConnection
getAdmin
in interface HConnection
getMaster
- do we check if master is aliveIOException
- if a remote or network exception occurspublic HRegionLocation getRegionLocation(TableName tableName, byte[] row, boolean reload) throws IOException
HConnection
getRegionLocation
in interface HConnection
tableName
- table namerow
- Row to find.reload
- If true do not use cache, otherwise bypass.IOException
- if a remote or network exception occurspublic HRegionLocation getRegionLocation(byte[] tableName, byte[] row, boolean reload) throws IOException
getRegionLocation
in interface HConnection
IOException
public void processBatch(List<? extends Row> actions, TableName tableName, ExecutorService pool, Object[] results) throws IOException, InterruptedException
HConnection
processBatch
in interface HConnection
actions
- The collection of actions.tableName
- Name of the hbase tablepool
- thread pool for parallel executionresults
- An empty array, same size as list. If an exception is thrown,
you can test here for partial results, and to determine which actions
processed successfully.IOException
- if there are problems talking to META. Per-item
exceptions are stored in the results array.InterruptedException
public void processBatch(List<? extends Row> actions, byte[] tableName, ExecutorService pool, Object[] results) throws IOException, InterruptedException
processBatch
in interface HConnection
IOException
InterruptedException
public <R> void processBatchCallback(List<? extends Row> list, TableName tableName, ExecutorService pool, Object[] results, Batch.Callback<R> callback) throws IOException, InterruptedException
HConnection
Row
implementations.processBatchCallback
in interface HConnection
IOException
InterruptedException
public <R> void processBatchCallback(List<? extends Row> list, byte[] tableName, ExecutorService pool, Object[] results, Batch.Callback<R> callback) throws IOException, InterruptedException
processBatchCallback
in interface HConnection
IOException
InterruptedException
public void setRegionCachePrefetch(TableName tableName, boolean enable)
HConnection
setRegionCachePrefetch
in interface HConnection
tableName
- name of table to configure.enable
- Set to true to enable region cache prefetch.public void setRegionCachePrefetch(byte[] tableName, boolean enable)
setRegionCachePrefetch
in interface HConnection
public boolean getRegionCachePrefetch(TableName tableName)
HConnection
getRegionCachePrefetch
in interface HConnection
tableName
- name of table to checkpublic boolean getRegionCachePrefetch(byte[] tableName)
getRegionCachePrefetch
in interface HConnection
public int getCurrentNrHRS() throws IOException
getCurrentNrHRS
in interface HConnection
IOException
- if a remote or network exception occurspublic HTableDescriptor[] getHTableDescriptorsByTableName(List<TableName> tableNames) throws IOException
getHTableDescriptorsByTableName
in interface HConnection
tableNames
- List of table namesIOException
- if a remote or network exception occurspublic HTableDescriptor[] getHTableDescriptors(List<String> tableNames) throws IOException
getHTableDescriptors
in interface HConnection
IOException
public boolean isClosed()
isClosed
in interface HConnection
public void clearCaches(ServerName sn)
HConnection
sn
.clearCaches
in interface HConnection
sn
- A server namepublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void deleteCachedRegionLocation(HRegionLocation location)
HConnection
deleteCachedRegionLocation
in interface HConnection
location
- The location object for the region, to be purged from cache.public org.apache.hadoop.hbase.client.MasterKeepAliveConnection getKeepAliveMasterService() throws MasterNotRunningException
HConnection
getKeepAliveMasterService
in interface HConnection
MasterNotRunningException
public boolean isDeadServer(ServerName serverName)
isDeadServer
in interface HConnection
public NonceGenerator getNonceGenerator()
getNonceGenerator
in interface HConnection
Copyright © 2014 The Apache Software Foundation. All rights reserved.