feat(sj_1.2.0-beta1):增加第一和最后一个路由功能
This commit is contained in:
parent
04f8137b3f
commit
838fe806fc
@ -0,0 +1,17 @@
|
|||||||
|
package com.aizuda.snailjob.server.common.allocate.client;
|
||||||
|
|
||||||
|
import com.aizuda.snailjob.server.common.ClientLoadBalance;
|
||||||
|
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
public class ClientLoadBalanceFirst implements ClientLoadBalance {
|
||||||
|
@Override
|
||||||
|
public String route(String key, TreeSet<String> clientAllAddressSet) {
|
||||||
|
return clientAllAddressSet.first();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int routeType() {
|
||||||
|
return ClientLoadBalanceManager.AllocationAlgorithmEnum.FIRST.getType();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.aizuda.snailjob.server.common.allocate.client;
|
||||||
|
|
||||||
|
import com.aizuda.snailjob.server.common.ClientLoadBalance;
|
||||||
|
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
public class ClientLoadBalanceLast implements ClientLoadBalance {
|
||||||
|
@Override
|
||||||
|
public String route(String key, TreeSet<String> clientAllAddressSet) {
|
||||||
|
return clientAllAddressSet.last();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int routeType() {
|
||||||
|
return ClientLoadBalanceManager.AllocationAlgorithmEnum.LAST.getType();
|
||||||
|
}
|
||||||
|
}
|
@ -29,7 +29,9 @@ public class ClientLoadBalanceManager {
|
|||||||
CONSISTENT_HASH(1, new ClientLoadBalanceConsistentHash(100)),
|
CONSISTENT_HASH(1, new ClientLoadBalanceConsistentHash(100)),
|
||||||
RANDOM(2, new ClientLoadBalanceRandom()),
|
RANDOM(2, new ClientLoadBalanceRandom()),
|
||||||
LRU(3, new ClientLoadBalanceLRU(100)),
|
LRU(3, new ClientLoadBalanceLRU(100)),
|
||||||
ROUND(4, new ClientLoadBalanceRound());
|
ROUND(4, new ClientLoadBalanceRound()),
|
||||||
|
FIRST(5, new ClientLoadBalanceFirst()),
|
||||||
|
LAST(6, new ClientLoadBalanceLast());
|
||||||
|
|
||||||
private final int type;
|
private final int type;
|
||||||
private final ClientLoadBalance clientLoadBalance;
|
private final ClientLoadBalance clientLoadBalance;
|
||||||
|
Loading…
Reference in New Issue
Block a user