mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
增加requestId追踪
This commit is contained in:
@@ -97,6 +97,7 @@ public class FlowExecutor {
|
|||||||
|
|
||||||
if(StringUtils.isBlank(slot.getRequestId())) {
|
if(StringUtils.isBlank(slot.getRequestId())) {
|
||||||
slot.generateRequestId();
|
slot.generateRequestId();
|
||||||
|
LOG.info("requestId[{}] has generated",slot.getRequestId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isInnerChain) {
|
if(!isInnerChain) {
|
||||||
@@ -120,13 +121,13 @@ public class FlowExecutor {
|
|||||||
if(component.isAccess()){
|
if(component.isAccess()){
|
||||||
component.execute();
|
component.execute();
|
||||||
if(component.isEnd()) {
|
if(component.isEnd()) {
|
||||||
LOG.info("component[{}] lead the chain to end",component.getClass().getSimpleName());
|
LOG.info("[{}]:component[{}] lead the chain to end",slot.getRequestId(),component.getClass().getSimpleName());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(Throwable t){
|
}catch(Throwable t){
|
||||||
if(component.isContinueOnError()){
|
if(component.isContinueOnError()){
|
||||||
LOG.error("component[{}] cause error,but flow is still go on",t,component.getClass().getSimpleName());
|
LOG.error("[{}]:component[{}] cause error,but flow is still go on",t,slot.getRequestId(),component.getClass().getSimpleName());
|
||||||
}else{
|
}else{
|
||||||
throw t;
|
throw t;
|
||||||
}
|
}
|
||||||
@@ -142,7 +143,7 @@ public class FlowExecutor {
|
|||||||
}
|
}
|
||||||
return (T)slot;
|
return (T)slot;
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
LOG.error("executor cause error",e);
|
LOG.error("[{}]:executor cause error",e,slot.getRequestId());
|
||||||
throw new FlowSystemException("executor cause error");
|
throw new FlowSystemException("executor cause error");
|
||||||
}finally{
|
}finally{
|
||||||
if(!isInnerChain) {
|
if(!isInnerChain) {
|
||||||
|
|||||||
@@ -32,8 +32,9 @@ public abstract class NodeComponent {
|
|||||||
private String nodeId;
|
private String nodeId;
|
||||||
|
|
||||||
public void execute() throws Exception{
|
public void execute() throws Exception{
|
||||||
LOG.info("start component[{}] execution",this.getClass().getSimpleName());
|
Slot slot = this.getSlot();
|
||||||
this.getSlot().addStep(new CmpStep(nodeId, CmpStepType.START));
|
LOG.info("[{}]:start component[{}] execution",slot.getRequestId(),this.getClass().getSimpleName());
|
||||||
|
slot.addStep(new CmpStep(nodeId, CmpStepType.START));
|
||||||
StopWatch stopWatch = new StopWatch();
|
StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
long initm=Runtime.getRuntime().freeMemory();
|
long initm=Runtime.getRuntime().freeMemory();
|
||||||
@@ -43,7 +44,7 @@ public abstract class NodeComponent {
|
|||||||
long timeSpent = stopWatch.getTime();
|
long timeSpent = stopWatch.getTime();
|
||||||
long endm=Runtime.getRuntime().freeMemory();
|
long endm=Runtime.getRuntime().freeMemory();
|
||||||
|
|
||||||
this.getSlot().addStep(new CmpStep(nodeId, CmpStepType.END));
|
slot.addStep(new CmpStep(nodeId, CmpStepType.END));
|
||||||
|
|
||||||
//性能统计
|
//性能统计
|
||||||
CompStatistics statistics = new CompStatistics();
|
CompStatistics statistics = new CompStatistics();
|
||||||
@@ -54,7 +55,7 @@ public abstract class NodeComponent {
|
|||||||
|
|
||||||
|
|
||||||
if(this instanceof NodeCondComponent){
|
if(this instanceof NodeCondComponent){
|
||||||
String condNodeId = this.getSlot().getCondResult(this.getClass().getName());
|
String condNodeId = slot.getCondResult(this.getClass().getName());
|
||||||
if(StringUtils.isNotBlank(condNodeId)){
|
if(StringUtils.isNotBlank(condNodeId)){
|
||||||
Node thisNode = FlowParser.getNode(nodeId);
|
Node thisNode = FlowParser.getNode(nodeId);
|
||||||
Node condNode = thisNode.getCondNode(condNodeId);
|
Node condNode = thisNode.getCondNode(condNodeId);
|
||||||
@@ -66,7 +67,7 @@ public abstract class NodeComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("componnet[{}] finished in {} milliseconds",this.getClass().getSimpleName(),timeSpent);
|
LOG.debug("[{}]:componnet[{}] finished in {} milliseconds",slot.getRequestId(),this.getClass().getSimpleName(),timeSpent);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void process() throws Exception;
|
protected abstract void process() throws Exception;
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ public class DataBus {
|
|||||||
|
|
||||||
public static void releaseSlot(int slotIndex){
|
public static void releaseSlot(int slotIndex){
|
||||||
if(slots[slotIndex] != null){
|
if(slots[slotIndex] != null){
|
||||||
|
LOG.info("[{}]:slot[{}] released",slots[slotIndex].getRequestId(),slotIndex);
|
||||||
slots[slotIndex] = null;
|
slots[slotIndex] = null;
|
||||||
OCCUPY_COUNT.decrementAndGet();
|
OCCUPY_COUNT.decrementAndGet();
|
||||||
LOG.info("slot[{}] released",slotIndex);
|
|
||||||
}else{
|
}else{
|
||||||
LOG.warn("slot[{}] already has been released",slotIndex);
|
LOG.warn("slot[{}] already has been released",slotIndex);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user