Also in the future please address your development-related questions
to the dev@ mailing list and not the user@ mailing list.
J-D
On Tue, Apr 26, 2011 at 2:29 AM, Gaojinchao wrote:
It has modified the parameter hbase.zookeeper.property.maxClientCnxns
It seems like that MAX_CACHED_HBASE_INSTANCES also needs modify.
Why does it get from configure parameter ?
@SuppressWarnings("serial")
public class HConnectionManager {
static final int MAX_CACHED_HBASE_INSTANCES = 31;
// A LRU Map of Configuration hashcode -> TableServers. We set instances to 31.
// The zk default max connections to the ensemble from the one client is 30 so
// should run into zk issues before hit this value of 31.
private static final Map<Configuration, HConnectionImplementation> HBASE_INSTANCES =
new LinkedHashMap<Configuration, HConnectionImplementation>
((int) (MAX_CACHED_HBASE_INSTANCES/0.75F)+1, 0.75F, true) {
@Override
protected boolean removeEldestEntry(Map.Entry<Configuration, HConnectionImplementation> eldest) {
return size() > MAX_CACHED_HBASE_INSTANCES;
}
};
// Does it have any connection leak?
public static HConnection getConnection(Configuration conf)
throws ZooKeeperConnectionException {
HConnectionImplementation connection;
synchronized (HBASE_INSTANCES) {
connection = HBASE_INSTANCES.get(conf);
if (connection == null) {
connection = new HConnectionImplementation(conf);
HBASE_INSTANCES.put(conf, connection);
}
}
return connection;
}
It has modified the parameter hbase.zookeeper.property.maxClientCnxns
It seems like that MAX_CACHED_HBASE_INSTANCES also needs modify.
Why does it get from configure parameter ?
@SuppressWarnings("serial")
public class HConnectionManager {
static final int MAX_CACHED_HBASE_INSTANCES = 31;
// A LRU Map of Configuration hashcode -> TableServers. We set instances to 31.
// The zk default max connections to the ensemble from the one client is 30 so
// should run into zk issues before hit this value of 31.
private static final Map<Configuration, HConnectionImplementation> HBASE_INSTANCES =
new LinkedHashMap<Configuration, HConnectionImplementation>
((int) (MAX_CACHED_HBASE_INSTANCES/0.75F)+1, 0.75F, true) {
@Override
protected boolean removeEldestEntry(Map.Entry<Configuration, HConnectionImplementation> eldest) {
return size() > MAX_CACHED_HBASE_INSTANCES;
}
};
// Does it have any connection leak?
public static HConnection getConnection(Configuration conf)
throws ZooKeeperConnectionException {
HConnectionImplementation connection;
synchronized (HBASE_INSTANCES) {
connection = HBASE_INSTANCES.get(conf);
if (connection == null) {
connection = new HConnectionImplementation(conf);
HBASE_INSTANCES.put(conf, connection);
}
}
return connection;
}