feat(scheduler): 允许集群判断规则为空
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.lanyuanxiaoyao.service.scheduler.quartz.distribute.cluster;
|
package com.lanyuanxiaoyao.service.scheduler.quartz.distribute.cluster;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.lanyuanxiaoyao.service.scheduler.quartz.distribute.strategy.AvailableStrategy;
|
import com.lanyuanxiaoyao.service.scheduler.quartz.distribute.strategy.AvailableStrategy;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -18,6 +19,10 @@ public class Cluster {
|
|||||||
private final String queue;
|
private final String queue;
|
||||||
private final AvailableStrategy availableStrategy;
|
private final AvailableStrategy availableStrategy;
|
||||||
|
|
||||||
|
public Cluster(String cluster, String queue) {
|
||||||
|
this(cluster, queue, null);
|
||||||
|
}
|
||||||
|
|
||||||
public Cluster(String cluster, String queue, AvailableStrategy availableStrategy) {
|
public Cluster(String cluster, String queue, AvailableStrategy availableStrategy) {
|
||||||
this.cluster = cluster;
|
this.cluster = cluster;
|
||||||
this.queue = queue;
|
this.queue = queue;
|
||||||
@@ -34,6 +39,9 @@ public class Cluster {
|
|||||||
|
|
||||||
public boolean available() {
|
public boolean available() {
|
||||||
try {
|
try {
|
||||||
|
if (ObjectUtil.isNull(availableStrategy)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return availableStrategy.available();
|
return availableStrategy.available();
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
logger.error(StrUtil.format("Check cluster {} available fail", this.cluster), throwable);
|
logger.error(StrUtil.format("Check cluster {} available fail", this.cluster), throwable);
|
||||||
|
|||||||
Reference in New Issue
Block a user