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();
}
}

 

發佈了287 篇原創文章 · 獲贊 12 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章