Class ConnectionFactory
Connection
s. Managing the lifecycle of
the Connection
s to the cluster is the responsibility of the caller. From a
Connection
, Table
implementations are retrieved with
Connection.getTable(org.apache.hadoop.hbase.TableName)
. Example:
Connection connection = ConnectionFactory.createConnection(config); Table table = connection.getTable(TableName.valueOf("table1")); try { // Use the table as needed, for a single operation and a single thread } finally { table.close(); connection.close(); }Since 2.2.0, Connection created by ConnectionFactory can contain user-specified kerberos credentials if caller has following two configurations set:
- hbase.client.keytab.file, points to a valid keytab on the local filesystem
- hbase.client.kerberos.principal, gives the Kerberos principal to use
Similarly,
Connection
also returns Admin
and RegionLocator
implementations.- Since:
- 0.99.0
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CompletableFuture<AsyncConnection>
CallcreateAsyncConnection(Configuration)
using default HBaseConfiguration.static CompletableFuture<AsyncConnection>
createAsyncConnection
(URI connectionUri) CallcreateAsyncConnection(URI, Configuration)
using default HBaseConfiguration.static CompletableFuture<AsyncConnection>
createAsyncConnection
(URI connectionUri, org.apache.hadoop.conf.Configuration conf) CallcreateAsyncConnection(Configuration, User)
using the givenconnectionUri
,conf
and a User object created byUserProvider
.static CompletableFuture<AsyncConnection>
createAsyncConnection
(URI connectionUri, org.apache.hadoop.conf.Configuration conf, User user) Create a new AsyncConnection instance using the passedconnectionUri
,conf
anduser
.static CompletableFuture<AsyncConnection>
createAsyncConnection
(URI connectionUri, org.apache.hadoop.conf.Configuration conf, User user, Map<String, byte[]> connectionAttributes) Create a new AsyncConnection instance using the passedconnectionUri
,conf
anduser
.static CompletableFuture<AsyncConnection>
createAsyncConnection
(org.apache.hadoop.conf.Configuration conf) CallcreateAsyncConnection(Configuration, User)
using the givenconf
and a User object created byUserProvider
.static CompletableFuture<AsyncConnection>
createAsyncConnection
(org.apache.hadoop.conf.Configuration conf, User user) Create a new AsyncConnection instance using the passedconf
anduser
.static CompletableFuture<AsyncConnection>
createAsyncConnection
(org.apache.hadoop.conf.Configuration conf, User user, Map<String, byte[]> connectionAttributes) Create a new AsyncConnection instance using the passedconf
anduser
.static Connection
Create a new Connection instance using default HBaseConfiguration.static Connection
createConnection
(URI connectionUri) Create a new Connection instance using default HBaseConfiguration.static Connection
createConnection
(URI connectionUri, org.apache.hadoop.conf.Configuration conf) Create a new Connection instance using the passedconf
instance.static Connection
createConnection
(URI connectionUri, org.apache.hadoop.conf.Configuration conf, ExecutorService pool) Create a new Connection instance using the passedconf
instance.static Connection
createConnection
(URI connectionUri, org.apache.hadoop.conf.Configuration conf, ExecutorService pool, User user) Create a new Connection instance using the passedconf
instance.static Connection
createConnection
(URI connectionUri, org.apache.hadoop.conf.Configuration conf, ExecutorService pool, User user, Map<String, byte[]> connectionAttributes) Create a new Connection instance using the passedconf
instance.static Connection
createConnection
(URI connectionUri, org.apache.hadoop.conf.Configuration conf, User user) Create a new Connection instance using the passedconf
instance.static Connection
createConnection
(org.apache.hadoop.conf.Configuration conf) Create a new Connection instance using the passedconf
instance.static Connection
createConnection
(org.apache.hadoop.conf.Configuration conf, ExecutorService pool) Create a new Connection instance using the passedconf
instance.static Connection
createConnection
(org.apache.hadoop.conf.Configuration conf, ExecutorService pool, User user) Create a new Connection instance using the passedconf
instance.static Connection
createConnection
(org.apache.hadoop.conf.Configuration conf, ExecutorService pool, User user, Map<String, byte[]> connectionAttributes) Create a new Connection instance using the passedconf
instance.static Connection
createConnection
(org.apache.hadoop.conf.Configuration conf, User user) Create a new Connection instance using the passedconf
instance.
-
Field Details
-
LOG
-
HBASE_CLIENT_ASYNC_CONNECTION_IMPL
- See Also:
-
-
Constructor Details
-
ConnectionFactory
protected ConnectionFactory()No public c.tors
-
-
Method Details
-
createConnection
Create a new Connection instance using default HBaseConfiguration. Connection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection, meta cache, and connections to region servers and masters.
The caller is responsible for callingConnection.close()
on the returned connection instance. Typical usage:try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("table1"))) { table.get(...); ... }
- Returns:
- Connection object for
conf
- Throws:
IOException
-
createConnection
Create a new Connection instance using default HBaseConfiguration. Connection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection, meta cache, and connections to region servers and masters.
The caller is responsible for callingConnection.close()
on the returned connection instance. Typical usage:try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("table1"))) { table.get(...); ... }
- Parameters:
connectionUri
- the connection uri for the hbase cluster- Returns:
- Connection object for
conf
- Throws:
IOException
-
createConnection
public static Connection createConnection(org.apache.hadoop.conf.Configuration conf) throws IOException Create a new Connection instance using the passedconf
instance. Connection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection(if used), meta cache, and connections to region servers and masters.
The caller is responsible for callingConnection.close()
on the returned connection instance. Typical usage:try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("table1"))) { table.get(...); ... }
- Parameters:
conf
- configuration- Returns:
- Connection object for
conf
- Throws:
IOException
-
createConnection
public static Connection createConnection(URI connectionUri, org.apache.hadoop.conf.Configuration conf) throws IOException Create a new Connection instance using the passedconf
instance. Connection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection(if used), meta cache, and connections to region servers and masters.
The caller is responsible for callingConnection.close()
on the returned connection instance. Typical usage:try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("table1"))) { table.get(...); ... }
- Parameters:
connectionUri
- the connection uri for the hbase clusterconf
- configuration- Returns:
- Connection object for
conf
- Throws:
IOException
-
createConnection
public static Connection createConnection(org.apache.hadoop.conf.Configuration conf, ExecutorService pool) throws IOException Create a new Connection instance using the passedconf
instance. Connection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection(if used), meta cache, and connections to region servers and masters.
The caller is responsible for callingConnection.close()
on the returned connection instance. Typical usage:try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("table1"))) { table.get(...); ... }
- Parameters:
conf
- configurationpool
- the thread pool to use for batch operations- Returns:
- Connection object for
conf
- Throws:
IOException
-
createConnection
public static Connection createConnection(URI connectionUri, org.apache.hadoop.conf.Configuration conf, ExecutorService pool) throws IOException Create a new Connection instance using the passedconf
instance. Connection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection(if used), meta cache, and connections to region servers and masters.
The caller is responsible for callingConnection.close()
on the returned connection instance. Typical usage:try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("table1"))) { table.get(...); ... }
- Parameters:
connectionUri
- the connection uri for the hbase clusterconf
- configurationpool
- the thread pool to use for batch operations- Returns:
- Connection object for
conf
- Throws:
IOException
-
createConnection
public static Connection createConnection(org.apache.hadoop.conf.Configuration conf, User user) throws IOException Create a new Connection instance using the passedconf
instance. Connection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection(if used), meta cache, and connections to region servers and masters.
The caller is responsible for callingConnection.close()
on the returned connection instance. Typical usage:try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("table1"))) { table.get(...); ... }
- Parameters:
conf
- configurationuser
- the user the connection is for- Returns:
- Connection object for
conf
- Throws:
IOException
-
createConnection
public static Connection createConnection(URI connectionUri, org.apache.hadoop.conf.Configuration conf, User user) throws IOException Create a new Connection instance using the passedconf
instance. Connection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection(if used), meta cache, and connections to region servers and masters.
The caller is responsible for callingConnection.close()
on the returned connection instance. Typical usage:try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("table1"))) { table.get(...); ... }
- Parameters:
connectionUri
- the connection uri for the hbase clusterconf
- configurationuser
- the user the connection is for- Returns:
- Connection object for
conf
- Throws:
IOException
-
createConnection
public static Connection createConnection(org.apache.hadoop.conf.Configuration conf, ExecutorService pool, User user) throws IOException Create a new Connection instance using the passedconf
instance. Connection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection(if used), meta cache, and connections to region servers and masters.
The caller is responsible for callingConnection.close()
on the returned connection instance. Typical usage:try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("table1"))) { table.get(...); ... }
- Parameters:
conf
- configurationuser
- the user the connection is forpool
- the thread pool to use for batch operations- Returns:
- Connection object for
conf
- Throws:
IOException
-
createConnection
public static Connection createConnection(URI connectionUri, org.apache.hadoop.conf.Configuration conf, ExecutorService pool, User user) throws IOException Create a new Connection instance using the passedconf
instance. Connection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection(if used), meta cache, and connections to region servers and masters.
The caller is responsible for callingConnection.close()
on the returned connection instance. Typical usage:try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("table1"))) { table.get(...); ... }
- Parameters:
connectionUri
- the connection uri for the hbase clusterconf
- configurationuser
- the user the connection is forpool
- the thread pool to use for batch operations- Returns:
- Connection object for
conf
- Throws:
IOException
-
createConnection
public static Connection createConnection(org.apache.hadoop.conf.Configuration conf, ExecutorService pool, User user, Map<String, byte[]> connectionAttributes) throws IOExceptionCreate a new Connection instance using the passedconf
instance. Connection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection(if used), meta cache, and connections to region servers and masters.
The caller is responsible for callingConnection.close()
on the returned connection instance. Typical usage:try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("table1"))) { table.get(...); ... }
- Parameters:
conf
- configurationuser
- the user the connection is forpool
- the thread pool to use for batch operationsconnectionAttributes
- attributes to be sent along to server during connection establish- Returns:
- Connection object for
conf
- Throws:
IOException
-
createConnection
public static Connection createConnection(URI connectionUri, org.apache.hadoop.conf.Configuration conf, ExecutorService pool, User user, Map<String, byte[]> connectionAttributes) throws IOExceptionCreate a new Connection instance using the passedconf
instance. Connection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection(if used), meta cache, and connections to region servers and masters.
The caller is responsible for callingConnection.close()
on the returned connection instance. Typical usage:Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("table1")); try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("table1"))) { table.get(...); ... }
- Parameters:
connectionUri
- the connection uri for the hbase clusterconf
- configurationuser
- the user the connection is forpool
- the thread pool to use for batch operationsconnectionAttributes
- attributes to be sent along to server during connection establish- Returns:
- Connection object for
conf
- Throws:
IOException
-
createAsyncConnection
CallcreateAsyncConnection(Configuration)
using default HBaseConfiguration.- Returns:
- AsyncConnection object wrapped by CompletableFuture
- See Also:
-
createAsyncConnection
CallcreateAsyncConnection(URI, Configuration)
using default HBaseConfiguration.- Parameters:
connectionUri
- the connection uri for the hbase cluster- Returns:
- AsyncConnection object wrapped by CompletableFuture
- See Also:
-
createAsyncConnection
public static CompletableFuture<AsyncConnection> createAsyncConnection(org.apache.hadoop.conf.Configuration conf) CallcreateAsyncConnection(Configuration, User)
using the givenconf
and a User object created byUserProvider
. The givenconf
will also be used to initialize theUserProvider
.- Parameters:
conf
- configuration- Returns:
- AsyncConnection object wrapped by CompletableFuture
- See Also:
-
createAsyncConnection
public static CompletableFuture<AsyncConnection> createAsyncConnection(URI connectionUri, org.apache.hadoop.conf.Configuration conf) CallcreateAsyncConnection(Configuration, User)
using the givenconnectionUri
,conf
and a User object created byUserProvider
. The givenconf
will also be used to initialize theUserProvider
.- Parameters:
connectionUri
- the connection uri for the hbase clusterconf
- configuration- Returns:
- AsyncConnection object wrapped by CompletableFuture
- See Also:
-
createAsyncConnection
public static CompletableFuture<AsyncConnection> createAsyncConnection(org.apache.hadoop.conf.Configuration conf, User user) Create a new AsyncConnection instance using the passedconf
anduser
. AsyncConnection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection, meta cache, and connections to region servers and masters.The caller is responsible for calling
Closeable.close()
on the returned connection instance.Usually you should only create one AsyncConnection instance in your code and use it everywhere as it is thread safe.
- Parameters:
conf
- configurationuser
- the user the asynchronous connection is for- Returns:
- AsyncConnection object wrapped by CompletableFuture
-
createAsyncConnection
public static CompletableFuture<AsyncConnection> createAsyncConnection(URI connectionUri, org.apache.hadoop.conf.Configuration conf, User user) Create a new AsyncConnection instance using the passedconnectionUri
,conf
anduser
. AsyncConnection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection(if used), meta cache, and connections to region servers and masters.The caller is responsible for calling
Closeable.close()
on the returned connection instance.Usually you should only create one AsyncConnection instance in your code and use it everywhere as it is thread safe.
- Parameters:
connectionUri
- the connection uri for the hbase clusterconf
- configurationuser
- the user the asynchronous connection is for- Returns:
- AsyncConnection object wrapped by CompletableFuture
-
createAsyncConnection
public static CompletableFuture<AsyncConnection> createAsyncConnection(org.apache.hadoop.conf.Configuration conf, User user, Map<String, byte[]> connectionAttributes) Create a new AsyncConnection instance using the passedconf
anduser
. AsyncConnection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection, meta cache, and connections to region servers and masters.The caller is responsible for calling
Closeable.close()
on the returned connection instance.Usually you should only create one AsyncConnection instance in your code and use it everywhere as it is thread safe.
- Parameters:
conf
- configurationuser
- the user the asynchronous connection is forconnectionAttributes
- attributes to be sent along to server during connection establish- Returns:
- AsyncConnection object wrapped by CompletableFuture
-
createAsyncConnection
public static CompletableFuture<AsyncConnection> createAsyncConnection(URI connectionUri, org.apache.hadoop.conf.Configuration conf, User user, Map<String, byte[]> connectionAttributes) Create a new AsyncConnection instance using the passedconnectionUri
,conf
anduser
. AsyncConnection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection(if used), meta cache, and connections to region servers and masters.The caller is responsible for calling
Closeable.close()
on the returned connection instance.Usually you should only create one AsyncConnection instance in your code and use it everywhere as it is thread safe.
- Parameters:
connectionUri
- the connection uri for the hbase clusterconf
- configurationuser
- the user the asynchronous connection is forconnectionAttributes
- attributes to be sent along to server during connection establish- Returns:
- AsyncConnection object wrapped by CompletableFuture
-