我的hbase客户端连接太多了

时间:2017-06-04 05:17:41

标签: hbase hbase-client

为了获得最大吞吐量,我使用批量放置和增量将数据放入hbase, 代码示例:

Configuration configuration = HBaseConfiguration.create();
configuration.set("hbase.zookeeper.quorum", "10.2.1.12:2181");
configuration.set("hbase.zookeeper.znode.parent", "/hbase");
Connection connection = ConnectionFactory.createConnection(configuration);
Table table = null;
try {
   table = connection.getTable(TableName.valueOf("test"));
   Object[] results = new Object[incrementList.size()];
   table.batch(incrementList, results);
   for (Object result : results) {
       if (null == result) {
           failed++;
       } else {
           //System.out.println("Batch operation result: " + result);
       }
   }
   System.out.println("Batch operation failed: " + failed);
} catch (Exception ex) {
   throw new RPCCallException("Hbase put error: " + ex.getMessage(), ex);
} finally {
   table.close();
}
connection.close();

有233个连接线。 和线程堆栈: enter image description here

hbase-client version:

<dependency>
  <groupId>org.apache.hbase</groupId>
  <artifactId>hbase-client</artifactId>
  <version>1.3.0</version>
</dependency>

1 个答案:

答案 0 :(得分:2)

我发现问题,hbase连接的线程池的默认配置是:core = max = 256,所以线程数将增加到256