You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by en...@apache.org on 2014/10/02 04:26:59 UTC
git commit: HBASE-12140 Add ConnectionFactory.createConnection() to
create using default HBaseConfiguration. (Jean-Marc Spaggiari))
Repository: hbase
Updated Branches:
refs/heads/master 387f90e39 -> 11e28eb76
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/11e28eb7
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/11e28eb7
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/11e28eb7
Branch: refs/heads/master
Commit: 11e28eb76b0f5b55386af08e688c50ce5184c5be
Parents: 387f90e
Author: Enis Soztutar <en...@apache.org>
Authored: Wed Oct 1 19:26:39 2014 -0700
Committer: Enis Soztutar <en...@apache.org>
Committed: Wed Oct 1 19:26:39 2014 -0700
----------------------------------------------------------------------
.../hadoop/hbase/client/ConnectionFactory.java | 28 ++++++++++++++++++++
1 file changed, 28 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/11e28eb7/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