You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by "jpisaac (via GitHub)" <gi...@apache.org> on 2025/05/08 20:50:38 UTC

Re: [PR] PHOENIX-7605 Adding ability to configure threadpool at principal level [phoenix]

jpisaac commented on code in PR #2138:
URL: https://github.com/apache/phoenix/pull/2138#discussion_r2080441760


##########
phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionQueryServicesImplTest.java:
##########
@@ -330,26 +375,26 @@ public void testSysTaskSplitPolicyWithError() {
     public void testGetSysMutexTableWithName() throws Exception {
         when(mockAdmin.tableExists(any())).thenReturn(true);
         when(mockConn.getAdmin()).thenReturn(mockAdmin);
-        when(mockConn.getTable(TableName.valueOf("SYSTEM.MUTEX")))
+        when(mockConn.getTable(eq(TableName.valueOf("SYSTEM.MUTEX")), any()))

Review Comment:
   why did this needed to change?



##########
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:
   nit: remove space between "-shared -pool"



-- 
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: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org