提交 | 用户 | 时间
|
722af2
|
1 |
package com.xxl.job.admin.core.route; |
X |
2 |
|
|
3 |
import com.xxl.job.admin.core.route.strategy.*; |
|
4 |
import com.xxl.job.admin.core.util.I18nUtil; |
|
5 |
|
|
6 |
/** |
|
7 |
* Created by xuxueli on 17/3/10. |
|
8 |
*/ |
|
9 |
public enum ExecutorRouteStrategyEnum { |
|
10 |
|
|
11 |
FIRST(I18nUtil.getString("jobconf_route_first"), new ExecutorRouteFirst()), |
|
12 |
LAST(I18nUtil.getString("jobconf_route_last"), new ExecutorRouteLast()), |
|
13 |
ROUND(I18nUtil.getString("jobconf_route_round"), new ExecutorRouteRound()), |
|
14 |
RANDOM(I18nUtil.getString("jobconf_route_random"), new ExecutorRouteRandom()), |
|
15 |
CONSISTENT_HASH(I18nUtil.getString("jobconf_route_consistenthash"), new ExecutorRouteConsistentHash()), |
|
16 |
LEAST_FREQUENTLY_USED(I18nUtil.getString("jobconf_route_lfu"), new ExecutorRouteLFU()), |
|
17 |
LEAST_RECENTLY_USED(I18nUtil.getString("jobconf_route_lru"), new ExecutorRouteLRU()), |
|
18 |
FAILOVER(I18nUtil.getString("jobconf_route_failover"), new ExecutorRouteFailover()), |
|
19 |
BUSYOVER(I18nUtil.getString("jobconf_route_busyover"), new ExecutorRouteBusyover()), |
|
20 |
SHARDING_BROADCAST(I18nUtil.getString("jobconf_route_shard"), null); |
|
21 |
|
|
22 |
ExecutorRouteStrategyEnum(String title, ExecutorRouter router) { |
|
23 |
this.title = title; |
|
24 |
this.router = router; |
|
25 |
} |
|
26 |
|
|
27 |
private String title; |
|
28 |
private ExecutorRouter router; |
|
29 |
|
|
30 |
public String getTitle() { |
|
31 |
return title; |
|
32 |
} |
|
33 |
|
|
34 |
public ExecutorRouter getRouter() { |
|
35 |
return router; |
|
36 |
} |
|
37 |
|
|
38 |
public static ExecutorRouteStrategyEnum match(String name, ExecutorRouteStrategyEnum defaultItem) { |
|
39 |
if (name != null) { |
|
40 |
for (ExecutorRouteStrategyEnum item : ExecutorRouteStrategyEnum.values()) { |
|
41 |
if (item.name().equals(name)) { |
|
42 |
return item; |
|
43 |
} |
|
44 |
} |
|
45 |
} |
|
46 |
return defaultItem; |
|
47 |
} |
|
48 |
|
|
49 |
} |