enhancement #I7F567 增加对业务自定义requestId传入的支持
This commit is contained in:
parent
3a9eadc60c
commit
8b52655c6b
|
@ -7,10 +7,10 @@ import com.yomahub.liteflow.enums.NodeTypeEnum;
|
|||
import com.yomahub.liteflow.exception.NodeBuildException;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.element.Node;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.monitor.MonitorFile;
|
||||
import com.yomahub.liteflow.spi.holder.PathContentParserHolder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -18,7 +18,7 @@ import java.util.Objects;
|
|||
|
||||
public class LiteFlowNodeBuilder {
|
||||
|
||||
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
|
||||
private final LFLog LOG = LFLoggerManager.getLogger(this.getClass());
|
||||
|
||||
private final Node node;
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ import com.yomahub.liteflow.flow.FlowBus;
|
|||
import com.yomahub.liteflow.flow.element.Chain;
|
||||
import com.yomahub.liteflow.flow.element.Node;
|
||||
import com.yomahub.liteflow.flow.element.Condition;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -32,7 +32,7 @@ import java.util.Objects;
|
|||
*/
|
||||
public class LiteFlowChainELBuilder {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LiteFlowChainELBuilder.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(LiteFlowChainELBuilder.class);
|
||||
|
||||
private Chain chain;
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ import com.yomahub.liteflow.flow.LiteflowResponse;
|
|||
import com.yomahub.liteflow.flow.element.Chain;
|
||||
import com.yomahub.liteflow.flow.element.Node;
|
||||
import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.monitor.MonitorFile;
|
||||
import com.yomahub.liteflow.parser.base.FlowParser;
|
||||
import com.yomahub.liteflow.parser.factory.FlowParserProvider;
|
||||
|
@ -30,8 +32,6 @@ import com.yomahub.liteflow.slot.Slot;
|
|||
import com.yomahub.liteflow.spi.holder.ContextCmpInitHolder;
|
||||
import com.yomahub.liteflow.spi.holder.PathContentParserHolder;
|
||||
import com.yomahub.liteflow.thread.ExecutorHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Future;
|
||||
|
@ -43,7 +43,7 @@ import java.util.concurrent.Future;
|
|||
*/
|
||||
public class FlowExecutor {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FlowExecutor.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(FlowExecutor.class);
|
||||
|
||||
private static final String PREFIX_FORMAT_CONFIG_REGEX = "xml:|json:|yml:|el_xml:|el_json:|el_yml:";
|
||||
|
||||
|
@ -264,24 +264,44 @@ public class FlowExecutor {
|
|||
|
||||
// 调用一个流程并返回LiteflowResponse,允许多上下文的传入
|
||||
public LiteflowResponse execute2Resp(String chainId, Object param, Class<?>... contextBeanClazzArray) {
|
||||
return this.execute2Resp(chainId, param, contextBeanClazzArray, null);
|
||||
return this.execute2Resp(chainId, param, null, contextBeanClazzArray, null);
|
||||
}
|
||||
|
||||
public LiteflowResponse execute2Resp(String chainId, Object param, Object... contextBeanArray) {
|
||||
return this.execute2Resp(chainId, param, null, contextBeanArray);
|
||||
return this.execute2Resp(chainId, param, null, null, contextBeanArray);
|
||||
}
|
||||
|
||||
public LiteflowResponse execute2RespWithRid(String chainId, Object param, String requestId, Class<?>... contextBeanClazzArray) {
|
||||
return this.execute2Resp(chainId, param, requestId, contextBeanClazzArray, null);
|
||||
}
|
||||
|
||||
public LiteflowResponse execute2RespWithRid(String chainId, Object param, String requestId, Object... contextBeanArray) {
|
||||
return this.execute2Resp(chainId, param, requestId, null, contextBeanArray);
|
||||
}
|
||||
|
||||
// 调用一个流程并返回Future<LiteflowResponse>,允许多上下文的传入
|
||||
public Future<LiteflowResponse> execute2Future(String chainId, Object param, Class<?>... contextBeanClazzArray) {
|
||||
return ExecutorHelper.loadInstance()
|
||||
.buildMainExecutor(liteflowConfig.getMainExecutorClass())
|
||||
.submit(() -> FlowExecutorHolder.loadInstance().execute2Resp(chainId, param, contextBeanClazzArray, null));
|
||||
.submit(() -> FlowExecutorHolder.loadInstance().execute2Resp(chainId, param, contextBeanClazzArray));
|
||||
}
|
||||
|
||||
public Future<LiteflowResponse> execute2Future(String chainId, Object param, Object... contextBeanArray) {
|
||||
return ExecutorHelper.loadInstance()
|
||||
.buildMainExecutor(liteflowConfig.getMainExecutorClass())
|
||||
.submit(() -> FlowExecutorHolder.loadInstance().execute2Resp(chainId, param, null, contextBeanArray));
|
||||
.submit(() -> FlowExecutorHolder.loadInstance().execute2Resp(chainId, param, contextBeanArray));
|
||||
}
|
||||
|
||||
public Future<LiteflowResponse> execute2FutureWithRid(String chainId, Object param, String requestId, Class<?>... contextBeanClazzArray) {
|
||||
return ExecutorHelper.loadInstance()
|
||||
.buildMainExecutor(liteflowConfig.getMainExecutorClass())
|
||||
.submit(() -> FlowExecutorHolder.loadInstance().execute2RespWithRid(chainId, param, requestId, contextBeanClazzArray));
|
||||
}
|
||||
|
||||
public Future<LiteflowResponse> execute2FutureWithRid(String chainId, Object param, String requestId, Object... contextBeanArray) {
|
||||
return ExecutorHelper.loadInstance()
|
||||
.buildMainExecutor(liteflowConfig.getMainExecutorClass())
|
||||
.submit(() -> FlowExecutorHolder.loadInstance().execute2RespWithRid(chainId, param, requestId, contextBeanArray));
|
||||
}
|
||||
|
||||
// 调用一个流程,返回默认的上下文,适用于简单的调用
|
||||
|
@ -296,19 +316,19 @@ public class FlowExecutor {
|
|||
}
|
||||
}
|
||||
|
||||
private LiteflowResponse execute2Resp(String chainId, Object param, Class<?>[] contextBeanClazzArray,
|
||||
private LiteflowResponse execute2Resp(String chainId, Object param, String requestId, Class<?>[] contextBeanClazzArray,
|
||||
Object[] contextBeanArray) {
|
||||
Slot slot = doExecute(chainId, param, contextBeanClazzArray, contextBeanArray, null, InnerChainTypeEnum.NONE);
|
||||
Slot slot = doExecute(chainId, param, requestId, contextBeanClazzArray, contextBeanArray, null, InnerChainTypeEnum.NONE);
|
||||
return LiteflowResponse.newMainResponse(slot);
|
||||
}
|
||||
|
||||
private LiteflowResponse invoke2Resp(String chainId, Object param, Integer slotIndex,
|
||||
InnerChainTypeEnum innerChainType) {
|
||||
Slot slot = doExecute(chainId, param, null, null, slotIndex, innerChainType);
|
||||
Slot slot = doExecute(chainId, param, null, null, null, slotIndex, innerChainType);
|
||||
return LiteflowResponse.newInnerResponse(chainId, slot);
|
||||
}
|
||||
|
||||
private Slot doExecute(String chainId, Object param, Class<?>[] contextBeanClazzArray, Object[] contextBeanArray,
|
||||
private Slot doExecute(String chainId, Object param, String requestId, Class<?>[] contextBeanClazzArray, Object[] contextBeanArray,
|
||||
Integer slotIndex, InnerChainTypeEnum innerChainType) {
|
||||
if (FlowBus.needInit()) {
|
||||
init(true);
|
||||
|
@ -345,11 +365,14 @@ public class FlowExecutor {
|
|||
slot.addSubChain(chainId);
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(slot.getRequestId())) {
|
||||
//如果传入了用户的RequestId,则用这个请求Id,如果没传入,则进行生成
|
||||
if (StrUtil.isNotBlank(requestId)){
|
||||
slot.putRequestId(requestId);
|
||||
LFLoggerManager.setRequestId(requestId);
|
||||
}else if(StrUtil.isBlank(slot.getRequestId())){
|
||||
slot.generateRequestId();
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
|
||||
LOG.info("requestId[{}] has generated", slot.getRequestId());
|
||||
}
|
||||
LFLoggerManager.setRequestId(slot.getRequestId());
|
||||
LOG.info("requestId has generated");
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotNull(param)) {
|
||||
|
@ -369,8 +392,7 @@ public class FlowExecutor {
|
|||
chain = FlowBus.getChain(chainId);
|
||||
|
||||
if (ObjectUtil.isNull(chain)) {
|
||||
String errorMsg = StrUtil.format("[{}]:couldn't find chain with the id[{}]", slot.getRequestId(),
|
||||
chainId);
|
||||
String errorMsg = StrUtil.format("couldn't find chain with the id[{}]", chainId);
|
||||
throw new ChainNotFoundException(errorMsg);
|
||||
}
|
||||
// 执行chain
|
||||
|
@ -378,15 +400,13 @@ public class FlowExecutor {
|
|||
}
|
||||
catch (ChainEndException e) {
|
||||
if (ObjectUtil.isNotNull(chain)) {
|
||||
String warnMsg = StrUtil.format("[{}]:chain[{}] execute end on slot[{}]", slot.getRequestId(),
|
||||
chain.getChainName(), slotIndex);
|
||||
String warnMsg = StrUtil.format("chain[{}] execute end on slot[{}]", chain.getChainId(), slotIndex);
|
||||
LOG.warn(warnMsg);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (ObjectUtil.isNotNull(chain)) {
|
||||
String errMsg = StrUtil.format("[{}]:chain[{}] execute error on slot[{}]", slot.getRequestId(),
|
||||
chain.getChainName(), slotIndex);
|
||||
String errMsg = StrUtil.format("chain[{}] execute error on slot[{}]", chain.getChainId(), slotIndex);
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
|
||||
LOG.error(errMsg, e);
|
||||
}
|
||||
|
@ -416,6 +436,7 @@ public class FlowExecutor {
|
|||
if (innerChainType.equals(InnerChainTypeEnum.NONE)) {
|
||||
slot.printStep();
|
||||
DataBus.releaseSlot(slotIndex);
|
||||
LFLoggerManager.removeRequestId();
|
||||
}
|
||||
}
|
||||
return slot;
|
||||
|
|
|
@ -16,6 +16,8 @@ import com.yomahub.liteflow.flow.element.Node;
|
|||
import com.yomahub.liteflow.flow.executor.NodeExecutor;
|
||||
import com.yomahub.liteflow.flow.executor.DefaultNodeExecutor;
|
||||
import com.yomahub.liteflow.enums.NodeTypeEnum;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.spi.holder.CmpAroundAspectHolder;
|
||||
import com.yomahub.liteflow.util.JsonUtil;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -37,7 +39,7 @@ import java.util.Map;
|
|||
*/
|
||||
public abstract class NodeComponent {
|
||||
|
||||
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
|
||||
private final LFLog LOG = LFLoggerManager.getLogger(this.getClass());
|
||||
|
||||
private MonitorBus monitorBus;
|
||||
|
||||
|
@ -113,8 +115,7 @@ public abstract class NodeComponent {
|
|||
self.onError();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
String errMsg = StrUtil.format("[{}]:component[{}] onError method happens exception",
|
||||
slot.getRequestId(), this.getDisplayName());
|
||||
String errMsg = StrUtil.format("component[{}] onError method happens exception", this.getDisplayName());
|
||||
LOG.error(errMsg);
|
||||
}
|
||||
throw e;
|
||||
|
@ -125,8 +126,7 @@ public abstract class NodeComponent {
|
|||
|
||||
stopWatch.stop();
|
||||
final long timeSpent = stopWatch.getTotalTimeMillis();
|
||||
LOG.debug("[{}]:component[{}] finished in {} milliseconds", slot.getRequestId(), this.getDisplayName(),
|
||||
timeSpent);
|
||||
LOG.debug("component[{}] finished in {} milliseconds", this.getDisplayName(), timeSpent);
|
||||
|
||||
// 往CmpStep中放入时间消耗信息
|
||||
cmpStep.setTimeSpent(timeSpent);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.yomahub.liteflow.core;
|
||||
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.script.ScriptExecuteWrap;
|
||||
import com.yomahub.liteflow.script.ScriptExecutorFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -15,7 +17,7 @@ import java.util.Map;
|
|||
*/
|
||||
public class ScriptCommonComponent extends NodeComponent implements ScriptComponent {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
private final LFLog LOG = LFLoggerManager.getLogger(this.getClass());
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
|
@ -25,7 +27,7 @@ public class ScriptCommonComponent extends NodeComponent implements ScriptCompon
|
|||
|
||||
@Override
|
||||
public void loadScript(String script, String language) {
|
||||
log.info("load script for component[{}]", getDisplayName());
|
||||
LOG.info("load script for component[{}]", getDisplayName());
|
||||
ScriptExecutorFactory.loadInstance().getScriptExecutor(language).load(getNodeId(), script);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,13 +13,13 @@ import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
|
|||
import com.yomahub.liteflow.enums.NodeTypeEnum;
|
||||
import com.yomahub.liteflow.exception.ComponentMethodDefineErrorException;
|
||||
import com.yomahub.liteflow.exception.LiteFlowException;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.util.LiteFlowProxyUtil;
|
||||
import com.yomahub.liteflow.util.SerialsUtil;
|
||||
import net.bytebuddy.ByteBuddy;
|
||||
import net.bytebuddy.implementation.InvocationHandlerAdapter;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
|
@ -40,7 +40,7 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public class ComponentProxy {
|
||||
|
||||
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
|
||||
private final LFLog LOG = LFLoggerManager.getLogger(this.getClass());
|
||||
|
||||
private final String nodeId;
|
||||
|
||||
|
|
|
@ -5,15 +5,13 @@ import cn.hutool.core.util.StrUtil;
|
|||
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
|
||||
import com.yomahub.liteflow.annotation.LiteflowMethod;
|
||||
import com.yomahub.liteflow.core.*;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.util.LiteFlowProxyUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* 节点类型枚举
|
||||
|
@ -49,7 +47,7 @@ public enum NodeTypeEnum {
|
|||
|
||||
BREAK_SCRIPT("break_script", "循环跳出脚本", true, ScriptBreakComponent.class);
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(NodeTypeEnum.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(NodeTypeEnum.class);
|
||||
|
||||
private String code;
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ import com.yomahub.liteflow.exception.ComponentCannotRegisterException;
|
|||
import com.yomahub.liteflow.exception.NullNodeTypeException;
|
||||
import com.yomahub.liteflow.flow.element.Chain;
|
||||
import com.yomahub.liteflow.flow.element.Node;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.parser.el.LocalJsonFlowELParser;
|
||||
import com.yomahub.liteflow.parser.el.LocalXmlFlowELParser;
|
||||
import com.yomahub.liteflow.parser.el.LocalYmlFlowELParser;
|
||||
|
@ -29,9 +31,6 @@ import com.yomahub.liteflow.spi.holder.ContextAwareHolder;
|
|||
import com.yomahub.liteflow.spi.local.LocalContextAware;
|
||||
import com.yomahub.liteflow.util.CopyOnWriteHashMap;
|
||||
import com.yomahub.liteflow.util.LiteFlowProxyUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -45,7 +44,7 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public class FlowBus {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FlowBus.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(FlowBus.class);
|
||||
|
||||
private static final Map<String, Chain> chainMap = new CopyOnWriteHashMap<>();
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@ package com.yomahub.liteflow.flow.element;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.yomahub.liteflow.exception.ChainEndException;
|
||||
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.ExecuteTypeEnum;
|
||||
import com.yomahub.liteflow.exception.FlowSystemException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -26,7 +26,7 @@ import java.util.List;
|
|||
*/
|
||||
public class Chain implements Executable{
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Chain.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(Chain.class);
|
||||
|
||||
private String chainId;
|
||||
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
*/
|
||||
package com.yomahub.liteflow.flow.element;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.slot.DataBus;
|
||||
|
@ -24,8 +25,6 @@ import com.yomahub.liteflow.enums.ExecuteTypeEnum;
|
|||
import com.yomahub.liteflow.enums.NodeTypeEnum;
|
||||
import com.yomahub.liteflow.exception.ChainEndException;
|
||||
import com.yomahub.liteflow.exception.FlowSystemException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Node节点,实现可执行器 Node节点并不是单例的,每构建一次都会copy出一个新的实例
|
||||
|
@ -34,7 +33,7 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class Node implements Executable, Cloneable{
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Node.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(Node.class);
|
||||
|
||||
private String id;
|
||||
|
||||
|
@ -136,7 +135,7 @@ public class Node implements Executable, Cloneable{
|
|||
if (instance.isAccess()) {
|
||||
// 根据配置判断是否打印执行中的日志
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
|
||||
LOG.info("[{}]:[O]start component[{}] execution", slot.getRequestId(), instance.getDisplayName());
|
||||
LOG.info("[O]start component[{}] execution", instance.getDisplayName());
|
||||
}
|
||||
|
||||
// 这里开始进行重试的逻辑和主逻辑的运行
|
||||
|
@ -147,13 +146,12 @@ public class Node implements Executable, Cloneable{
|
|||
}
|
||||
else {
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
|
||||
LOG.info("[{}]:[X]skip component[{}] execution", slot.getRequestId(), instance.getDisplayName());
|
||||
LOG.info("[X]skip component[{}] execution", instance.getDisplayName());
|
||||
}
|
||||
}
|
||||
// 如果组件覆盖了isEnd方法,或者在在逻辑中主要调用了setEnd(true)的话,流程就会立马结束
|
||||
if (instance.isEnd()) {
|
||||
String errorInfo = StrUtil.format("[{}]:[{}] lead the chain to end", slot.getRequestId(),
|
||||
instance.getDisplayName());
|
||||
String errorInfo = StrUtil.format("[{}] lead the chain to end", instance.getDisplayName());
|
||||
throw new ChainEndException(errorInfo);
|
||||
}
|
||||
}
|
||||
|
@ -163,13 +161,11 @@ public class Node implements Executable, Cloneable{
|
|||
catch (Exception e) {
|
||||
// 如果组件覆盖了isContinueOnError方法,返回为true,那即便出了异常,也会继续流程
|
||||
if (instance.isContinueOnError()) {
|
||||
String errorMsg = MessageFormat.format("[{0}]:component[{1}] cause error,but flow is still go on",
|
||||
slot.getRequestId(), id);
|
||||
String errorMsg = StrUtil.format("component[{}] cause error,but flow is still go on", id);
|
||||
LOG.error(errorMsg);
|
||||
}
|
||||
else {
|
||||
String errorMsg = MessageFormat.format("[{0}]:component[{1}] cause error,error:{2}",
|
||||
slot.getRequestId(), id, e.getMessage());
|
||||
String errorMsg = StrUtil.format("component[{}] cause error,error:{}", id, e.getMessage());
|
||||
LOG.error(errorMsg);
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -16,13 +16,13 @@ import com.yomahub.liteflow.flow.element.Condition;
|
|||
import com.yomahub.liteflow.flow.parallel.CompletableFutureTimeout;
|
||||
import com.yomahub.liteflow.flow.parallel.ParallelSupplier;
|
||||
import com.yomahub.liteflow.flow.parallel.WhenFutureObj;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.slot.DataBus;
|
||||
import com.yomahub.liteflow.slot.Slot;
|
||||
import com.yomahub.liteflow.thread.ExecutorHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -37,7 +37,7 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public class WhenCondition extends Condition {
|
||||
|
||||
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
|
||||
private final LFLog LOG = LFLoggerManager.getLogger(this.getClass());
|
||||
|
||||
// 只在when类型下有效,以区分当when调用链调用失败时是否继续往下执行 默认false不继续执行
|
||||
private boolean ignoreError = false;
|
||||
|
@ -167,8 +167,7 @@ public class WhenCondition extends Condition {
|
|||
|
||||
// 输出超时信息
|
||||
timeOutWhenFutureObjList.forEach(whenFutureObj -> LOG.warn(
|
||||
"requestId [{}] executing thread has reached max-wait-seconds, thread canceled.Execute-item: [{}]",
|
||||
slot.getRequestId(), whenFutureObj.getExecutorName()));
|
||||
"executing thread has reached max-wait-seconds, thread canceled.Execute-item: [{}]", whenFutureObj.getExecutorName()));
|
||||
|
||||
// 当配置了ignoreError = false,出现interrupted或者!f.get()的情况,将抛出WhenExecuteException
|
||||
if (!this.isIgnoreError()) {
|
||||
|
@ -180,15 +179,13 @@ public class WhenCondition extends Condition {
|
|||
// 循环判断CompletableFuture的返回值,如果异步执行失败,则抛出相应的业务异常
|
||||
for (WhenFutureObj whenFutureObj : allCompletableWhenFutureObjList) {
|
||||
if (!whenFutureObj.isSuccess()) {
|
||||
LOG.info(StrUtil.format("requestId [{}] when-executor[{}] execute failed. errorResume [false].",
|
||||
slot.getRequestId(), whenFutureObj.getExecutorName()));
|
||||
LOG.info(StrUtil.format("when-executor[{}] execute failed. errorResume [false].", whenFutureObj.getExecutorName()));
|
||||
throw whenFutureObj.getEx();
|
||||
}
|
||||
}
|
||||
} else if (interrupted[0]) {
|
||||
// 这里由于配置了ignoreError,所以只打印warn日志
|
||||
LOG.warn("requestId [{}] executing when condition timeout , but ignore with errorResume.",
|
||||
slot.getRequestId());
|
||||
LOG.warn("executing when condition timeout , but ignore with errorResume.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package com.yomahub.liteflow.flow.executor;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
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.exception.ChainEndException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -18,7 +17,7 @@ import java.util.List;
|
|||
*/
|
||||
public abstract class NodeExecutor {
|
||||
|
||||
protected final Logger LOG = LoggerFactory.getLogger(this.getClass());
|
||||
protected final LFLog LOG = LFLoggerManager.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* 执行器执行入口-若需要更大维度的执行方式可以重写该方法
|
||||
|
@ -58,8 +57,7 @@ public abstract class NodeExecutor {
|
|||
*/
|
||||
protected void retry(NodeComponent instance, int currentRetryCount) throws Exception {
|
||||
Slot slot = DataBus.getSlot(instance.getSlotIndex());
|
||||
LOG.info("[{}]:component[{}] performs {} retry", slot.getRequestId(), instance.getDisplayName(),
|
||||
currentRetryCount + 1);
|
||||
LOG.info("component[{}] performs {} retry", instance.getDisplayName(), currentRetryCount + 1);
|
||||
// 执行业务逻辑的主要入口
|
||||
instance.execute();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.yomahub.liteflow.flow.parallel;
|
||||
|
||||
import com.yomahub.liteflow.flow.element.Executable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ import java.util.function.Supplier;
|
|||
*/
|
||||
public class ParallelSupplier implements Supplier<WhenFutureObj> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ParallelSupplier.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(ParallelSupplier.class);
|
||||
|
||||
private final Executable executableItem;
|
||||
|
||||
|
|
|
@ -0,0 +1,397 @@
|
|||
package com.yomahub.liteflow.log;
|
||||
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.Marker;
|
||||
|
||||
/**
|
||||
* 日志包装类
|
||||
* @since 2.10.5
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
public class LFLog implements Logger{
|
||||
|
||||
private Logger log;
|
||||
|
||||
private LiteflowConfig liteflowConfig;
|
||||
|
||||
public LFLog(Logger log) {
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
private String getRId(){
|
||||
String requestId = LFLoggerManager.getRequestId();
|
||||
if (StrUtil.isBlank(requestId)){
|
||||
return StrUtil.EMPTY;
|
||||
}else{
|
||||
return StrUtil.format("[{}]:", LFLoggerManager.getRequestId());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPrint(){
|
||||
try{
|
||||
if (ObjectUtil.isNull(liteflowConfig)){
|
||||
liteflowConfig = LiteflowConfigGetter.get();
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNull(liteflowConfig)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return liteflowConfig.getPrintExecutionLog();
|
||||
}catch (Exception e){
|
||||
//这里如果出错,肯定是在启动阶段,但是判断日志是不是应该打印,不应该报错,所以不处理错误
|
||||
//返回错误依旧打印
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.log.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTraceEnabled() {
|
||||
return this.log.isTraceEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String s) {
|
||||
this.log.trace(getRId() + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String s, Object o) {
|
||||
this.log.trace(getRId() + s, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String s, Object o, Object o1) {
|
||||
this.log.trace(getRId() + s, o, o1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String s, Object... objects) {
|
||||
this.log.trace(getRId() + s, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String s, Throwable throwable) {
|
||||
this.log.trace(getRId() + s, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTraceEnabled(Marker marker) {
|
||||
return this.log.isTraceEnabled(marker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Marker marker, String s) {
|
||||
this.log.trace(marker, getRId() + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Marker marker, String s, Object o) {
|
||||
this.log.trace(marker, getRId() + s, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Marker marker, String s, Object o, Object o1) {
|
||||
this.log.trace(marker, getRId() + s, o, o1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Marker marker, String s, Object... objects) {
|
||||
this.log.trace(marker, getRId() + s, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Marker marker, String s, Throwable throwable) {
|
||||
this.log.trace(marker, getRId() + s, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugEnabled() {
|
||||
return this.log.isDebugEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String s) {
|
||||
this.log.debug(getRId() + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String s, Object o) {
|
||||
this.log.debug(getRId() + s, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String s, Object o, Object o1) {
|
||||
this.log.debug(getRId() + s, o, o1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String s, Object... objects) {
|
||||
this.log.debug(getRId() + s, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String s, Throwable throwable) {
|
||||
this.log.debug(getRId() + s, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugEnabled(Marker marker) {
|
||||
return this.log.isDebugEnabled(marker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Marker marker, String s) {
|
||||
this.log.debug(marker, getRId() + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Marker marker, String s, Object o) {
|
||||
this.log.debug(marker, getRId() + s, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Marker marker, String s, Object o, Object o1) {
|
||||
this.log.debug(marker, getRId() + s, o, o1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Marker marker, String s, Object... objects) {
|
||||
this.log.debug(marker, getRId() + s, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Marker marker, String s, Throwable throwable) {
|
||||
this.log.debug(marker, getRId() + s, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInfoEnabled() {
|
||||
return this.log.isInfoEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String s) {
|
||||
if (isPrint()) {
|
||||
this.log.info(getRId() + s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String s, Object o) {
|
||||
if (isPrint()) {
|
||||
this.log.info(getRId() + s, o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String s, Object o, Object o1) {
|
||||
if (isPrint()) {
|
||||
this.log.info(getRId() + s, o, o1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String s, Object... objects) {
|
||||
if (isPrint()) {
|
||||
this.log.info(getRId() + s, objects);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String s, Throwable throwable) {
|
||||
if (isPrint()) {
|
||||
this.log.info(getRId() + s, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInfoEnabled(Marker marker) {
|
||||
return this.log.isInfoEnabled(marker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Marker marker, String s) {
|
||||
if (isPrint()) {
|
||||
this.log.info(marker, getRId() + s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Marker marker, String s, Object o) {
|
||||
if (isPrint()) {
|
||||
this.log.info(marker, getRId() + s, o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Marker marker, String s, Object o, Object o1) {
|
||||
if (isPrint()) {
|
||||
this.log.info(marker, getRId() + s, o, o1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Marker marker, String s, Object... objects) {
|
||||
if (isPrint()) {
|
||||
this.log.info(marker, getRId() + s , objects);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Marker marker, String s, Throwable throwable) {
|
||||
if (isPrint()) {
|
||||
this.log.info(marker, getRId() + s ,throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWarnEnabled() {
|
||||
return this.log.isWarnEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String s) {
|
||||
if (isPrint()) {
|
||||
this.log.warn(getRId() + s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String s, Object o) {
|
||||
if (isPrint()) {
|
||||
this.log.warn(getRId() + s, o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String s, Object... objects) {
|
||||
if (isPrint()) {
|
||||
this.log.warn(getRId() + s, objects);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String s, Object o, Object o1) {
|
||||
if (isPrint()) {
|
||||
this.log.warn(getRId() + s, o, o1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String s, Throwable throwable) {
|
||||
if (isPrint()) {
|
||||
this.log.warn(getRId() + s, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWarnEnabled(Marker marker) {
|
||||
return this.log.isWarnEnabled(marker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Marker marker, String s) {
|
||||
if (isPrint()) {
|
||||
this.log.warn(marker, getRId() + s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Marker marker, String s, Object o) {
|
||||
if (isPrint()) {
|
||||
this.log.warn(marker, getRId() + s, o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Marker marker, String s, Object o, Object o1) {
|
||||
if (isPrint()) {
|
||||
this.log.warn(marker, getRId() + s, o, o1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Marker marker, String s, Object... objects) {
|
||||
if (isPrint()) {
|
||||
this.log.warn(marker, getRId() + s, objects);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Marker marker, String s, Throwable throwable) {
|
||||
if (isPrint()) {
|
||||
this.log.warn(marker, getRId() + s, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isErrorEnabled() {
|
||||
return this.log.isErrorEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String s) {
|
||||
this.log.error(getRId() + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String s, Object o) {
|
||||
this.log.error(getRId() + s, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String s, Object o, Object o1) {
|
||||
this.log.error(getRId() + s, o, o1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String s, Object... objects) {
|
||||
this.log.error(getRId() + s, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String s, Throwable throwable) {
|
||||
this.log.error(getRId() + s, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isErrorEnabled(Marker marker) {
|
||||
return this.log.isErrorEnabled(marker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Marker marker, String s) {
|
||||
this.log.error(marker, getRId() + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Marker marker, String s, Object o) {
|
||||
this.log.error(marker, getRId() + s, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Marker marker, String s, Object o, Object o1) {
|
||||
this.log.error(marker, getRId() + s, o, o1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Marker marker, String s, Object... objects) {
|
||||
this.log.error(marker, getRId() + s, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Marker marker, String s, Throwable throwable) {
|
||||
this.log.error(marker, getRId() + s, throwable);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.yomahub.liteflow.log;
|
||||
|
||||
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 日志包装工厂
|
||||
* @since 2.10.5
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
public class LFLoggerManager {
|
||||
|
||||
private static final Map<String, LFLog> logMap = new HashMap<>();
|
||||
|
||||
private static final TransmittableThreadLocal<String> requestIdTL = new TransmittableThreadLocal<>();
|
||||
|
||||
public static LFLog getLogger(Class<?> clazz){
|
||||
if (logMap.containsKey(clazz.getName())){
|
||||
return logMap.get(clazz.getName());
|
||||
}else{
|
||||
Logger log = LoggerFactory.getLogger(clazz.getName());
|
||||
LFLog lfLog = new LFLog(log);
|
||||
logMap.put(clazz.getName(), lfLog);
|
||||
return lfLog;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setRequestId(String requestId){
|
||||
requestIdTL.set(requestId);
|
||||
}
|
||||
|
||||
public static String getRequestId(){
|
||||
return requestIdTL.get();
|
||||
}
|
||||
|
||||
public static void removeRequestId(){
|
||||
requestIdTL.remove();
|
||||
}
|
||||
}
|
|
@ -8,11 +8,11 @@
|
|||
package com.yomahub.liteflow.monitor;
|
||||
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.slot.DataBus;
|
||||
import com.yomahub.liteflow.util.BoundedPriorityBlockingQueue;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
@ -33,7 +33,7 @@ public class MonitorBus {
|
|||
|
||||
private LiteflowConfig liteflowConfig;
|
||||
|
||||
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
|
||||
private final LFLog LOG = LFLoggerManager.getLogger(this.getClass());
|
||||
|
||||
private final ConcurrentHashMap<String, BoundedPriorityBlockingQueue<CompStatistics>> statisticsMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
|
|
@ -1,31 +1,18 @@
|
|||
package com.yomahub.liteflow.monitor;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.watch.SimpleWatcher;
|
||||
import cn.hutool.core.io.watch.WatchMonitor;
|
||||
import cn.hutool.core.io.watch.watchers.DelayWatcher;
|
||||
import cn.hutool.core.lang.Singleton;
|
||||
import com.yomahub.liteflow.core.FlowExecutorHolder;
|
||||
import org.apache.commons.io.filefilter.FileFilterUtils;
|
||||
import org.apache.commons.io.filefilter.HiddenFileFilter;
|
||||
import org.apache.commons.io.filefilter.IOFileFilter;
|
||||
import org.apache.commons.io.monitor.FileAlterationListener;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
|
||||
import org.apache.commons.io.monitor.FileAlterationMonitor;
|
||||
import org.apache.commons.io.monitor.FileAlterationObserver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.WatchEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 规则文件监听器
|
||||
|
@ -34,7 +21,7 @@ import java.util.function.Consumer;
|
|||
*/
|
||||
public class MonitorFile {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
private final LFLog LOG = LFLoggerManager.getLogger(this.getClass());
|
||||
|
||||
private final Set<String> PATH_SET = new HashSet<>();
|
||||
|
||||
|
@ -75,13 +62,13 @@ public class MonitorFile {
|
|||
observer.addListener(new FileAlterationListenerAdaptor() {
|
||||
@Override
|
||||
public void onFileChange(File file) {
|
||||
logger.info("file modify,filePath={}", file.getAbsolutePath());
|
||||
LOG.info("file modify,filePath={}", file.getAbsolutePath());
|
||||
FlowExecutorHolder.loadInstance().reloadRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileDelete(File file) {
|
||||
logger.info("file delete,filePath={}", file.getAbsolutePath());
|
||||
LOG.info("file delete,filePath={}", file.getAbsolutePath());
|
||||
FlowExecutorHolder.loadInstance().reloadRule();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -4,12 +4,12 @@ import cn.hutool.core.util.ReUtil;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.exception.ErrorSupportPathException;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.parser.base.FlowParser;
|
||||
import com.yomahub.liteflow.parser.el.ClassJsonFlowELParser;
|
||||
import com.yomahub.liteflow.parser.el.ClassXmlFlowELParser;
|
||||
import com.yomahub.liteflow.parser.el.ClassYmlFlowELParser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -33,7 +33,7 @@ import static com.yomahub.liteflow.parser.factory.FlowParserProvider.ConfigRegex
|
|||
*/
|
||||
public class FlowParserProvider {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FlowExecutor.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(FlowExecutor.class);
|
||||
|
||||
private static final FlowParserFactory LOCAL_PARSER_FACTORY = new LocalParserFactory();
|
||||
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package com.yomahub.liteflow.script.jsr223;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.exception.LiteFlowException;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.script.ScriptExecuteWrap;
|
||||
import com.yomahub.liteflow.script.ScriptExecutor;
|
||||
import com.yomahub.liteflow.script.exception.ScriptLoadException;
|
||||
import com.yomahub.liteflow.util.CopyOnWriteHashMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import javax.script.*;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -20,7 +18,7 @@ import java.util.Map;
|
|||
*/
|
||||
public abstract class JSR223ScriptExecutor extends ScriptExecutor {
|
||||
|
||||
protected final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
protected final LFLog LOG = LFLoggerManager.getLogger(this.getClass());
|
||||
|
||||
private ScriptEngine scriptEngine;
|
||||
|
||||
|
|
|
@ -4,14 +4,14 @@ import cn.hutool.core.collection.ListUtil;
|
|||
import cn.hutool.core.util.*;
|
||||
import com.yomahub.liteflow.exception.LiteFlowException;
|
||||
import com.yomahub.liteflow.exception.ScriptBeanMethodInvokeException;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.script.annotation.ScriptBean;
|
||||
import com.yomahub.liteflow.util.LiteFlowProxyUtil;
|
||||
import com.yomahub.liteflow.util.SerialsUtil;
|
||||
import net.bytebuddy.ByteBuddy;
|
||||
import net.bytebuddy.implementation.InvocationHandlerAdapter;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
|
@ -20,7 +20,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class ScriptBeanProxy {
|
||||
|
||||
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
|
||||
private final LFLog LOG = LFLoggerManager.getLogger(this.getClass());
|
||||
|
||||
private final Object bean;
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ import cn.hutool.core.map.MapUtil;
|
|||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -31,7 +31,7 @@ import java.util.stream.IntStream;
|
|||
*/
|
||||
public class DataBus {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DataBus.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(DataBus.class);
|
||||
|
||||
public static AtomicInteger OCCUPY_COUNT = new AtomicInteger(0);
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class DataBus {
|
|||
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
|
||||
if (ObjectUtil.isNotNull(SLOTS.get(slotIndex))) {
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
|
||||
LOG.info("[{}]:slot[{}] released", SLOTS.get(slotIndex).getRequestId(), slotIndex);
|
||||
LOG.info("slot[{}] released", slotIndex);
|
||||
}
|
||||
SLOTS.remove(slotIndex);
|
||||
QUEUE.add(slotIndex);
|
||||
|
|
|
@ -15,11 +15,9 @@ import com.yomahub.liteflow.exception.NoSuchContextBeanException;
|
|||
import com.yomahub.liteflow.exception.NullParamException;
|
||||
import com.yomahub.liteflow.flow.entity.CmpStep;
|
||||
import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Deque;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -39,7 +37,7 @@ import java.util.function.Consumer;
|
|||
@SuppressWarnings("unchecked")
|
||||
public class Slot {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Slot.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(Slot.class);
|
||||
|
||||
private static final String REQUEST = "_request";
|
||||
|
||||
|
@ -344,7 +342,7 @@ public class Slot {
|
|||
this.executeStepsStr = getExecuteStepStr(true);
|
||||
}
|
||||
if (LiteflowConfigGetter.get().getPrintExecutionLog()) {
|
||||
LOG.info("[{}]:CHAIN_NAME[{}]\n{}", getRequestId(), this.getChainName(), this.executeStepsStr);
|
||||
LOG.info("CHAIN_NAME[{}]\n{}", this.getChainName(), this.executeStepsStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -352,6 +350,10 @@ public class Slot {
|
|||
metaDataMap.put(REQUEST_ID, IdGeneratorHolder.getInstance().generate());
|
||||
}
|
||||
|
||||
public void putRequestId(String requestId){
|
||||
metaDataMap.put(REQUEST_ID, requestId);
|
||||
}
|
||||
|
||||
public String getRequestId() {
|
||||
return (String) metaDataMap.get(REQUEST_ID);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import cn.hutool.core.map.MapUtil;
|
|||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.exception.ThreadExecutorServiceCreateException;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.ContextAwareHolder;
|
||||
|
@ -28,7 +30,7 @@ import java.util.concurrent.*;
|
|||
*/
|
||||
public class ExecutorHelper {
|
||||
|
||||
private final Logger LOG = LoggerFactory.getLogger(ExecutorHelper.class);
|
||||
private final LFLog LOG = LFLoggerManager.getLogger(ExecutorHelper.class);
|
||||
|
||||
/**
|
||||
* 此处使用Map缓存线程池信息 key - 线程池构建者的Class全类名 value - 线程池对象
|
||||
|
|
|
@ -3,19 +3,12 @@ package com.yomahub.liteflow.util;
|
|||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.yomahub.liteflow.exception.JsonProcessException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
|
@ -25,7 +18,7 @@ import java.util.TimeZone;
|
|||
*/
|
||||
public class JsonUtil {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JsonUtil.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(JsonUtil.class);
|
||||
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.yomahub.liteflow.util;
|
||||
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -12,7 +14,7 @@ import java.util.Optional;
|
|||
*/
|
||||
public class LOGOPrinter {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LOGOPrinter.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(LOGOPrinter.class);
|
||||
|
||||
/**
|
||||
* LiteFlow 当前版本号
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.yomahub.liteflow.util;
|
||||
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.spi.holder.ContextAwareHolder;
|
||||
import com.yomahub.liteflow.thread.ExecutorHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
@ -15,7 +15,7 @@ import java.util.concurrent.ExecutorService;
|
|||
*/
|
||||
public class LiteFlowExecutorPoolShutdown {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LiteFlowExecutorPoolShutdown.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(LiteFlowExecutorPoolShutdown.class);
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() throws Exception {
|
||||
|
|
|
@ -7,8 +7,8 @@ import com.yomahub.liteflow.core.proxy.ComponentProxy;
|
|||
import com.yomahub.liteflow.enums.NodeTypeEnum;
|
||||
import com.yomahub.liteflow.exception.ComponentProxyErrorException;
|
||||
import com.yomahub.liteflow.exception.LiteFlowException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -21,7 +21,7 @@ import java.util.List;
|
|||
*/
|
||||
public class LiteFlowProxyUtil {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LiteFlowProxyUtil.class);
|
||||
private static final LFLog LOG = LFLoggerManager.getLogger(LiteFlowProxyUtil.class);
|
||||
|
||||
/**
|
||||
* 判断一个bean是否是声明式组件
|
||||
|
|
|
@ -108,4 +108,11 @@ public class LoopELSpringbootTest extends BaseTest {
|
|||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("001101201", str);
|
||||
}
|
||||
|
||||
//FOR循环同一个组件,下标获取不到问题的测试
|
||||
@Test
|
||||
public void testLoop9() throws Exception {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain9", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ public class CCmp extends NodeComponent {
|
|||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println(this.getLoopIndex());
|
||||
System.out.println("CCmp executed!");
|
||||
}
|
||||
|
||||
|
|
|
@ -48,4 +48,8 @@
|
|||
)
|
||||
);
|
||||
</chain>
|
||||
|
||||
<chain name="chain9">
|
||||
FOR(2).DO(THEN(c, c, c));
|
||||
</chain>
|
||||
</flow>
|
2
pom.xml
2
pom.xml
|
@ -39,7 +39,7 @@
|
|||
</scm>
|
||||
|
||||
<properties>
|
||||
<revision>2.10.5-BETA1</revision>
|
||||
<revision>2.10.5</revision>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
|
Loading…
Reference in New Issue