feat(scheduler): 允许集群判断规则为空
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user