You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bb...@apache.org on 2024/03/29 15:37:49 UTC

(hbase) branch branch-2.6 updated: HBASE-27657 Addendum: Add back removed public method in ConnectionFactory

This is an automated email from the ASF dual-hosted git repository.

bbeaudreault pushed a commit to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.6 by this push:
     new d619634fbcc HBASE-27657 Addendum: Add back removed public method in ConnectionFactory
d619634fbcc is described below

commit d619634fbccbbc5c1fd8ed5330a8ad43ffa2ca48
Author: Bryan Beaudreault <bb...@apache.org>
AuthorDate: Fri Mar 29 11:35:02 2024 -0400

    HBASE-27657 Addendum: Add back removed public method in ConnectionFactory
---
 .../hadoop/hbase/client/ConnectionFactory.java     | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java
index 0978b36b5ae..0a95d1b195e 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java
@@ -190,6 +190,36 @@ public class ConnectionFactory {
     return createConnection(conf, null, user, Collections.emptyMap());
   }
 
+  /**
+   * Create a new Connection instance using the passed <code>conf</code> instance. 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. <br>
+   * The caller is responsible for calling {@link Connection#close()} on the returned connection
+   * instance. Typical usage:
+   *
+   * <pre>
+   * Connection connection = ConnectionFactory.createConnection(conf);
+   * Table table = connection.getTable(TableName.valueOf("table1"));
+   * try {
+   *   table.get(...);
+   *   ...
+   * } finally {
+   *   table.close();
+   *   connection.close();
+   * }
+   * </pre>
+   *
+   * @param conf configuration
+   * @param user the user the connection is for
+   * @param pool the thread pool to use for batch operations
+   * @return Connection object for <code>conf</code>
+   */
+  public static Connection createConnection(Configuration conf, ExecutorService pool,
+    final User user) throws IOException {
+    return createConnection(conf, pool, user, Collections.emptyMap());
+  }
+
   /**
    * Create a new Connection instance using the passed <code>conf</code> instance. Connection
    * encapsulates all housekeeping for a connection to the cluster. All tables and interfaces