HBASE-12140 Add ConnectionFactory.createConnection() to create using default HBaseConfiguration. (Jean-Marc Spaggiari))
This commit is contained in:
parent
387f90e394
commit
11e28eb76b
|
@ -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;
|
||||
|
@ -59,6 +60,33 @@ public class ConnectionFactory {
|
|||
protected 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
|
||||
|
|
Loading…
Reference in New Issue