mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
优化LFLog日志的相关代码
This commit is contained in:
@@ -343,13 +343,10 @@ public class FlowExecutor {
|
||||
else {
|
||||
slotIndex = DataBus.offerSlotByBean(ListUtil.toList(contextBeanArray));
|
||||
}
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
|
||||
LOG.info("slot[{}] offered", slotIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (slotIndex == -1) {
|
||||
throw new NoAvailableSlotException("there is no available slot");
|
||||
if (slotIndex == -1) {
|
||||
throw new NoAvailableSlotException("there is no available slot");
|
||||
}
|
||||
}
|
||||
|
||||
Slot slot = DataBus.getSlot(slotIndex);
|
||||
@@ -357,14 +354,6 @@ public class FlowExecutor {
|
||||
throw new NoAvailableSlotException(StrUtil.format("the slot[{}] is not exist", slotIndex));
|
||||
}
|
||||
|
||||
// 如果是隐式流程,事先把subException给置空,然后把隐式流程的chainId放入slot元数据中
|
||||
// 我知道这在多线程调用隐式流程中会有问题。但是考虑到这种场景的不会多,也有其他的转换方式。
|
||||
// 所以暂且这么做,以后再优化
|
||||
if (!innerChainType.equals(InnerChainTypeEnum.NONE)) {
|
||||
slot.removeSubException(chainId);
|
||||
slot.addSubChain(chainId);
|
||||
}
|
||||
|
||||
//如果传入了用户的RequestId,则用这个请求Id,如果没传入,则进行生成
|
||||
if (StrUtil.isNotBlank(requestId)){
|
||||
slot.putRequestId(requestId);
|
||||
@@ -375,6 +364,19 @@ public class FlowExecutor {
|
||||
LOG.info("requestId has generated");
|
||||
}
|
||||
|
||||
if (innerChainType.equals(InnerChainTypeEnum.NONE)) {
|
||||
LOG.info("slot[{}] offered", slotIndex);
|
||||
}
|
||||
|
||||
// 如果是隐式流程,事先把subException给置空,然后把隐式流程的chainId放入slot元数据中
|
||||
// 我知道这在多线程调用隐式流程中会有问题。但是考虑到这种场景的不会多,也有其他的转换方式。
|
||||
// 所以暂且这么做,以后再优化
|
||||
if (!innerChainType.equals(InnerChainTypeEnum.NONE)) {
|
||||
slot.removeSubException(chainId);
|
||||
slot.addSubChain(chainId);
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNotNull(param)) {
|
||||
if (innerChainType.equals(InnerChainTypeEnum.NONE)) {
|
||||
slot.setRequestData(param);
|
||||
|
||||
@@ -133,10 +133,7 @@ public class Node implements Executable, Cloneable{
|
||||
|
||||
// 判断是否可执行,所以isAccess经常作为一个组件进入的实际判断要素,用作检查slot里的参数的完备性
|
||||
if (instance.isAccess()) {
|
||||
// 根据配置判断是否打印执行中的日志
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
|
||||
LOG.info("[O]start component[{}] execution", instance.getDisplayName());
|
||||
}
|
||||
LOG.info("[O]start component[{}] execution", instance.getDisplayName());
|
||||
|
||||
// 这里开始进行重试的逻辑和主逻辑的运行
|
||||
NodeExecutor nodeExecutor = NodeExecutorHelper.loadInstance()
|
||||
@@ -145,9 +142,7 @@ public class Node implements Executable, Cloneable{
|
||||
nodeExecutor.execute(instance);
|
||||
}
|
||||
else {
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
|
||||
LOG.info("[X]skip component[{}] execution", instance.getDisplayName());
|
||||
}
|
||||
LOG.info("[X]skip component[{}] execution", instance.getDisplayName());
|
||||
}
|
||||
// 如果组件覆盖了isEnd方法,或者在在逻辑中主要调用了setEnd(true)的话,流程就会立马结束
|
||||
if (instance.isEnd()) {
|
||||
|
||||
@@ -342,27 +342,38 @@ public class LFLog implements Logger{
|
||||
|
||||
@Override
|
||||
public void error(String s) {
|
||||
this.log.error(getRId() + s);
|
||||
if (isPrint()) {
|
||||
this.log.error(getRId() + s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String s, Object o) {
|
||||
this.log.error(getRId() + s, o);
|
||||
if (isPrint()) {
|
||||
this.log.error(getRId() + s, o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String s, Object o, Object o1) {
|
||||
this.log.error(getRId() + s, o, o1);
|
||||
if (isPrint()) {
|
||||
this.log.error(getRId() + s, o, o1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String s, Object... objects) {
|
||||
this.log.error(getRId() + s, objects);
|
||||
if (isPrint()) {
|
||||
this.log.error(getRId() + s, objects);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String s, Throwable throwable) {
|
||||
this.log.error(getRId() + s, throwable);
|
||||
if (isPrint()) {
|
||||
this.log.error(getRId() + s, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -372,26 +383,36 @@ public class LFLog implements Logger{
|
||||
|
||||
@Override
|
||||
public void error(Marker marker, String s) {
|
||||
this.log.error(marker, getRId() + s);
|
||||
if (isPrint()) {
|
||||
this.log.error(marker, getRId() + s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Marker marker, String s, Object o) {
|
||||
this.log.error(marker, getRId() + s, o);
|
||||
if (isPrint()) {
|
||||
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);
|
||||
if (isPrint()) {
|
||||
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);
|
||||
if (isPrint()) {
|
||||
this.log.error(marker, getRId() + s, objects);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Marker marker, String s, Throwable throwable) {
|
||||
this.log.error(marker, getRId() + s, throwable);
|
||||
if (isPrint()) {
|
||||
this.log.error(marker, getRId() + s, throwable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,9 +136,7 @@ public class DataBus {
|
||||
public static void releaseSlot(int slotIndex) {
|
||||
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
|
||||
if (ObjectUtil.isNotNull(SLOTS.get(slotIndex))) {
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
|
||||
LOG.info("slot[{}] released", slotIndex);
|
||||
}
|
||||
LOG.info("slot[{}] released", slotIndex);
|
||||
SLOTS.remove(slotIndex);
|
||||
QUEUE.add(slotIndex);
|
||||
OCCUPY_COUNT.decrementAndGet();
|
||||
|
||||
Reference in New Issue
Block a user