public interface HConnection extends Abortable, Closeable
HConnectionManager
manages instances of this class.
HConnections are used by HTable
mostly but also by
HBaseAdmin
, CatalogTracker
,
and ZooKeeperWatcher
. HConnection instances can be shared. Sharing
is usually what you want because rather than each HConnection instance
having to do its own discovery of regions out on the cluster, instead, all
clients get to share the one cache of locations. Sharing makes cleanup of
HConnections awkward. See HConnectionManager
for cleanup
discussion.
HConnectionManager
Modifier and Type | Method and Description |
---|---|
void |
clearCaches(String sn)
Clear any caches that pertain to server name
sn |
void |
clearRegionCache()
Allows flushing the region cache.
|
void |
clearRegionCache(byte[] tableName)
Allows flushing the region cache of all locations that pertain to
tableName |
void |
deleteCachedRegionLocation(HRegionLocation location)
Deletes cached locations for the specific region.
|
org.apache.hadoop.conf.Configuration |
getConfiguration() |
int |
getCurrentNrHRS()
Deprecated.
This method will be changed from public to package protected.
|
HRegionInterface |
getHRegionConnection(HServerAddress regionServer)
Deprecated.
|
HRegionInterface |
getHRegionConnection(HServerAddress regionServer,
boolean getMaster)
Deprecated.
|
HRegionInterface |
getHRegionConnection(String hostname,
int port)
Establishes a connection to the region server at the specified address.
|
HRegionInterface |
getHRegionConnection(String hostname,
int port,
boolean getMaster)
Establishes a connection to the region server at the specified address.
|
HTableDescriptor |
getHTableDescriptor(byte[] tableName) |
HTableDescriptor[] |
getHTableDescriptors(List<String> tableNames) |
HMasterInterface |
getMaster()
Deprecated.
Removed because it was a mistake exposing master in this
interface (master is an implementation detail). Master functions are
available from HConnection or HBaseAdmin, without having to use
directly the master.
Deprecated in HBase 0.94
|
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)
Deprecated.
Use
HConnectionManager#withoutRetries(ServerCallable) |
<T> T |
getRegionServerWithRetries(ServerCallable<T> callable)
Deprecated.
Use
HConnectionManager#withoutRetries(ServerCallable) |
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.
|
String[] |
getTableNames() |
ZooKeeperWatcher |
getZooKeeperWatcher()
Deprecated.
Removed because it was a mistake exposing zookeeper in this
interface (ZooKeeper is an implementation detail).
Deprecated in HBase 0.94
|
boolean |
isClosed() |
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[] regionName)
Gets the location of the region of regionName.
|
HRegionLocation |
locateRegion(byte[] tableName,
byte[] row)
Find the location of the region of tableName that row
lives in.
|
List<HRegionLocation> |
locateRegions(byte[] tableName)
Gets the locations of all regions in the specified table, tableName.
|
List<HRegionLocation> |
locateRegions(byte[] tableName,
boolean useCache,
boolean offlined)
Gets the locations of all regions in the specified table, tableName.
|
void |
prewarmRegionCache(byte[] tableName,
Map<HRegionInfo,HServerAddress> regions)
Load the region map and warm up the global region cache for the table.
|
void |
processBatch(List<? extends Row> actions,
byte[] 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)
Parameterized batch processing, allowing varying return types for different
Row implementations. |
<T extends CoprocessorProtocol,R> |
processExecs(Class<T> protocol,
List<byte[]> rows,
byte[] tableName,
ExecutorService pool,
Batch.Call<T,R> call,
Batch.Callback<R> callback)
Executes the given
Batch.Call
callable for each row in the given list and invokes
Batch.Callback.update(byte[], byte[], Object)
for each result returned. |
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.
|
org.apache.hadoop.conf.Configuration getConfiguration()
HTableInterface getTable(String tableName) throws IOException
HConnectionManager.createConnection(Configuration)
).tableName
- IOException
HTableInterface getTable(byte[] tableName) throws IOException
HConnectionManager.createConnection(Configuration)
).tableName
- IOException
HTableInterface getTable(String tableName, ExecutorService pool) throws IOException
HConnectionManager.createConnection(Configuration)
).tableName
- pool
- The thread pool to use for batch operations, null to use a default pool.IOException
HTableInterface getTable(byte[] tableName, ExecutorService pool) throws IOException
HConnectionManager.createConnection(Configuration)
).tableName
- pool
- The thread pool to use for batch operations, null to use a default pool.IOException
@Deprecated ZooKeeperWatcher getZooKeeperWatcher() throws IOException
IOException
- if a remote or network exception occurs@Deprecated HMasterInterface getMaster() throws MasterNotRunningException, ZooKeeperConnectionException
MasterNotRunningException
- if the master is not runningZooKeeperConnectionException
- if unable to connect to zookeeperboolean isMasterRunning() throws MasterNotRunningException, ZooKeeperConnectionException
MasterNotRunningException
ZooKeeperConnectionException
boolean isTableEnabled(byte[] tableName) throws IOException
tableName
- table nameIOException
- if a remote or network exception occursboolean isTableDisabled(byte[] tableName) throws IOException
tableName
- table nameIOException
- if a remote or network exception occursboolean isTableAvailable(byte[] tableName) throws IOException
tableName
- table nameIOException
- if a remote or network exception occursHTableDescriptor[] listTables() throws IOException
IOException
- if a remote or network exception occursHTableDescriptor getHTableDescriptor(byte[] tableName) throws IOException
tableName
- table nameIOException
- if a remote or network exception occursHRegionLocation locateRegion(byte[] tableName, byte[] row) throws IOException
tableName
- name of the table row is inrow
- row key you're trying to find the region ofIOException
- if a remote or network exception occursvoid clearRegionCache()
void clearRegionCache(byte[] tableName)
tableName
tableName
- Name of the table whose regions we are to remove from
cache.void deleteCachedRegionLocation(HRegionLocation location)
location
- The location object for the region, to be purged from cache.HRegionLocation relocateRegion(byte[] tableName, byte[] row) throws IOException
tableName
- name of the table row is inrow
- row key you're trying to find the region ofIOException
- if a remote or network exception occursHRegionLocation locateRegion(byte[] regionName) throws IOException
regionName
- name of the region to locateIOException
- if a remote or network exception occursList<HRegionLocation> locateRegions(byte[] tableName) throws IOException
tableName
- table to get regions ofIOException
List<HRegionLocation> locateRegions(byte[] tableName, boolean useCache, boolean offlined) throws IOException
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
HRegionInterface getHRegionConnection(HServerAddress regionServer) throws IOException
getHRegionConnection(String, int)
regionServer
- - the server to connect toIOException
- if a remote or network exception occursHRegionInterface getHRegionConnection(String hostname, int port) throws IOException
hostname
- RegionServer hostnameport
- RegionServer portIOException
- if a remote or network exception occursHRegionInterface getHRegionConnection(HServerAddress regionServer, boolean getMaster) throws IOException
getHRegionConnection(HServerAddress, boolean)
regionServer
- - the server to connect togetMaster
- - do we check if master is aliveIOException
- if a remote or network exception occursHRegionInterface getHRegionConnection(String hostname, int port, boolean getMaster) throws IOException
hostname
- RegionServer hostnameport
- RegionServer portgetMaster
- - do we check if master is aliveIOException
- if a remote or network exception occursHRegionLocation getRegionLocation(byte[] tableName, byte[] row, boolean reload) throws IOException
tableName
- table namerow
- Row to find.reload
- If true do not use cache, otherwise bypass.IOException
- if a remote or network exception occurs<T> T getRegionServerWithRetries(ServerCallable<T> callable) throws IOException, RuntimeException
HConnectionManager#withoutRetries(ServerCallable)
T
- the type of the return valuecallable
- callable to runIOException
- if a remote or network exception occursRuntimeException
- other unspecified error<T> T getRegionServerWithoutRetries(ServerCallable<T> callable) throws IOException, RuntimeException
HConnectionManager#withoutRetries(ServerCallable)
T
- the type of the return valuecallable
- callable to runIOException
- if a remote or network exception occursRuntimeException
- other unspecified errorvoid processBatch(List<? extends Row> actions, byte[] tableName, ExecutorService pool, Object[] results) throws IOException, InterruptedException
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
<R> void processBatchCallback(List<? extends Row> list, byte[] tableName, ExecutorService pool, Object[] results, Batch.Callback<R> callback) throws IOException, InterruptedException
Row
implementations.IOException
InterruptedException
<T extends CoprocessorProtocol,R> void processExecs(Class<T> protocol, List<byte[]> rows, byte[] tableName, ExecutorService pool, Batch.Call<T,R> call, Batch.Callback<R> callback) throws IOException, Throwable
Batch.Call
callable for each row in the given list and invokes
Batch.Callback.update(byte[], byte[], Object)
for each result returned.T
- the protocol interface typeR
- the callable's return typeprotocol
- the protocol interface being calledrows
- a list of row keys for which the callable should be invokedtableName
- table name for the coprocessor invokedpool
- ExecutorService used to submit the calls per rowcall
- instance on which to invoke
Batch.Call.call(Object)
for each rowcallback
- instance on which to invoke
Batch.Callback.update(byte[], byte[], Object)
for each resultIOException
Throwable
void setRegionCachePrefetch(byte[] tableName, boolean enable)
tableName
- name of table to configure.enable
- Set to true to enable region cache prefetch.boolean getRegionCachePrefetch(byte[] tableName)
tableName
- name of table to checkvoid prewarmRegionCache(byte[] tableName, Map<HRegionInfo,HServerAddress> regions)
tableName
- name of the table to perform region cache prewarm.regions
- a region map.int getCurrentNrHRS() throws IOException
IOException
- if a remote or network exception occursHTableDescriptor[] getHTableDescriptors(List<String> tableNames) throws IOException
tableNames
- List of table namesIOException
- if a remote or network exception occursString[] getTableNames() throws IOException
IOException
- if a remote or network exception occursboolean isClosed()
void clearCaches(String sn)
sn
sn
- A server name as hostname:portCopyright © 2014 The Apache Software Foundation. All Rights Reserved.