From b655295f33fe4bc6bfad6dfec4a7352161e6cc35 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Thu, 29 Feb 2024 18:27:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(scheduler):=20=E5=85=81=E8=AE=B8=E9=9B=86?= =?UTF-8?q?=E7=BE=A4=E5=88=A4=E6=96=AD=E8=A7=84=E5=88=99=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduler/quartz/distribute/cluster/Cluster.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/service-scheduler/src/main/java/com/lanyuanxiaoyao/service/scheduler/quartz/distribute/cluster/Cluster.java b/service-scheduler/src/main/java/com/lanyuanxiaoyao/service/scheduler/quartz/distribute/cluster/Cluster.java index 6b3c513..1b2ed44 100644 --- a/service-scheduler/src/main/java/com/lanyuanxiaoyao/service/scheduler/quartz/distribute/cluster/Cluster.java +++ b/service-scheduler/src/main/java/com/lanyuanxiaoyao/service/scheduler/quartz/distribute/cluster/Cluster.java @@ -1,5 +1,6 @@ package com.lanyuanxiaoyao.service.scheduler.quartz.distribute.cluster; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.lanyuanxiaoyao.service.scheduler.quartz.distribute.strategy.AvailableStrategy; import org.slf4j.Logger; @@ -18,6 +19,10 @@ public class Cluster { private final String queue; private final AvailableStrategy availableStrategy; + public Cluster(String cluster, String queue) { + this(cluster, queue, null); + } + public Cluster(String cluster, String queue, AvailableStrategy availableStrategy) { this.cluster = cluster; this.queue = queue; @@ -34,6 +39,9 @@ public class Cluster { public boolean available() { try { + if (ObjectUtil.isNull(availableStrategy)) { + return true; + } return availableStrategy.available(); } catch (Throwable throwable) { logger.error(StrUtil.format("Check cluster {} available fail", this.cluster), throwable);