This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new 6d5a02d [3.0] Add Optional Injvm deep copy when module are the same
(#9539)
6d5a02d is described below
commit 6d5a02d1346e982c5f044d5a5e573d66fd4bd8f5
Author: Albumen Kevin <[email protected]>
AuthorDate: Fri Jan 7 11:33:04 2022 +0800
[3.0] Add Optional Injvm deep copy when module are the same (#9539)
---
.../org/apache/dubbo/common/constants/CommonConstants.java | 5 +++++
.../org/apache/dubbo/rpc/protocol/injvm/InjvmInvoker.java | 12 ++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
index 89504d7..90d1805 100644
---
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
+++
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
@@ -519,4 +519,9 @@ public interface CommonConstants {
String CURRENT_CLUSTER_INVOKER_KEY = "currentClusterInvoker";
String ENABLE_ROUTER_SNAPSHOT_PRINT_KEY = "ENABLE_ROUTER_SNAPSHOT_PRINT";
+
+ String INJVM_COPY_UTIL_KEY = "injvm-copy-util";
+
+ String INJVM_IGNORE_SAME_MODULE_KEY = "injvm.ignore.same-module";
+
}
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 4b20d26..959b031 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
@@ -40,6 +40,7 @@ import org.apache.dubbo.rpc.protocol.AbstractInvoker;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
@@ -59,13 +60,16 @@ public class InjvmInvoker<T> extends AbstractInvoker<T> {
private final ParamDeepCopyUtil paramDeepCopyUtil;
+ private final boolean shouldIgnoreSameModule;
+
InjvmInvoker(Class<T> type, URL url, String key, Map<String, Exporter<?>>
exporterMap) {
super(type, url);
this.key = key;
this.exporterMap = exporterMap;
this.executorRepository =
url.getOrDefaultApplicationModel().getExtensionLoader(ExecutorRepository.class).getDefaultExtension();
this.paramDeepCopyUtil =
url.getOrDefaultFrameworkModel().getExtensionLoader(ParamDeepCopyUtil.class)
- .getExtension(url.getParameter("injvm-copy-util",
DefaultParamDeepCopyUtil.NAME));
+
.getExtension(url.getParameter(CommonConstants.INJVM_COPY_UTIL_KEY,
DefaultParamDeepCopyUtil.NAME));
+ this.shouldIgnoreSameModule =
url.getParameter(CommonConstants.INJVM_IGNORE_SAME_MODULE_KEY, false);
}
@Override
@@ -147,7 +151,11 @@ public class InjvmInvoker<T> extends AbstractInvoker<T> {
return invocation;
}
String methodName = invocation.getMethodName();
- if(CommonConstants.$INVOKE.equals(methodName)) {
+
+ ServiceModel consumerServiceModel = invocation.getServiceModel();
+ boolean shouldSkip = shouldIgnoreSameModule && consumerServiceModel !=
null &&
+ Objects.equals(providerServiceModel.getModuleModel(),
consumerServiceModel.getModuleModel());
+ if(CommonConstants.$INVOKE.equals(methodName) || shouldSkip) {
// generic invoke, skip copy arguments
RpcInvocation copiedInvocation = new
RpcInvocation(invocation.getTargetServiceUniqueName(),
providerServiceModel, methodName, invocation.getServiceName(),
invocation.getProtocolServiceKey(),