소스 검색

支持自定义核心数

wangliang 4 년 전
부모
커밋
e8902d314f

+ 10 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/domain/SysDomain.java

@@ -38,6 +38,16 @@ public class SysDomain implements Serializable {
 
     Integer threadPoolCoreSize;
 
+    boolean customThreadPoolCoreSize;
+
+    public boolean isCustomThreadPoolCoreSize() {
+        return customThreadPoolCoreSize;
+    }
+
+    public void setCustomThreadPoolCoreSize(boolean customThreadPoolCoreSize) {
+        this.customThreadPoolCoreSize = customThreadPoolCoreSize;
+    }
+
     public Integer getAutoCreatePdfResetMaxCount() {
         return autoCreatePdfResetMaxCount;
     }

+ 4 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/threadPool/MyThreadPool.java

@@ -30,6 +30,9 @@ public class MyThreadPool extends ThreadPoolTaskExecutor {
     @Value("${sys.config.threadPoolCoreSize}")
     Integer threadPoolCoreSize;
 
+    @Value("${sys.config.customThreadPoolCoreSize}")
+    boolean customThreadPoolCoreSize;
+
     @PostConstruct
     public void init() {
         taskThreadPool();
@@ -45,7 +48,7 @@ public class MyThreadPool extends ThreadPoolTaskExecutor {
         if (Objects.isNull(threadPoolTaskExecutor)) {
             log.info("cpuNum:{}", cpuNum);
             threadPoolTaskExecutor = new MyThreadPool();
-            if (cpuNum > 0) {
+            if (!customThreadPoolCoreSize && cpuNum > 0) {
                 threadPoolTaskExecutor.setCorePoolSize(cpuNum);//核心线程数
                 threadPoolTaskExecutor.setMaxPoolSize(cpuNum * 2);//最大线程数
             } else {

+ 1 - 0
distributed-print/src/main/resources/application.properties

@@ -59,6 +59,7 @@ sys.config.adminLogoUrl=http://qmth-test.oss-cn-shenzhen.aliyuncs.com/frontend/w
 sys.config.htmlToPdfUrl=/usr/local/bin/wkhtmltopdf
 sys.config.autoCreatePdfResetMaxCount=5
 sys.config.threadPoolCoreSize=5
+sys.config.customThreadPoolCoreSize=true
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 
 org.center.url=https://solar.qmth.com.cn