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
|
||||
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)) {
|
||||
|
@ -148,7 +148,7 @@ public class SaveJobInfoRequest {
|
||||
|
||||
public DispatchStrategy getDispatchStrategy() {
|
||||
if (dispatchStrategy == null) {
|
||||
return DispatchStrategy.HEALTH_FIRST;
|
||||
return DispatchStrategy.PERFORMANCE_FIRST;
|
||||
}
|
||||
return dispatchStrategy;
|
||||
}
|
||||
|
@ -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()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user