Skip to content

Commit 64b3771

Browse files
committed
solve #6842 Broadcast cluster means that multiple machines will be called,which is not converted to injvm protocol at this time.
1 parent a588723 commit 64b3771

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ public interface CommonConstants {
236236
String PORT_KEY = "port";
237237
String DUBBO_IP_TO_BIND = "DUBBO_IP_TO_BIND";
238238

239+
/**
240+
* broadcast cluster.
241+
*/
242+
String BROADCAST_CLUSTER = "broadcast";
243+
239244
/**
240245
* The property name for {@link NetworkInterface#getDisplayName() the name of network interface} that
241246
* the Dubbo application prefers

dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmProtocol.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
import java.util.Map;
3131

32+
import static org.apache.dubbo.common.constants.CommonConstants.BROADCAST_CLUSTER;
33+
import static org.apache.dubbo.common.constants.CommonConstants.CLUSTER_KEY;
3234
import static org.apache.dubbo.rpc.Constants.SCOPE_KEY;
3335
import static org.apache.dubbo.rpc.Constants.SCOPE_LOCAL;
3436
import static org.apache.dubbo.rpc.Constants.SCOPE_REMOTE;
@@ -111,6 +113,11 @@ public boolean isInjvmRefer(URL url) {
111113
// generic invocation is not local reference
112114
return false;
113115
} else if (getExporter(exporterMap, url) != null) {
116+
// Broadcast cluster means that multiple machines will be called,
117+
// which is not converted to injvm protocol at this time.
118+
if (BROADCAST_CLUSTER.equalsIgnoreCase(url.getParameter(CLUSTER_KEY))) {
119+
return false;
120+
}
114121
// by default, go through local reference if there's the service exposed locally
115122
return true;
116123
} else {

dubbo-rpc/dubbo-rpc-injvm/src/test/java/org/apache/dubbo/rpc/protocol/injvm/InjvmProtocolTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ public void testIsInjvmRefer() throws Exception {
119119
url = URL.valueOf("fake://127.0.0.1/TestService").addParameter(GENERIC_KEY, true);
120120
assertFalse(InjvmProtocol.getInjvmProtocol().isInjvmRefer(url));
121121

122+
url = URL.valueOf("fake://127.0.0.1/TestService").addParameter("cluster", "broadcast");
123+
assertFalse(InjvmProtocol.getInjvmProtocol().isInjvmRefer(url));
122124
}
123125

124126

0 commit comments

Comments
 (0)