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(); } }
相关推荐
大而话之BigData 2020-06-16
晨曦之星 2020-08-14
lwb 2020-07-26
eternityzzy 2020-07-19
ITwangnengjie 2020-06-14
gengwx00 2020-06-11
大而话之BigData 2020-06-10
鲸鱼写程序 2020-06-08
needyit 2020-06-04
strongyoung 2020-06-04
WeiHHH 2020-05-30
ITwangnengjie 2020-05-09
gengwx00 2020-05-08
gengwx00 2020-05-09
大而话之BigData 2020-05-06
Buerzhu 2020-05-01
gengwx00 2020-04-30