Skip to content

Commit e255f54

Browse files
authored
Merge pull request #1872, get the real methodname to support consistenthash for generic invoke.
1 parent 286fb12 commit e255f54

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.alibaba.dubbo.common.URL;
2121
import com.alibaba.dubbo.rpc.Invocation;
2222
import com.alibaba.dubbo.rpc.Invoker;
23+
import com.alibaba.dubbo.rpc.support.RpcUtils;
2324

2425
import java.io.UnsupportedEncodingException;
2526
import java.security.MessageDigest;
@@ -41,11 +42,12 @@ public class ConsistentHashLoadBalance extends AbstractLoadBalance {
4142
@SuppressWarnings("unchecked")
4243
@Override
4344
protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) {
44-
String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName();
45+
String methodName = RpcUtils.getMethodName(invocation);
46+
String key = invokers.get(0).getUrl().getServiceKey() + "." + methodName;
4547
int identityHashCode = System.identityHashCode(invokers);
4648
ConsistentHashSelector<T> selector = (ConsistentHashSelector<T>) selectors.get(key);
4749
if (selector == null || selector.identityHashCode != identityHashCode) {
48-
selectors.put(key, new ConsistentHashSelector<T>(invokers, invocation.getMethodName(), identityHashCode));
50+
selectors.put(key, new ConsistentHashSelector<T>(invokers, methodName, identityHashCode));
4951
selector = (ConsistentHashSelector<T>) selectors.get(key);
5052
}
5153
return selector.select(invocation);

dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/AbstractClusterInvoker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public Result invoke(final Invocation invocation) throws RpcException {
228228
List<Invoker<T>> invokers = list(invocation);
229229
if (invokers != null && !invokers.isEmpty()) {
230230
loadbalance = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(invokers.get(0).getUrl()
231-
.getMethodParameter(invocation.getMethodName(), Constants.LOADBALANCE_KEY, Constants.DEFAULT_LOADBALANCE));
231+
.getMethodParameter(RpcUtils.getMethodName(invocation), Constants.LOADBALANCE_KEY, Constants.DEFAULT_LOADBALANCE));
232232
}
233233
RpcUtils.attachInvocationIdIfAsync(getUrl(), invocation);
234234
return doInvoke(invocation, invokers, loadbalance);

0 commit comments

Comments
 (0)