Hbase1.1.2的HTablePool已经被弃用,用什么来代替HTablePool呢?

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbsae.client.Table;

int main() {
// create a new hbase configuration object. (singleton)
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", commonConf.getString("hbase.zookeeper.quorum"));
conf.set("hbase.rpc.engine", commonConf.getString("hbase.rpc.engine"));
// create a new hbase connection object. (singleton)
Connection connection = ConnectionFactory.createConnection(conf);

try {
while (true) {
// create a table instance everytime you need.
// you don't have to pool this object, because hbase client implementation
// do necessary resource caching & control internally.
Table table = connection.getTable(TableName.valueOf("table"));
...
table.close();
}
} finally {
// close the hbase connection on application shutdown.
connection.close();
}
}

 

你可能感兴趣的:(hbase)