hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject git commit: HBASE-12140 Add ConnectionFactory.createConnection() to create using default HBaseConfiguration. (Jean-Marc Spaggiari))
Date Thu, 02 Oct 2014 02:30:38 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 17b2c0f90 -> 5ad5d0e8b


HBASE-12140 Add ConnectionFactory.createConnection() to create using default HBaseConfiguration.
(Jean-Marc Spaggiari))


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/5ad5d0e8
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/5ad5d0e8
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/5ad5d0e8

Branch: refs/heads/branch-1
Commit: 5ad5d0e8bca68b13a7461b6cfd9c41330e513b94
Parents: 17b2c0f
Author: Enis Soztutar <enis@apache.org>
Authored: Wed Oct 1 19:26:39 2014 -0700
Committer: Enis Soztutar <enis@apache.org>
Committed: Wed Oct 1 19:27:20 2014 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/client/ConnectionFactory.java  | 28 ++++++++++++++++++++
 1 file changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/5ad5d0e8/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java
----------------------------------------------------------------------
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 74f7c54..aedaade 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
@@ -25,6 +25,7 @@ import java.util.concurrent.ExecutorService;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.hbase.security.UserProvider;
@@ -60,6 +61,33 @@ public class ConnectionFactory {
   }
 
   /**
+   * 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 calling {@link Connection#close()} on the returned
+   * connection instance.
+   *
+   * Typical usage:
+   * <pre>
+   * Connection connection = ConnectionFactory.createConnection();
+   * Table table = connection.getTable(TableName.valueOf("mytable"));
+   * try {
+   *   table.get(...);
+   *   ...
+   * } finally {
+   *   table.close();
+   *   connection.close();
+   * }
+   * </pre>
+   *
+   * @return Connection object for <code>conf</code>
+   */
+  public static Connection createConnection() throws IOException {
+    return createConnection(HBaseConfiguration.create(), null, null);
+  }
+
+  /**
    * 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


Mime
View raw message