This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 4b1c5e6 solve #6842 Broadcast cluster means that multiple machines
will be called,which is not converted to injvm protocol at this time. (#7365)
4b1c5e6 is described below
commit 4b1c5e68235b7c2b8faa9879850c917c9e29d165
Author: xiaoheng1 <[email protected]>
AuthorDate: Mon Apr 12 17:10:59 2021 +0800
solve #6842 Broadcast cluster means that multiple machines will be
called,which is not converted to injvm protocol at this time. (#7365)
---
.../java/org/apache/dubbo/common/constants/CommonConstants.java | 5 +++++
.../java/org/apache/dubbo/rpc/protocol/injvm/InjvmProtocol.java | 7 +++++++
.../org/apache/dubbo/rpc/protocol/injvm/InjvmProtocolTest.java | 2 ++
3 files changed, 14 insertions(+)
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 494fd34..13ebd7a 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
@@ -241,6 +241,11 @@ public interface CommonConstants {
String DUBBO_IP_TO_BIND = "DUBBO_IP_TO_BIND";
/**
+ * broadcast cluster.
+ */
+ String BROADCAST_CLUSTER = "broadcast";
+
+ /**
* The property name for {@link NetworkInterface#getDisplayName() the name
of network interface} that
* the Dubbo application prefers
*
diff --git
a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmProtocol.java
b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmProtocol.java
index 3e681b2..668e05c 100644
---
a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmProtocol.java
+++
b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmProtocol.java
@@ -29,6 +29,8 @@ import org.apache.dubbo.rpc.support.ProtocolUtils;
import java.util.Map;
+import static
org.apache.dubbo.common.constants.CommonConstants.BROADCAST_CLUSTER;
+import static org.apache.dubbo.common.constants.CommonConstants.CLUSTER_KEY;
import static org.apache.dubbo.rpc.Constants.SCOPE_KEY;
import static org.apache.dubbo.rpc.Constants.SCOPE_LOCAL;
import static org.apache.dubbo.rpc.Constants.SCOPE_REMOTE;
@@ -111,6 +113,11 @@ public class InjvmProtocol extends AbstractProtocol
implements Protocol {
// generic invocation is not local reference
return false;
} else if (getExporter(exporterMap, url) != null) {
+ // Broadcast cluster means that multiple machines will be called,
+ // which is not converted to injvm protocol at this time.
+ if
(BROADCAST_CLUSTER.equalsIgnoreCase(url.getParameter(CLUSTER_KEY))) {
+ return false;
+ }
// by default, go through local reference if there's the service
exposed locally
return true;
} else {
diff --git
a/dubbo-rpc/dubbo-rpc-injvm/src/test/java/org/apache/dubbo/rpc/protocol/injvm/InjvmProtocolTest.java
b/dubbo-rpc/dubbo-rpc-injvm/src/test/java/org/apache/dubbo/rpc/protocol/injvm/InjvmProtocolTest.java
index 9e7eadf..c1eaee8 100644
---
a/dubbo-rpc/dubbo-rpc-injvm/src/test/java/org/apache/dubbo/rpc/protocol/injvm/InjvmProtocolTest.java
+++
b/dubbo-rpc/dubbo-rpc-injvm/src/test/java/org/apache/dubbo/rpc/protocol/injvm/InjvmProtocolTest.java
@@ -119,6 +119,8 @@ public class InjvmProtocolTest {
url =
URL.valueOf("fake://127.0.0.1/TestService").addParameter(GENERIC_KEY, true);
assertFalse(InjvmProtocol.getInjvmProtocol().isInjvmRefer(url));
+ url =
URL.valueOf("fake://127.0.0.1/TestService").addParameter("cluster",
"broadcast");
+ assertFalse(InjvmProtocol.getInjvmProtocol().isInjvmRefer(url));
}