refactor: rename one DispatchStrategy

This commit is contained in:
tjq 2021-06-20 15:50:53 +08:00
parent aaaf533dd6
commit e8424eff4d
3 changed files with 4 additions and 4 deletions

View File

@ -13,14 +13,14 @@ import lombok.Getter;
@AllArgsConstructor
public enum DispatchStrategy {
HEALTH_FIRST(1),
PERFORMANCE_FIRST(1),
RANDOM(2);
private final int v;
public static DispatchStrategy of(Integer v) {
if (v == null) {
return HEALTH_FIRST;
return PERFORMANCE_FIRST;
}
for (DispatchStrategy ds : values()) {
if (v.equals(ds.v)) {

View File

@ -148,7 +148,7 @@ public class SaveJobInfoRequest {
public DispatchStrategy getDispatchStrategy() {
if (dispatchStrategy == null) {
return DispatchStrategy.HEALTH_FIRST;
return DispatchStrategy.PERFORMANCE_FIRST;
}
return dispatchStrategy;
}

View File

@ -195,7 +195,7 @@ public class DispatchService {
private WorkerInfo selectTaskTracker(JobInfoDO jobInfo, List<WorkerInfo> workerInfos) {
DispatchStrategy dispatchStrategy = DispatchStrategy.of(jobInfo.getDispatchStrategy());
switch (dispatchStrategy) {
case HEALTH_FIRST:
case PERFORMANCE_FIRST:
return workerInfos.get(0);
case RANDOM:
return workerInfos.get(ThreadLocalRandom.current().nextInt(workerInfos.size()));