mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-17 05:20:42 +08:00
@@ -18,6 +18,7 @@ import com.yomahub.liteflow.enums.NodeTypeEnum;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.CmpAroundAspectHolder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -303,4 +304,12 @@ public abstract class NodeComponent{
|
||||
public String getChainName(){
|
||||
return getSlot().getChainName();
|
||||
}
|
||||
|
||||
public String getDisplayName(){
|
||||
if(StringUtils.isEmpty(this.name)){
|
||||
return this.nodeId;
|
||||
}else {
|
||||
return this.nodeId + "(" + this.name + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ScriptComponent extends NodeComponent{
|
||||
}
|
||||
|
||||
public void loadScript(String script) {
|
||||
log.info("load script for component[{}]", getNodeId());
|
||||
log.info("load script for component[{}][{}]", getNodeId(),getDisplayName());
|
||||
ScriptExecutorFactory.loadInstance().getScriptExecutor().load(getNodeId(), script);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ 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.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -156,7 +157,7 @@ public class FlowBus {
|
||||
|
||||
nodeMap.put(nodeId, node);
|
||||
} catch (Exception e) {
|
||||
String error = StrUtil.format("component[{}] register error", cmpClazz.getName());
|
||||
String error = StrUtil.format("component[{}][{}] register error", cmpClazz.getName(), StringUtils.isEmpty(name)?nodeId:nodeId+"("+name+")");
|
||||
LOG.error(error, e);
|
||||
throw new ComponentCannotRegisterException(error);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class Node implements Executable,Cloneable{
|
||||
if (instance.isAccess()) {
|
||||
//根据配置判断是否打印执行中的日志
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())){
|
||||
LOG.info("[{}]:[O]start component[{}] [{}] execution",slot.getRequestId(),instance.getClass().getSimpleName(),instance.getName());
|
||||
LOG.info("[{}]:[O]start component[{}][{}] execution",slot.getRequestId(),instance.getClass().getSimpleName(),instance.getDisplayName());
|
||||
}
|
||||
|
||||
//这里开始进行重试的逻辑和主逻辑的运行
|
||||
@@ -135,12 +135,12 @@ public class Node implements Executable,Cloneable{
|
||||
nodeExecutor.execute(instance);
|
||||
//如果组件覆盖了isEnd方法,或者在在逻辑中主要调用了setEnd(true)的话,流程就会立马结束
|
||||
if (instance.isEnd()) {
|
||||
String errorInfo = StrUtil.format("[{}]:component[{}] lead the chain to end", slot.getRequestId(), instance.getClass().getSimpleName());
|
||||
String errorInfo = StrUtil.format("[{}]:[{}] lead the chain to end", slot.getRequestId(), instance.getClass().getSimpleName(),instance.getDisplayName());
|
||||
throw new ChainEndException(errorInfo);
|
||||
}
|
||||
} else {
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())){
|
||||
LOG.info("[{}]:[X]skip component[{}] execution", slot.getRequestId(), instance.getClass().getSimpleName());
|
||||
LOG.info("[{}]:[X]skip component[{}][{}] execution", slot.getRequestId(), instance.getClass().getSimpleName(),instance.getDisplayName());
|
||||
}
|
||||
}
|
||||
} catch (ChainEndException e){
|
||||
|
||||
@@ -50,7 +50,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.getNodeId(), currentRetryCount + 1);
|
||||
LOG.info("[{}]:component[{}][{}] performs {} retry", slot.getRequestId(), instance.getNodeId(),instance.getDisplayName(), currentRetryCount + 1);
|
||||
//执行业务逻辑的主要入口
|
||||
instance.execute();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user