I am trying to create a hbase connection pool. I tried the following. But I do not know the consequences. Will it affect my work? Can anybody help? Hosts can be deleted or even local.
HashMap cons = new HashMap();
public void getDataFromHbase(String host, String tableid){
conf.set("hbase.zookeeper.quorum", host);
ThreadPoolExecutor executor= (ThreadPoolExecutor) Executors.newCachedThreadPool();
executor.setMaximumPoolSize(50);
if(cons.get(host+"tableA_"+tableid) != null){
table1 = cons.get(host+"tableA_"+tableid);
table2 = cons.get(host+"tableB_"+tableid);
}
else{
table1 = new HTable(conf,Bytes.toBytes("tableA_"+tableid),executor);
table2 = new HTable(conf,Bytes.toBytes("tableB_"+tableid),executor);
cons.put(host+"tableA_"+tableid,table1);
cons.put(host+"tableB_"+tableid,table2);
}
Scan scan = new Scan();
scan.addFamily(Bytes.toBytes("n"));
scan.setCaching(1000);
ResultScanner resultScanner = table1.getScanner(scan);
ResultScanner resultScannerB = table2.getScanner(scan);
}
source
share