Resently, my app meets a problem list as follows
Can't construct instance of class org/apache/hadoop/hbase/client/HBaseAdmin
Exception in thread "Thread-2" java.lang.OutOfMemoryError: unable to
create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:640)
at org.apache.zookeeper.ClientCnxn.start(ClientCnxn.java:414)
at org.apache.zookeeper.ZooKeeper.<init>(ZooKeeper.java:378)
at org.apache.hadoop.hbase.zookeeper.ZKUtil.connect(ZKUtil.java:97)
at
org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<init>(ZooKeeperWatcher.java:119)
at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getZooKeeperWatcher(HConnectionManager.java:1002)
at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.setupZookeeperTrackers(HConnectionManager.java:304)
at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.<init>(HConnectionManager.java:295)
at
org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:157)
at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:90)
Call to org.apache.hadoop.hbase.HBaseAdmin::HBaseAdmin failed!
My app create HBaseAdmin every 30s,and the threads used by my app
increases about 1thread/30s.See from the stack, there is only one
HBaseAdmin in Memory, but lots of Configuration and
HConnectionImplementation instances.
I can see from the sources, everytime when HBaseAdmin is created, a new
Configuration and HConnectionImplementation is created and added to
HConnectionManager.HBASE_INSTANCES.So they are not collected by gc when
HBaseAdmin is collected.
So i think we need to add a close methord to remove the
Configuration&HConnectionImplementation from
HConnectionManager.HBASE_INSTANCES.Just as follows:
public void close(){
HConnectionManager.deleteConnection(getConfiguration(), true);
}