HBASE-9917 Fix it so Default Connection Pool does not spin up max threads even when not needed
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1540945 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f8f0a927e3
commit
c3fcaec3f4
|
@ -720,22 +720,22 @@ public class HConnectionManager {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (batchPool == null) {
|
if (batchPool == null) {
|
||||||
int maxThreads = conf.getInt("hbase.hconnection.threads.max", 256);
|
int maxThreads = conf.getInt("hbase.hconnection.threads.max", 256);
|
||||||
|
int coreThreads = conf.getInt("hbase.hconnection.threads.core", 0);
|
||||||
if (maxThreads == 0) {
|
if (maxThreads == 0) {
|
||||||
maxThreads = Runtime.getRuntime().availableProcessors() * 8;
|
maxThreads = Runtime.getRuntime().availableProcessors() * 8;
|
||||||
}
|
}
|
||||||
long keepAliveTime = conf.getLong(
|
long keepAliveTime = conf.getLong("hbase.hconnection.threads.keepalivetime", 10);
|
||||||
"hbase.hconnection.threads.keepalivetime", 60);
|
|
||||||
LinkedBlockingQueue<Runnable> workQueue =
|
LinkedBlockingQueue<Runnable> workQueue =
|
||||||
new LinkedBlockingQueue<Runnable>(256 *
|
new LinkedBlockingQueue<Runnable>(maxThreads *
|
||||||
conf.getInt(HConstants.HBASE_CLIENT_MAX_TOTAL_TASKS,
|
conf.getInt(HConstants.HBASE_CLIENT_MAX_TOTAL_TASKS,
|
||||||
HConstants.DEFAULT_HBASE_CLIENT_MAX_TOTAL_TASKS));
|
HConstants.DEFAULT_HBASE_CLIENT_MAX_TOTAL_TASKS));
|
||||||
this.batchPool = new ThreadPoolExecutor(
|
this.batchPool = new ThreadPoolExecutor(
|
||||||
maxThreads,
|
coreThreads,
|
||||||
maxThreads,
|
maxThreads,
|
||||||
keepAliveTime,
|
keepAliveTime,
|
||||||
TimeUnit.SECONDS,
|
TimeUnit.SECONDS,
|
||||||
workQueue,
|
workQueue,
|
||||||
Threads.newDaemonThreadFactory("hbase-connection-shared-executor"));
|
Threads.newDaemonThreadFactory(toString() + "-shared-"));
|
||||||
}
|
}
|
||||||
this.cleanupPool = true;
|
this.cleanupPool = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue