From 5da0e7bf4a5deb45ed35d51dcd73ef942feeb1be Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Tue, 24 Oct 2023 19:17:16 +0800 Subject: [PATCH] =?UTF-8?q?WhenFutureObj=E5=AF=B9=E8=B1=A1=E4=B8=AD?= =?UTF-8?q?=E7=9A=84executorName=E6=94=B9=E6=88=90executorId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/flow/parallel/WhenFutureObj.java | 25 +++++++++---------- .../strategy/ParallelStrategyExecutor.java | 4 +-- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/WhenFutureObj.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/WhenFutureObj.java index c0953b891..33bb8b963 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/WhenFutureObj.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/WhenFutureObj.java @@ -2,7 +2,6 @@ package com.yomahub.liteflow.flow.parallel; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.exception.WhenTimeoutException; -import com.yomahub.liteflow.property.LiteflowConfigGetter; /** * 并行异步CompletableFuture里的值对象 @@ -16,34 +15,34 @@ public class WhenFutureObj { private boolean timeout; - private String executorName; + private String executorId; private Exception ex; - public static WhenFutureObj success(String executorName) { + public static WhenFutureObj success(String executorId) { WhenFutureObj result = new WhenFutureObj(); result.setSuccess(true); result.setTimeout(false); - result.setExecutorName(executorName); + result.setExecutorId(executorId); return result; } - public static WhenFutureObj fail(String executorName, Exception ex) { + public static WhenFutureObj fail(String executorId, Exception ex) { WhenFutureObj result = new WhenFutureObj(); result.setSuccess(false); result.setTimeout(false); - result.setExecutorName(executorName); + result.setExecutorId(executorId); result.setEx(ex); return result; } - public static WhenFutureObj timeOut(String executorName) { + public static WhenFutureObj timeOut(String executorId) { WhenFutureObj result = new WhenFutureObj(); result.setSuccess(false); result.setTimeout(true); - result.setExecutorName(executorName); + result.setExecutorId(executorId); result.setEx(new WhenTimeoutException( - StrUtil.format("Timed out when executing the component[{}]",executorName))); + StrUtil.format("Timed out when executing the component[{}]",executorId))); return result; } @@ -55,12 +54,12 @@ public class WhenFutureObj { this.success = success; } - public String getExecutorName() { - return executorName; + public String getExecutorId() { + return executorId; } - public void setExecutorName(String executorName) { - this.executorName = executorName; + public void setExecutorId(String executorId) { + this.executorId = executorId; } public Exception getEx() { diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/ParallelStrategyExecutor.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/ParallelStrategyExecutor.java index cd390352a..47b6c4ca1 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/ParallelStrategyExecutor.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/ParallelStrategyExecutor.java @@ -207,7 +207,7 @@ public abstract class ParallelStrategyExecutor { // 输出超时信息 timeOutWhenFutureObjList.forEach(whenFutureObj -> LOG.warn( - "executing thread has reached max-wait-seconds, thread canceled.Execute-item: [{}]", whenFutureObj.getExecutorName())); + "executing thread has reached max-wait-seconds, thread canceled.Execute-item: [{}]", whenFutureObj.getExecutorId())); // 当配置了 ignoreError = false,出现 interrupted 或者 !f.get() 的情况,将抛出 WhenExecuteException if (!whenCondition.isIgnoreError()) { @@ -219,7 +219,7 @@ public abstract class ParallelStrategyExecutor { // 循环判断CompletableFuture的返回值,如果异步执行失败,则抛出相应的业务异常 for (WhenFutureObj whenFutureObj : allCompletableWhenFutureObjList) { if (!whenFutureObj.isSuccess()) { - LOG.info(StrUtil.format("when-executor[{}] execute failed. errorResume [false].", whenFutureObj.getExecutorName())); + LOG.info(StrUtil.format("when-executor[{}] execute failed. errorResume [false].", whenFutureObj.getExecutorId())); throw whenFutureObj.getEx(); } }