Fix get method name from invocation (#12519)
* Fix get method name from invocation * fix compile
This commit is contained in:
parent
e6e68f6b84
commit
e07e5e294b
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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<T> 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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<T> 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.
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 <T> Collection<String> getInvokerAddrList(List<Invoker<T>> invokers, Invocation invocation) {
|
||||
String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName();
|
||||
String key = invokers.get(0).getUrl().getServiceKey() + "." + RpcUtils.getMethodName(invocation);
|
||||
Map<String, WeightedRoundRobin> map = methodWeightMap.get(key);
|
||||
if (map != null) {
|
||||
return map.keySet();
|
||||
|
|
@ -89,7 +90,7 @@ public class RoundRobinLoadBalance extends AbstractLoadBalance {
|
|||
|
||||
@Override
|
||||
protected <T> Invoker<T> doSelect(List<Invoker<T>> 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<String, WeightedRoundRobin> map = ConcurrentHashMapUtils.computeIfAbsent(methodWeightMap, key, k -> new ConcurrentHashMap<>());
|
||||
int totalWeight = 0;
|
||||
long maxCurrent = Long.MIN_VALUE;
|
||||
|
|
|
|||
|
|
@ -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<T> 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.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<T> extends AbstractStateRouter<T> {
|
|||
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));
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ public abstract class AbstractClusterInvoker<T> implements ClusterInvoker<T> {
|
|||
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<T> implements ClusterInvoker<T> {
|
|||
protected void checkInvokers(List<Invoker<T>> 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()
|
||||
|
|
|
|||
|
|
@ -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<T> extends AbstractClusterInvoker<T> {
|
|||
// 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<T> extends AbstractClusterInvoker<T> {
|
|||
@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<T> 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 {
|
||||
|
|
|
|||
|
|
@ -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<T> extends AbstractClusterInvoker<T> {
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -97,13 +97,13 @@ public class MockClusterInvoker<T> implements ClusterInvoker<T> {
|
|||
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<T> implements ClusterInvoker<T> {
|
|||
}
|
||||
|
||||
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<T> implements ClusterInvoker<T> {
|
|||
} 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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<T> implements ClusterInvoker<T>, 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);
|
||||
|
|
|
|||
|
|
@ -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 <T> Invoker<T> doSelect(List<Invoker<T>> 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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 <dubbo:service executes=\"" + max +
|
||||
"\" /> limited.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class ChannelWrappedInvoker<T> extends AbstractInvoker<T> {
|
|||
|
||||
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<AppResponse> appResponseFuture = currentClient.request(request).thenApply(AppResponse.class::cast);
|
||||
|
|
|
|||
|
|
@ -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<T> extends AbstractInvoker<T> {
|
|||
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<T> extends AbstractInvoker<T> {
|
|||
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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Channel> 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);
|
||||
|
|
|
|||
|
|
@ -103,11 +103,11 @@ public class InjvmInvoker<T> extends AbstractInvoker<T> {
|
|||
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));
|
||||
|
||||
|
|
|
|||
|
|
@ -219,11 +219,11 @@ public class TripleInvoker<T> extends AbstractInvoker<T> {
|
|||
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));
|
||||
|
||||
|
|
|
|||
|
|
@ -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<T> extends AbstractStateRouter<T> implements XdsRouteRuleListener, EdsEndpointListener {
|
||||
|
||||
|
|
@ -171,7 +172,7 @@ public class XdsRouter<T> extends AbstractStateRouter<T> 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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue