This is an automated email from the ASF dual-hosted git repository. dengzh pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push: new e974e5a093a HIVE-27340: ThreadPool in HS2 over HTTP should respect the customized ThreadFactory (Zhihua Deng, reviewed by Attila Turoczy, Denys Kuzmenko) e974e5a093a is described below commit e974e5a093a230db57d21e94e6ace8bc141a0339 Author: dengzh <dengzhhu...@gmail.com> AuthorDate: Tue Jun 13 09:24:08 2023 +0800 HIVE-27340: ThreadPool in HS2 over HTTP should respect the customized ThreadFactory (Zhihua Deng, reviewed by Attila Turoczy, Denys Kuzmenko) Closes #4322 --- .../apache/hive/service/cli/thrift/ThriftHttpCLIService.java | 10 +++++++++- .../java/org/apache/hadoop/hive/metastore/HiveMetaStore.java | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/service/src/java/org/apache/hive/service/cli/thrift/ThriftHttpCLIService.java b/service/src/java/org/apache/hive/service/cli/thrift/ThriftHttpCLIService.java index 160a65735b8..1e573cc87cc 100644 --- a/service/src/java/org/apache/hive/service/cli/thrift/ThriftHttpCLIService.java +++ b/service/src/java/org/apache/hive/service/cli/thrift/ThriftHttpCLIService.java @@ -21,6 +21,7 @@ package org.apache.hive.service.cli.thrift; import java.security.KeyStore; import java.util.Arrays; import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.Set; @@ -95,7 +96,14 @@ public class ThriftHttpCLIService extends ThriftCLIService { String threadPoolName = "HiveServer2-HttpHandler-Pool"; ThreadPoolExecutor executorService = new ThreadPoolExecutor(minWorkerThreads, maxWorkerThreads,workerKeepAliveTime, TimeUnit.SECONDS, - new SynchronousQueue<Runnable>(), new ThreadFactoryWithGarbageCleanup(threadPoolName)); + new SynchronousQueue<Runnable>(), new ThreadFactoryWithGarbageCleanup(threadPoolName)) { + @Override + public void setThreadFactory(ThreadFactory threadFactory) { + // ExecutorThreadPool will override the ThreadFactoryWithGarbageCleanup with his own ThreadFactory, + // Override this method to ignore the action. + LOG.warn("Ignore setting the thread factory as the pool has already provided his own: {}", getThreadFactory()); + } + }; ExecutorThreadPool threadPool = new ExecutorThreadPool(executorService); diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index 1eeec25ec0f..40f5fe37991 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -88,6 +88,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -404,7 +405,13 @@ public class HiveMetaStore extends ThriftHiveMetastore { thread.setDaemon(true); thread.setName("Metastore-HttpHandler-Pool: Thread-" + thread.getId()); return thread; - }); + }) { + @Override + public void setThreadFactory(ThreadFactory threadFactory) { + // Avoid ExecutorThreadPool overriding the ThreadFactory + LOG.warn("Ignore setting the thread factory as the pool has already provided his own: {}", getThreadFactory()); + } + }; ExecutorThreadPool threadPool = new ExecutorThreadPool((ThreadPoolExecutor) executorService); // HTTP Server org.eclipse.jetty.server.Server server = new Server(threadPool);