@InterfaceAudience.Public @InterfaceStability.Evolving public interface Connection extends Abortable, Closeable
ConnectionFactory
class. The lifecycle of the connection is managed by the caller, who has to close()
the connection to release the resources.
The connection object contains logic to find the master, locate regions out on the cluster,
keeps a cache of locations and then knows how to re-calibrate after they move. The individual
connections to servers, meta cache, zookeeper connection, etc are all shared by the
Table
and Admin
instances obtained from this connection.
Connection creation is a heavy-weight operation. Connection implementations are thread-safe,
so that the client can create a connection once, and share it with different threads.
Table
and Admin
instances, on the other hand, are light-weight and are not
thread-safe. Typically, a single connection per client application is instantiated and every
thread will obtain its own Table instance. Caching or pooling of Table
and Admin
is not recommended.
This class replaces HConnection
, which is now deprecated.
ConnectionFactory
Modifier and Type | Method and Description |
---|---|
void |
close() |
Admin |
getAdmin()
Retrieve an Admin implementation to administer an HBase cluster.
|
org.apache.hadoop.conf.Configuration |
getConfiguration() |
RegionLocator |
getRegionLocator(TableName tableName)
Retrieve a RegionLocator implementation to inspect region information on a table.
|
Table |
getTable(TableName tableName)
Retrieve a Table implementation for accessing a table.
|
Table |
getTable(TableName tableName,
ExecutorService pool)
Retrieve a Table implementation for accessing a table.
|
boolean |
isClosed()
Returns whether the connection is closed or not.
|
org.apache.hadoop.conf.Configuration getConfiguration()
Table getTable(TableName tableName) throws IOException
tableName
- the name of the tableIOException
Table getTable(TableName tableName, ExecutorService pool) throws IOException
tableName
- the name of the tablepool
- The thread pool to use for batch operations, null to use a default pool.IOException
RegionLocator getRegionLocator(TableName tableName) throws IOException
tableName
- Name of the table who's region is to be examinedIOException
Admin getAdmin() throws IOException
IOException
void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
IOException
boolean isClosed()
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.