Skip to content

Commit 096b6fb

Browse files
Merge branch '3.2' into tracing
2 parents da2cc39 + 5f39404 commit 096b6fb

File tree

60 files changed

+286
-140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+286
-140
lines changed

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/filter/support/ConsumerContextFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcExcept
110110
if (timeoutCountDown.isExpired()) {
111111
return AsyncRpcResult.newDefaultAsyncResult(new RpcException(RpcException.TIMEOUT_TERMINATE,
112112
"No time left for making the following call: " + invocation.getServiceName() + "."
113-
+ invocation.getMethodName() + ", terminate directly."), invocation);
113+
+ RpcUtils.getMethodName(invocation) + ", terminate directly."), invocation);
114114
}
115115
}
116116
}

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.dubbo.rpc.Invoker;
2323
import org.apache.dubbo.rpc.cluster.ClusterInvoker;
2424
import org.apache.dubbo.rpc.cluster.LoadBalance;
25+
import org.apache.dubbo.rpc.support.RpcUtils;
2526

2627
import java.util.List;
2728

@@ -83,7 +84,7 @@ protected int getWeight(Invoker<?> invoker, Invocation invocation) {
8384
if (REGISTRY_SERVICE_REFERENCE_PATH.equals(url.getServiceInterface())) {
8485
weight = url.getParameter(WEIGHT_KEY, DEFAULT_WEIGHT);
8586
} else {
86-
weight = url.getMethodParameter(invocation.getMethodName(), WEIGHT_KEY, DEFAULT_WEIGHT);
87+
weight = url.getMethodParameter(RpcUtils.getMethodName(invocation), WEIGHT_KEY, DEFAULT_WEIGHT);
8788
if (weight > 0) {
8889
long timestamp = invoker.getUrl().getParameter(TIMESTAMP_KEY, 0L);
8990
if (timestamp > 0L) {

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.concurrent.ConcurrentHashMap;
2929
import java.util.concurrent.ConcurrentMap;
3030

31-
import static org.apache.dubbo.common.constants.CommonConstants.$INVOKE;
3231
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
3332

3433
/**
@@ -97,10 +96,7 @@ private static final class ConsistentHashSelector<T> {
9796
}
9897

9998
public Invoker<T> select(Invocation invocation) {
100-
boolean isGeneric = invocation.getMethodName().equals($INVOKE);
101-
String key = toKey(invocation.getArguments(),isGeneric);
102-
103-
byte[] digest = Bytes.getMD5(key);
99+
byte[] digest = Bytes.getMD5(RpcUtils.getMethodName(invocation));
104100
return selectForKey(hash(digest, 0));
105101
}
106102

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.apache.dubbo.rpc.Invocation;
2121
import org.apache.dubbo.rpc.Invoker;
2222
import org.apache.dubbo.rpc.RpcStatus;
23+
import org.apache.dubbo.rpc.support.RpcUtils;
2324

2425
import java.util.List;
2526
import java.util.concurrent.ThreadLocalRandom;
@@ -60,7 +61,7 @@ protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation
6061
for (int i = 0; i < length; i++) {
6162
Invoker<T> invoker = invokers.get(i);
6263
// Get the active number of the invoker
63-
int active = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()).getActive();
64+
int active = RpcStatus.getStatus(invoker.getUrl(), RpcUtils.getMethodName(invocation)).getActive();
6465
// Get the weight of the invoker's configuration. The default value is 100.
6566
int afterWarmup = getWeight(invoker, invocation);
6667
// save for later use
@@ -97,7 +98,7 @@ protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation
9798
return invokers.get(leastIndexes[0]);
9899
}
99100
if (!sameWeight && totalWeight > 0) {
100-
// If (not every invoker has the same weight & at least one invoker's weight>0), select randomly based on
101+
// If (not every invoker has the same weight & at least one invoker's weight>0), select randomly based on
101102
// totalWeight.
102103
int offsetWeight = ThreadLocalRandom.current().nextInt(totalWeight);
103104
// Return a invoker based on the random value.

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RandomLoadBalance.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.dubbo.rpc.Invocation;
2222
import org.apache.dubbo.rpc.Invoker;
2323
import org.apache.dubbo.rpc.cluster.ClusterInvoker;
24+
import org.apache.dubbo.rpc.support.RpcUtils;
2425

2526
import java.util.Arrays;
2627
import java.util.List;
@@ -115,7 +116,7 @@ private <T> boolean needWeightLoadBalance(List<Invoker<T>> invokers, Invocation
115116
String weight = invokerUrl.getParameter(WEIGHT_KEY);
116117
return StringUtils.isNotEmpty(weight);
117118
} else {
118-
String weight = invokerUrl.getMethodParameter(invocation.getMethodName(), WEIGHT_KEY);
119+
String weight = invokerUrl.getMethodParameter(RpcUtils.getMethodName(invocation), WEIGHT_KEY);
119120
if (StringUtils.isNotEmpty(weight)) {
120121
return true;
121122
} else {

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.apache.dubbo.common.utils.ConcurrentHashMapUtils;
2121
import org.apache.dubbo.rpc.Invocation;
2222
import org.apache.dubbo.rpc.Invoker;
23+
import org.apache.dubbo.rpc.support.RpcUtils;
2324

2425
import java.util.Collection;
2526
import java.util.List;
@@ -79,7 +80,7 @@ public void setLastUpdate(long lastUpdate) {
7980
* @return
8081
*/
8182
protected <T> Collection<String> getInvokerAddrList(List<Invoker<T>> invokers, Invocation invocation) {
82-
String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName();
83+
String key = invokers.get(0).getUrl().getServiceKey() + "." + RpcUtils.getMethodName(invocation);
8384
Map<String, WeightedRoundRobin> map = methodWeightMap.get(key);
8485
if (map != null) {
8586
return map.keySet();
@@ -89,7 +90,7 @@ protected <T> Collection<String> getInvokerAddrList(List<Invoker<T>> invokers, I
8990

9091
@Override
9192
protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) {
92-
String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName();
93+
String key = invokers.get(0).getUrl().getServiceKey() + "." + RpcUtils.getMethodName(invocation);
9394
ConcurrentMap<String, WeightedRoundRobin> map = ConcurrentHashMapUtils.computeIfAbsent(methodWeightMap, key, k -> new ConcurrentHashMap<>());
9495
int totalWeight = 0;
9596
long maxCurrent = Long.MIN_VALUE;

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ShortestResponseLoadBalance.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.dubbo.rpc.cluster.Constants;
2626
import org.apache.dubbo.rpc.model.ApplicationModel;
2727
import org.apache.dubbo.rpc.model.ScopeModelAware;
28+
import org.apache.dubbo.rpc.support.RpcUtils;
2829

2930
import java.util.List;
3031
import java.util.concurrent.ConcurrentHashMap;
@@ -116,7 +117,7 @@ protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation
116117
// Filter out all the shortest response invokers
117118
for (int i = 0; i < length; i++) {
118119
Invoker<T> invoker = invokers.get(i);
119-
RpcStatus rpcStatus = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName());
120+
RpcStatus rpcStatus = RpcStatus.getStatus(invoker.getUrl(), RpcUtils.getMethodName(invocation));
120121
SlideWindowData slideWindowData = ConcurrentHashMapUtils.computeIfAbsent(methodMap, rpcStatus, SlideWindowData::new);
121122

122123
// Calculate the estimated response time from the product of active connections and succeeded average elapsed time.

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/matcher/AbstractConditionMatcher.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.dubbo.rpc.Invocation;
2323
import org.apache.dubbo.rpc.cluster.router.condition.matcher.pattern.ValuePattern;
2424
import org.apache.dubbo.rpc.model.ModuleModel;
25+
import org.apache.dubbo.rpc.support.RpcUtils;
2526

2627
import java.util.HashSet;
2728
import java.util.List;
@@ -55,7 +56,7 @@ public static String getSampleValueFromUrl(String conditionKey, Map<String, Stri
5556
String sampleValue;
5657
//get real invoked method name from invocation
5758
if (invocation != null && (METHOD_KEY.equals(conditionKey) || METHODS_KEY.equals(conditionKey))) {
58-
sampleValue = invocation.getMethodName();
59+
sampleValue = RpcUtils.getMethodName(invocation);
5960
} else {
6061
sampleValue = sample.get(conditionKey);
6162
}

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/mesh/rule/virtualservice/match/DubboMethodMatch.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.match;
1919

2020
import org.apache.dubbo.rpc.Invocation;
21+
import org.apache.dubbo.rpc.support.RpcUtils;
2122

2223
import java.util.List;
2324
import java.util.Map;
@@ -83,7 +84,7 @@ public String toString() {
8384

8485
public boolean isMatch(Invocation invocation) {
8586
StringMatch nameMatch = getName_match();
86-
if (nameMatch != null && !nameMatch.isMatch(invocation.getMethodName())) {
87+
if (nameMatch != null && !nameMatch.isMatch(RpcUtils.getMethodName(invocation))) {
8788
return false;
8889
}
8990

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/script/ScriptStateRouter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.dubbo.rpc.cluster.router.RouterSnapshotNode;
3030
import org.apache.dubbo.rpc.cluster.router.state.AbstractStateRouter;
3131
import org.apache.dubbo.rpc.cluster.router.state.BitList;
32+
import org.apache.dubbo.rpc.support.RpcUtils;
3233

3334
import javax.script.Bindings;
3435
import javax.script.Compilable;
@@ -139,7 +140,7 @@ protected BitList<Invoker<T>> doRoute(BitList<Invoker<T>> invokers, URL url, Inv
139140
return function.eval(bindings);
140141
} catch (ScriptException e) {
141142
logger.error(CLUSTER_SCRIPT_EXCEPTION, "Scriptrouter exec script error", "", "Script route error, rule has been ignored. rule: " + rule + ", method:" +
142-
invocation.getMethodName() + ", url: " + RpcContext.getContext().getUrl(), e);
143+
RpcUtils.getMethodName(invocation) + ", url: " + RpcContext.getContext().getUrl(), e);
143144
return invokers;
144145
}
145146
}, accessControlContext));

0 commit comments

Comments
 (0)