virajjasani commented on code in PR #2138:
URL: https://github.com/apache/phoenix/pull/2138#discussion_r2080803457
##########
phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java:
##########
@@ -417,6 +427,8 @@ public ConnectionInfo getConnectionInfo() {
private Connection invalidateMetadataCacheConnection = null;
private final Object invalidateMetadataCacheConnLock = new Object();
private MetricsMetadataCachingSource metricsMetadataCachingSource;
+ private ThreadPoolExecutor threadPoolExecutor;
Review Comment:
nit: initialize with `null` to clearly differentiate null vs not-null case
based on whether the config is enabled
##########
phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java:
##########
@@ -472,6 +485,21 @@ public ConnectionQueryServicesImpl(QueryServices services,
ConnectionInfo connec
if (connectionInfo.getPrincipal() != null) {
config.set(QUERY_SERVICES_NAME, connectionInfo.getPrincipal());
}
+ if (config.getBoolean(CQSI_THREAD_POOL_ENABLED,
DEFAULT_CQSI_THREAD_POOL_ENABLED)) {
+ final int keepAlive =
config.getInt(CQSI_THREAD_POOL_KEEP_ALIVE_SECONDS,
DEFAULT_CQSI_THREAD_POOL_KEEP_ALIVE_SECONDS);
+ final int corePoolSize =
config.getInt(CQSI_THREAD_POOL_CORE_POOL_SIZE,
DEFAULT_CQSI_THREAD_POOL_CORE_POOL_SIZE);
+ final int maxThreads = config.getInt(CQSI_THREAD_POOL_MAX_THREADS,
DEFAULT_CQSI_THREAD_POOL_MAX_THREADS);
+ final int maxQueue = config.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")
Review Comment:
why we need `threadPoolNumber` when we are already using `%d`?
##########
phoenix-core-client/src/main/java/org/apache/phoenix/query/QueryServices.java:
##########
@@ -384,6 +384,13 @@ public interface QueryServices extends SQLCloseable {
public static final String PHOENIX_VIEW_TTL_TENANT_VIEWS_PER_SCAN_LIMIT =
"phoenix.view.ttl.tenant_views_per_scan.limit";
// Block mutations based on cluster role record
public static final String CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED =
"phoenix.cluster.role.based.mutation.block.enabled";
+ public static final String CQSI_THREAD_POOL_ENABLED =
"phoenix.cqsi.thread.pool.enabled";
Review Comment:
Let's add comment reg when to use this config
--
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]