Skip to content

Commit

Permalink
Create constants for 'hash.names' and 'hash.arguments' (#3744) (#3758)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniela Marques de Morais authored and kexianjun committed Mar 28, 2019
1 parent e8d8538 commit fca31c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import static org.apache.dubbo.common.Constants.HASH_ARGUMENTS;
import static org.apache.dubbo.common.Constants.HASH_NODES;

/**
* ConsistentHashLoadBalance
*/
Expand Down Expand Up @@ -67,8 +70,8 @@ private static final class ConsistentHashSelector<T> {
this.virtualInvokers = new TreeMap<Long, Invoker<T>>();
this.identityHashCode = identityHashCode;
URL url = invokers.get(0).getUrl();
this.replicaNumber = url.getMethodParameter(methodName, "hash.nodes", 160);
String[] index = Constants.COMMA_SPLIT_PATTERN.split(url.getMethodParameter(methodName, "hash.arguments", "0"));
this.replicaNumber = url.getMethodParameter(methodName, HASH_NODES, 160);
String[] index = Constants.COMMA_SPLIT_PATTERN.split(url.getMethodParameter(methodName, HASH_ARGUMENTS, "0"));
argumentIndex = new int[index.length];
for (int i = 0; i < index.length; i++) {
argumentIndex[i] = Integer.parseInt(index[i]);
Expand Down
10 changes: 10 additions & 0 deletions dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,16 @@ public class Constants {

public static final String TELNET = "telnet";

/**
* Hash nodes name
*/
public static final String HASH_NODES = "hash.nodes";

/**
* Hash arguments name
*/
public static final String HASH_ARGUMENTS = "hash.arguments";

/**
* Application name;
*/
Expand Down

0 comments on commit fca31c4

Please sign in to comment.