增加requestId追踪

This commit is contained in:
bryan.zhang
2018-01-10 15:26:14 +08:00
parent 958a1dc7a5
commit 42257ed691
3 changed files with 11 additions and 9 deletions

View File

@@ -97,6 +97,7 @@ public class FlowExecutor {
if(StringUtils.isBlank(slot.getRequestId())) {
slot.generateRequestId();
LOG.info("requestId[{}] has generated",slot.getRequestId());
}
if(!isInnerChain) {
@@ -120,13 +121,13 @@ public class FlowExecutor {
if(component.isAccess()){
component.execute();
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;
}
}
}catch(Throwable t){
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{
throw t;
}
@@ -142,7 +143,7 @@ public class FlowExecutor {
}
return (T)slot;
}catch(Exception e){
LOG.error("executor cause error",e);
LOG.error("[{}]:executor cause error",e,slot.getRequestId());
throw new FlowSystemException("executor cause error");
}finally{
if(!isInnerChain) {

View File

@@ -32,8 +32,9 @@ public abstract class NodeComponent {
private String nodeId;
public void execute() throws Exception{
LOG.info("start component[{}] execution",this.getClass().getSimpleName());
this.getSlot().addStep(new CmpStep(nodeId, CmpStepType.START));
Slot slot = this.getSlot();
LOG.info("[{}]:start component[{}] execution",slot.getRequestId(),this.getClass().getSimpleName());
slot.addStep(new CmpStep(nodeId, CmpStepType.START));
StopWatch stopWatch = new StopWatch();
stopWatch.start();
long initm=Runtime.getRuntime().freeMemory();
@@ -43,7 +44,7 @@ public abstract class NodeComponent {
long timeSpent = stopWatch.getTime();
long endm=Runtime.getRuntime().freeMemory();
this.getSlot().addStep(new CmpStep(nodeId, CmpStepType.END));
slot.addStep(new CmpStep(nodeId, CmpStepType.END));
//性能统计
CompStatistics statistics = new CompStatistics();
@@ -54,7 +55,7 @@ public abstract class NodeComponent {
if(this instanceof NodeCondComponent){
String condNodeId = this.getSlot().getCondResult(this.getClass().getName());
String condNodeId = slot.getCondResult(this.getClass().getName());
if(StringUtils.isNotBlank(condNodeId)){
Node thisNode = FlowParser.getNode(nodeId);
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;

View File

@@ -47,9 +47,9 @@ public class DataBus {
public static void releaseSlot(int slotIndex){
if(slots[slotIndex] != null){
LOG.info("[{}]:slot[{}] released",slots[slotIndex].getRequestId(),slotIndex);
slots[slotIndex] = null;
OCCUPY_COUNT.decrementAndGet();
LOG.info("slot[{}] released",slotIndex);
}else{
LOG.warn("slot[{}] already has been released",slotIndex);
}