mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 04:02:09 +08:00
feature #I7YYLE 添加组件降级启动配置
This commit is contained in:
@@ -10,6 +10,7 @@ import com.ql.util.express.exception.QLException;
|
||||
import com.yomahub.liteflow.builder.el.operator.base.BaseOperator;
|
||||
import com.yomahub.liteflow.builder.el.operator.base.OperatorHelper;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.exception.ELParseException;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.element.FallbackNodeProxy;
|
||||
import com.yomahub.liteflow.flow.element.Node;
|
||||
@@ -26,7 +27,13 @@ public class NodeOperator extends BaseOperator<Node> {
|
||||
|
||||
@Override
|
||||
public Node build(Object[] objects) throws Exception {
|
||||
|
||||
// 检查是否开启了组件降级功能
|
||||
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
|
||||
Boolean enable = liteflowConfig.getFallbackCmpEnable();
|
||||
if (!enable) {
|
||||
throw new ELParseException("The fallback component is disabled");
|
||||
}
|
||||
|
||||
OperatorHelper.checkObjectSizeEqOne(objects);
|
||||
String nodeId = OperatorHelper.convert(objects[0], String.class);
|
||||
|
||||
|
||||
@@ -97,9 +97,6 @@ public class LiteflowConfig {
|
||||
// 是否打印执行中的日志
|
||||
private Boolean printExecutionLog;
|
||||
|
||||
// 替补组件class路径
|
||||
private String substituteCmpClass;
|
||||
|
||||
// 规则文件/脚本文件变更监听
|
||||
private Boolean enableMonitorFile = Boolean.FALSE;
|
||||
|
||||
@@ -111,6 +108,9 @@ public class LiteflowConfig {
|
||||
|
||||
//使用默认并行循环线程池时,最大队列数
|
||||
private Integer parallelQueueLimit;
|
||||
|
||||
// 是否启用组件降级
|
||||
private Boolean fallbackCmpEnable;
|
||||
|
||||
public Boolean getEnableMonitorFile() {
|
||||
return enableMonitorFile;
|
||||
@@ -373,14 +373,6 @@ public class LiteflowConfig {
|
||||
this.printExecutionLog = printExecutionLog;
|
||||
}
|
||||
|
||||
public String getSubstituteCmpClass() {
|
||||
return substituteCmpClass;
|
||||
}
|
||||
|
||||
public void setSubstituteCmpClass(String substituteCmpClass) {
|
||||
this.substituteCmpClass = substituteCmpClass;
|
||||
}
|
||||
|
||||
public String getRuleSourceExtData() {
|
||||
return ruleSourceExtData;
|
||||
}
|
||||
@@ -454,4 +446,16 @@ public class LiteflowConfig {
|
||||
public void setParallelLoopExecutorClass(String parallelLoopExecutorClass) {
|
||||
this.parallelLoopExecutorClass = parallelLoopExecutorClass;
|
||||
}
|
||||
|
||||
public Boolean getFallbackCmpEnable() {
|
||||
if (ObjectUtil.isNull(this.fallbackCmpEnable)) {
|
||||
return false;
|
||||
} else {
|
||||
return fallbackCmpEnable;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFallbackCmpEnable(Boolean fallbackCmpEnable) {
|
||||
this.fallbackCmpEnable = fallbackCmpEnable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,10 +46,10 @@ public class LiteflowAutoConfiguration {
|
||||
liteflowConfig.setMainExecutorWorks(property.getMainExecutorWorks());
|
||||
liteflowConfig.setMainExecutorClass(property.getMainExecutorClass());
|
||||
liteflowConfig.setPrintExecutionLog(property.isPrintExecutionLog());
|
||||
liteflowConfig.setSubstituteCmpClass(property.getSubstituteCmpClass());
|
||||
liteflowConfig.setParallelMaxWorkers(property.getParallelMaxWorkers());
|
||||
liteflowConfig.setParallelQueueLimit(property.getParallelQueueLimit());
|
||||
liteflowConfig.setParallelLoopExecutorClass(property.getParallelLoopExecutorClass());
|
||||
liteflowConfig.setFallbackCmpEnable(property.isFallbackCmpEnable());
|
||||
return liteflowConfig;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,9 +67,6 @@ public class LiteflowProperty {
|
||||
// 是否打印执行过程中的日志
|
||||
private boolean printExecutionLog;
|
||||
|
||||
// 替补组件的class路径
|
||||
private String substituteCmpClass;
|
||||
|
||||
//并行循环线程池类路径
|
||||
private String parallelLoopExecutorClass;
|
||||
|
||||
@@ -78,6 +75,9 @@ public class LiteflowProperty {
|
||||
|
||||
//使用默认并行循环线程池时,最大队列数
|
||||
private Integer parallelQueueLimit;
|
||||
|
||||
// 是否启用组件降级
|
||||
private Boolean fallbackCmpEnable;
|
||||
|
||||
public boolean isEnable() {
|
||||
return enable;
|
||||
@@ -212,14 +212,6 @@ public class LiteflowProperty {
|
||||
this.requestIdGeneratorClass = requestIdGeneratorClass;
|
||||
}
|
||||
|
||||
public String getSubstituteCmpClass() {
|
||||
return substituteCmpClass;
|
||||
}
|
||||
|
||||
public void setSubstituteCmpClass(String substituteCmpClass) {
|
||||
this.substituteCmpClass = substituteCmpClass;
|
||||
}
|
||||
|
||||
public String getRuleSourceExtData() {
|
||||
return ruleSourceExtData;
|
||||
}
|
||||
@@ -251,4 +243,12 @@ public class LiteflowProperty {
|
||||
public void setParallelQueueLimit(Integer parallelQueueLimit) {
|
||||
this.parallelQueueLimit = parallelQueueLimit;
|
||||
}
|
||||
|
||||
public Boolean isFallbackCmpEnable() {
|
||||
return fallbackCmpEnable;
|
||||
}
|
||||
|
||||
public void setFallbackCmpEnable(Boolean fallbackCmpEnable) {
|
||||
this.fallbackCmpEnable = fallbackCmpEnable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,9 +74,6 @@ public class LiteflowProperty {
|
||||
// 是否打印执行过程中的日志
|
||||
private boolean printExecutionLog;
|
||||
|
||||
// 替补组件的class路径
|
||||
private String substituteCmpClass;
|
||||
|
||||
// 规则文件/脚本文件变更监听
|
||||
private Boolean enableMonitorFile;
|
||||
|
||||
@@ -87,6 +84,9 @@ public class LiteflowProperty {
|
||||
|
||||
//使用默认并行循环线程池时,最大队列数
|
||||
private Integer parallelQueueLimit;
|
||||
|
||||
// 是否启用组件降级
|
||||
private Boolean fallbackCmpEnable;
|
||||
|
||||
public Boolean getEnableMonitorFile() {
|
||||
return enableMonitorFile;
|
||||
@@ -226,14 +226,6 @@ public class LiteflowProperty {
|
||||
this.requestIdGeneratorClass = requestIdGeneratorClass;
|
||||
}
|
||||
|
||||
public String getSubstituteCmpClass() {
|
||||
return substituteCmpClass;
|
||||
}
|
||||
|
||||
public void setSubstituteCmpClass(String substituteCmpClass) {
|
||||
this.substituteCmpClass = substituteCmpClass;
|
||||
}
|
||||
|
||||
public String getRuleSourceExtData() {
|
||||
return ruleSourceExtData;
|
||||
}
|
||||
@@ -289,4 +281,12 @@ public class LiteflowProperty {
|
||||
public void setParallelQueueLimit(Integer parallelQueueLimit) {
|
||||
this.parallelQueueLimit = parallelQueueLimit;
|
||||
}
|
||||
|
||||
public Boolean isFallbackCmpEnable() {
|
||||
return fallbackCmpEnable;
|
||||
}
|
||||
|
||||
public void setFallbackCmpEnable(Boolean fallbackCmpEnable) {
|
||||
this.fallbackCmpEnable = fallbackCmpEnable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,11 +46,11 @@ public class LiteflowPropertyAutoConfiguration {
|
||||
liteflowConfig.setMainExecutorWorks(property.getMainExecutorWorks());
|
||||
liteflowConfig.setMainExecutorClass(property.getMainExecutorClass());
|
||||
liteflowConfig.setPrintExecutionLog(property.isPrintExecutionLog());
|
||||
liteflowConfig.setSubstituteCmpClass(property.getSubstituteCmpClass());
|
||||
liteflowConfig.setEnableMonitorFile(property.getEnableMonitorFile());
|
||||
liteflowConfig.setParallelMaxWorkers(property.getParallelMaxWorkers());
|
||||
liteflowConfig.setParallelQueueLimit(property.getParallelQueueLimit());
|
||||
liteflowConfig.setParallelLoopExecutorClass(property.getParallelLoopExecutorClass());
|
||||
liteflowConfig.setFallbackCmpEnable(property.isFallbackCmpEnable());
|
||||
return liteflowConfig;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,13 +138,6 @@
|
||||
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "liteflow.substitute-cmp-class",
|
||||
"type": "java.lang.String",
|
||||
"description": "substitute component class.",
|
||||
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
|
||||
"defaultValue": ""
|
||||
},
|
||||
{
|
||||
"name": "liteflow.monitor.enable-log",
|
||||
"type": "java.lang.Boolean",
|
||||
@@ -200,6 +193,13 @@
|
||||
"description": "Custom thread pool implement for parallel-loop executor.",
|
||||
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
|
||||
"defaultValue": "com.yomahub.liteflow.thread.LiteFlowDefaultParallelLoopExecutorBuilder"
|
||||
},
|
||||
{
|
||||
"name": "liteflow.fallback-cmp-enable",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable fallback component.",
|
||||
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
|
||||
"defaultValue": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
liteflow.rule-source=fallback/flow.el.xml
|
||||
liteflow.rule-source=fallback/flow.el.xml
|
||||
liteflow.fallback-cmp-enable=true
|
||||
Reference in New Issue
Block a user