mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 12:12:08 +08:00
修正一些注释的上错误
This commit is contained in:
@@ -104,18 +104,14 @@ public abstract class NodeComponent{
|
|||||||
|
|
||||||
public abstract void process() throws Exception;
|
public abstract void process() throws Exception;
|
||||||
|
|
||||||
/**
|
//process前置处理
|
||||||
* process前置处理
|
|
||||||
*/
|
|
||||||
public void beforeProcess(String nodeId, Slot slot) {
|
public void beforeProcess(String nodeId, Slot slot) {
|
||||||
if (ObjectUtil.isNotNull(ComponentScanner.cmpAroundAspect)) {
|
if (ObjectUtil.isNotNull(ComponentScanner.cmpAroundAspect)) {
|
||||||
ComponentScanner.cmpAroundAspect.beforeProcess(nodeId, slot);
|
ComponentScanner.cmpAroundAspect.beforeProcess(nodeId, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//process后置处理
|
||||||
* process后置处理
|
|
||||||
*/
|
|
||||||
public void afterProcess(String nodeId, Slot slot) {
|
public void afterProcess(String nodeId, Slot slot) {
|
||||||
if (ObjectUtil.isNotNull(ComponentScanner.cmpAroundAspect)) {
|
if (ObjectUtil.isNotNull(ComponentScanner.cmpAroundAspect)) {
|
||||||
ComponentScanner.cmpAroundAspect.afterProcess(nodeId, slot);
|
ComponentScanner.cmpAroundAspect.afterProcess(nodeId, slot);
|
||||||
@@ -123,26 +119,17 @@ public abstract class NodeComponent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
//是否进入该节点
|
||||||
* 是否进入该节点
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public boolean isAccess(){
|
public boolean isAccess(){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//出错是否继续执行(这个只适用于串行流程,并行节点不起作用)
|
||||||
* 出错是否继续执行(这个只适用于串行流程,并行节点不起作用)
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public boolean isContinueOnError() {
|
public boolean isContinueOnError() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//是否结束整个流程(不往下继续执行)
|
||||||
* 是否结束整个流程(不往下继续执行)
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public boolean isEnd() {
|
public boolean isEnd() {
|
||||||
Boolean isEnd = isEndTL.get();
|
Boolean isEnd = isEndTL.get();
|
||||||
if(ObjectUtil.isNull(isEnd)){
|
if(ObjectUtil.isNull(isEnd)){
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import com.yomahub.liteflow.entity.data.Slot;
|
|||||||
* 默认的节点执行器
|
* 默认的节点执行器
|
||||||
*
|
*
|
||||||
* @author sikadai
|
* @author sikadai
|
||||||
* @date 2022/1/24 17:00
|
* @since 2.6.9
|
||||||
*/
|
*/
|
||||||
public class DefaultNodeExecutor extends NodeExecutor {
|
public class DefaultNodeExecutor extends NodeExecutor {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -14,17 +14,12 @@ import java.util.List;
|
|||||||
* 节点执行器 - 自定的执行策略需要实现该类
|
* 节点执行器 - 自定的执行策略需要实现该类
|
||||||
*
|
*
|
||||||
* @author sikadai
|
* @author sikadai
|
||||||
* @date 2022/1/24 17:00
|
* @since 2.6.9
|
||||||
*/
|
*/
|
||||||
public abstract class NodeExecutor {
|
public abstract class NodeExecutor {
|
||||||
protected final Logger LOG = LoggerFactory.getLogger(this.getClass());
|
protected final Logger LOG = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
/**
|
//执行器执行入口-若需要更大维度的执行方式可以重写该方法
|
||||||
* 执行器执行入口-若需要更大维度的执行方式可以重写该方法
|
|
||||||
*
|
|
||||||
* @param instance : 执行的节点实例
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public void execute(NodeComponent instance) throws Exception {
|
public void execute(NodeComponent instance) throws Exception {
|
||||||
int retryCount = instance.getRetryCount();
|
int retryCount = instance.getRetryCount();
|
||||||
List<Class<? extends Exception>> forExceptions = Arrays.asList(instance.getRetryForExceptions());
|
List<Class<? extends Exception>> forExceptions = Arrays.asList(instance.getRetryForExceptions());
|
||||||
@@ -52,14 +47,7 @@ public abstract class NodeExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//执行重试逻辑 - 子类通过实现该方法进行重试逻辑的控制
|
||||||
* 执行重试逻辑 - 子类通过实现该方法进行重试逻辑的控制
|
|
||||||
*
|
|
||||||
* @param instance : 执行的节点实例
|
|
||||||
* @param currentRetryCount : 当前重试的次数
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected void retry(NodeComponent instance, int currentRetryCount) throws Exception {
|
protected void retry(NodeComponent instance, int currentRetryCount) throws Exception {
|
||||||
Slot slot = DataBus.getSlot(instance.getSlotIndex());
|
Slot slot = DataBus.getSlot(instance.getSlotIndex());
|
||||||
LOG.info("[{}]:component[{}] performs {} retry", slot.getRequestId(), instance.getNodeId(), currentRetryCount + 1);
|
LOG.info("[{}]:component[{}] performs {} retry", slot.getRequestId(), instance.getNodeId(), currentRetryCount + 1);
|
||||||
|
|||||||
@@ -12,45 +12,27 @@ import java.util.Map;
|
|||||||
* 节点执行器帮助器
|
* 节点执行器帮助器
|
||||||
*
|
*
|
||||||
* @author sikadai
|
* @author sikadai
|
||||||
* @date 2022/1/24 19:00
|
* @since 2.6.9
|
||||||
*/
|
*/
|
||||||
public class NodeExecutorHelper {
|
public class NodeExecutorHelper {
|
||||||
/**
|
//此处使用Map缓存线程池信息
|
||||||
* 此处使用Map缓存线程池信息
|
|
||||||
* key - 节点执行器类Class全名
|
|
||||||
* value - 节点执行器对象
|
|
||||||
*/
|
|
||||||
private final Map<Class<? extends NodeExecutor>, NodeExecutor> nodeExecutorMap;
|
private final Map<Class<? extends NodeExecutor>, NodeExecutor> nodeExecutorMap;
|
||||||
|
|
||||||
private NodeExecutorHelper() {
|
private NodeExecutorHelper() {
|
||||||
nodeExecutorMap = Maps.newConcurrentMap();
|
nodeExecutorMap = Maps.newConcurrentMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//使用静态内部类实现单例模式
|
||||||
* 使用静态内部类实现单例模式
|
|
||||||
*/
|
|
||||||
private static class Holder {
|
private static class Holder {
|
||||||
static final NodeExecutorHelper INSTANCE = new NodeExecutorHelper();
|
static final NodeExecutorHelper INSTANCE = new NodeExecutorHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//获取帮助者的实例
|
||||||
* 获取帮助者的实例
|
|
||||||
*/
|
|
||||||
public static NodeExecutorHelper loadInstance() {
|
public static NodeExecutorHelper loadInstance() {
|
||||||
// 外围类能直接访问内部类(不管是否是静态的)的私有变量
|
// 外围类能直接访问内部类(不管是否是静态的)的私有变量
|
||||||
return Holder.INSTANCE;
|
return Holder.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 单例模式驱动-通过调用该方法构建节点执行器
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* 单例模式驱动-通过调用该方法构建节点执行器
|
|
||||||
* 若nodeExecutorClass为空,则会使用默认的节点执行器
|
|
||||||
*
|
|
||||||
* @param nodeExecutorClass : 节点执行器的Class
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public NodeExecutor buildNodeExecutor(Class<? extends NodeExecutor> nodeExecutorClass) {
|
public NodeExecutor buildNodeExecutor(Class<? extends NodeExecutor> nodeExecutorClass) {
|
||||||
// 高频操作-采取apache判空操作-效率高于hutool的isBlank将近3倍
|
// 高频操作-采取apache判空操作-效率高于hutool的isBlank将近3倍
|
||||||
if (ObjectUtil.isNull(nodeExecutorClass)) {
|
if (ObjectUtil.isNull(nodeExecutorClass)) {
|
||||||
|
|||||||
@@ -23,9 +23,6 @@ import java.util.function.Function;
|
|||||||
* @since 2.6.4
|
* @since 2.6.4
|
||||||
*/
|
*/
|
||||||
public class CompletableFutureTimeout {
|
public class CompletableFutureTimeout {
|
||||||
/**
|
|
||||||
* Singleton delay scheduler, used only for starting and * cancelling tasks.
|
|
||||||
*/
|
|
||||||
static final class Delayer {
|
static final class Delayer {
|
||||||
static ScheduledFuture<?> delay(Runnable command, long delay, TimeUnit unit) {
|
static ScheduledFuture<?> delay(Runnable command, long delay, TimeUnit unit) {
|
||||||
return delayer.schedule(command, delay, unit);
|
return delayer.schedule(command, delay, unit);
|
||||||
@@ -57,17 +54,13 @@ public class CompletableFutureTimeout {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//哪个先完成 就apply哪一个结果 这是一个关键的API,exceptionally出现异常后返回默认值
|
||||||
* 哪个先完成 就apply哪一个结果 这是一个关键的API,exceptionally出现异常后返回默认值
|
|
||||||
*/
|
|
||||||
public static <T> CompletableFuture<T> completeOnTimeout(T t, CompletableFuture<T> future, long timeout, TimeUnit unit) {
|
public static <T> CompletableFuture<T> completeOnTimeout(T t, CompletableFuture<T> future, long timeout, TimeUnit unit) {
|
||||||
final CompletableFuture<T> timeoutFuture = timeoutAfter(timeout, unit);
|
final CompletableFuture<T> timeoutFuture = timeoutAfter(timeout, unit);
|
||||||
return future.applyToEither(timeoutFuture, Function.identity()).exceptionally((throwable) -> t);
|
return future.applyToEither(timeoutFuture, Function.identity()).exceptionally((throwable) -> t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//哪个先完成 就apply哪一个结果 这是一个关键的API,不设置默认值,超时后抛出异常
|
||||||
* 哪个先完成 就apply哪一个结果 这是一个关键的API,不设置默认值,超时后抛出异常
|
|
||||||
*/
|
|
||||||
public static <T> CompletableFuture<T> orTimeout(T t, CompletableFuture<T> future, long timeout, TimeUnit unit) {
|
public static <T> CompletableFuture<T> orTimeout(T t, CompletableFuture<T> future, long timeout, TimeUnit unit) {
|
||||||
final CompletableFuture<T> timeoutFuture = timeoutAfter(timeout, unit);
|
final CompletableFuture<T> timeoutFuture = timeoutAfter(timeout, unit);
|
||||||
return future.applyToEither(timeoutFuture, Function.identity()).exceptionally((throwable) -> t);
|
return future.applyToEither(timeoutFuture, Function.identity()).exceptionally((throwable) -> t);
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ public abstract class FlowParser {
|
|||||||
|
|
||||||
public abstract void parse(List<String> contentList) throws Exception;
|
public abstract void parse(List<String> contentList) throws Exception;
|
||||||
|
|
||||||
/**
|
//根据配置的ruleSource查找匹配的资源
|
||||||
* 根据配置的ruleSource查找匹配的资源
|
|
||||||
*/
|
|
||||||
protected Resource[] matchRuleResources(final List<String> pathList) throws IOException {
|
protected Resource[] matchRuleResources(final List<String> pathList) throws IOException {
|
||||||
Assert.notEmpty(pathList, "rule source must not be null");
|
Assert.notEmpty(pathList, "rule source must not be null");
|
||||||
|
|
||||||
|
|||||||
@@ -15,18 +15,7 @@ public interface ExecutorBuilder {
|
|||||||
|
|
||||||
ExecutorService buildExecutor();
|
ExecutorService buildExecutor();
|
||||||
|
|
||||||
/**
|
//构建默认的线程池对象
|
||||||
* <p>
|
|
||||||
* 构建默认的线程池对象
|
|
||||||
* </p>
|
|
||||||
* @author sikadai
|
|
||||||
* @date 2022/1/21 23:07
|
|
||||||
* @param corePoolSize : 核心线程池数量
|
|
||||||
* @param maximumPoolSize : 最大线程池数量
|
|
||||||
* @param queueCapacity : 队列的容量
|
|
||||||
* @param threadName : 线程吃名称
|
|
||||||
* @return java.util.concurrent.ExecutorService
|
|
||||||
*/
|
|
||||||
default ExecutorService buildDefaultExecutor(int corePoolSize, int maximumPoolSize, int queueCapacity, String threadName) {
|
default ExecutorService buildDefaultExecutor(int corePoolSize, int maximumPoolSize, int queueCapacity, String threadName) {
|
||||||
return TtlExecutors.getTtlExecutorService(new ThreadPoolExecutor(corePoolSize,
|
return TtlExecutors.getTtlExecutorService(new ThreadPoolExecutor(corePoolSize,
|
||||||
maximumPoolSize,
|
maximumPoolSize,
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class ExecutorHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用默认的等待时间1分钟,来关闭目标线程组。
|
*
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param pool 需要关闭的线程组.
|
* @param pool 需要关闭的线程组.
|
||||||
@@ -63,6 +63,7 @@ public class ExecutorHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* <p>
|
||||||
* 关闭ExecutorService的线程管理者
|
* 关闭ExecutorService的线程管理者
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
@@ -85,9 +86,7 @@ public class ExecutorHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//构建全局默认线程池
|
||||||
* 构建全局默认线程池
|
|
||||||
*/
|
|
||||||
public ExecutorService buildExecutor() {
|
public ExecutorService buildExecutor() {
|
||||||
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
|
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
|
||||||
if (!executorServiceMap.containsKey(liteflowConfig.getThreadExecutorClass())) {
|
if (!executorServiceMap.containsKey(liteflowConfig.getThreadExecutorClass())) {
|
||||||
@@ -97,16 +96,7 @@ public class ExecutorHelper {
|
|||||||
return executorServiceMap.get(liteflowConfig.getThreadExecutorClass());
|
return executorServiceMap.get(liteflowConfig.getThreadExecutorClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//构建线程池执行器 - 支持多个when公用一个线程池
|
||||||
* <p>
|
|
||||||
* 构建线程池执行器 - 支持多个when公用一个线程池
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param threadExecutorClass : 线程池构建者的Class全类名
|
|
||||||
* @return java.util.concurrent.ExecutorService
|
|
||||||
* @author sikadai
|
|
||||||
* @date 2022/1/21 23:00
|
|
||||||
*/
|
|
||||||
public ExecutorService buildExecutor(String threadExecutorClass) {
|
public ExecutorService buildExecutor(String threadExecutorClass) {
|
||||||
if (StrUtil.isBlank(threadExecutorClass)) {
|
if (StrUtil.isBlank(threadExecutorClass)) {
|
||||||
return buildExecutor();
|
return buildExecutor();
|
||||||
|
|||||||
Reference in New Issue
Block a user