diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/filter/support/ConsumerContextFilter.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/filter/support/ConsumerContextFilter.java index 4efa2ba9fe..582578b5e9 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/filter/support/ConsumerContextFilter.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/filter/support/ConsumerContextFilter.java @@ -110,7 +110,7 @@ public class ConsumerContextFilter implements ClusterFilter, ClusterFilter.Liste if (timeoutCountDown.isExpired()) { return AsyncRpcResult.newDefaultAsyncResult(new RpcException(RpcException.TIMEOUT_TERMINATE, "No time left for making the following call: " + invocation.getServiceName() + "." - + invocation.getMethodName() + ", terminate directly."), invocation); + + RpcUtils.getMethodName(invocation) + ", terminate directly."), invocation); } } } diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java index a4866e888b..59ecd9a305 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java @@ -22,6 +22,7 @@ import org.apache.dubbo.rpc.Invocation; import org.apache.dubbo.rpc.Invoker; import org.apache.dubbo.rpc.cluster.ClusterInvoker; import org.apache.dubbo.rpc.cluster.LoadBalance; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.List; @@ -83,7 +84,7 @@ public abstract class AbstractLoadBalance implements LoadBalance { if (REGISTRY_SERVICE_REFERENCE_PATH.equals(url.getServiceInterface())) { weight = url.getParameter(WEIGHT_KEY, DEFAULT_WEIGHT); } else { - weight = url.getMethodParameter(invocation.getMethodName(), WEIGHT_KEY, DEFAULT_WEIGHT); + weight = url.getMethodParameter(RpcUtils.getMethodName(invocation), WEIGHT_KEY, DEFAULT_WEIGHT); if (weight > 0) { long timestamp = invoker.getUrl().getParameter(TIMESTAMP_KEY, 0L); if (timestamp > 0L) { diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java index 8604def436..37386ab186 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java @@ -28,7 +28,6 @@ import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import static org.apache.dubbo.common.constants.CommonConstants.$INVOKE; import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN; /** @@ -97,10 +96,7 @@ public class ConsistentHashLoadBalance extends AbstractLoadBalance { } public Invoker select(Invocation invocation) { - boolean isGeneric = invocation.getMethodName().equals($INVOKE); - String key = toKey(invocation.getArguments(),isGeneric); - - byte[] digest = Bytes.getMD5(key); + byte[] digest = Bytes.getMD5(RpcUtils.getMethodName(invocation)); return selectForKey(hash(digest, 0)); } diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java index 41c1bab569..9eb41f6fe9 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java @@ -20,6 +20,7 @@ import org.apache.dubbo.common.URL; import org.apache.dubbo.rpc.Invocation; import org.apache.dubbo.rpc.Invoker; import org.apache.dubbo.rpc.RpcStatus; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.List; import java.util.concurrent.ThreadLocalRandom; @@ -60,7 +61,7 @@ public class LeastActiveLoadBalance extends AbstractLoadBalance { for (int i = 0; i < length; i++) { Invoker invoker = invokers.get(i); // Get the active number of the invoker - int active = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()).getActive(); + int active = RpcStatus.getStatus(invoker.getUrl(), RpcUtils.getMethodName(invocation)).getActive(); // Get the weight of the invoker's configuration. The default value is 100. int afterWarmup = getWeight(invoker, invocation); // save for later use @@ -97,7 +98,7 @@ public class LeastActiveLoadBalance extends AbstractLoadBalance { return invokers.get(leastIndexes[0]); } if (!sameWeight && totalWeight > 0) { - // If (not every invoker has the same weight & at least one invoker's weight>0), select randomly based on + // If (not every invoker has the same weight & at least one invoker's weight>0), select randomly based on // totalWeight. int offsetWeight = ThreadLocalRandom.current().nextInt(totalWeight); // Return a invoker based on the random value. diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RandomLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RandomLoadBalance.java index ce5bdaa16c..1b0b9fce7e 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RandomLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RandomLoadBalance.java @@ -21,6 +21,7 @@ import org.apache.dubbo.common.utils.StringUtils; import org.apache.dubbo.rpc.Invocation; import org.apache.dubbo.rpc.Invoker; import org.apache.dubbo.rpc.cluster.ClusterInvoker; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.Arrays; import java.util.List; @@ -115,7 +116,7 @@ public class RandomLoadBalance extends AbstractLoadBalance { String weight = invokerUrl.getParameter(WEIGHT_KEY); return StringUtils.isNotEmpty(weight); } else { - String weight = invokerUrl.getMethodParameter(invocation.getMethodName(), WEIGHT_KEY); + String weight = invokerUrl.getMethodParameter(RpcUtils.getMethodName(invocation), WEIGHT_KEY); if (StringUtils.isNotEmpty(weight)) { return true; } else { diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java index 8a24a4af4a..0ee6a82c5d 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java @@ -20,6 +20,7 @@ import org.apache.dubbo.common.URL; import org.apache.dubbo.common.utils.ConcurrentHashMapUtils; import org.apache.dubbo.rpc.Invocation; import org.apache.dubbo.rpc.Invoker; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.Collection; import java.util.List; @@ -79,7 +80,7 @@ public class RoundRobinLoadBalance extends AbstractLoadBalance { * @return */ protected Collection getInvokerAddrList(List> invokers, Invocation invocation) { - String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName(); + String key = invokers.get(0).getUrl().getServiceKey() + "." + RpcUtils.getMethodName(invocation); Map map = methodWeightMap.get(key); if (map != null) { return map.keySet(); @@ -89,7 +90,7 @@ public class RoundRobinLoadBalance extends AbstractLoadBalance { @Override protected Invoker doSelect(List> invokers, URL url, Invocation invocation) { - String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName(); + String key = invokers.get(0).getUrl().getServiceKey() + "." + RpcUtils.getMethodName(invocation); ConcurrentMap map = ConcurrentHashMapUtils.computeIfAbsent(methodWeightMap, key, k -> new ConcurrentHashMap<>()); int totalWeight = 0; long maxCurrent = Long.MIN_VALUE; diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ShortestResponseLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ShortestResponseLoadBalance.java index 9b9eae5005..67df332e48 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ShortestResponseLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ShortestResponseLoadBalance.java @@ -25,6 +25,7 @@ import org.apache.dubbo.rpc.RpcStatus; import org.apache.dubbo.rpc.cluster.Constants; import org.apache.dubbo.rpc.model.ApplicationModel; import org.apache.dubbo.rpc.model.ScopeModelAware; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.List; import java.util.concurrent.ConcurrentHashMap; @@ -116,7 +117,7 @@ public class ShortestResponseLoadBalance extends AbstractLoadBalance implements // Filter out all the shortest response invokers for (int i = 0; i < length; i++) { Invoker invoker = invokers.get(i); - RpcStatus rpcStatus = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()); + RpcStatus rpcStatus = RpcStatus.getStatus(invoker.getUrl(), RpcUtils.getMethodName(invocation)); SlideWindowData slideWindowData = ConcurrentHashMapUtils.computeIfAbsent(methodMap, rpcStatus, SlideWindowData::new); // Calculate the estimated response time from the product of active connections and succeeded average elapsed time. diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/matcher/AbstractConditionMatcher.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/matcher/AbstractConditionMatcher.java index 1dc8310700..db5cd94b95 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/matcher/AbstractConditionMatcher.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/matcher/AbstractConditionMatcher.java @@ -22,6 +22,7 @@ import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.rpc.Invocation; import org.apache.dubbo.rpc.cluster.router.condition.matcher.pattern.ValuePattern; import org.apache.dubbo.rpc.model.ModuleModel; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.HashSet; import java.util.List; @@ -55,7 +56,7 @@ public abstract class AbstractConditionMatcher implements ConditionMatcher { String sampleValue; //get real invoked method name from invocation if (invocation != null && (METHOD_KEY.equals(conditionKey) || METHODS_KEY.equals(conditionKey))) { - sampleValue = invocation.getMethodName(); + sampleValue = RpcUtils.getMethodName(invocation); } else { sampleValue = sample.get(conditionKey); } diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/mesh/rule/virtualservice/match/DubboMethodMatch.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/mesh/rule/virtualservice/match/DubboMethodMatch.java index 32644cf526..f252410478 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/mesh/rule/virtualservice/match/DubboMethodMatch.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/mesh/rule/virtualservice/match/DubboMethodMatch.java @@ -18,6 +18,7 @@ package org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.match; import org.apache.dubbo.rpc.Invocation; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.List; import java.util.Map; @@ -83,7 +84,7 @@ public class DubboMethodMatch { public boolean isMatch(Invocation invocation) { StringMatch nameMatch = getName_match(); - if (nameMatch != null && !nameMatch.isMatch(invocation.getMethodName())) { + if (nameMatch != null && !nameMatch.isMatch(RpcUtils.getMethodName(invocation))) { return false; } diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/script/ScriptStateRouter.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/script/ScriptStateRouter.java index ac01380be1..d0f918094a 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/script/ScriptStateRouter.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/script/ScriptStateRouter.java @@ -29,6 +29,7 @@ import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.cluster.router.RouterSnapshotNode; import org.apache.dubbo.rpc.cluster.router.state.AbstractStateRouter; import org.apache.dubbo.rpc.cluster.router.state.BitList; +import org.apache.dubbo.rpc.support.RpcUtils; import javax.script.Bindings; import javax.script.Compilable; @@ -139,7 +140,7 @@ public class ScriptStateRouter extends AbstractStateRouter { return function.eval(bindings); } catch (ScriptException e) { logger.error(CLUSTER_SCRIPT_EXCEPTION, "Scriptrouter exec script error", "", "Script route error, rule has been ignored. rule: " + rule + ", method:" + - invocation.getMethodName() + ", url: " + RpcContext.getContext().getUrl(), e); + RpcUtils.getMethodName(invocation) + ", url: " + RpcContext.getContext().getUrl(), e); return invokers; } }, accessControlContext)); diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvoker.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvoker.java index 89c58a6dc9..f6325df43b 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvoker.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvoker.java @@ -158,7 +158,7 @@ public abstract class AbstractClusterInvoker implements ClusterInvoker { if (CollectionUtils.isEmpty(invokers)) { return null; } - String methodName = invocation == null ? StringUtils.EMPTY_STRING : invocation.getMethodName(); + String methodName = invocation == null ? StringUtils.EMPTY_STRING : RpcUtils.getMethodName(invocation); boolean sticky = invokers.get(0).getUrl() .getMethodParameter(methodName, CLUSTER_STICKY_KEY, DEFAULT_CLUSTER_STICKY); @@ -363,7 +363,7 @@ public abstract class AbstractClusterInvoker implements ClusterInvoker { protected void checkInvokers(List> invokers, Invocation invocation) { if (CollectionUtils.isEmpty(invokers)) { throw new RpcException(RpcException.NO_INVOKER_AVAILABLE_AFTER_FILTER, "Failed to invoke the method " - + invocation.getMethodName() + " in the service " + getInterface().getName() + + RpcUtils.getMethodName(invocation) + " in the service " + getInterface().getName() + ". No provider available for the service " + getDirectory().getConsumerUrl().getServiceKey() + " from registry " + getDirectory().getUrl().getAddress() + " on the consumer " + NetUtils.getLocalHost() diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/FailbackClusterInvoker.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/FailbackClusterInvoker.java index 368244a1df..1a20839768 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/FailbackClusterInvoker.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/FailbackClusterInvoker.java @@ -32,6 +32,7 @@ import org.apache.dubbo.rpc.RpcContext; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.cluster.Directory; import org.apache.dubbo.rpc.cluster.LoadBalance; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.Collections; import java.util.List; @@ -109,7 +110,9 @@ public class FailbackClusterInvoker extends AbstractClusterInvoker { // Then the serviceContext will be cleared after the call is completed. return invokeWithContextAsync(invoker, invocation, consumerUrl); } catch (Throwable e) { - logger.error(CLUSTER_FAILED_INVOKE_SERVICE,"Failback to invoke method and start to retries","","Failback to invoke method " + invocation.getMethodName() + ", wait for retry in background. Ignored exception: " + logger.error(CLUSTER_FAILED_INVOKE_SERVICE,"Failback to invoke method and start to retries", + "","Failback to invoke method " + RpcUtils.getMethodName(invocation) + + ", wait for retry in background. Ignored exception: " + e.getMessage() + ", ",e); if (retries > 0) { addFailed(loadbalance, invocation, invokers, invoker, consumerUrl); @@ -161,13 +164,13 @@ public class FailbackClusterInvoker extends AbstractClusterInvoker { @Override public void run(Timeout timeout) { try { - logger.info("Attempt to retry to invoke method " + invocation.getMethodName() + + logger.info("Attempt to retry to invoke method " + RpcUtils.getMethodName(invocation) + ". The total will retry " + retries + " times, the current is the " + retriedTimes + " retry"); Invoker retryInvoker = select(loadbalance, invocation, invokers, Collections.singletonList(lastInvoker)); lastInvoker = retryInvoker; invokeWithContextAsync(retryInvoker, invocation, consumerUrl); } catch (Throwable e) { - logger.error(CLUSTER_FAILED_INVOKE_SERVICE,"Failed retry to invoke method","","Failed retry to invoke method " + invocation.getMethodName() + ", waiting again.",e); + logger.error(CLUSTER_FAILED_INVOKE_SERVICE,"Failed retry to invoke method","","Failed retry to invoke method " + RpcUtils.getMethodName(invocation) + ", waiting again.",e); if ((++retriedTimes) >= retries) { logger.error(CLUSTER_FAILED_INVOKE_SERVICE,"Failed retry to invoke method and retry times exceed threshold","","Failed retry times exceed threshold (" + retries + "), We have to abandon, invocation->" + invocation,e); } else { diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/FailfastClusterInvoker.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/FailfastClusterInvoker.java index 22c708f824..87b3b45c5a 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/FailfastClusterInvoker.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/FailfastClusterInvoker.java @@ -24,6 +24,7 @@ import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.cluster.Directory; import org.apache.dubbo.rpc.cluster.LoadBalance; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.List; @@ -51,7 +52,7 @@ public class FailfastClusterInvoker extends AbstractClusterInvoker { throw new RpcException(e instanceof RpcException ? ((RpcException) e).getCode() : 0, "Failfast invoke providers " + invoker.getUrl() + " " + loadbalance.getClass().getSimpleName() + " for service " + getInterface().getName() - + " method " + invocation.getMethodName() + " on consumer " + NetUtils.getLocalHost() + + " method " + RpcUtils.getMethodName(invocation) + " on consumer " + NetUtils.getLocalHost() + " use dubbo version " + Version.getVersion() + ", but no luck to perform the invocation. Last error is: " + e.getMessage(), e.getCause() != null ? e.getCause() : e); diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java index a935fd95ea..348c6e032d 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java @@ -97,13 +97,13 @@ public class MockClusterInvoker implements ClusterInvoker { public Result invoke(Invocation invocation) throws RpcException { Result result; - String value = getUrl().getMethodParameter(invocation.getMethodName(), MOCK_KEY, Boolean.FALSE.toString()).trim(); + String value = getUrl().getMethodParameter(RpcUtils.getMethodName(invocation), MOCK_KEY, Boolean.FALSE.toString()).trim(); if (ConfigUtils.isEmpty(value)) { //no mock result = this.invoker.invoke(invocation); } else if (value.startsWith(FORCE_KEY)) { if (logger.isWarnEnabled()) { - logger.warn(CLUSTER_FAILED_MOCK_REQUEST,"force mock","","force-mock: " + invocation.getMethodName() + " force-mock enabled , url : " + getUrl()); + logger.warn(CLUSTER_FAILED_MOCK_REQUEST,"force mock","","force-mock: " + RpcUtils.getMethodName(invocation) + " force-mock enabled , url : " + getUrl()); } //force:direct mock result = doMockInvoke(invocation, null); @@ -128,7 +128,7 @@ public class MockClusterInvoker implements ClusterInvoker { } if (logger.isWarnEnabled()) { - logger.warn(CLUSTER_FAILED_MOCK_REQUEST,"failed to mock invoke","","fail-mock: " + invocation.getMethodName() + " fail-mock enabled , url : " + getUrl(),e); + logger.warn(CLUSTER_FAILED_MOCK_REQUEST,"failed to mock invoke","","fail-mock: " + RpcUtils.getMethodName(invocation) + " fail-mock enabled , url : " + getUrl(),e); } result = doMockInvoke(invocation, e); } @@ -198,7 +198,7 @@ public class MockClusterInvoker implements ClusterInvoker { } catch (RpcException e) { if (logger.isInfoEnabled()) { logger.info("Exception when try to invoke mock. Get mock invokers error for service:" - + getUrl().getServiceInterface() + ", method:" + invocation.getMethodName() + + getUrl().getServiceInterface() + ", method:" + RpcUtils.getMethodName(invocation) + ", will construct a new mock with 'new MockInvoker()'.", e); } } diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/ScopeClusterInvoker.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/ScopeClusterInvoker.java index 71b7ddf95d..a0564c9b0a 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/ScopeClusterInvoker.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/ScopeClusterInvoker.java @@ -35,6 +35,7 @@ import org.apache.dubbo.rpc.cluster.Directory; import org.apache.dubbo.rpc.cluster.directory.StaticDirectory; import org.apache.dubbo.rpc.listener.ExporterChangeListener; import org.apache.dubbo.rpc.listener.InjvmExporterListener; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.ArrayList; import java.util.List; @@ -142,26 +143,26 @@ public class ScopeClusterInvoker implements ClusterInvoker, ExporterChange // When broadcasting, it should be called remotely. if (isBroadcast()) { if (logger.isDebugEnabled()) { - logger.debug("Performing broadcast call for method: " + invocation.getMethodName() + " of service: " + getUrl().getServiceKey()); + logger.debug("Performing broadcast call for method: " + RpcUtils.getMethodName(invocation) + " of service: " + getUrl().getServiceKey()); } return invoker.invoke(invocation); } if (peerFlag) { if (logger.isDebugEnabled()) { - logger.debug("Performing point-to-point call for method: " + invocation.getMethodName() + " of service: " + getUrl().getServiceKey()); + logger.debug("Performing point-to-point call for method: " + RpcUtils.getMethodName(invocation) + " of service: " + getUrl().getServiceKey()); } // If it's a point-to-point direct connection, invoke the original Invoker return invoker.invoke(invocation); } if (isInjvmExported()) { if (logger.isDebugEnabled()) { - logger.debug("Performing local JVM call for method: " + invocation.getMethodName() + " of service: " + getUrl().getServiceKey()); + logger.debug("Performing local JVM call for method: " + RpcUtils.getMethodName(invocation) + " of service: " + getUrl().getServiceKey()); } // If it's exported to the local JVM, invoke the corresponding Invoker return injvmInvoker.invoke(invocation); } if (logger.isDebugEnabled()) { - logger.debug("Performing remote call for method: " + invocation.getMethodName() + " of service: " + getUrl().getServiceKey()); + logger.debug("Performing remote call for method: " + RpcUtils.getMethodName(invocation) + " of service: " + getUrl().getServiceKey()); } // Otherwise, delegate the invocation to the original Invoker return invoker.invoke(invocation); diff --git a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java index a8a39062ad..98f9aa78fd 100644 --- a/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java +++ b/dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java @@ -17,6 +17,8 @@ package com.alibaba.dubbo.rpc.cluster.loadbalance; +import org.apache.dubbo.rpc.support.RpcUtils; + import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; import com.alibaba.dubbo.rpc.Invocation; @@ -40,7 +42,7 @@ public abstract class AbstractLoadBalance implements LoadBalance { protected abstract Invoker doSelect(List> invokers, URL url, Invocation invocation); protected int getWeight(Invoker invoker, Invocation invocation) { - int weight = invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.WEIGHT_KEY, Constants.DEFAULT_WEIGHT); + int weight = invoker.getUrl().getMethodParameter(RpcUtils.getMethodName(invocation), Constants.WEIGHT_KEY, Constants.DEFAULT_WEIGHT); if (weight > 0) { long timestamp = invoker.getUrl().getParameter(Constants.TIMESTAMP_KEY, 0L); if (timestamp > 0L) { diff --git a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/data/RtStatComposite.java b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/data/RtStatComposite.java index a6e7a681d2..c440a35b77 100644 --- a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/data/RtStatComposite.java +++ b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/data/RtStatComposite.java @@ -30,6 +30,7 @@ import org.apache.dubbo.metrics.model.sample.MetricSample; import org.apache.dubbo.metrics.report.AbstractMetricsExport; import org.apache.dubbo.rpc.Invocation; import org.apache.dubbo.rpc.model.ApplicationModel; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.ArrayList; import java.util.Arrays; @@ -94,7 +95,7 @@ public class RtStatComposite extends AbstractMetricsExport { public void calcMethodKeyRt(Invocation invocation, String registryOpType, Long responseTime) { for (LongContainer container : rtStats.stream().filter(longContainer -> longContainer.specifyType(registryOpType)).collect(Collectors.toList())) { - Number current = (Number) ConcurrentHashMapUtils.computeIfAbsent(container, invocation.getTargetServiceUniqueName() + "_" + invocation.getMethodName(), container.getInitFunc()); + Number current = (Number) ConcurrentHashMapUtils.computeIfAbsent(container, invocation.getTargetServiceUniqueName() + "_" + RpcUtils.getMethodName(invocation), container.getInitFunc()); container.getConsumerFunc().accept(responseTime, current); } } diff --git a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MethodMetric.java b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MethodMetric.java index 1985dae228..d3f47a7d8a 100644 --- a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MethodMetric.java +++ b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MethodMetric.java @@ -20,6 +20,7 @@ package org.apache.dubbo.metrics.model; import org.apache.dubbo.metrics.model.sample.MetricSample; import org.apache.dubbo.rpc.Invocation; import org.apache.dubbo.rpc.model.ApplicationModel; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.Map; import java.util.Objects; @@ -40,7 +41,7 @@ public class MethodMetric extends ServiceKeyMetric { public MethodMetric(ApplicationModel applicationModel, Invocation invocation) { super(applicationModel, MetricsSupport.getInterfaceName(invocation)); - this.methodName = MetricsSupport.getMethodName(invocation); + this.methodName = RpcUtils.getMethodName(invocation); this.side = MetricsSupport.getSide(invocation); this.group = MetricsSupport.getGroup(invocation); this.version = MetricsSupport.getVersion(invocation); diff --git a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsSupport.java b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsSupport.java index a8f26efd13..b444f7a4a7 100644 --- a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsSupport.java +++ b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsSupport.java @@ -30,7 +30,6 @@ import org.apache.dubbo.metrics.model.key.MetricsPlaceValue; import org.apache.dubbo.rpc.Invocation; import org.apache.dubbo.rpc.Invoker; import org.apache.dubbo.rpc.RpcException; -import org.apache.dubbo.rpc.RpcInvocation; import org.apache.dubbo.rpc.model.ApplicationModel; import java.util.HashMap; @@ -55,7 +54,6 @@ import static org.apache.dubbo.common.utils.NetUtils.getLocalHostName; import static org.apache.dubbo.metrics.MetricsConstants.ATTACHMENT_KEY_SERVICE; import static org.apache.dubbo.metrics.MetricsConstants.INVOCATION; import static org.apache.dubbo.metrics.MetricsConstants.SELF_INCREMENT_SIZE; -import static org.apache.dubbo.rpc.support.RpcUtils.isGenericCall; public class MetricsSupport { @@ -159,17 +157,6 @@ public class MetricsSupport { return ivArr[0]; } - public static String getMethodName(Invocation invocation) { - String methodName = invocation.getMethodName(); - if (invocation instanceof RpcInvocation - && isGenericCall(((RpcInvocation) invocation).getParameterTypesDesc(), methodName) - && invocation.getArguments() != null - && invocation.getArguments().length == 3) { - methodName = ((String) invocation.getArguments()[0]).trim(); - } - return methodName; - } - public static String getGroup(Invocation invocation) { String serviceUniqueName = invocation.getTargetServiceUniqueName(); String group = null; diff --git a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java b/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java index f8afc4a588..2d0ec9823b 100644 --- a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java +++ b/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java @@ -116,7 +116,7 @@ public class MonitorFilter implements Filter, Filter.Listener { * @return */ private AtomicInteger getConcurrent(Invoker invoker, Invocation invocation) { - String key = invoker.getInterface().getName() + "." + invocation.getMethodName(); + String key = invoker.getInterface().getName() + "." + RpcUtils.getMethodName(invocation); return ConcurrentHashMapUtils.computeIfAbsent(concurrents, key, k -> new AtomicInteger()); } diff --git a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/AccessKeyAuthenticator.java b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/AccessKeyAuthenticator.java index d4c7750ed1..875a3c3304 100644 --- a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/AccessKeyAuthenticator.java +++ b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/AccessKeyAuthenticator.java @@ -27,6 +27,7 @@ import org.apache.dubbo.common.constants.CommonConstants; import org.apache.dubbo.common.utils.StringUtils; import org.apache.dubbo.rpc.Invocation; import org.apache.dubbo.rpc.model.ApplicationModel; +import org.apache.dubbo.rpc.support.RpcUtils; public class AccessKeyAuthenticator implements Authenticator { private final ApplicationModel applicationModel; @@ -54,7 +55,7 @@ public class AccessKeyAuthenticator implements Authenticator { if (StringUtils.isAnyEmpty(accessKeyId, consumer, requestTimestamp, originSignature)) { throw new RpcAuthenticationException("Failed to authenticate, maybe consumer side did not enable the auth"); } - + AccessKeyPair accessKeyPair; try { accessKeyPair = getAccessKeyPair(invocation, url); @@ -86,7 +87,7 @@ public class AccessKeyAuthenticator implements Authenticator { } String getSignature(URL url, Invocation invocation, String secretKey, String time) { - String requestString = String.format(Constants.SIGNATURE_STRING_FORMAT, url.getColonSeparatedKey(), invocation.getMethodName(), secretKey, time); + String requestString = String.format(Constants.SIGNATURE_STRING_FORMAT, url.getColonSeparatedKey(), RpcUtils.getMethodName(invocation), secretKey, time); boolean parameterEncrypt = url.getParameter(Constants.PARAMETER_SIGNATURE_ENABLE_KEY, false); if (parameterEncrypt) { return SignatureUtils.sign(invocation.getArguments(), requestString, secretKey); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/AccessLogFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/AccessLogFilter.java index 0ad448d487..184aaf2001 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/AccessLogFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/AccessLogFilter.java @@ -30,6 +30,7 @@ import org.apache.dubbo.rpc.Invoker; import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.support.AccessLogData; +import org.apache.dubbo.rpc.support.RpcUtils; import java.io.File; import java.io.FileWriter; @@ -198,7 +199,7 @@ public class AccessLogFilter implements Filter { private AccessLogData buildAccessLogData(Invoker invoker, Invocation inv) { AccessLogData logData = AccessLogData.newLogData(); logData.setServiceName(invoker.getInterface().getName()); - logData.setMethodName(inv.getMethodName()); + logData.setMethodName(RpcUtils.getMethodName(inv)); logData.setVersion(invoker.getUrl().getVersion()); logData.setGroup(invoker.getUrl().getGroup()); logData.setInvocationTime(new Date()); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java index dc954d70e6..6123b5ba10 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java @@ -24,6 +24,7 @@ import org.apache.dubbo.rpc.Invoker; import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.RpcStatus; +import org.apache.dubbo.rpc.support.RpcUtils; import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER; import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY; @@ -49,11 +50,11 @@ public class ActiveLimitFilter implements Filter, Filter.Listener { @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { URL url = invoker.getUrl(); - String methodName = invocation.getMethodName(); + String methodName = RpcUtils.getMethodName(invocation); int max = invoker.getUrl().getMethodParameter(methodName, ACTIVES_KEY, 0); - final RpcStatus rpcStatus = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()); + final RpcStatus rpcStatus = RpcStatus.getStatus(invoker.getUrl(), RpcUtils.getMethodName(invocation)); if (!RpcStatus.beginCount(url, methodName, max)) { - long timeout = invoker.getUrl().getMethodParameter(invocation.getMethodName(), TIMEOUT_KEY, 0); + long timeout = invoker.getUrl().getMethodParameter(RpcUtils.getMethodName(invocation), TIMEOUT_KEY, 0); long start = System.currentTimeMillis(); long remain = timeout; synchronized (rpcStatus) { @@ -68,7 +69,7 @@ public class ActiveLimitFilter implements Filter, Filter.Listener { if (remain <= 0) { throw new RpcException(RpcException.LIMIT_EXCEEDED_EXCEPTION, "Waiting concurrent invoke timeout in client-side for service: " + - invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + + invoker.getInterface().getName() + ", method: " + RpcUtils.getMethodName(invocation) + ", elapsed: " + elapsed + ", timeout: " + timeout + ". concurrent invokes: " + rpcStatus.getActive() + ". max concurrent invoke limit: " + max); } @@ -83,7 +84,7 @@ public class ActiveLimitFilter implements Filter, Filter.Listener { @Override public void onResponse(Result appResponse, Invoker invoker, Invocation invocation) { - String methodName = invocation.getMethodName(); + String methodName = RpcUtils.getMethodName(invocation); URL url = invoker.getUrl(); int max = invoker.getUrl().getMethodParameter(methodName, ACTIVES_KEY, 0); @@ -93,7 +94,7 @@ public class ActiveLimitFilter implements Filter, Filter.Listener { @Override public void onError(Throwable t, Invoker invoker, Invocation invocation) { - String methodName = invocation.getMethodName(); + String methodName = RpcUtils.getMethodName(invocation); URL url = invoker.getUrl(); int max = invoker.getUrl().getMethodParameter(methodName, ACTIVES_KEY, 0); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/DeprecatedFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/DeprecatedFilter.java index 98654af030..228cc44a82 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/DeprecatedFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/DeprecatedFilter.java @@ -26,6 +26,7 @@ import org.apache.dubbo.rpc.Invocation; import org.apache.dubbo.rpc.Invoker; import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcException; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.Set; @@ -47,10 +48,10 @@ public class DeprecatedFilter implements Filter { @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { - String key = invoker.getInterface().getName() + "." + invocation.getMethodName(); + String key = invoker.getInterface().getName() + "." + RpcUtils.getMethodName(invocation); if (!LOGGED.contains(key)) { LOGGED.add(key); - if (invoker.getUrl().getMethodParameter(invocation.getMethodName(), DEPRECATED_KEY, false)) { + if (invoker.getUrl().getMethodParameter(RpcUtils.getMethodName(invocation), DEPRECATED_KEY, false)) { LOGGER.error(COMMON_UNSUPPORTED_INVOKER, "", "", "The service method " + invoker.getInterface().getName() + "." + getMethodSignature(invocation) + " is DEPRECATED! Declare from " + invoker.getUrl()); } } @@ -58,7 +59,7 @@ public class DeprecatedFilter implements Filter { } private String getMethodSignature(Invocation invocation) { - StringBuilder buf = new StringBuilder(invocation.getMethodName()); + StringBuilder buf = new StringBuilder(RpcUtils.getMethodName(invocation)); buf.append('('); Class[] types = invocation.getParameterTypes(); if (types != null && types.length > 0) { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ExceptionFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ExceptionFilter.java index 91c830cb53..2cadfec117 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ExceptionFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ExceptionFilter.java @@ -29,6 +29,7 @@ import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcContext; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.service.GenericService; +import org.apache.dubbo.rpc.support.RpcUtils; import java.lang.reflect.Method; @@ -66,7 +67,7 @@ public class ExceptionFilter implements Filter, Filter.Listener { } // directly throw if the exception appears in the signature try { - Method method = invoker.getInterface().getMethod(invocation.getMethodName(), invocation.getParameterTypes()); + Method method = invoker.getInterface().getMethod(RpcUtils.getMethodName(invocation), invocation.getParameterTypes()); Class[] exceptionClasses = method.getExceptionTypes(); for (Class exceptionClass : exceptionClasses) { if (exception.getClass().equals(exceptionClass)) { @@ -78,7 +79,10 @@ public class ExceptionFilter implements Filter, Filter.Listener { } // for the exception not found in method's signature, print ERROR message in server's log. - logger.error(CONFIG_FILTER_VALIDATION_EXCEPTION, "", "", "Got unchecked and undeclared exception which called by " + RpcContext.getServiceContext().getRemoteHost() + ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", exception: " + exception.getClass().getName() + ": " + exception.getMessage(), exception); + logger.error(CONFIG_FILTER_VALIDATION_EXCEPTION, "", "", + "Got unchecked and undeclared exception which called by " + RpcContext.getServiceContext().getRemoteHost() + + ". service: " + invoker.getInterface().getName() + ", method: " + RpcUtils.getMethodName(invocation) + + ", exception: " + exception.getClass().getName() + ": " + exception.getMessage(), exception); // directly throw if exception class and interface class are in the same jar file. String serviceFile = ReflectUtils.getCodeBase(invoker.getInterface()); @@ -99,14 +103,20 @@ public class ExceptionFilter implements Filter, Filter.Listener { // otherwise, wrap with RuntimeException and throw back to the client appResponse.setException(new RuntimeException(StringUtils.toString(exception))); } catch (Throwable e) { - logger.warn(CONFIG_FILTER_VALIDATION_EXCEPTION, "", "", "Fail to ExceptionFilter when called by " + RpcContext.getServiceContext().getRemoteHost() + ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e); + logger.warn(CONFIG_FILTER_VALIDATION_EXCEPTION, "", "", + "Fail to ExceptionFilter when called by " + RpcContext.getServiceContext().getRemoteHost() + + ". service: " + invoker.getInterface().getName() + ", method: " + RpcUtils.getMethodName(invocation) + + ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e); } } } @Override public void onError(Throwable e, Invoker invoker, Invocation invocation) { - logger.error(CONFIG_FILTER_VALIDATION_EXCEPTION, "", "", "Got unchecked and undeclared exception which called by " + RpcContext.getServiceContext().getRemoteHost() + ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e); + logger.error(CONFIG_FILTER_VALIDATION_EXCEPTION, "", "", + "Got unchecked and undeclared exception which called by " + RpcContext.getServiceContext().getRemoteHost() + + ". service: " + invoker.getInterface().getName() + ", method: " + RpcUtils.getMethodName(invocation) + + ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e); } // For test purpose diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ExecuteLimitFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ExecuteLimitFilter.java index da36479724..e77e512f3e 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ExecuteLimitFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ExecuteLimitFilter.java @@ -26,9 +26,10 @@ import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.RpcStatus; import org.apache.dubbo.rpc.service.GenericService; +import org.apache.dubbo.rpc.support.RpcUtils; + import static org.apache.dubbo.common.constants.CommonConstants.$INVOKE; import static org.apache.dubbo.common.constants.CommonConstants.$INVOKE_ASYNC; - import static org.apache.dubbo.rpc.Constants.EXECUTES_KEY; @@ -45,11 +46,11 @@ public class ExecuteLimitFilter implements Filter, Filter.Listener { @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { URL url = invoker.getUrl(); - String methodName = invocation.getMethodName(); + String methodName = RpcUtils.getMethodName(invocation); int max = url.getMethodParameter(methodName, EXECUTES_KEY, 0); if (!RpcStatus.beginCount(url, methodName, max)) { throw new RpcException(RpcException.LIMIT_EXCEEDED_EXCEPTION, - "Failed to invoke method " + invocation.getMethodName() + " in provider " + + "Failed to invoke method " + RpcUtils.getMethodName(invocation) + " in provider " + url + ", cause: The service using threads greater than limited."); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ProfilerServerFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ProfilerServerFilter.java index 97f108d60b..36aa5c8ca0 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ProfilerServerFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ProfilerServerFilter.java @@ -103,7 +103,7 @@ public class ProfilerServerFilter implements Filter, BaseFilter.Listener { Long timeout = RpcUtils.convertToNumber(invocation.getObjectAttachmentWithoutConvert(TIMEOUT_KEY)); if (timeout == null) { - timeout = (long) invoker.getUrl().getMethodPositiveParameter(invocation.getMethodName(), TIMEOUT_KEY, DEFAULT_TIMEOUT); + timeout = (long) invoker.getUrl().getMethodPositiveParameter(RpcUtils.getMethodName(invocation), TIMEOUT_KEY, DEFAULT_TIMEOUT); } long usage = profiler.getEndTime() - profiler.getStartTime(); if (((usage / (1000_000L * ProfilerSwitch.getWarnPercent())) > timeout) && timeout != -1) { @@ -118,7 +118,7 @@ public class ProfilerServerFilter implements Filter, BaseFilter.Listener { "client: %s\n" + "invocation context:\n%s" + "thread info: \n%s", - invocation.getTargetServiceUniqueName(), invocation.getMethodName(), usage / 1000_000, usage % 1000_000, timeout, + invocation.getTargetServiceUniqueName(), RpcUtils.getMethodName(invocation), usage / 1000_000, usage % 1000_000, timeout, invocation.get(CLIENT_IP_KEY), attachment, Profiler.buildDetail(profiler))); } } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TimeoutFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TimeoutFilter.java index f4dae94073..dac40680de 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TimeoutFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TimeoutFilter.java @@ -27,6 +27,7 @@ import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcContext; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.TimeoutCountDown; +import org.apache.dubbo.rpc.support.RpcUtils; import static org.apache.dubbo.common.constants.CommonConstants.TIME_COUNTDOWN_KEY; import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROXY_TIMEOUT_REQUEST; @@ -51,7 +52,7 @@ public class TimeoutFilter implements Filter, Filter.Listener { TimeoutCountDown countDown = (TimeoutCountDown) obj; if (countDown.isExpired()) { if (logger.isWarnEnabled()) { - logger.warn(PROXY_TIMEOUT_REQUEST, "", "", "invoke timed out. method: " + invocation.getMethodName() + + logger.warn(PROXY_TIMEOUT_REQUEST, "", "", "invoke timed out. method: " + RpcUtils.getMethodName(invocation) + " url is " + invoker.getUrl() + ", invoke elapsed " + countDown.elapsedMillis() + " ms."); } } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TokenFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TokenFilter.java index 056d27e6a1..f00dae649d 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TokenFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TokenFilter.java @@ -25,6 +25,7 @@ import org.apache.dubbo.rpc.Invoker; import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcContext; import org.apache.dubbo.rpc.RpcException; +import org.apache.dubbo.rpc.support.RpcUtils; import static org.apache.dubbo.rpc.Constants.TOKEN_KEY; @@ -45,7 +46,7 @@ public class TokenFilter implements Filter { Class serviceType = invoker.getInterface(); String remoteToken = (String) inv.getObjectAttachmentWithoutConvert(TOKEN_KEY); if (!token.equals(remoteToken)) { - throw new RpcException("Invalid token! Forbid invoke remote service " + serviceType + " method " + inv.getMethodName() + + throw new RpcException("Invalid token! Forbid invoke remote service " + serviceType + " method " + RpcUtils.getMethodName(inv) + "() from consumer " + RpcContext.getServiceContext().getRemoteHost() + " to provider " + RpcContext.getServiceContext().getLocalHost()+ ", consumer incorrect token is " + remoteToken); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TokenHeaderFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TokenHeaderFilter.java index d72b790a47..583e91d4cc 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TokenHeaderFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TokenHeaderFilter.java @@ -23,6 +23,7 @@ import org.apache.dubbo.rpc.Invoker; import org.apache.dubbo.rpc.RpcContext; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.RpcInvocation; +import org.apache.dubbo.rpc.support.RpcUtils; import static org.apache.dubbo.rpc.Constants.TOKEN_KEY; import static org.apache.dubbo.rpc.RpcException.FORBIDDEN_EXCEPTION; @@ -36,7 +37,7 @@ public class TokenHeaderFilter implements HeaderFilter { Class serviceType = invoker.getInterface(); String remoteToken = (String) invocation.getObjectAttachmentWithoutConvert(TOKEN_KEY); if (!token.equals(remoteToken)) { - throw new RpcException(FORBIDDEN_EXCEPTION, "Forbid invoke remote service " + serviceType + " method " + invocation.getMethodName() + + throw new RpcException(FORBIDDEN_EXCEPTION, "Forbid invoke remote service " + serviceType + " method " + RpcUtils.getMethodName(invocation) + "() from consumer " + RpcContext.getServiceContext().getRemoteHost() + " to provider " + RpcContext.getServiceContext().getLocalHost() + ", consumer incorrect token is " + remoteToken); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TpsLimitFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TpsLimitFilter.java index 4678e0109f..e06444d693 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TpsLimitFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TpsLimitFilter.java @@ -26,6 +26,7 @@ import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.filter.tps.DefaultTPSLimiter; import org.apache.dubbo.rpc.filter.tps.TPSLimiter; +import org.apache.dubbo.rpc.support.RpcUtils; import static org.apache.dubbo.rpc.Constants.TPS_LIMIT_RATE_KEY; @@ -49,7 +50,7 @@ public class TpsLimitFilter implements Filter { "Failed to invoke service " + invoker.getInterface().getName() + "." + - invocation.getMethodName() + + RpcUtils.getMethodName(invocation) + " because exceed max service tps."); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/tps/DefaultTPSLimiter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/tps/DefaultTPSLimiter.java index 05d32ca483..9d638c0278 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/tps/DefaultTPSLimiter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/tps/DefaultTPSLimiter.java @@ -18,6 +18,7 @@ package org.apache.dubbo.rpc.filter.tps; import org.apache.dubbo.common.URL; import org.apache.dubbo.rpc.Invocation; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -38,8 +39,8 @@ public class DefaultTPSLimiter implements TPSLimiter { @Override public boolean isAllowable(URL url, Invocation invocation) { - int rate = url.getMethodParameter(invocation.getMethodName(), TPS_LIMIT_RATE_KEY, -1); - long interval = url.getMethodParameter(invocation.getMethodName(), TPS_LIMIT_INTERVAL_KEY, DEFAULT_TPS_LIMIT_INTERVAL); + int rate = url.getMethodParameter(RpcUtils.getMethodName(invocation), TPS_LIMIT_RATE_KEY, -1); + long interval = url.getMethodParameter(RpcUtils.getMethodName(invocation), TPS_LIMIT_INTERVAL_KEY, DEFAULT_TPS_LIMIT_INTERVAL); String serviceKey = url.getServiceKey(); if (rate > 0) { StatItem statItem = stats.get(serviceKey); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/AccessLogData.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/AccessLogData.java index 0265517eae..a3acfb2efd 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/AccessLogData.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/AccessLogData.java @@ -284,7 +284,7 @@ public final class AccessLogData { public void buildAccessLogData(Invoker invoker, Invocation inv) { setServiceName(invoker.getInterface().getName()); - setMethodName(inv.getMethodName()); + setMethodName(RpcUtils.getMethodName(inv)); setVersion(invoker.getUrl().getVersion()); setGroup(invoker.getUrl().getGroup()); setInvocationTime(new Date()); diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java index 9723ebf78f..2bc90887fb 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java @@ -39,6 +39,7 @@ import org.apache.dubbo.rpc.model.ModuleModel; import org.apache.dubbo.rpc.model.ProviderModel; import org.apache.dubbo.rpc.model.ServiceDescriptor; import org.apache.dubbo.rpc.model.ServiceMetadata; +import org.apache.dubbo.rpc.support.RpcUtils; import java.io.IOException; import java.util.HashMap; @@ -52,9 +53,9 @@ import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY; import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY; import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY; import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY; +import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_TYPE_MISMATCH; import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_DESTROY_INVOKER; import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_LOAD_MODEL; -import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_TYPE_MISMATCH; import static org.apache.dubbo.rpc.Constants.IS_SERVER_KEY; import static org.apache.dubbo.rpc.protocol.dubbo.Constants.CALLBACK_SERVICE_KEY; import static org.apache.dubbo.rpc.protocol.dubbo.Constants.CALLBACK_SERVICE_PROXY_KEY; @@ -219,7 +220,7 @@ public class CallbackServiceCodec { channel.setAttribute(CHANNEL_CALLBACK_KEY, callbackInvokers); } callbackInvokers.add(invoker); - logger.info("method " + inv.getMethodName() + " include a callback service :" + invoker.getUrl() + ", a proxy :" + invoker + " has been created."); + logger.info("method " + RpcUtils.getMethodName(inv) + " include a callback service :" + invoker.getUrl() + ", a proxy :" + invoker + " has been created."); } } } else { @@ -307,7 +308,7 @@ public class CallbackServiceCodec { public Object encodeInvocationArgument(Channel channel, RpcInvocation inv, int paraIndex) throws IOException { // get URL directly URL url = inv.getInvoker() == null ? null : inv.getInvoker().getUrl(); - byte callbackStatus = isCallBack(url, inv.getProtocolServiceKey(), inv.getMethodName(), paraIndex); + byte callbackStatus = isCallBack(url, inv.getProtocolServiceKey(), RpcUtils.getMethodName(inv), paraIndex); Object[] args = inv.getArguments(); Class[] pts = inv.getParameterTypes(); switch (callbackStatus) { @@ -334,7 +335,7 @@ public class CallbackServiceCodec { } return inObject; } - byte callbackstatus = isCallBack(url, inv.getProtocolServiceKey(), inv.getMethodName(), paraIndex); + byte callbackstatus = isCallBack(url, inv.getProtocolServiceKey(), RpcUtils.getMethodName(inv), paraIndex); switch (callbackstatus) { case CallbackServiceCodec.CALLBACK_CREATE: try { diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java index 1b1b9a5999..71645f8dc6 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java @@ -81,7 +81,7 @@ class ChannelWrappedInvoker extends AbstractInvoker { try { if (RpcUtils.isOneway(getUrl(), inv)) { // may have concurrency issue - currentClient.send(request, getUrl().getMethodParameter(invocation.getMethodName(), SENT_KEY, false)); + currentClient.send(request, getUrl().getMethodParameter(RpcUtils.getMethodName(invocation), SENT_KEY, false)); return AsyncRpcResult.newDefaultAsyncResult(invocation); } else { CompletableFuture appResponseFuture = currentClient.request(request).thenApply(AppResponse.class::cast); diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvoker.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvoker.java index 613ee79d58..9dfb716e75 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvoker.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvoker.java @@ -19,10 +19,10 @@ package org.apache.dubbo.rpc.protocol.dubbo; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.Version; import org.apache.dubbo.common.config.ConfigurationUtils; +import org.apache.dubbo.common.serialize.SerializationException; import org.apache.dubbo.common.utils.AtomicPositiveInteger; import org.apache.dubbo.remoting.Constants; import org.apache.dubbo.remoting.RemotingException; -import org.apache.dubbo.common.serialize.SerializationException; import org.apache.dubbo.remoting.TimeoutException; import org.apache.dubbo.remoting.exchange.ExchangeClient; import org.apache.dubbo.remoting.exchange.Request; @@ -102,7 +102,7 @@ public class DubboInvoker extends AbstractInvoker { if (timeout <= 0) { return AsyncRpcResult.newDefaultAsyncResult(new RpcException(RpcException.TIMEOUT_TERMINATE, "No time left for making the following call: " + invocation.getServiceName() + "." - + invocation.getMethodName() + ", terminate directly."), invocation); + + RpcUtils.getMethodName(invocation) + ", terminate directly."), invocation); } invocation.setAttachment(TIMEOUT_KEY, String.valueOf(timeout)); @@ -135,9 +135,9 @@ public class DubboInvoker extends AbstractInvoker { return result; } } catch (TimeoutException e) { - throw new RpcException(RpcException.TIMEOUT_EXCEPTION, "Invoke remote method timeout. method: " + invocation.getMethodName() + ", provider: " + getUrl() + ", cause: " + e.getMessage(), e); + throw new RpcException(RpcException.TIMEOUT_EXCEPTION, "Invoke remote method timeout. method: " + RpcUtils.getMethodName(invocation) + ", provider: " + getUrl() + ", cause: " + e.getMessage(), e); } catch (RemotingException e) { - String remoteExpMsg = "Failed to invoke remote method: " + invocation.getMethodName() + ", provider: " + getUrl() + ", cause: " + e.getMessage(); + String remoteExpMsg = "Failed to invoke remote method: " + RpcUtils.getMethodName(invocation) + ", provider: " + getUrl() + ", cause: " + e.getMessage(); if (e.getCause() instanceof IOException && e.getCause().getCause() instanceof SerializationException) { throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, remoteExpMsg, e); } else { diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/FutureFilter.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/FutureFilter.java index b35e00d8d9..ce6d89555d 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/FutureFilter.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/FutureFilter.java @@ -28,11 +28,11 @@ import org.apache.dubbo.rpc.cluster.filter.ClusterFilter; import org.apache.dubbo.rpc.model.AsyncMethodInfo; import org.apache.dubbo.rpc.model.ConsumerModel; import org.apache.dubbo.rpc.model.ServiceModel; +import org.apache.dubbo.rpc.support.RpcUtils; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import static org.apache.dubbo.common.constants.CommonConstants.$INVOKE; import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_REQUEST; import static org.apache.dubbo.rpc.protocol.dubbo.Constants.ASYNC_METHOD_INFO; @@ -180,10 +180,10 @@ public class FutureFilter implements ClusterFilter, ClusterFilter.Listener { } onthrowMethod.invoke(onthrowInst, params); } catch (Throwable e) { - logger.error(PROTOCOL_FAILED_REQUEST, "", "", invocation.getMethodName() + ".call back method invoke error . callback method :" + onthrowMethod + ", url:" + invoker.getUrl(), e); + logger.error(PROTOCOL_FAILED_REQUEST, "", "", RpcUtils.getMethodName(invocation) + ".call back method invoke error . callback method :" + onthrowMethod + ", url:" + invoker.getUrl(), e); } } else { - logger.error(PROTOCOL_FAILED_REQUEST, "", "", invocation.getMethodName() + ".call back method invoke error . callback method :" + onthrowMethod + ", url:" + invoker.getUrl(), exception); + logger.error(PROTOCOL_FAILED_REQUEST, "", "", RpcUtils.getMethodName(invocation) + ".call back method invoke error . callback method :" + onthrowMethod + ", url:" + invoker.getUrl(), exception); } } @@ -198,10 +198,7 @@ public class FutureFilter implements ClusterFilter, ClusterFilter.Listener { return null; } - String methodName = invocation.getMethodName(); - if (methodName.equals($INVOKE)) { - methodName = (String) invocation.getArguments()[0]; - } + String methodName = RpcUtils.getMethodName(invocation); return ((ConsumerModel) serviceModel).getAsyncInfo(methodName); } diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java index badd7a6490..f26692e722 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java @@ -32,6 +32,7 @@ import org.apache.dubbo.rpc.Invoker; import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcContext; import org.apache.dubbo.rpc.RpcException; +import org.apache.dubbo.rpc.support.RpcUtils; import java.util.ArrayList; import java.util.Set; @@ -79,7 +80,7 @@ public class TraceFilter implements Filter { Result result = invoker.invoke(invocation); long end = System.currentTimeMillis(); if (TRACERS.size() > 0) { - String key = invoker.getInterface().getName() + "." + invocation.getMethodName(); + String key = invoker.getInterface().getName() + "." + RpcUtils.getMethodName(invocation); Set channels = TRACERS.get(key); if (CollectionUtils.isEmpty(channels)) { key = invoker.getInterface().getName(); @@ -105,7 +106,7 @@ public class TraceFilter implements Filter { String prompt = channel.getUrl().getParameter(Constants.PROMPT_KEY, Constants.DEFAULT_PROMPT); channel.send("\r\n" + RpcContext.getServiceContext().getRemoteAddress() + " -> " + invoker.getInterface().getName() - + "." + invocation.getMethodName() + + "." + RpcUtils.getMethodName(invocation) + "(" + JsonUtils.toJson(invocation.getArguments()) + ")" + " -> " + JsonUtils.toJson(result.getValue()) + "\r\nelapsed: " + (end - start) + " ms." + "\r\n\r\n" + prompt); diff --git a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmInvoker.java b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmInvoker.java index 3f8665c8d6..7e3a1d11fb 100644 --- a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmInvoker.java +++ b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmInvoker.java @@ -103,11 +103,11 @@ public class InjvmInvoker extends AbstractInvoker { invocation.setAttachment(Constants.TOKEN_KEY, serverURL.getParameter(Constants.TOKEN_KEY)); } - int timeout = RpcUtils.calculateTimeout(getUrl(), invocation, invocation.getMethodName(), DEFAULT_TIMEOUT); + int timeout = RpcUtils.calculateTimeout(getUrl(), invocation, RpcUtils.getMethodName(invocation), DEFAULT_TIMEOUT); if (timeout <= 0) { return AsyncRpcResult.newDefaultAsyncResult(new RpcException(RpcException.TIMEOUT_TERMINATE, "No time left for making the following call: " + invocation.getServiceName() + "." - + invocation.getMethodName() + ", terminate directly."), invocation); + + RpcUtils.getMethodName(invocation) + ", terminate directly."), invocation); } invocation.setAttachment(TIMEOUT_KEY, String.valueOf(timeout)); diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleInvoker.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleInvoker.java index b6bad67e5f..cda6a57c22 100644 --- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleInvoker.java +++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleInvoker.java @@ -219,11 +219,11 @@ public class TripleInvoker extends AbstractInvoker { AsyncRpcResult invokeUnary(MethodDescriptor methodDescriptor, Invocation invocation, ClientCall call, Executor callbackExecutor) { - int timeout = RpcUtils.calculateTimeout(getUrl(), invocation, invocation.getMethodName(), 3000); + int timeout = RpcUtils.calculateTimeout(getUrl(), invocation, RpcUtils.getMethodName(invocation), 3000); if (timeout <= 0) { return AsyncRpcResult.newDefaultAsyncResult(new RpcException(RpcException.TIMEOUT_TERMINATE, "No time left for making the following call: " + invocation.getServiceName() + "." - + invocation.getMethodName() + ", terminate directly."), invocation); + + RpcUtils.getMethodName(invocation)+ ", terminate directly."), invocation); } invocation.setAttachment(TIMEOUT_KEY, String.valueOf(timeout)); diff --git a/dubbo-xds/src/main/java/org/apache/dubbo/rpc/cluster/router/xds/XdsRouter.java b/dubbo-xds/src/main/java/org/apache/dubbo/rpc/cluster/router/xds/XdsRouter.java index 299fcd6417..c994a219ad 100644 --- a/dubbo-xds/src/main/java/org/apache/dubbo/rpc/cluster/router/xds/XdsRouter.java +++ b/dubbo-xds/src/main/java/org/apache/dubbo/rpc/cluster/router/xds/XdsRouter.java @@ -16,15 +16,6 @@ */ package org.apache.dubbo.rpc.cluster.router.xds; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ThreadLocalRandom; -import java.util.stream.Collectors; - import org.apache.dubbo.common.URL; import org.apache.dubbo.common.utils.CollectionUtils; import org.apache.dubbo.common.utils.ConcurrentHashSet; @@ -45,6 +36,16 @@ import org.apache.dubbo.rpc.cluster.router.xds.rule.HeaderMatcher; import org.apache.dubbo.rpc.cluster.router.xds.rule.HttpRequestMatch; import org.apache.dubbo.rpc.cluster.router.xds.rule.PathMatcher; import org.apache.dubbo.rpc.cluster.router.xds.rule.XdsRouteRule; +import org.apache.dubbo.rpc.support.RpcUtils; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ThreadLocalRandom; +import java.util.stream.Collectors; public class XdsRouter extends AbstractStateRouter implements XdsRouteRuleListener, EdsEndpointListener { @@ -171,7 +172,7 @@ public class XdsRouter extends AbstractStateRouter implements XdsRouteRule } PathMatcher pathMatcher = requestMatch.getPathMatcher(); if (pathMatcher != null) { - String path = "/" + invocation.getInvoker().getUrl().getPath() + "/" + invocation.getMethodName(); + String path = "/" + invocation.getInvoker().getUrl().getPath() + "/" + RpcUtils.getMethodName(invocation); if (!pathMatcher.isMatch(path)) { return null; }