mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
refactor: rename one DispatchStrategy
This commit is contained in:
parent
aaaf533dd6
commit
e8424eff4d
@ -13,14 +13,14 @@ import lombok.Getter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum DispatchStrategy {
|
public enum DispatchStrategy {
|
||||||
|
|
||||||
HEALTH_FIRST(1),
|
PERFORMANCE_FIRST(1),
|
||||||
RANDOM(2);
|
RANDOM(2);
|
||||||
|
|
||||||
private final int v;
|
private final int v;
|
||||||
|
|
||||||
public static DispatchStrategy of(Integer v) {
|
public static DispatchStrategy of(Integer v) {
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
return HEALTH_FIRST;
|
return PERFORMANCE_FIRST;
|
||||||
}
|
}
|
||||||
for (DispatchStrategy ds : values()) {
|
for (DispatchStrategy ds : values()) {
|
||||||
if (v.equals(ds.v)) {
|
if (v.equals(ds.v)) {
|
||||||
|
@ -148,7 +148,7 @@ public class SaveJobInfoRequest {
|
|||||||
|
|
||||||
public DispatchStrategy getDispatchStrategy() {
|
public DispatchStrategy getDispatchStrategy() {
|
||||||
if (dispatchStrategy == null) {
|
if (dispatchStrategy == null) {
|
||||||
return DispatchStrategy.HEALTH_FIRST;
|
return DispatchStrategy.PERFORMANCE_FIRST;
|
||||||
}
|
}
|
||||||
return dispatchStrategy;
|
return dispatchStrategy;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ public class DispatchService {
|
|||||||
private WorkerInfo selectTaskTracker(JobInfoDO jobInfo, List<WorkerInfo> workerInfos) {
|
private WorkerInfo selectTaskTracker(JobInfoDO jobInfo, List<WorkerInfo> workerInfos) {
|
||||||
DispatchStrategy dispatchStrategy = DispatchStrategy.of(jobInfo.getDispatchStrategy());
|
DispatchStrategy dispatchStrategy = DispatchStrategy.of(jobInfo.getDispatchStrategy());
|
||||||
switch (dispatchStrategy) {
|
switch (dispatchStrategy) {
|
||||||
case HEALTH_FIRST:
|
case PERFORMANCE_FIRST:
|
||||||
return workerInfos.get(0);
|
return workerInfos.get(0);
|
||||||
case RANDOM:
|
case RANDOM:
|
||||||
return workerInfos.get(ThreadLocalRandom.current().nextInt(workerInfos.size()));
|
return workerInfos.get(ThreadLocalRandom.current().nextInt(workerInfos.size()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user