From 42257ed6915ae8e4ea9306a656267d86f9e6745b Mon Sep 17 00:00:00 2001 From: "bryan.zhang" Date: Wed, 10 Jan 2018 15:26:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0requestId=E8=BF=BD=E8=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/thebeastshop/liteflow/core/FlowExecutor.java | 7 ++++--- .../com/thebeastshop/liteflow/core/NodeComponent.java | 11 ++++++----- .../thebeastshop/liteflow/entity/data/DataBus.java | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/thebeastshop/liteflow/core/FlowExecutor.java b/src/main/java/com/thebeastshop/liteflow/core/FlowExecutor.java index a10e217b8..1eabad407 100644 --- a/src/main/java/com/thebeastshop/liteflow/core/FlowExecutor.java +++ b/src/main/java/com/thebeastshop/liteflow/core/FlowExecutor.java @@ -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) { diff --git a/src/main/java/com/thebeastshop/liteflow/core/NodeComponent.java b/src/main/java/com/thebeastshop/liteflow/core/NodeComponent.java index e5cf999dc..87b3dd63f 100644 --- a/src/main/java/com/thebeastshop/liteflow/core/NodeComponent.java +++ b/src/main/java/com/thebeastshop/liteflow/core/NodeComponent.java @@ -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; diff --git a/src/main/java/com/thebeastshop/liteflow/entity/data/DataBus.java b/src/main/java/com/thebeastshop/liteflow/entity/data/DataBus.java index 9cd3b52fa..d0e483796 100644 --- a/src/main/java/com/thebeastshop/liteflow/entity/data/DataBus.java +++ b/src/main/java/com/thebeastshop/liteflow/entity/data/DataBus.java @@ -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); }