ritegarg commented on code in PR #2138:
URL: https://github.com/apache/phoenix/pull/2138#discussion_r2087298007
##########
phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java:
##########
@@ -478,31 +490,65 @@ public ConnectionQueryServicesImpl(QueryServices
services, ConnectionInfo connec
// Without making a copy of the configuration we cons up, we lose some
of our properties
// on the server side during testing.
- this.config =
HBaseFactoryProvider.getConfigurationFactory().getConfiguration(config);
+ Configuration finalConfig = HBaseFactoryProvider
+
.getConfigurationFactory().getConfiguration(config);
+ this.config = finalConfig;
+
+ if (finalConfig.getBoolean(CQSI_THREAD_POOL_ENABLED,
DEFAULT_CQSI_THREAD_POOL_ENABLED)) {
+ final int keepAlive =
finalConfig.getInt(CQSI_THREAD_POOL_KEEP_ALIVE_SECONDS,
+ DEFAULT_CQSI_THREAD_POOL_KEEP_ALIVE_SECONDS);
+ final int corePoolSize =
finalConfig.getInt(CQSI_THREAD_POOL_CORE_POOL_SIZE,
+ DEFAULT_CQSI_THREAD_POOL_CORE_POOL_SIZE);
+ final int maxThreads =
finalConfig.getInt(CQSI_THREAD_POOL_MAX_THREADS,
+ DEFAULT_CQSI_THREAD_POOL_MAX_THREADS);
+ final int maxQueue = finalConfig.getInt(CQSI_THREAD_POOL_MAX_QUEUE,
+ DEFAULT_CQSI_THREAD_POOL_MAX_QUEUE);
+ final String threadPoolName = connectionInfo.getPrincipal() != null
+ ? connectionInfo.getPrincipal()
+ : DEFAULT_QUERY_SERVICES_NAME;
+ // Based on implementations used in
+ // org.apache.hadoop.hbase.client.ConnectionImplementation
+ final BlockingQueue<Runnable> workQueue = new
LinkedBlockingQueue<>(maxQueue);
+ this.threadPoolExecutor =
+ new ThreadPoolExecutor(corePoolSize, maxThreads,
keepAlive, TimeUnit.SECONDS,
+ workQueue, new ThreadFactoryBuilder()
+ .setDaemon(true)
+ .setNameFormat("CQSI-" + threadPoolName
+ + "-" +
threadPoolNumber.incrementAndGet()
+ + "-shared-pool-%d")
+ .setUncaughtExceptionHandler(
+
Threads.LOGGING_EXCEPTION_HANDLER)
+ .build());
+ this.threadPoolExecutor.allowCoreThreadTimeOut(finalConfig
+ .getBoolean(CQSI_THREAD_POOL_ALLOW_CORE_THREAD_TIMEOUT,
+ DEFAULT_CQSI_THREAD_POOL_ALLOW_CORE_THREAD_TIMEOUT));
Review Comment:
Ack
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]