feature #IAPI07 chain维度线程池隔离

This commit is contained in:
jason
2024-10-21 21:10:08 +08:00
parent 35ea7356ff
commit f34b3e9cc5
204 changed files with 4437 additions and 378 deletions

View File

@@ -1,5 +1,7 @@
package com.yomahub.liteflow.springboot;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.yomahub.liteflow.enums.ParseModeEnum;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -35,9 +37,6 @@ public class LiteflowProperty {
// FlowExecutor的execute2Future的自定义线程池
private String mainExecutorClass;
// 并行线程执行器class路径
private String threadExecutorClass;
// 异步线程最大等待描述
@Deprecated
private int whenMaxWaitSeconds;
@@ -46,12 +45,6 @@ public class LiteflowProperty {
private TimeUnit whenMaxWaitTimeUnit;
// 异步线程池最大线程数
private int whenMaxWorkers;
// 异步线程池最大队列数量
private int whenQueueLimit;
// 异步线程池是否隔离
private boolean whenThreadPoolIsolate;
@@ -80,14 +73,6 @@ public class LiteflowProperty {
// 规则文件/脚本文件变更监听
private boolean enableMonitorFile;
private String parallelLoopExecutorClass;
//使用默认并行循环线程池时,最大线程数
private int parallelMaxWorkers;
//使用默认并行循环线程池时,最大队列数
private int parallelQueueLimit;
// 是否启用组件降级
private boolean fallbackCmpEnable;
@@ -101,6 +86,15 @@ public class LiteflowProperty {
//脚本特殊设置选项
private Map<String, String> scriptSetting;
//全局线程池所用class路径(when+异步循环)
private String globalThreadPoolExecutorClass;
//全局线程池最大线程数(when+异步循环)
private Integer globalThreadPoolSize;
//全局线程池最大队列数(when+异步循环)
private Integer globalThreadPoolQueueSize;
public boolean isEnableMonitorFile() {
return enableMonitorFile;
}
@@ -143,22 +137,6 @@ public class LiteflowProperty {
this.whenMaxWaitSeconds = whenMaxWaitSeconds;
}
public int getWhenMaxWorkers() {
return whenMaxWorkers;
}
public void setWhenMaxWorkers(int whenMaxWorkers) {
this.whenMaxWorkers = whenMaxWorkers;
}
public int getWhenQueueLimit() {
return whenQueueLimit;
}
public void setWhenQueueLimit(int whenQueueLimit) {
this.whenQueueLimit = whenQueueLimit;
}
public ParseModeEnum getParseMode() {
return parseMode;
}
@@ -193,14 +171,6 @@ public class LiteflowProperty {
this.printBanner = printBanner;
}
public String getThreadExecutorClass() {
return threadExecutorClass;
}
public void setThreadExecutorClass(String threadExecutorClass) {
this.threadExecutorClass = threadExecutorClass;
}
public String getNodeExecutorClass() {
return nodeExecutorClass;
}
@@ -273,30 +243,6 @@ public class LiteflowProperty {
this.whenMaxWaitTimeUnit = whenMaxWaitTimeUnit;
}
public String getParallelLoopExecutorClass() {
return parallelLoopExecutorClass;
}
public void setParallelLoopExecutorClass(String parallelLoopExecutorClass) {
this.parallelLoopExecutorClass = parallelLoopExecutorClass;
}
public int getParallelMaxWorkers() {
return parallelMaxWorkers;
}
public void setParallelMaxWorkers(int parallelMaxWorkers) {
this.parallelMaxWorkers = parallelMaxWorkers;
}
public int getParallelQueueLimit() {
return parallelQueueLimit;
}
public void setParallelQueueLimit(int parallelQueueLimit) {
this.parallelQueueLimit = parallelQueueLimit;
}
public boolean isFallbackCmpEnable() {
return fallbackCmpEnable;
}
@@ -336,4 +282,40 @@ public class LiteflowProperty {
public void setScriptSetting(Map<String, String> scriptSetting) {
this.scriptSetting = scriptSetting;
}
public Integer getGlobalThreadPoolSize() {
if (ObjectUtil.isNull(globalThreadPoolSize)) {
return 16;
} else {
return globalThreadPoolSize;
}
}
public void setGlobalThreadPoolSize(Integer globalThreadPoolSize) {
this.globalThreadPoolSize = globalThreadPoolSize;
}
public Integer getGlobalThreadPoolQueueSize() {
if (ObjectUtil.isNull(globalThreadPoolQueueSize)) {
return 512;
} else {
return globalThreadPoolQueueSize;
}
}
public void setGlobalThreadPoolQueueSize(Integer globalThreadPoolQueueSize) {
this.globalThreadPoolQueueSize = globalThreadPoolQueueSize;
}
public String getGlobalThreadPoolExecutorClass() {
if (StrUtil.isBlank(globalThreadPoolExecutorClass)) {
return "com.yomahub.liteflow.thread.LiteFlowDefaultGlobalExecutorBuilder";
} else {
return globalThreadPoolExecutorClass;
}
}
public void setGlobalThreadPoolExecutorClass(String globalThreadPoolExecutorClass) {
this.globalThreadPoolExecutorClass = globalThreadPoolExecutorClass;
}
}

View File

@@ -26,12 +26,9 @@ public class LiteflowPropertyAutoConfiguration {
liteflowConfig.setRuleSourceExtData(property.getRuleSourceExtData());
liteflowConfig.setRuleSourceExtDataMap(property.getRuleSourceExtDataMap());
liteflowConfig.setSlotSize(property.getSlotSize());
liteflowConfig.setThreadExecutorClass(property.getThreadExecutorClass());
liteflowConfig.setWhenMaxWaitSeconds(property.getWhenMaxWaitSeconds());
liteflowConfig.setWhenMaxWaitTime(property.getWhenMaxWaitTime());
liteflowConfig.setWhenMaxWaitTimeUnit(property.getWhenMaxWaitTimeUnit());
liteflowConfig.setWhenMaxWorkers(property.getWhenMaxWorkers());
liteflowConfig.setWhenQueueLimit(property.getWhenQueueLimit());
liteflowConfig.setWhenThreadPoolIsolate(property.isWhenThreadPoolIsolate());
liteflowConfig.setParseMode(property.getParseMode());
liteflowConfig.setEnable(property.isEnable());
@@ -44,9 +41,6 @@ public class LiteflowPropertyAutoConfiguration {
liteflowConfig.setMainExecutorClass(property.getMainExecutorClass());
liteflowConfig.setPrintExecutionLog(property.isPrintExecutionLog());
liteflowConfig.setEnableMonitorFile(property.isEnableMonitorFile());
liteflowConfig.setParallelMaxWorkers(property.getParallelMaxWorkers());
liteflowConfig.setParallelQueueLimit(property.getParallelQueueLimit());
liteflowConfig.setParallelLoopExecutorClass(property.getParallelLoopExecutorClass());
liteflowConfig.setFallbackCmpEnable(property.isFallbackCmpEnable());
liteflowConfig.setFastLoad(property.isFastLoad());
liteflowConfig.setEnableLog(liteflowMonitorProperty.isEnableLog());
@@ -54,6 +48,9 @@ public class LiteflowPropertyAutoConfiguration {
liteflowConfig.setDelay(liteflowMonitorProperty.getDelay());
liteflowConfig.setPeriod(liteflowMonitorProperty.getPeriod());
liteflowConfig.setScriptSetting(property.getScriptSetting());
liteflowConfig.setGlobalThreadPoolExecutorClass(property.getGlobalThreadPoolExecutorClass());
liteflowConfig.setGlobalThreadPoolQueueSize(property.getGlobalThreadPoolQueueSize());
liteflowConfig.setGlobalThreadPoolSize(property.getGlobalThreadPoolSize());
return liteflowConfig;
}

View File

@@ -61,13 +61,6 @@
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
"defaultValue": "com.yomahub.liteflow.thread.LiteFlowDefaultMainExecutorBuilder"
},
{
"name": "liteflow.thread-executor-class",
"type": "java.lang.String",
"description": "Custom thread pool implement for when executor.",
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
"defaultValue": "com.yomahub.liteflow.thread.LiteFlowDefaultWhenExecutorBuilder"
},
{
"name": "liteflow.when-max-wait-seconds",
"type": "java.lang.Integer",
@@ -89,20 +82,6 @@
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
"defaultValue": "MILLISECONDS"
},
{
"name": "liteflow.when-max-workers",
"type": "java.lang.Integer",
"description": "Set the async thread pool worker max-size on \" when \" mode.",
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
"defaultValue": 16
},
{
"name": "liteflow.when-queue-limit",
"type": "java.lang.Integer",
"description": "Set the async thread pool queue max-size on \" when \" mode.",
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
"defaultValue": 512
},
{
"name": "liteflow.when-thread-pool-isolate",
"type": "java.lang.Boolean",
@@ -194,32 +173,32 @@
"sourceType": "com.yomahub.liteflow.springboot.LiteflowMonitorProperty",
"defaultValue": false
},
{
"name": "liteflow.parallel-max-workers",
"type": "java.lang.Integer",
"description": "Set the async thread pool worker max-size on \" parallel-loop \" mode.",
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
"defaultValue": 16
},
{
"name": "liteflow.parallel-queue-limit",
"type": "java.lang.Integer",
"description": "Set the async thread pool queue max-size on \" parallel-loop \" mode.",
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
"defaultValue": 512
},
{
"name": "liteflow.parallel-loop-executor-class",
"type": "java.lang.String",
"description": "Custom thread pool implement for parallel-loop executor.",
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
"defaultValue": "com.yomahub.liteflow.thread.LiteFlowDefaultParallelLoopExecutorBuilder"
},
{
"name": "liteflow.script-setting",
"type": "java.util.Map",
"description": "script special settings.",
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty"
},
{
"name": "liteflow.global-thread-pool-size",
"type": "java.lang.Integer",
"description": "Set the global chain thread pool worker max-size.",
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
"defaultValue": 16
},
{
"name": "liteflow.global-thread-pool-queue-size",
"type": "java.lang.Integer",
"description": "Set the global chain thread pool queue max-size ",
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
"defaultValue": 512
},
{
"name": "liteflow.global-thread-pool-executor-class",
"type": "java.lang.String",
"description": "Custom the global chain thread pool implement for global chain executor.",
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
"defaultValue": "com.yomahub.liteflow.thread.LiteFlowDefaultGlobalExecutorBuilder"
}
]
}

View File

@@ -4,11 +4,8 @@ liteflow.slot-size=1024
liteflow.main-executor-works=64
liteflow.main-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultMainExecutorBuilder
liteflow.request-id-generator-class=com.yomahub.liteflow.flow.id.DefaultRequestIdGenerator
liteflow.thread-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultWhenExecutorBuilder
liteflow.when-max-wait-time=15000
liteflow.when-max-wait-time-unit=MILLISECONDS
liteflow.when-max-workers=16
liteflow.when-queue-limit=512
liteflow.when-thread-pool-isolate=false
liteflow.parse-mode=PARSE_ALL_ON_START
liteflow.retry-count=0
@@ -18,12 +15,12 @@ liteflow.print-execution-log=true
liteflow.fallback-cmp-enable=false
liteflow.fast-load=false
liteflow.check-node-exists=true
liteflow.parallel-max-workers=16
liteflow.parallel-queue-limit=512
liteflow.parallel-loop-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultParallelLoopExecutorBuilder
liteflow.monitor.enable-log=false
liteflow.monitor.queue-limit=200
liteflow.monitor.delay=300000
liteflow.monitor.period=300000
liteflow.enable-monitor-file=false
liteflow.global-thread-pool-size=16
liteflow.global-thread-pool-queue-size=512
liteflow.global-thread-pool-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultGlobalExecutorBuilder