Skip to content

Commit

Permalink
optimize: load balance strategy use constants (apache#3320)
Browse files Browse the repository at this point in the history
  • Loading branch information
LiWenGu committed Dec 8, 2020
1 parent 10c03d0 commit 4853e10
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
import static io.seata.config.ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR;
import static io.seata.config.ConfigurationKeys.FILE_ROOT_REGISTRY;
import static io.seata.common.DefaultValues.VIRTUAL_NODES_DEFAULT;
import static io.seata.discovery.loadbalance.LoadBalanceFactory.CONSISTENT_HASH_LOAD_BALANCE;

/**
* The type consistent hash load balance.
*
* @author ph3636
*/
@LoadLevel(name = "ConsistentHashLoadBalance")
@LoadLevel(name = CONSISTENT_HASH_LOAD_BALANCE)
public class ConsistentHashLoadBalance extends AbstractLoadBalance {

private static final String VIRTUAL_NODES = FILE_ROOT_REGISTRY + FILE_CONFIG_SPLIT_CHAR + "loadBalanceVirtualNodes";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
import io.seata.common.loader.LoadLevel;
import io.seata.common.rpc.RpcStatus;

import static io.seata.discovery.loadbalance.LoadBalanceFactory.LEAST_ACTIVE_LOAD_BALANCE;

/**
* The type Least Active load balance.
*
* @author ph3636
*/
@LoadLevel(name = "LeastActiveLoadBalance")
@LoadLevel(name = LEAST_ACTIVE_LOAD_BALANCE)
public class LeastActiveLoadBalance extends AbstractLoadBalance {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ public class LoadBalanceFactory {
*/
private static final String LOAD_BALANCE = FILE_ROOT_REGISTRY + FILE_CONFIG_SPLIT_CHAR + "loadBalance";

public static final String RANDOM_LOAD_BALANCE = DEFAULT_LOAD_BALANCE;

public static final String ROUND_ROBIN_LOAD_BALANCE = "RoundRobinLoadBalance";

public static final String CONSISTENT_HASH_LOAD_BALANCE = "ConsistentHashLoadBalance";

public static final String LEAST_ACTIVE_LOAD_BALANCE = "LeastActiveLoadBalance";


/**
* Get instance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@

import io.seata.common.loader.LoadLevel;

import static io.seata.discovery.loadbalance.LoadBalanceFactory.RANDOM_LOAD_BALANCE;

/**
* The type Random load balance.
*
* @author yuoyao
*/
@LoadLevel(name = "RandomLoadBalance")
@LoadLevel(name = RANDOM_LOAD_BALANCE)
public class RandomLoadBalance extends AbstractLoadBalance {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@

import io.seata.common.loader.LoadLevel;

import static io.seata.discovery.loadbalance.LoadBalanceFactory.ROUND_ROBIN_LOAD_BALANCE;

/**
* The type Round robin load balance.
*
* @author slievrly
*/
@LoadLevel(name = "RoundRobinLoadBalance")
@LoadLevel(name = ROUND_ROBIN_LOAD_BALANCE)
public class RoundRobinLoadBalance extends AbstractLoadBalance {

private final AtomicInteger sequence = new AtomicInteger();
Expand Down

0 comments on commit 4853e10

Please sign in to comment.