Hbase Connection Pool 1.0.0

Since the Hbase 1.0+ API does not process the connection pool using HConnectionI want to know what are the best methods for creating a connection pool?

So far I have created an object Connectionlike ThreadLocal, but I'm not sure if this is a good idea.

In general, since the connection object is so heavy, is it useful to create a connection pool?

Does anyone have any ideas?

+4
source share
2 answers

I asked a question from Carter's page , and here is his answer:

" , .

, , Connections "" , , . Table, Admin BufferedMutatator . "" . factory.

, , , , . , Connection. . , ".

+3

, , thread-safe. , Table Admin, Connection

private static class ConnectionHolder{
  private final Connection connection;

  private ConnectionHolder(){
   connection = ConnectionFactory.createConnection(config); 
  }

 Connection getConnection(){
  return connection;
  }
}

, Connection, . Tables ResultScanners

Table getTable(String name){
  Table table = connection.getTable(TableName.valueOf(name));
  return table;
}

try(Table table = getTable("tableName")){
  ...
} 
+3

Source: https://habr.com/ru/post/1607354/


All Articles