@InterfaceAudience.Public public interface Connection extends org.apache.hadoop.hbase.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.
ConnectionFactory
Modifier and Type | Method and Description |
---|---|
void |
clearRegionLocationCache()
Clear all the entries in the region location cache, for all the tables.
|
void |
close() |
Admin |
getAdmin()
Retrieve an Admin implementation to administer an HBase cluster.
|
BufferedMutator |
getBufferedMutator(BufferedMutatorParams params)
Retrieve a
BufferedMutator for performing client-side buffering of writes. |
BufferedMutator |
getBufferedMutator(TableName tableName)
Retrieve a
BufferedMutator for performing client-side buffering of writes. |
org.apache.hadoop.conf.Configuration |
getConfiguration() |
RegionLocator |
getRegionLocator(TableName tableName)
Retrieve a RegionLocator implementation to inspect region information on a table.
|
default Table |
getTable(TableName tableName)
Retrieve a Table implementation for accessing a table.
|
default Table |
getTable(TableName tableName,
ExecutorService pool)
Retrieve a Table implementation for accessing a table.
|
TableBuilder |
getTableBuilder(TableName tableName,
ExecutorService pool)
Returns an
TableBuilder for creating Table . |
boolean |
isClosed()
Returns whether the connection is closed or not.
|
org.apache.hadoop.conf.Configuration getConfiguration()
default Table getTable(TableName tableName) throws IOException
The caller is responsible for calling Table.close()
on the returned
table instance.
Since 0.98.1 this method no longer checks table existence. An exception will be thrown if the table does not exist only when the first operation is attempted.
tableName
- the name of the tableIOException
default Table getTable(TableName tableName, ExecutorService pool) throws IOException
The caller is responsible for calling Table.close()
on the returned
table instance.
Since 0.98.1 this method no longer checks table existence. An exception will be thrown if the table does not exist only when the first operation is attempted.
tableName
- the name of the tablepool
- The thread pool to use for batch operations, null to use a default pool.IOException
BufferedMutator getBufferedMutator(TableName tableName) throws IOException
Retrieve a BufferedMutator
for performing client-side buffering of writes. The
BufferedMutator
returned by this method is thread-safe. This BufferedMutator will
use the Connection's ExecutorService. This object can be used for long lived operations.
The caller is responsible for calling BufferedMutator.close()
on
the returned BufferedMutator
instance.
This accessor will use the connection's ExecutorService and will throw an exception in the main thread when an asynchronous exception occurs.
tableName
- the name of the tableBufferedMutator
for the supplied tableName.IOException
BufferedMutator getBufferedMutator(BufferedMutatorParams params) throws IOException
BufferedMutator
for performing client-side buffering of writes. The
BufferedMutator
returned by this method is thread-safe. This object can be used for
long lived table operations. The caller is responsible for calling
BufferedMutator.close()
on the returned BufferedMutator
instance.params
- details on how to instantiate the BufferedMutator
.BufferedMutator
for the supplied tableName.IOException
RegionLocator getRegionLocator(TableName tableName) throws IOException
Closeable.close()
on the returned
RegionLocator instance.
RegionLocator needs to be unmanagedtableName
- Name of the table who's region is to be examinedIOException
void clearRegionLocationCache()
RegionLocator.clearRegionLocationCache()
.
This may cause performance issue so use it with caution.Admin getAdmin() throws IOException
Admin.close()
on the returned
Admin instance.IOException
void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
IOException
boolean isClosed()
TableBuilder getTableBuilder(TableName tableName, ExecutorService pool)
TableBuilder
for creating Table
.tableName
- the name of the tablepool
- the thread pool to use for requests like batch and scanCopyright © 2007–2021 The Apache Software Foundation. All rights reserved.