From 91d3e9b368a5a6967b24fd6438114e7b646248b7 Mon Sep 17 00:00:00 2001 From: jason <2353220944@qq.com> Date: Mon, 28 Oct 2024 15:10:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Echain=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E6=B1=A0=E9=9A=94=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builder/el/LiteFlowChainELBuilder.java | 11 ++- .../builder/el/operator/WhenOperator.java | 3 - .../liteflow/common/ChainConstant.java | 2 + .../yomahub/liteflow/flow/element/Chain.java | 17 +++- .../strategy/ParallelStrategyExecutor.java | 18 +++-- .../liteflow/parser/helper/ParserHelper.java | 28 +++---- .../liteflow/property/LiteflowConfig.java | 62 --------------- .../liteflow/thread/ExecutorHelper.java | 39 ++++----- .../LiteFlowDefaultChainExecutorBuilder.java | 25 ------ .../src/main/resources/dtd/liteflow.dtd | 1 + .../config/LiteflowAutoConfiguration.java | 5 -- .../solon/config/LiteflowProperty.java | 46 ----------- .../META-INF/liteflow-default.properties | 4 - .../liteflow/springboot/LiteflowProperty.java | 46 ----------- .../LiteflowPropertyAutoConfiguration.java | 4 - ...itional-spring-configuration-metadata.json | 28 ------- .../META-INF/liteflow-default.properties | 4 - ...r1.java => CustomChainThreadExecutor.java} | 6 +- ... => CustomThreadPoolELSpringbootTest.java} | 43 ++++------ ...or2.java => CustomWhenThreadExecutor.java} | 6 +- ...efaultChainThreadPoolELSpringbootTest.java | 45 ----------- .../GlobalThreadPoolELSpringbootTest.java | 79 +++++++++++++++++++ .../test/chainThreadPool/cmp/FCmp.java | 2 +- .../test/chainThreadPool/cmp/ICmp.java | 2 +- .../test/chainThreadPool/cmp/WCmp.java | 2 +- .../chainThreadPool/application.properties | 3 - .../chainThreadPool/application2.properties | 5 +- .../resources/chainThreadPool/flow.el.xml | 23 +++++- .../resources/chainThreadPool/flow2.el.xml | 21 +++-- 29 files changed, 198 insertions(+), 382 deletions(-) delete mode 100644 liteflow-core/src/main/java/com/yomahub/liteflow/thread/LiteFlowDefaultChainExecutorBuilder.java rename liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/{CustomThreadExecutor1.java => CustomChainThreadExecutor.java} (70%) rename liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/{CustomChainThreadPoolELSpringbootTest.java => CustomThreadPoolELSpringbootTest.java} (60%) rename liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/{CustomThreadExecutor2.java => CustomWhenThreadExecutor.java} (70%) delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/DefaultChainThreadPoolELSpringbootTest.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/GlobalThreadPoolELSpringbootTest.java diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/LiteFlowChainELBuilder.java b/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/LiteFlowChainELBuilder.java index 0e5505217..0995f3cf0 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/LiteFlowChainELBuilder.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/LiteFlowChainELBuilder.java @@ -1,7 +1,10 @@ package com.yomahub.liteflow.builder.el; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.*; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.CharUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.ql.util.express.DefaultContext; @@ -30,7 +33,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; -import java.util.function.Consumer; /** * Chain基于代码形式的组装器 EL表达式规则专属组装器 @@ -243,6 +245,11 @@ public class LiteFlowChainELBuilder { return this; } + public LiteFlowChainELBuilder setThreadPoolExecutorClass(String threadPoolExecutorClass) { + this.chain.setThreadPoolExecutorClass(threadPoolExecutorClass); + return this; + } + /** * EL表达式校验,此方法已经过时,请使用 {@link LiteFlowChainELBuilder#validateWithEx(String)} * diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/WhenOperator.java b/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/WhenOperator.java index 60b676dc5..00cfa58e0 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/WhenOperator.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/WhenOperator.java @@ -26,9 +26,6 @@ public class WhenOperator extends BaseOperator { OperatorHelper.checkObjMustBeCommonTypeItem(obj); whenCondition.addExecutable(OperatorHelper.convert(obj, Executable.class)); whenCondition.setThreadExecutorClass(liteflowConfig.getThreadExecutorClass()); - if (liteflowConfig.getChainThreadPoolIsolate()) { - whenCondition.setThreadExecutorClass(liteflowConfig.getChainThreadExecutorClass()); - } } return whenCondition; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/common/ChainConstant.java b/liteflow-core/src/main/java/com/yomahub/liteflow/common/ChainConstant.java index e54c6af2f..071ae60e3 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/common/ChainConstant.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/common/ChainConstant.java @@ -34,6 +34,8 @@ public interface ChainConstant { String NAMESPACE = "namespace"; + String THREAD_POOL_EXECUTOR_CLASS = "thread-pool-executor-class"; + String DEFAULT_NAMESPACE = "default"; String VALUE = "value"; diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Chain.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Chain.java index f8d6ae437..a9203432b 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Chain.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Chain.java @@ -12,18 +12,17 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.BooleanUtil; import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder; import com.yomahub.liteflow.common.ChainConstant; +import com.yomahub.liteflow.enums.ExecuteableTypeEnum; import com.yomahub.liteflow.exception.ChainEndException; +import com.yomahub.liteflow.exception.FlowSystemException; import com.yomahub.liteflow.lifecycle.LifeCycleHolder; -import com.yomahub.liteflow.lifecycle.PostProcessChainExecuteLifeCycle; import com.yomahub.liteflow.log.LFLog; import com.yomahub.liteflow.log.LFLoggerManager; import com.yomahub.liteflow.slot.DataBus; import com.yomahub.liteflow.slot.Slot; -import com.yomahub.liteflow.enums.ExecuteableTypeEnum; -import com.yomahub.liteflow.exception.FlowSystemException; + import java.util.ArrayList; import java.util.List; -import java.util.function.Consumer; /** * chain对象,实现可执行器 @@ -46,6 +45,8 @@ public class Chain implements Executable{ private String namespace = ChainConstant.DEFAULT_NAMESPACE; + private String threadPoolExecutorClass; + public Chain(String chainName) { this.chainId = chainName; } @@ -223,4 +224,12 @@ public class Chain implements Executable{ public void setNamespace(String namespace) { this.namespace = namespace; } + + public String getThreadPoolExecutorClass() { + return threadPoolExecutorClass; + } + + public void setThreadPoolExecutorClass(String threadPoolExecutorClass) { + this.threadPoolExecutorClass = threadPoolExecutorClass; + } } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/ParallelStrategyExecutor.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/ParallelStrategyExecutor.java index 109055a53..42cb958de 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/ParallelStrategyExecutor.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/ParallelStrategyExecutor.java @@ -133,16 +133,22 @@ public abstract class ParallelStrategyExecutor { // 默认设置不隔离。也就是说,默认情况是一个线程池类一个实例,如果什么都不配置,那也就是在 when 的情况下,全局一个线程池。 ExecutorService parallelExecutor; + String chainId = DataBus.getSlot(slotIndex).getChainId(); + + Chain chain = FlowBus.getChain(chainId); + if (BooleanUtil.isTrue(liteflowConfig.getWhenThreadPoolIsolate())) { - parallelExecutor = ExecutorHelper.loadInstance().buildWhenExecutorWithHash(whenCondition.getThreadExecutorClass(), String.valueOf(whenCondition.hashCode())); - } else if (BooleanUtil.isTrue(liteflowConfig.getChainThreadPoolIsolate())) { - //chain 线程池隔离 - String chainId = DataBus.getSlot(slotIndex).getChainId(); - Chain chain = FlowBus.getChain(chainId); + //condition层级线程池 parallelExecutor = - ExecutorHelper.loadInstance().buildChainExecutorWithHash(whenCondition.getThreadExecutorClass(), + ExecutorHelper.loadInstance().buildWhenExecutorWithHash(whenCondition.getThreadExecutorClass(), + String.valueOf(whenCondition.hashCode())); + } else if (ObjectUtil.isNotEmpty(chain.getThreadPoolExecutorClass())) { + //chain层级线程池 + parallelExecutor = + ExecutorHelper.loadInstance().buildWhenExecutorWithHash(chain.getThreadPoolExecutorClass(), String.valueOf(chain.hashCode())); } else { + //全局线程池 parallelExecutor = ExecutorHelper.loadInstance().buildWhenExecutor(whenCondition.getThreadExecutorClass()); } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java index 9c3df1206..50dafedd0 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java @@ -1,6 +1,5 @@ package com.yomahub.liteflow.parser.helper; -import cn.hutool.core.util.BooleanUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.fasterxml.jackson.databind.JsonNode; @@ -17,15 +16,8 @@ import com.yomahub.liteflow.util.ElRegexUtil; import org.dom4j.Document; import org.dom4j.Element; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.function.Consumer; -import java.util.function.Function; import static com.yomahub.liteflow.common.ChainConstant.*; @@ -96,10 +88,6 @@ public class ParserHelper { .build(); } - /** - * xml 形式的主要解析过程 - * @param documentList documentList - */ /** * xml 形式的主要解析过程 * @param documentList documentList @@ -316,7 +304,12 @@ public class ParserHelper { JsonNode routeJsonNode = chainNode.get(ROUTE); - LiteFlowChainELBuilder builder = LiteFlowChainELBuilder.createChain().setChainId(chainId).setNamespace(namespace); + String threadPoolExecutorClass = chainNode.get(THREAD_POOL_EXECUTOR_CLASS) == null ? + null : chainNode.get(THREAD_POOL_EXECUTOR_CLASS).textValue(); + + LiteFlowChainELBuilder builder = + LiteFlowChainELBuilder.createChain().setChainId(chainId).setNamespace(namespace) + .setThreadPoolExecutorClass(threadPoolExecutorClass); // 如果有route这个标签,说明是决策表chain // 决策表链路必须有route和body这两个标签 @@ -347,7 +340,12 @@ public class ParserHelper { Element routeElement = e.element(ROUTE); - LiteFlowChainELBuilder builder = LiteFlowChainELBuilder.createChain().setChainId(chainId).setNamespace(namespace); + String threadPoolExecutorClass = e.attributeValue(THREAD_POOL_EXECUTOR_CLASS) == null ? + null : e.attributeValue(THREAD_POOL_EXECUTOR_CLASS); + + LiteFlowChainELBuilder builder = + LiteFlowChainELBuilder.createChain().setChainId(chainId).setNamespace(namespace) + .setThreadPoolExecutorClass(threadPoolExecutorClass); // 如果有route这个标签,说明是决策表chain // 决策表链路必须有route和body这两个标签 diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java b/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java index 89350c00c..7568b95ab 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java @@ -123,20 +123,6 @@ public class LiteflowConfig { //脚本特殊设置选项 private Map scriptSetting; - // chain线程池最大线程数 - private Integer chainMaxWorkers; - - // chain线程池最大队列数量 - private Integer chainQueueLimit; - - // chain线程执行器class路径 - private String chainThreadExecutorClass; - - // chain线程池是否隔离 - // 每一个chain里的when和异步循环合并起来都用单独的线程池。也就是说定义了多少个chain,就有多少个线程池 - private Boolean chainThreadPoolIsolate; - - public Boolean getEnableMonitorFile() { return enableMonitorFile; } @@ -522,52 +508,4 @@ public class LiteflowConfig { public void setScriptSetting(Map scriptSetting) { this.scriptSetting = scriptSetting; } - - public Boolean getChainThreadPoolIsolate() { - if (ObjectUtil.isNull(chainThreadPoolIsolate)) { - return Boolean.FALSE; - } else { - return chainThreadPoolIsolate; - } - } - - public void setChainThreadPoolIsolate(Boolean chainThreadPoolIsolate) { - this.chainThreadPoolIsolate = chainThreadPoolIsolate; - } - - public Integer getChainMaxWorkers() { - if (ObjectUtil.isNull(chainMaxWorkers)) { - return 16; - } else { - return chainMaxWorkers; - } - } - - public void setChainMaxWorkers(Integer chainMaxWorkers) { - this.chainMaxWorkers = chainMaxWorkers; - } - - public Integer getChainQueueLimit() { - if (ObjectUtil.isNull(chainMaxWorkers)) { - return 512; - } else { - return chainQueueLimit; - } - } - - public void setChainQueueLimit(Integer chainQueueLimit) { - this.chainQueueLimit = chainQueueLimit; - } - - public String getChainThreadExecutorClass() { - if (StrUtil.isBlank(chainThreadExecutorClass)) { - return "com.yomahub.liteflow.thread.LiteFlowDefaultChainExecutorBuilder"; - } else { - return chainThreadExecutorClass; - } - } - - public void setChainThreadExecutorClass(String chainThreadExecutorClass) { - this.chainThreadExecutorClass = chainThreadExecutorClass; - } } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorHelper.java b/liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorHelper.java index f0a4a27d8..d8b49f82a 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorHelper.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorHelper.java @@ -9,7 +9,6 @@ package com.yomahub.liteflow.thread; import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.BooleanUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.exception.ThreadExecutorServiceCreateException; @@ -132,15 +131,24 @@ public class ExecutorHelper { //构造并行循环的线程池 public ExecutorService buildLoopParallelExecutor(Integer slotIndex) { + ExecutorService parallelExecutor; LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); - //chain线程池 - if (BooleanUtil.isTrue(liteflowConfig.getChainThreadPoolIsolate())) { - //获取chain的hash - String chainId = DataBus.getSlot(slotIndex).getChainId(); - Chain chain = FlowBus.getChain(chainId); - return getExecutorService(liteflowConfig.getChainThreadExecutorClass(), String.valueOf(chain.hashCode())); + //获取chain的hash + String chainId = DataBus.getSlot(slotIndex).getChainId(); + Chain chain = FlowBus.getChain(chainId); + + //condition层级线程池 TODO + + //chain层级线程池 + if (ObjectUtil.isNotEmpty(chain.getThreadPoolExecutorClass())) { + //chain层级线程池 + parallelExecutor = getExecutorService(chain.getThreadPoolExecutorClass(), + String.valueOf(chain.hashCode())); + } else { + //全局线程池 + parallelExecutor = getExecutorService(liteflowConfig.getParallelLoopExecutorClass()); } - return getExecutorService(liteflowConfig.getParallelLoopExecutorClass()); + return parallelExecutor; } private ExecutorService getExecutorService(String clazz){ @@ -183,19 +191,4 @@ public class ExecutorHelper { } } - // 构建chain线程池 - clazz和condition的hash值共同作为缓存key - public ExecutorService buildChainExecutorWithHash(String conditionHash) { - LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); - return buildChainExecutorWithHash(liteflowConfig.getChainThreadExecutorClass(), conditionHash); - } - - // 构建chain线程池 - clazz和condition的hash值共同作为缓存key - public ExecutorService buildChainExecutorWithHash(String clazz, String conditionHash) { - if (StrUtil.isBlank(clazz)) { - return buildChainExecutorWithHash(conditionHash); - } - return getExecutorService(clazz, conditionHash); - } - - } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/thread/LiteFlowDefaultChainExecutorBuilder.java b/liteflow-core/src/main/java/com/yomahub/liteflow/thread/LiteFlowDefaultChainExecutorBuilder.java deleted file mode 100644 index 3148a08cf..000000000 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/thread/LiteFlowDefaultChainExecutorBuilder.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.yomahub.liteflow.thread; - -import cn.hutool.core.util.ObjectUtil; -import com.yomahub.liteflow.property.LiteflowConfig; -import com.yomahub.liteflow.property.LiteflowConfigGetter; - -import java.util.concurrent.ExecutorService; - -/** - * LiteFlow默认的chain多线程执行器实现 - */ -public class LiteFlowDefaultChainExecutorBuilder implements ExecutorBuilder { - - @Override - public ExecutorService buildExecutor() { - LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); - // 只有在非spring的场景下liteflowConfig才会为null - if (ObjectUtil.isNull(liteflowConfig)) { - liteflowConfig = new LiteflowConfig(); - } - return buildDefaultExecutor(liteflowConfig.getChainMaxWorkers(), liteflowConfig.getChainMaxWorkers(), - liteflowConfig.getChainQueueLimit(), "chain-thread-"); - } - -} diff --git a/liteflow-core/src/main/resources/dtd/liteflow.dtd b/liteflow-core/src/main/resources/dtd/liteflow.dtd index 324f17cbe..d7927fd29 100644 --- a/liteflow-core/src/main/resources/dtd/liteflow.dtd +++ b/liteflow-core/src/main/resources/dtd/liteflow.dtd @@ -22,4 +22,5 @@ extends CDATA #IMPLIED enable (true|false) #IMPLIED namespace CDATA #IMPLIED + thread-pool-executor-class CDATA #IMPLIED > \ No newline at end of file diff --git a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowAutoConfiguration.java b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowAutoConfiguration.java index fd4856f40..5d560cfde 100644 --- a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowAutoConfiguration.java +++ b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowAutoConfiguration.java @@ -51,11 +51,6 @@ public class LiteflowAutoConfiguration { liteflowConfig.setParallelQueueLimit(property.getParallelQueueLimit()); liteflowConfig.setParallelLoopExecutorClass(property.getParallelLoopExecutorClass()); liteflowConfig.setFallbackCmpEnable(property.isFallbackCmpEnable()); - liteflowConfig.setChainThreadExecutorClass(property.getChainThreadExecutorClass()); - liteflowConfig.setChainQueueLimit(property.getParallelQueueLimit()); - liteflowConfig.setChainMaxWorkers(property.getParallelMaxWorkers()); - liteflowConfig.setChainThreadPoolIsolate(property.isChainThreadPoolIsolate()); - return liteflowConfig; } diff --git a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowProperty.java b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowProperty.java index 734eda775..d58dd333f 100644 --- a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowProperty.java +++ b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowProperty.java @@ -83,19 +83,6 @@ public class LiteflowProperty { // 是否启用组件降级 private Boolean fallbackCmpEnable; - // chain线程池是否隔离 - // 每一个chain里的when和异步循环合并起来都用单独的线程池。也就是说定义了多少个chain,就有多少个线程池 - private Boolean chainThreadPoolIsolate; - - // chain线程池最大线程数 - private int chainMaxWorkers; - - // chain线程池最大队列数量 - private int chainQueueLimit; - - // chain线程执行器class路径 - private String chainThreadExecutorClass; - public boolean isEnable() { return enable; } @@ -280,37 +267,4 @@ public class LiteflowProperty { public Boolean getFallbackCmpEnable() { return fallbackCmpEnable; } - - public void setChainThreadPoolIsolate(boolean chainThreadPoolIsolate) { - this.chainThreadPoolIsolate = chainThreadPoolIsolate; - } - - public boolean isChainThreadPoolIsolate() { - return chainThreadPoolIsolate; - } - - public int getChainMaxWorkers() { - return chainMaxWorkers; - } - - public void setChainMaxWorkers(int chainMaxWorkers) { - this.chainMaxWorkers = chainMaxWorkers; - } - - public int getChainQueueLimit() { - return chainQueueLimit; - } - - public void setChainQueueLimit(int chainQueueLimit) { - this.chainQueueLimit = chainQueueLimit; - } - - public String getChainThreadExecutorClass() { - return chainThreadExecutorClass; - } - - public void setChainThreadExecutorClass(String chainThreadExecutorClass) { - this.chainThreadExecutorClass = chainThreadExecutorClass; - } - } diff --git a/liteflow-solon-plugin/src/main/resources/META-INF/liteflow-default.properties b/liteflow-solon-plugin/src/main/resources/META-INF/liteflow-default.properties index b669a3a64..c1fda2e94 100644 --- a/liteflow-solon-plugin/src/main/resources/META-INF/liteflow-default.properties +++ b/liteflow-solon-plugin/src/main/resources/META-INF/liteflow-default.properties @@ -18,7 +18,3 @@ liteflow.monitor.queue-limit=200 liteflow.monitor.delay=300000 liteflow.monitor.period=300000 liteflow.fallback-cmp-enable=false -liteflow.chain-max-workers=16 -liteflow.chain-queue-limit=512 -liteflow.chain-thread-pool-isolate=false -liteflow.chain-thread-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultChainExecutorBuilder \ No newline at end of file diff --git a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java index 34e3c434d..930a62d4c 100644 --- a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java +++ b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java @@ -101,19 +101,6 @@ public class LiteflowProperty { //脚本特殊设置选项 private Map scriptSetting; - // chain线程池是否隔离 - // 每一个chain里的when和异步循环合并起来都用单独的线程池。也就是说定义了多少个chain,就有多少个线程池 - private Boolean chainThreadPoolIsolate; - - // chain线程池最大线程数 - private int chainMaxWorkers; - - // chain线程池最大队列数量 - private int chainQueueLimit; - - // chain线程执行器class路径 - private String chainThreadExecutorClass; - public boolean isEnableMonitorFile() { return enableMonitorFile; } @@ -349,37 +336,4 @@ public class LiteflowProperty { public void setScriptSetting(Map scriptSetting) { this.scriptSetting = scriptSetting; } - - public void setChainThreadPoolIsolate(boolean chainThreadPoolIsolate) { - this.chainThreadPoolIsolate = chainThreadPoolIsolate; - } - - public boolean isChainThreadPoolIsolate() { - return chainThreadPoolIsolate; - } - - public int getChainMaxWorkers() { - return chainMaxWorkers; - } - - public void setChainMaxWorkers(int chainMaxWorkers) { - this.chainMaxWorkers = chainMaxWorkers; - } - - public int getChainQueueLimit() { - return chainQueueLimit; - } - - public void setChainQueueLimit(int chainQueueLimit) { - this.chainQueueLimit = chainQueueLimit; - } - - public String getChainThreadExecutorClass() { - return chainThreadExecutorClass; - } - - public void setChainThreadExecutorClass(String chainThreadExecutorClass) { - this.chainThreadExecutorClass = chainThreadExecutorClass; - } - } diff --git a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/config/LiteflowPropertyAutoConfiguration.java b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/config/LiteflowPropertyAutoConfiguration.java index 4976f0eca..37356fcb3 100644 --- a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/config/LiteflowPropertyAutoConfiguration.java +++ b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/config/LiteflowPropertyAutoConfiguration.java @@ -54,10 +54,6 @@ public class LiteflowPropertyAutoConfiguration { liteflowConfig.setDelay(liteflowMonitorProperty.getDelay()); liteflowConfig.setPeriod(liteflowMonitorProperty.getPeriod()); liteflowConfig.setScriptSetting(property.getScriptSetting()); - liteflowConfig.setChainThreadPoolIsolate(property.isChainThreadPoolIsolate()); - liteflowConfig.setChainThreadExecutorClass(property.getChainThreadExecutorClass()); - liteflowConfig.setChainMaxWorkers(property.getChainMaxWorkers()); - liteflowConfig.setChainQueueLimit(property.getChainQueueLimit()); return liteflowConfig; } diff --git a/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 91514d93c..83b0b668e 100644 --- a/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -220,34 +220,6 @@ "type": "java.util.Map", "description": "script special settings.", "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty" - }, - { - "name": "liteflow.chain-thread-pool-isolate", - "type": "java.lang.Boolean", - "description": "set whether the chain thread pool is isolated.", - "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty", - "defaultValue": false - }, - { - "name": "liteflow.chain-max-workers", - "type": "java.lang.Integer", - "description": "Set the chain thread pool worker max-size on \" when \" mode.", - "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty", - "defaultValue": 16 - }, - { - "name": "liteflow.chain-queue-limit", - "type": "java.lang.Integer", - "description": "Set the chain thread pool queue max-size on \" when \" mode.", - "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty", - "defaultValue": 512 - }, - { - "name": "liteflow.chain-thread-executor-class", - "type": "java.lang.String", - "description": "Custom chain thread pool implement for when executor.", - "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty", - "defaultValue": "com.yomahub.liteflow.thread.LiteFlowDefaultChainExecutorBuilder" } ] } \ No newline at end of file diff --git a/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties b/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties index eeaeb1b99..37aeb4645 100644 --- a/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties +++ b/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties @@ -26,8 +26,4 @@ liteflow.monitor.queue-limit=200 liteflow.monitor.delay=300000 liteflow.monitor.period=300000 liteflow.enable-monitor-file=false -liteflow.chain-max-workers=16 -liteflow.chain-queue-limit=512 -liteflow.chain-thread-pool-isolate=false -liteflow.chain-thread-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultChainExecutorBuilder diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomThreadExecutor1.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadExecutor.java similarity index 70% rename from liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomThreadExecutor1.java rename to liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadExecutor.java index f19c37ec4..c46a2e8e5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomThreadExecutor1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadExecutor.java @@ -7,7 +7,7 @@ import com.yomahub.liteflow.thread.ExecutorBuilder; import java.util.concurrent.ExecutorService; -public class CustomThreadExecutor1 implements ExecutorBuilder { +public class CustomChainThreadExecutor implements ExecutorBuilder { @Override public ExecutorService buildExecutor() { @@ -16,8 +16,8 @@ public class CustomThreadExecutor1 implements ExecutorBuilder { if (ObjectUtil.isNull(liteflowConfig)) { liteflowConfig = new LiteflowConfig(); } - return buildDefaultExecutor(liteflowConfig.getChainMaxWorkers(), liteflowConfig.getChainMaxWorkers(), - liteflowConfig.getChainQueueLimit(), "customer-chain-thead-1"); + return buildDefaultExecutor(16, 16, + 512, "customer-chain-thead"); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadPoolELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomThreadPoolELSpringbootTest.java similarity index 60% rename from liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadPoolELSpringbootTest.java rename to liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomThreadPoolELSpringbootTest.java index b98d4bbda..f50aa6389 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadPoolELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomThreadPoolELSpringbootTest.java @@ -21,10 +21,10 @@ import java.util.List; * springboot环境下chain线程池隔离测试 */ @TestPropertySource(value = "classpath:/chainThreadPool/application2.properties") -@SpringBootTest(classes = CustomChainThreadPoolELSpringbootTest.class) +@SpringBootTest(classes = CustomThreadPoolELSpringbootTest.class) @EnableAutoConfiguration @ComponentScan({"com.yomahub.liteflow.test.chainThreadPool.cmp"}) -public class CustomChainThreadPoolELSpringbootTest extends BaseTest { +public class CustomThreadPoolELSpringbootTest extends BaseTest { private final Logger log = LoggerFactory.getLogger(this.getClass()); @@ -32,61 +32,48 @@ public class CustomChainThreadPoolELSpringbootTest extends BaseTest { private FlowExecutor flowExecutor; /** - * 测试chain自定义线程池隔离 + * 测试WEHN上condition线程池和chain线程池隔离-优先以WHEN上为准 */ @Test - public void testCustomChainThreadPool1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); - DefaultContext context = response.getFirstContextBean(); - Assertions.assertTrue(response.isSuccess()); - Assertions.assertTrue(context.getData("threadNameFor").toString().startsWith("customer-chain-thead-1")); - Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead-1")); + public void testCustomChainThreadPool() { + LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response1.getFirstContextBean(); + Assertions.assertTrue(response1.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-thead")); } /** - * 测试when上自定义线程池和chain线程池隔离-优先以when上为准 + * 测试FOR上condition线程池和chain线程池隔离-优先以FOR上为准 */ @Test public void testCustomChainThreadPool2() { LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response1.getFirstContextBean(); Assertions.assertTrue(response1.isSuccess()); - Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead-2")); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead")); } /** - * 测试并行FOR循环全局线程池和chain线程池隔离-优先以chain线程池上为准 + * 测试WHILE上condition线程池和chain线程池隔离-优先以WHILE上为准 */ @Test public void testCustomChainThreadPool3() { LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response1.getFirstContextBean(); Assertions.assertTrue(response1.isSuccess()); - Assertions.assertTrue(context.getData("threadNameFor").toString().startsWith("customer-chain-thead-1")); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead")); } /** - * 测试并行条件循环全局线程池和chain线程池隔离-优先以chain线程池上为准 + * 测试ITERATOR上condition线程池和chain线程池隔离-优先以ITERATOR上为准 */ @Test public void testCustomChainThreadPool4() { - LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", "arg"); - DefaultContext context = response1.getFirstContextBean(); - Assertions.assertTrue(response1.isSuccess()); - Assertions.assertTrue(context.getData("threadNameWhile").toString().startsWith("customer-chain-thead-1")); - } - - /** - * 测试并行迭代循环全局线程池和chain线程池隔离-优先以chain线程池上为准 - */ - @Test - public void testCustomChainThreadPool5() { List list = ListUtil.toList("1", "2", "3", "4", "5"); - LiteflowResponse response1 = flowExecutor.execute2Resp("chain5", list); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list); DefaultContext context = response1.getFirstContextBean(); Assertions.assertTrue(response1.isSuccess()); - Assertions.assertTrue(context.getData("threadNameIterator").toString().startsWith("customer-chain-thead-1")); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead")); } - } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomThreadExecutor2.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomWhenThreadExecutor.java similarity index 70% rename from liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomThreadExecutor2.java rename to liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomWhenThreadExecutor.java index 4527fbd16..d0571543f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomThreadExecutor2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomWhenThreadExecutor.java @@ -7,7 +7,7 @@ import com.yomahub.liteflow.thread.ExecutorBuilder; import java.util.concurrent.ExecutorService; -public class CustomThreadExecutor2 implements ExecutorBuilder { +public class CustomWhenThreadExecutor implements ExecutorBuilder { @Override public ExecutorService buildExecutor() { @@ -16,8 +16,8 @@ public class CustomThreadExecutor2 implements ExecutorBuilder { if (ObjectUtil.isNull(liteflowConfig)) { liteflowConfig = new LiteflowConfig(); } - return buildDefaultExecutor(liteflowConfig.getChainMaxWorkers(), liteflowConfig.getChainMaxWorkers(), - liteflowConfig.getChainQueueLimit(), "customer-chain-thead-2"); + return buildDefaultExecutor(16, 16, + 512, "customer-when-thead"); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/DefaultChainThreadPoolELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/DefaultChainThreadPoolELSpringbootTest.java deleted file mode 100644 index 5c31217aa..000000000 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/DefaultChainThreadPoolELSpringbootTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.yomahub.liteflow.test.chainThreadPool; - -import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.slot.DefaultContext; -import com.yomahub.liteflow.test.BaseTest; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.test.context.TestPropertySource; - -import javax.annotation.Resource; - -/** - * springboot环境下chain线程池隔离测试 - */ -@TestPropertySource(value = "classpath:/chainThreadPool/application.properties") -@SpringBootTest(classes = DefaultChainThreadPoolELSpringbootTest.class) -@EnableAutoConfiguration -@ComponentScan({"com.yomahub.liteflow.test.chainThreadPool.cmp"}) -public class DefaultChainThreadPoolELSpringbootTest extends BaseTest { - - private final Logger log = LoggerFactory.getLogger(this.getClass()); - - @Resource - private FlowExecutor flowExecutor; - - /** - * 测试chain默认线程池隔离 - */ - @Test - public void testDefaultChainThreadPool() { - LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); - DefaultContext context = response.getFirstContextBean(); - Assertions.assertTrue(response.isSuccess()); - Assertions.assertTrue(context.getData("threadNameFor").toString().startsWith("chain-thread-")); - Assertions.assertTrue(context.getData("threadName").toString().startsWith("chain-thread-")); - - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/GlobalThreadPoolELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/GlobalThreadPoolELSpringbootTest.java new file mode 100644 index 000000000..f307c0496 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/GlobalThreadPoolELSpringbootTest.java @@ -0,0 +1,79 @@ +package com.yomahub.liteflow.test.chainThreadPool; + +import cn.hutool.core.collection.ListUtil; +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; +import com.yomahub.liteflow.test.BaseTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +import javax.annotation.Resource; +import java.util.List; + +/** + * springboot环境下chain线程池隔离测试 + */ +@TestPropertySource(value = "classpath:/chainThreadPool/application.properties") +@SpringBootTest(classes = GlobalThreadPoolELSpringbootTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.chainThreadPool.cmp"}) +public class GlobalThreadPoolELSpringbootTest extends BaseTest { + + private final Logger log = LoggerFactory.getLogger(this.getClass()); + + @Resource + private FlowExecutor flowExecutor; + + /** + * 测试WHEN上全局线程池和chain线程池隔离-优先以chain上为准 + */ + @Test + public void testGlobalChainThreadPool() { + LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response1.getFirstContextBean(); + Assertions.assertTrue(response1.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead")); + } + + /** + * 测试FOR上全局线程池和chain线程池隔离-优先以chain上为准 + */ + @Test + public void testGlobalChainThreadPool2() { + LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg"); + DefaultContext context = response1.getFirstContextBean(); + Assertions.assertTrue(response1.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead")); + } + + /** + * 测试WHILE上全局线程池和chain线程池隔离-优先以chain上为准 + */ + @Test + public void testGlobalChainThreadPool3() { + LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg"); + DefaultContext context = response1.getFirstContextBean(); + Assertions.assertTrue(response1.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead")); + } + + /** + * 测试ITERATOR上全局线程池和chain线程池隔离-优先以chain上为准 + */ + @Test + public void testGlobalChainThreadPool4() { + List list = ListUtil.toList("1", "2", "3", "4", "5"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list); + DefaultContext context = response1.getFirstContextBean(); + Assertions.assertTrue(response1.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead")); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/FCmp.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/FCmp.java index 3e48aac9f..0905db127 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/FCmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/FCmp.java @@ -18,7 +18,7 @@ public class FCmp extends NodeComponent { @Override public void process() { DefaultContext context = this.getFirstContextBean(); - context.setData("threadNameFor", Thread.currentThread().getName()); + context.setData("threadName", Thread.currentThread().getName()); System.out.println("FCmp executed!"); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ICmp.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ICmp.java index 25424c581..3caaabda6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ICmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ICmp.java @@ -18,7 +18,7 @@ public class ICmp extends NodeComponent { @Override public void process() { DefaultContext context = this.getFirstContextBean(); - context.setData("threadNameIterator", Thread.currentThread().getName()); + context.setData("threadName", Thread.currentThread().getName()); System.out.println("ICmp executed!"); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/WCmp.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/WCmp.java index 8c394ddb5..bbe890509 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/WCmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/WCmp.java @@ -18,7 +18,7 @@ public class WCmp extends NodeComponent { @Override public void process() { DefaultContext context = this.getFirstContextBean(); - context.setData("threadNameWhile", Thread.currentThread().getName()); + context.setData("threadName", Thread.currentThread().getName()); System.out.println("WCmp executed!"); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/application.properties b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/application.properties index 587e96142..aad6bd9de 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/application.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/application.properties @@ -1,4 +1 @@ liteflow.rule-source=chainThreadPool/flow.el.xml -liteflow.chain-thread-pool-isolate=true -liteflow.chain-max-workers=10 -liteflow.chain-queue-limit=1024 diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/application2.properties b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/application2.properties index 7a2dc1480..ecac47dd6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/application2.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/application2.properties @@ -1,5 +1,2 @@ liteflow.rule-source=chainThreadPool/flow2.el.xml -liteflow.chain-thread-pool-isolate=true -liteflow.chain-max-workers=10 -liteflow.chain-queue-limit=1024 -liteflow.chain-thread-executor-class=com.yomahub.liteflow.test.chainThreadPool.CustomThreadExecutor1 +liteflow.when-thread-pool-isolate=true diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/flow.el.xml index f15a3b45f..da5f247c5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/flow.el.xml @@ -1,9 +1,24 @@ - - FOR(5).parallel(true).DO(THEN(f,WHEN( - THEN(a,b) - )) + + WHEN(a,b); + + + + FOR(5).parallel(true).DO(THEN(a,f + ) ); + + + WHILE(z).parallel(true).DO(THEN(w,d)); + + + + ITERATOR(it).parallel(true).DO(THEN(a,i)); + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/flow2.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/flow2.el.xml index c8a40aaaf..4b280ba91 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/flow2.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/chainThreadPool/flow2.el.xml @@ -1,27 +1,24 @@ - - FOR(5).parallel(true).DO(THEN(f,WHEN( - THEN(a,b) - )) - ); + + WHEN(a,b).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomWhenThreadExecutor"); - - WHEN(a, b).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomThreadExecutor2"); - - - + FOR(5).parallel(true).DO(THEN(a,f ) ); - + WHILE(z).parallel(true).DO(THEN(w,d)); - + ITERATOR(it).parallel(true).DO(THEN(a,i)); \ No newline at end of file