This is an automated email from the ASF dual-hosted git repository.
liujun 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 dc54172 Move URL usage to ServiceConfigURL & Make Monitor Work (#7852)
dc54172 is described below
commit dc54172eb8ea7de54a1dfad794ef027218f06366
Author: Albumen Kevin <[email protected]>
AuthorDate: Tue May 25 14:17:17 2021 +0800
Move URL usage to ServiceConfigURL & Make Monitor Work (#7852)
---
.../org/apache/dubbo/rpc/cluster/Constants.java | 2 +
.../rpc/cluster/directory/AbstractDirectory.java | 4 +-
.../loadbalance/AbstractLoadBalanceTest.java | 9 +++--
.../common/url/component/ServiceConfigURL.java | 34 +++++++++++++++++
.../org/apache/dubbo/common/utils/UrlUtils.java | 5 ++-
.../apache/dubbo/config/MetadataReportConfig.java | 3 +-
.../test/java/org/apache/dubbo/common/URLTest.java | 9 +++--
.../common/extension/ExtensionLoaderTest.java | 3 +-
.../extension/ExtensionLoader_Adaptive_Test.java | 23 ++++++------
.../support/eager/EagerThreadPoolExecutorTest.java | 3 +-
.../dubbo/common/utils/ExecutorUtilTest.java | 3 +-
.../org/apache/dubbo/config/ReferenceConfig.java | 9 +++--
.../org/apache/dubbo/config/ServiceConfig.java | 7 ++--
.../dubbo/config/utils/ConfigValidationUtils.java | 2 +-
.../dubbo/config/bootstrap/DubboBootstrapTest.java | 3 +-
.../org/apache/dubbo/config/cache/CacheTest.java | 3 +-
.../org/apache/dubbo/config/mock/MockRegistry.java | 3 +-
.../dubbo/config/spring/SimpleRegistryService.java | 5 ++-
dubbo-monitor/dubbo-monitor-api/pom.xml | 5 +++
.../monitor/support/MonitorClusterFilter.java | 19 ++++------
.../dubbo/monitor/support/MonitorFilter.java | 24 +++++++-----
...g.apache.dubbo.rpc.cluster.filter.ClusterFilter | 1 +
.../dubbo/monitor/support/MonitorFilterTest.java | 10 ++---
.../apache/dubbo/monitor/dubbo/StatisticsTest.java | 3 +-
.../registry/integration/RegistryProtocol.java | 13 ++++++-
.../registry/support/AbstractRegistryTest.java | 43 +++++++++++-----------
.../apache/dubbo/registry/nacos/NacosRegistry.java | 3 +-
.../apache/dubbo/remoting/api/NettyServerTest.java | 3 +-
.../remoting/http/jetty/JettyHttpBinderTest.java | 3 +-
.../remoting/http/tomcat/TomcatHttpBinderTest.java | 3 +-
.../transport/netty4/NettyTransporterTest.java | 5 ++-
.../support/AbstractZookeeperTransporter.java | 3 +-
.../rpc/protocol/dubbo/CallbackServiceCodec.java | 3 +-
.../dubbo/decode/DubboTelnetDecodeTest.java | 13 ++++---
.../rpc/protocol/dubbo/decode/MockChannel.java | 3 +-
.../rpc/protocol/tri/UnaryClientStreamTest.java | 3 +-
.../rpc/protocol/tri/UnaryServerStreamTest.java | 3 +-
37 files changed, 183 insertions(+), 110 deletions(-)
diff --git
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/Constants.java
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/Constants.java
index c2c4a18..0321113 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/Constants.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/Constants.java
@@ -96,6 +96,8 @@ public interface Constants {
*/
String REFER_KEY = "refer";
+ String ATTRIBUTE_KEY = "attribute";
+
/**
* The key name for export URL in register center
*/
diff --git
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java
index 88eda93..9e66c86 100644
---
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java
+++
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java
@@ -71,7 +71,7 @@ public abstract class AbstractDirectory<T> implements
Directory<T> {
throw new IllegalArgumentException("url == null");
}
- this.url = url.removeAttribute(REFER_KEY).removeParameter(MONITOR_KEY);
+ this.url = url.removeAttribute(REFER_KEY).removeAttribute(MONITOR_KEY);
Object referParams = url.getAttribute(REFER_KEY);
if (referParams != null) {
@@ -95,7 +95,7 @@ public abstract class AbstractDirectory<T> implements
Directory<T> {
// reserve parameters if url is already a consumer url
consumerUrlFrom = consumerUrlFrom.clearParameters();
}
- this.consumerUrl =
consumerUrlFrom.addParameters(queryMap).removeParameter(MONITOR_KEY);
+ this.consumerUrl =
consumerUrlFrom.addParameters(queryMap).removeAttribute(MONITOR_KEY);
}
setRouterChain(routerChain);
diff --git
a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalanceTest.java
b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalanceTest.java
index eec4d89..212ece0 100644
---
a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalanceTest.java
+++
b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalanceTest.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.rpc.cluster.loadbalance;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcInvocation;
@@ -49,12 +50,12 @@ public class AbstractLoadBalanceTest {
invocation.setMethodName("say");
Invoker invoker1 = mock(Invoker.class,
Mockito.withSettings().stubOnly());
- URL url1 = new URL("", "", 0, "DemoService", new HashMap<>());
+ URL url1 = new ServiceConfigURL("", "", 0, "DemoService", new
HashMap<>());
url1 = url1.addParameter(TIMESTAMP_KEY, System.currentTimeMillis() -
Integer.MAX_VALUE - 1);
given(invoker1.getUrl()).willReturn(url1);
Invoker invoker2 = mock(Invoker.class,
Mockito.withSettings().stubOnly());
- URL url2 = new URL("", "", 0, "DemoService", new HashMap<>());
+ URL url2 = new ServiceConfigURL("", "", 0, "DemoService", new
HashMap<>());
url2 = url2.addParameter(TIMESTAMP_KEY, System.currentTimeMillis() -
10 * 60 * 1000L - 1);
given(invoker2.getUrl()).willReturn(url2);
@@ -67,12 +68,12 @@ public class AbstractLoadBalanceTest {
invocation.setMethodName("say");
Invoker invoker1 = mock(Invoker.class,
Mockito.withSettings().stubOnly());
- URL url1 = new URL("", "", 0, "DemoService", new HashMap<>());
+ URL url1 = new ServiceConfigURL("", "", 0, "DemoService", new
HashMap<>());
url1 = url1.addParameter(REGISTRY_KEY + "." + WEIGHT_KEY, 10);
given(invoker1.getUrl()).willReturn(url1);
Invoker invoker2 = mock(Invoker.class,
Mockito.withSettings().stubOnly());
- URL url2 = new URL("", "", 0,
"org.apache.dubbo.registry.RegistryService", new HashMap<>());
+ URL url2 = new ServiceConfigURL("", "", 0,
"org.apache.dubbo.registry.RegistryService", new HashMap<>());
url2 = url2.addParameter(REGISTRY_KEY + "." + WEIGHT_KEY, 20);
given(invoker2.getUrl()).willReturn(url2);
diff --git
a/dubbo-common/src/main/java/org/apache/dubbo/common/url/component/ServiceConfigURL.java
b/dubbo-common/src/main/java/org/apache/dubbo/common/url/component/ServiceConfigURL.java
index 8702f5c..87018a9 100644
---
a/dubbo-common/src/main/java/org/apache/dubbo/common/url/component/ServiceConfigURL.java
+++
b/dubbo-common/src/main/java/org/apache/dubbo/common/url/component/ServiceConfigURL.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.common.url.component;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.utils.CollectionUtils;
import java.util.HashMap;
import java.util.Map;
@@ -38,6 +39,39 @@ public class ServiceConfigURL extends URL {
this.attributes = (attributes != null ? attributes : new HashMap<>());
}
+
+ public ServiceConfigURL(String protocol, String host, int port) {
+ this(protocol, null, null, host, port, null, (Map<String, String>)
null);
+ }
+
+ public ServiceConfigURL(String protocol, String host, int port, String[]
pairs) { // varargs ... conflict with the following path argument, use array
instead.
+ this(protocol, null, null, host, port, null,
CollectionUtils.toStringMap(pairs));
+ }
+
+ public ServiceConfigURL(String protocol, String host, int port,
Map<String, String> parameters) {
+ this(protocol, null, null, host, port, null, parameters);
+ }
+
+ public ServiceConfigURL(String protocol, String host, int port, String
path) {
+ this(protocol, null, null, host, port, path, (Map<String, String>)
null);
+ }
+
+ public ServiceConfigURL(String protocol, String host, int port, String
path, String... pairs) {
+ this(protocol, null, null, host, port, path,
CollectionUtils.toStringMap(pairs));
+ }
+
+ public ServiceConfigURL(String protocol, String host, int port, String
path, Map<String, String> parameters) {
+ this(protocol, null, null, host, port, path, parameters);
+ }
+
+ public ServiceConfigURL(String protocol, String username, String password,
String host, int port, String path) {
+ this(protocol, username, password, host, port, path, (Map<String,
String>) null);
+ }
+
+ public ServiceConfigURL(String protocol, String username, String password,
String host, int port, String path, String... pairs) {
+ this(protocol, username, password, host, port, path,
CollectionUtils.toStringMap(pairs));
+ }
+
public ServiceConfigURL(String protocol,
String username,
String password,
diff --git
a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java
b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java
index 9bb7a15..968dc7e 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java
@@ -19,6 +19,7 @@ package org.apache.dubbo.common.utils;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLStrParser;
import org.apache.dubbo.common.constants.RemotingConstants;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -158,7 +159,7 @@ public class UrlUtils {
}
}
if (changed) {
- u = new URL(protocol, username, password, host, port, path,
parameters);
+ u = new ServiceConfigURL(protocol, username, password, host, port,
path, parameters);
}
return u;
}
@@ -659,7 +660,7 @@ public class UrlUtils {
host = url;
}
- return new URL(protocol, username, password, host, port, path,
parameters);
+ return new ServiceConfigURL(protocol, username, password, host, port,
path, parameters);
}
public static boolean isConsumer(URL url) {
diff --git
a/dubbo-common/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java
b/dubbo-common/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java
index c3f8c93..0be5089 100644
---
a/dubbo-common/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java
+++
b/dubbo-common/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.config;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.config.support.Parameter;
@@ -107,7 +108,7 @@ public class MetadataReportConfig extends AbstractConfig {
map.putAll(convert(map, null));
// put the protocol of URL as the "metadata"
map.put("metadata", url.getProtocol());
- return new URL("metadata", url.getUsername(), url.getPassword(),
url.getHost(),
+ return new ServiceConfigURL("metadata", url.getUsername(),
url.getPassword(), url.getHost(),
url.getPort(), url.getPath(), map);
}
diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java
b/dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java
index 916da58..e8932c3 100644
--- a/dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java
+++ b/dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.dubbo.common;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.junit.jupiter.api.Assertions;
@@ -360,11 +361,11 @@ public class URLTest {
@Test
public void test_getAbsolutePath() throws Exception {
- URL url = new URL("p1", "1.2.2.2", 33);
+ URL url = new ServiceConfigURL("p1", "1.2.2.2", 33);
assertURLStrDecoder(url);
assertNull(url.getAbsolutePath());
- url = new URL("file", null, 90, "/home/user1/route.js");
+ url = new ServiceConfigURL("file", null, 90, "/home/user1/route.js");
assertURLStrDecoder(url);
assertEquals("/home/user1/route.js", url.getAbsolutePath());
}
@@ -377,7 +378,7 @@ public class URLTest {
Map<String, String> params = new HashMap<String, String>();
params.put("version", "1.0.0");
params.put("application", "morgan");
- URL url2 = new URL("dubbo", "admin", "hello1234", "10.20.130.230",
20880, "context/path", params);
+ URL url2 = new ServiceConfigURL("dubbo", "admin", "hello1234",
"10.20.130.230", 20880, "context/path", params);
assertURLStrDecoder(url2);
assertEquals(url1, url2);
@@ -756,7 +757,7 @@ public class URLTest {
@Test
public void test_Path() throws Exception {
- URL url = new URL("dubbo", "localhost", 20880, "////path");
+ URL url = new ServiceConfigURL("dubbo", "localhost", 20880,
"////path");
assertURLStrDecoder(url);
assertEquals("path", url.getPath());
}
diff --git
a/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java
b/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java
index a1a534a..746cab7 100644
---
a/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java
+++
b/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java
@@ -57,6 +57,7 @@ import
org.apache.dubbo.common.extension.ext9_empty.impl.Ext9EmptyImpl;
import org.apache.dubbo.common.extension.injection.InjectExt;
import org.apache.dubbo.common.extension.injection.impl.InjectExtImpl;
import org.apache.dubbo.common.lang.Prioritized;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -149,7 +150,7 @@ public class ExtensionLoaderTest {
assertThat(impl2, anyOf(instanceOf(Ext5Wrapper1.class),
instanceOf(Ext5Wrapper2.class)));
- URL url = new URL("p1", "1.2.3.4", 1010, "path1");
+ URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1");
int echoCount1 = Ext5Wrapper1.echoCount.get();
int echoCount2 = Ext5Wrapper2.echoCount.get();
diff --git
a/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Adaptive_Test.java
b/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Adaptive_Test.java
index fe64a63..047d0e2 100644
---
a/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Adaptive_Test.java
+++
b/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Adaptive_Test.java
@@ -27,6 +27,7 @@ import org.apache.dubbo.common.extension.ext4.NoUrlParamExt;
import org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt;
import org.apache.dubbo.common.extension.ext6_inject.Ext6;
import org.apache.dubbo.common.extension.ext6_inject.impl.Ext6Impl2;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.LogUtil;
import org.junit.jupiter.api.Assertions;
@@ -58,7 +59,7 @@ public class ExtensionLoader_Adaptive_Test {
SimpleExt ext =
ExtensionLoader.getExtensionLoader(SimpleExt.class).getAdaptiveExtension();
Map<String, String> map = new HashMap<String, String>();
- URL url = new URL("p1", "1.2.3.4", 1010, "path1", map);
+ URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1",
map);
String echo = ext.echo(url, "haha");
assertEquals("Ext1Impl1-echo", echo);
@@ -69,7 +70,7 @@ public class ExtensionLoader_Adaptive_Test {
Map<String, String> map = new HashMap<String, String>();
map.put("simple.ext", "impl2");
- URL url = new URL("p1", "1.2.3.4", 1010, "path1", map);
+ URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1",
map);
String echo = ext.echo(url, "haha");
assertEquals("Ext1Impl2-echo", echo);
@@ -82,7 +83,7 @@ public class ExtensionLoader_Adaptive_Test {
Map<String, String> map = new HashMap<String, String>();
map.put("key2", "impl2");
- URL url = new URL("p1", "1.2.3.4", 1010, "path1", map);
+ URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1", map);
String echo = ext.yell(url, "haha");
assertEquals("Ext1Impl2-yell", echo);
@@ -101,7 +102,7 @@ public class ExtensionLoader_Adaptive_Test {
assertEquals("Ext3Impl1-echo", echo); // default value
Map<String, String> map = new HashMap<String, String>();
- URL url = new URL("impl3", "1.2.3.4", 1010, "path1", map);
+ URL url = new ServiceConfigURL("impl3", "1.2.3.4", 1010, "path1",
map);
echo = ext.echo(url, "s");
assertEquals("Ext3Impl3-echo", echo); // use 2nd key, protocol
@@ -114,7 +115,7 @@ public class ExtensionLoader_Adaptive_Test {
{
Map<String, String> map = new HashMap<String, String>();
- URL url = new URL(null, "1.2.3.4", 1010, "path1", map);
+ URL url = new ServiceConfigURL(null, "1.2.3.4", 1010, "path1",
map);
String yell = ext.yell(url, "s");
assertEquals("Ext3Impl1-yell", yell); // default value
@@ -166,7 +167,7 @@ public class ExtensionLoader_Adaptive_Test {
SimpleExt ext =
ExtensionLoader.getExtensionLoader(SimpleExt.class).getAdaptiveExtension();
Map<String, String> map = new HashMap<String, String>();
- URL url = new URL("p1", "1.2.3.4", 1010, "path1", map);
+ URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1", map);
try {
ext.bang(url, 33);
@@ -196,7 +197,7 @@ public class ExtensionLoader_Adaptive_Test {
Map<String, String> map = new HashMap<String, String>();
map.put("ext2", "impl1");
- URL url = new URL("p1", "1.2.3.4", 1010, "path1", map);
+ URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1", map);
UrlHolder holder = new UrlHolder();
holder.setUrl(url);
@@ -209,7 +210,7 @@ public class ExtensionLoader_Adaptive_Test {
public void test_urlHolder_getAdaptiveExtension_noExtension() throws
Exception {
Ext2 ext =
ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
- URL url = new URL("p1", "1.2.3.4", 1010, "path1");
+ URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1");
UrlHolder holder = new UrlHolder();
holder.setUrl(url);
@@ -255,7 +256,7 @@ public class ExtensionLoader_Adaptive_Test {
Ext2 ext =
ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
Map<String, String> map = new HashMap<String, String>();
- URL url = new URL("p1", "1.2.3.4", 1010, "path1", map);
+ URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1", map);
try {
ext.bang(url, 33);
@@ -272,7 +273,7 @@ public class ExtensionLoader_Adaptive_Test {
public void
test_urlHolder_getAdaptiveExtension_ExceptionWhenNameNotProvided() throws
Exception {
Ext2 ext =
ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
- URL url = new URL("p1", "1.2.3.4", 1010, "path1");
+ URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1");
UrlHolder holder = new UrlHolder();
holder.setUrl(url);
@@ -299,7 +300,7 @@ public class ExtensionLoader_Adaptive_Test {
LogUtil.start();
Ext6 ext =
ExtensionLoader.getExtensionLoader(Ext6.class).getAdaptiveExtension();
- URL url = new URL("p1", "1.2.3.4", 1010, "path1");
+ URL url = new ServiceConfigURL("p1", "1.2.3.4", 1010, "path1");
url = url.addParameters("ext6", "impl1");
assertEquals("Ext6Impl1-echo-Ext1Impl1-echo", ext.echo(url, "ha"));
diff --git
a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/eager/EagerThreadPoolExecutorTest.java
b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/eager/EagerThreadPoolExecutorTest.java
index c7d610f..7846c0e 100644
---
a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/eager/EagerThreadPoolExecutorTest.java
+++
b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/eager/EagerThreadPoolExecutorTest.java
@@ -20,6 +20,7 @@ import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.threadpool.ThreadPool;
import org.apache.dubbo.common.threadpool.support.AbortPolicyWithReport;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.NamedThreadFactory;
import org.junit.jupiter.api.Assertions;
@@ -30,7 +31,7 @@ import java.util.concurrent.TimeUnit;
public class EagerThreadPoolExecutorTest {
- private static final URL URL = new URL("dubbo", "localhost", 8080);
+ private static final URL URL = new ServiceConfigURL("dubbo", "localhost",
8080);
/**
* It print like this:
diff --git
a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/ExecutorUtilTest.java
b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/ExecutorUtilTest.java
index 2653eae..3d0f465 100644
---
a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/ExecutorUtilTest.java
+++
b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/ExecutorUtilTest.java
@@ -18,6 +18,7 @@
package org.apache.dubbo.common.utils;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -77,7 +78,7 @@ public class ExecutorUtilTest {
@Test
public void testSetThreadName() throws Exception {
- URL url = new URL("dubbo", "localhost",
1234).addParameter(THREAD_NAME_KEY, "custom-thread");
+ URL url = new ServiceConfigURL("dubbo", "localhost",
1234).addParameter(THREAD_NAME_KEY, "custom-thread");
url = ExecutorUtil.setThreadName(url, "default-name");
assertThat(url.getParameter(THREAD_NAME_KEY),
equalTo("custom-thread-localhost:1234"));
}
diff --git
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
index d80b9ba..084a1ab 100644
---
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
+++
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
@@ -23,6 +23,7 @@ import org.apache.dubbo.common.constants.RegistryConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.ConfigUtils;
import org.apache.dubbo.common.utils.NetUtils;
@@ -324,7 +325,7 @@ public class ReferenceConfig<T> extends
ReferenceConfigBase<T> {
@SuppressWarnings({"unchecked", "rawtypes", "deprecation"})
private T createProxy(Map<String, String> map) {
if (shouldJvmRefer(map)) {
- URL url = new URL(LOCAL_PROTOCOL, LOCALHOST_VALUE, 0,
interfaceClass.getName()).addParameters(map);
+ URL url = new ServiceConfigURL(LOCAL_PROTOCOL, LOCALHOST_VALUE, 0,
interfaceClass.getName()).addParameters(map);
invoker = REF_PROTOCOL.refer(interfaceClass, url);
if (logger.isInfoEnabled()) {
logger.info("Using injvm service " + interfaceClass.getName());
@@ -357,7 +358,7 @@ public class ReferenceConfig<T> extends
ReferenceConfigBase<T> {
for (URL u : us) {
URL monitorUrl =
ConfigValidationUtils.loadMonitor(this, u);
if (monitorUrl != null) {
- map.put(MONITOR_KEY,
URL.encode(monitorUrl.toFullString()));
+ u = u.putAttribute(MONITOR_KEY, monitorUrl);
}
urls.add(u.putAttribute(REFER_KEY, map));
}
@@ -397,7 +398,7 @@ public class ReferenceConfig<T> extends
ReferenceConfigBase<T> {
logger.info("Referred dubbo service " + interfaceClass.getName());
}
- URL consumerURL = new URL(CONSUMER_PROTOCOL, map.get(REGISTER_IP_KEY),
0, map.get(INTERFACE_KEY), map);
+ URL consumerURL = new ServiceConfigURL(CONSUMER_PROTOCOL,
map.get(REGISTER_IP_KEY), 0, map.get(INTERFACE_KEY), map);
MetadataUtils.publishServiceDefinition(consumerURL);
// create service proxy
@@ -491,7 +492,7 @@ public class ReferenceConfig<T> extends
ReferenceConfigBase<T> {
* call, which is the default behavior
*/
protected boolean shouldJvmRefer(Map<String, String> map) {
- URL tmpUrl = new URL("temp", "localhost", 0, map);
+ URL tmpUrl = new ServiceConfigURL("temp", "localhost", 0, map);
boolean isJvmRefer;
if (isInjvm() == null) {
// if a url is specified, don't do local reference
diff --git
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
index 341d0a5..c1d7052 100644
---
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
+++
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
@@ -23,6 +23,7 @@ import org.apache.dubbo.common.bytecode.Wrapper;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.ClassUtils;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.ConfigUtils;
@@ -455,7 +456,7 @@ public class ServiceConfig<T> extends ServiceConfigBase<T> {
// export service
String host = findConfigedHosts(protocolConfig, registryURLs, map);
Integer port = findConfigedPorts(protocolConfig, name, map);
- URL url = new URL(name, host, port,
getContextPath(protocolConfig).map(p -> p + "/" + path).orElse(path), map);
+ URL url = new ServiceConfigURL(name, null, null, host, port,
getContextPath(protocolConfig).map(p -> p + "/" + path).orElse(path), map);
// You can customize Configurator to append extra parameters
if (ExtensionLoader.getExtensionLoader(ConfiguratorFactory.class)
@@ -483,7 +484,7 @@ public class ServiceConfig<T> extends ServiceConfigBase<T> {
url = url.addParameterIfAbsent(DYNAMIC_KEY,
registryURL.getParameter(DYNAMIC_KEY));
URL monitorUrl =
ConfigValidationUtils.loadMonitor(this, registryURL);
if (monitorUrl != null) {
- url = url.addParameterAndEncoded(MONITOR_KEY,
monitorUrl.toFullString());
+ url = url.putAttribute(MONITOR_KEY, monitorUrl);
}
if (logger.isInfoEnabled()) {
if (url.getParameter(REGISTER_KEY, true)) {
@@ -581,7 +582,7 @@ public class ServiceConfig<T> extends ServiceConfigBase<T> {
if (isInvalidLocalHost(hostToBind)) {
anyhost = true;
try {
- if(logger.isDebugEnabled()) {
+ if (logger.isDebugEnabled()) {
logger.info("No valid ip found from environment, try
to find valid host from DNS.");
}
hostToBind = InetAddress.getLocalHost().getHostAddress();
diff --git
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ConfigValidationUtils.java
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ConfigValidationUtils.java
index b7706ae..3422809 100644
---
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ConfigValidationUtils.java
+++
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ConfigValidationUtils.java
@@ -314,7 +314,7 @@ public class ConfigValidationUtils {
return URLBuilder.from(registryURL)
.setProtocol(DUBBO_PROTOCOL)
.addParameter(PROTOCOL_KEY, monitor.getProtocol())
- .putAttribute(REFER_KEY, StringUtils.toQueryString(map))
+ .putAttribute(REFER_KEY, map)
.build();
}
return null;
diff --git
a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java
b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java
index ce81e98..62a14b7 100644
---
a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java
+++
b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java
@@ -19,6 +19,7 @@ package org.apache.dubbo.config.bootstrap;
import org.apache.dubbo.common.URL;
import
org.apache.dubbo.common.config.configcenter.wrapper.CompositeDynamicConfiguration;
import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.ConfigUtils;
import org.apache.dubbo.config.AbstractInterfaceConfigTest;
import org.apache.dubbo.config.ApplicationConfig;
@@ -128,7 +129,7 @@ public class DubboBootstrapTest {
AbstractInterfaceConfigTest.InterfaceConfig interfaceConfig = new
AbstractInterfaceConfigTest.InterfaceConfig();
interfaceConfig.setApplication(new
ApplicationConfig("testLoadMonitor"));
interfaceConfig.setMonitor(new MonitorConfig());
- URL url = ConfigValidationUtils.loadMonitor(interfaceConfig, new
URL("dubbo", "addr1", 9090));
+ URL url = ConfigValidationUtils.loadMonitor(interfaceConfig, new
ServiceConfigURL("dubbo", "addr1", 9090));
Assertions.assertEquals("monitor-addr:12080", url.getAddress());
Assertions.assertEquals(MonitorService.class.getName(),
url.getParameter("interface"));
Assertions.assertNotNull(url.getParameter("dubbo"));
diff --git
a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/cache/CacheTest.java
b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/cache/CacheTest.java
index 990f01c..99b9bd3 100644
---
a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/cache/CacheTest.java
+++
b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/cache/CacheTest.java
@@ -21,6 +21,7 @@ import org.apache.dubbo.cache.CacheFactory;
import org.apache.dubbo.cache.support.threadlocal.ThreadLocalCache;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.MethodConfig;
import org.apache.dubbo.config.ProtocolConfig;
@@ -131,7 +132,7 @@ public class CacheTest {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("findCache.cache", "threadlocal");
- URL url = new URL("dubbo", "127.0.0.1", 29582,
"org.apache.dubbo.config.cache.CacheService", parameters);
+ URL url = new ServiceConfigURL("dubbo", "127.0.0.1", 29582,
"org.apache.dubbo.config.cache.CacheService", parameters);
Invocation invocation = new RpcInvocation("findCache",
CacheService.class.getName(), "", new Class[]{String.class}, new String[]{"0"},
null, null, null);
diff --git
a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/mock/MockRegistry.java
b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/mock/MockRegistry.java
index 290d4fd..735c942 100644
---
a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/mock/MockRegistry.java
+++
b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/mock/MockRegistry.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.config.mock;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.registry.NotifyListener;
import org.apache.dubbo.registry.Registry;
@@ -31,7 +32,7 @@ import static
org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY;
*/
public class MockRegistry implements Registry {
- static URL subscribedUrl = new URL("null", "0.0.0.0", 0);
+ static URL subscribedUrl = new ServiceConfigURL("null", "0.0.0.0", 0);
public static URL getSubscribedUrl() {
return subscribedUrl;
diff --git
a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/SimpleRegistryService.java
b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/SimpleRegistryService.java
index 7721d9b..e13fef6 100644
---
a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/SimpleRegistryService.java
+++
b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/SimpleRegistryService.java
@@ -19,6 +19,7 @@ package org.apache.dubbo.config.spring;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.common.utils.UrlUtils;
@@ -70,7 +71,7 @@ public class SimpleRegistryService extends
AbstractRegistryService {
List<URL> urls = getRegistered().get(service);
if ((RegistryService.class.getName() + ":0.0.0").equals(service)
&& CollectionUtils.isEmpty(urls)) {
- register(service, new URL("dubbo",
+ register(service, new ServiceConfigURL("dubbo",
NetUtils.getLocalHost(),
RpcContext.getServiceContext().getLocalPort(),
RegistryService.class.getName(),
@@ -123,7 +124,7 @@ public class SimpleRegistryService extends
AbstractRegistryService {
if (listeners != null && listeners.size() > 0) {
for (Map.Entry<String, NotifyListener> entry :
listeners.entrySet()) {
String service = entry.getKey();
- super.unsubscribe(service, new URL("subscribe",
+ super.unsubscribe(service, new ServiceConfigURL("subscribe",
RpcContext.getServiceContext().getRemoteHost(),
RpcContext.getServiceContext().getRemotePort(),
RegistryService.class.getName(),
getSubscribed(service)), entry.getValue());
diff --git a/dubbo-monitor/dubbo-monitor-api/pom.xml
b/dubbo-monitor/dubbo-monitor-api/pom.xml
index 9f1405a..000f1d8 100644
--- a/dubbo-monitor/dubbo-monitor-api/pom.xml
+++ b/dubbo-monitor/dubbo-monitor-api/pom.xml
@@ -35,6 +35,11 @@
<artifactId>dubbo-rpc-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-cluster</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/UnaryServerStreamTest.java
b/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/MonitorClusterFilter.java
similarity index 70%
copy from
dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/UnaryServerStreamTest.java
copy to
dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/MonitorClusterFilter.java
index ba32a36..06ea364 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/UnaryServerStreamTest.java
+++
b/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/MonitorClusterFilter.java
@@ -14,18 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.dubbo.monitor.support;
-package org.apache.dubbo.rpc.protocol.tri;
+import org.apache.dubbo.common.extension.Activate;
+import org.apache.dubbo.rpc.cluster.filter.ClusterFilter;
-import org.apache.dubbo.common.URL;
+import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER;
-import org.junit.jupiter.api.Test;
-
-class UnaryServerStreamTest {
-
- @Test
- @SuppressWarnings("all")
- public void testInit() {
- URL url = new URL("test", "1.2.3.4", 8080);
- }
-}
\ No newline at end of file
+@Activate(group = {CONSUMER})
+public class MonitorClusterFilter extends MonitorFilter implements
ClusterFilter {
+}
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 9fdb7d6..be9c521 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
@@ -20,6 +20,7 @@ import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.monitor.Monitor;
import org.apache.dubbo.monitor.MonitorFactory;
@@ -79,7 +80,7 @@ public class MonitorFilter implements Filter, Filter.Listener
{
*/
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws
RpcException {
- if (invoker.getUrl().hasParameter(MONITOR_KEY)) {
+ if (invoker.getUrl().hasAttribute(MONITOR_KEY)) {
invocation.put(MONITOR_FILTER_START_TIME,
System.currentTimeMillis());
getConcurrent(invoker, invocation).incrementAndGet(); // count up
}
@@ -94,7 +95,7 @@ public class MonitorFilter implements Filter, Filter.Listener
{
@Override
public void onResponse(Result result, Invoker<?> invoker, Invocation
invocation) {
- if (invoker.getUrl().hasParameter(MONITOR_KEY)) {
+ if (invoker.getUrl().hasAttribute(MONITOR_KEY)) {
collect(invoker, invocation, result,
RpcContext.getServiceContext().getRemoteHost(), (long)
invocation.get(MONITOR_FILTER_START_TIME), false);
getConcurrent(invoker, invocation).decrementAndGet(); // count down
}
@@ -102,7 +103,7 @@ public class MonitorFilter implements Filter,
Filter.Listener {
@Override
public void onError(Throwable t, Invoker<?> invoker, Invocation
invocation) {
- if (invoker.getUrl().hasParameter(MONITOR_KEY)) {
+ if (invoker.getUrl().hasAttribute(MONITOR_KEY)) {
collect(invoker, invocation, null,
RpcContext.getServiceContext().getRemoteHost(), (long)
invocation.get(MONITOR_FILTER_START_TIME), true);
getConcurrent(invoker, invocation).decrementAndGet(); // count down
}
@@ -120,13 +121,16 @@ public class MonitorFilter implements Filter,
Filter.Listener {
*/
private void collect(Invoker<?> invoker, Invocation invocation, Result
result, String remoteHost, long start, boolean error) {
try {
- URL monitorUrl = invoker.getUrl().getUrlParameter(MONITOR_KEY);
- Monitor monitor = monitorFactory.getMonitor(monitorUrl);
- if (monitor == null) {
- return;
+ Object monitorUrl;
+ monitorUrl = invoker.getUrl().getAttribute(MONITOR_KEY);
+ if(monitorUrl instanceof URL) {
+ Monitor monitor = monitorFactory.getMonitor((URL) monitorUrl);
+ if (monitor == null) {
+ return;
+ }
+ URL statisticsURL = createStatisticsUrl(invoker, invocation,
result, remoteHost, start, error);
+ monitor.collect(statisticsURL);
}
- URL statisticsURL = createStatisticsUrl(invoker, invocation,
result, remoteHost, start, error);
- monitor.collect(statisticsURL);
} catch (Throwable t) {
logger.warn("Failed to monitor count service " + invoker.getUrl()
+ ", cause: " + t.getMessage(), t);
}
@@ -174,7 +178,7 @@ public class MonitorFilter implements Filter,
Filter.Listener {
output = result.getAttachment(OUTPUT_KEY);
}
- return new URL(COUNT_PROTOCOL, NetUtils.getLocalHost(), localPort,
service + PATH_SEPARATOR + method, MonitorService.APPLICATION, application,
MonitorService.INTERFACE, service, MonitorService.METHOD, method, remoteKey,
remoteValue, error ? MonitorService.FAILURE : MonitorService.SUCCESS, "1",
MonitorService.ELAPSED, String.valueOf(elapsed), MonitorService.CONCURRENT,
String.valueOf(concurrent), INPUT_KEY, input, OUTPUT_KEY, output, GROUP_KEY,
group, VERSION_KEY, version);
+ return new ServiceConfigURL(COUNT_PROTOCOL, NetUtils.getLocalHost(),
localPort, service + PATH_SEPARATOR + method, MonitorService.APPLICATION,
application, MonitorService.INTERFACE, service, MonitorService.METHOD, method,
remoteKey, remoteValue, error ? MonitorService.FAILURE :
MonitorService.SUCCESS, "1", MonitorService.ELAPSED, String.valueOf(elapsed),
MonitorService.CONCURRENT, String.valueOf(concurrent), INPUT_KEY, input,
OUTPUT_KEY, output, GROUP_KEY, group, VERSION_KEY, version);
}
diff --git
a/dubbo-monitor/dubbo-monitor-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.cluster.filter.ClusterFilter
b/dubbo-monitor/dubbo-monitor-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.cluster.filter.ClusterFilter
new file mode 100644
index 0000000..c5bf757
--- /dev/null
+++
b/dubbo-monitor/dubbo-monitor-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.cluster.filter.ClusterFilter
@@ -0,0 +1 @@
+monitor=org.apache.dubbo.monitor.support.MonitorClusterFilter
\ No newline at end of file
diff --git
a/dubbo-monitor/dubbo-monitor-api/src/test/java/org/apache/dubbo/monitor/support/MonitorFilterTest.java
b/dubbo-monitor/dubbo-monitor-api/src/test/java/org/apache/dubbo/monitor/support/MonitorFilterTest.java
index 02c633c..d9cf387 100644
---
a/dubbo-monitor/dubbo-monitor-api/src/test/java/org/apache/dubbo/monitor/support/MonitorFilterTest.java
+++
b/dubbo-monitor/dubbo-monitor-api/src/test/java/org/apache/dubbo/monitor/support/MonitorFilterTest.java
@@ -33,8 +33,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
import java.util.Arrays;
import java.util.List;
@@ -64,11 +62,9 @@ public class MonitorFilterTest {
}
public URL getUrl() {
- try {
- return URL.valueOf("dubbo://" + NetUtils.getLocalHost() +
":20880?" + APPLICATION_KEY + "=abc&" + SIDE_KEY + "=" + CONSUMER_SIDE + "&" +
MONITOR_KEY + "=" + URLEncoder.encode("dubbo://" + NetUtils.getLocalHost() +
":7070", "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
+ return URL.valueOf("dubbo://" + NetUtils.getLocalHost() +
":20880?" +
+ APPLICATION_KEY + "=abc&" + SIDE_KEY + "=" + CONSUMER_SIDE)
+ .putAttribute(MONITOR_KEY, URL.valueOf("dubbo://" +
NetUtils.getLocalHost() + ":7070"));
}
@Override
diff --git
a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/StatisticsTest.java
b/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/StatisticsTest.java
index d98f9cd..b6956d7 100644
---
a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/StatisticsTest.java
+++
b/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/StatisticsTest.java
@@ -18,6 +18,7 @@ package org.apache.dubbo.monitor.dubbo;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.monitor.MonitorService;
import org.hamcrest.MatcherAssert;
@@ -66,7 +67,7 @@ public class StatisticsTest {
@Test
public void testToString() {
- Statistics statistics = new Statistics(new URL("dubbo",
"10.20.153.10", 0));
+ Statistics statistics = new Statistics(new ServiceConfigURL("dubbo",
"10.20.153.10", 0));
statistics.setApplication("demo");
statistics.setMethod("findPerson");
statistics.setServer("10.20.153.10");
diff --git
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
index 284304d..6db2cda 100644
---
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
+++
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
@@ -23,6 +23,7 @@ import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.timer.HashedWheelTimer;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.NamedThreadFactory;
import org.apache.dubbo.common.utils.StringUtils;
@@ -452,7 +453,15 @@ public class RegistryProtocol implements Protocol {
}
protected <T> Invoker<T> doRefer(Cluster cluster, Registry registry,
Class<T> type, URL url, Map<String, String> parameters) {
- URL consumerUrl = new URL(parameters.get(PROTOCOL_KEY) == null ? DUBBO
: parameters.get(PROTOCOL_KEY), parameters.get(REGISTER_IP_KEY), 0,
getPath(parameters, type), parameters);
+ Map<String, Object> consumerAttribute = new
HashMap<>(url.getAttributes());
+ consumerAttribute.remove(REFER_KEY);
+ URL consumerUrl = new ServiceConfigURL(parameters.get(PROTOCOL_KEY) ==
null ? DUBBO : parameters.get(PROTOCOL_KEY),
+ null,
+ null,
+ parameters.get(REGISTER_IP_KEY),
+ 0, getPath(parameters, type),
+ parameters,
+ consumerAttribute);
url = url.putAttribute(CONSUMER_URL_KEY, consumerUrl);
ClusterInvoker<T> migrationInvoker = getMigrationInvoker(this,
cluster, registry, type, url, consumerUrl);
return interceptInvoker(migrationInvoker, url, consumerUrl, url);
@@ -494,7 +503,7 @@ public class RegistryProtocol implements Protocol {
directory.setProtocol(protocol);
// all attributes of REFER_KEY
Map<String, String> parameters = new HashMap<String,
String>(directory.getConsumerUrl().getParameters());
- URL urlToRegistry = new URL(parameters.get(PROTOCOL_KEY) == null ?
DUBBO : parameters.get(PROTOCOL_KEY), parameters.remove(REGISTER_IP_KEY), 0,
getPath(parameters, type), parameters);
+ URL urlToRegistry = new ServiceConfigURL(parameters.get(PROTOCOL_KEY)
== null ? DUBBO : parameters.get(PROTOCOL_KEY),
parameters.remove(REGISTER_IP_KEY), 0, getPath(parameters, type), parameters);
URL consumerURL = directory.getConsumerUrl();
if (directory.isShouldRegister()) {
directory.setRegisteredConsumerUrl(urlToRegistry);
diff --git
a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java
b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java
index 8b57cba..ccce6a7 100644
---
a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java
+++
b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.registry.support;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.registry.NotifyListener;
import org.hamcrest.MatcherAssert;
@@ -54,7 +55,7 @@ public class AbstractRegistryTest {
//sync update cache file
url = url.addParameter("save.file", true);
testUrl =
URL.valueOf("http://192.168.0.3:9090/registry?check=false&file=N/A&interface=com.test");
- mockUrl = new URL("dubbo", "192.168.0.1", 2200);
+ mockUrl = new ServiceConfigURL("dubbo", "192.168.0.1", 2200);
parametersConsumer.put("application", "demo-consumer");
parametersConsumer.put("category", "consumer");
@@ -124,7 +125,7 @@ public class AbstractRegistryTest {
@Test
public void testUnregister() throws Exception {
//test one unregister
- URL url = new URL("dubbo", "192.168.0.1", 2200);
+ URL url = new ServiceConfigURL("dubbo", "192.168.0.1", 2200);
abstractRegistry.register(url);
abstractRegistry.unregister(url);
MatcherAssert.assertThat(false,
Matchers.equalTo(abstractRegistry.getRegistered().contains(url)));
@@ -158,7 +159,7 @@ public class AbstractRegistryTest {
//test subscribe
final AtomicReference<Boolean> notified = new
AtomicReference<Boolean>(false);
NotifyListener listener = urls -> notified.set(Boolean.TRUE);
- URL url = new URL("dubbo", "192.168.0.1", 2200);
+ URL url = new ServiceConfigURL("dubbo", "192.168.0.1", 2200);
abstractRegistry.subscribe(url, listener);
Set<NotifyListener> subscribeListeners =
abstractRegistry.getSubscribed().get(url);
MatcherAssert.assertThat(true,
Matchers.equalTo(subscribeListeners.contains(listener)));
@@ -173,7 +174,7 @@ public class AbstractRegistryTest {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
final AtomicReference<Boolean> notified = new
AtomicReference<Boolean>(false);
NotifyListener listener = urls -> notified.set(Boolean.TRUE);
- URL url = new URL("dubbo", "192.168.0.1", 2200);
+ URL url = new ServiceConfigURL("dubbo", "192.168.0.1", 2200);
abstractRegistry.subscribe(null, listener);
Assertions.fail("subscribe url == null");
});
@@ -184,7 +185,7 @@ public class AbstractRegistryTest {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
final AtomicReference<Boolean> notified = new
AtomicReference<Boolean>(false);
NotifyListener listener = urls -> notified.set(Boolean.TRUE);
- URL url = new URL("dubbo", "192.168.0.1", 2200);
+ URL url = new ServiceConfigURL("dubbo", "192.168.0.1", 2200);
abstractRegistry.subscribe(url, null);
Assertions.fail("listener url == null");
});
@@ -204,7 +205,7 @@ public class AbstractRegistryTest {
public void testUnsubscribeIfNotifyNull() throws Exception {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
final AtomicReference<Boolean> notified = new
AtomicReference<Boolean>(false);
- URL url = new URL("dubbo", "192.168.0.1", 2200);
+ URL url = new ServiceConfigURL("dubbo", "192.168.0.1", 2200);
abstractRegistry.unsubscribe(url, null);
Assertions.fail("unsubscribe listener == null");
});
@@ -314,13 +315,13 @@ public class AbstractRegistryTest {
public void testNotify() throws Exception {
final AtomicReference<Boolean> notified = new
AtomicReference<Boolean>(false);
NotifyListener listener1 = urls -> notified.set(Boolean.TRUE);
- URL url1 = new URL("dubbo", "192.168.0.1", 2200, parametersConsumer);
+ URL url1 = new ServiceConfigURL("dubbo", "192.168.0.1", 2200,
parametersConsumer);
abstractRegistry.subscribe(url1, listener1);
NotifyListener listener2 = urls -> notified.set(Boolean.TRUE);
- URL url2 = new URL("dubbo", "192.168.0.2", 2201, parametersConsumer);
+ URL url2 = new ServiceConfigURL("dubbo", "192.168.0.2", 2201,
parametersConsumer);
abstractRegistry.subscribe(url2, listener2);
NotifyListener listener3 = urls -> notified.set(Boolean.TRUE);
- URL url3 = new URL("dubbo", "192.168.0.3", 2202, parametersConsumer);
+ URL url3 = new ServiceConfigURL("dubbo", "192.168.0.3", 2202,
parametersConsumer);
abstractRegistry.subscribe(url3, listener3);
List<URL> urls = new ArrayList<>();
urls.add(url1);
@@ -340,13 +341,13 @@ public class AbstractRegistryTest {
public void testNotifyList() throws Exception {
final AtomicReference<Boolean> notified = new
AtomicReference<Boolean>(false);
NotifyListener listener1 = urls -> notified.set(Boolean.TRUE);
- URL url1 = new URL("dubbo", "192.168.0.1", 2200, parametersConsumer);
+ URL url1 = new ServiceConfigURL("dubbo", "192.168.0.1", 2200,
parametersConsumer);
abstractRegistry.subscribe(url1, listener1);
NotifyListener listener2 = urls -> notified.set(Boolean.TRUE);
- URL url2 = new URL("dubbo", "192.168.0.2", 2201, parametersConsumer);
+ URL url2 = new ServiceConfigURL("dubbo", "192.168.0.2", 2201,
parametersConsumer);
abstractRegistry.subscribe(url2, listener2);
NotifyListener listener3 = urls -> notified.set(Boolean.TRUE);
- URL url3 = new URL("dubbo", "192.168.0.3", 2202, parametersConsumer);
+ URL url3 = new ServiceConfigURL("dubbo", "192.168.0.3", 2202,
parametersConsumer);
abstractRegistry.subscribe(url3, listener3);
List<URL> urls = new ArrayList<>();
urls.add(url1);
@@ -364,13 +365,13 @@ public class AbstractRegistryTest {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
final AtomicReference<Boolean> notified = new
AtomicReference<Boolean>(false);
NotifyListener listener1 = urls -> notified.set(Boolean.TRUE);
- URL url1 = new URL("dubbo", "192.168.0.1", 2200,
parametersConsumer);
+ URL url1 = new ServiceConfigURL("dubbo", "192.168.0.1", 2200,
parametersConsumer);
abstractRegistry.subscribe(url1, listener1);
NotifyListener listener2 = urls -> notified.set(Boolean.TRUE);
- URL url2 = new URL("dubbo", "192.168.0.2", 2201,
parametersConsumer);
+ URL url2 = new ServiceConfigURL("dubbo", "192.168.0.2", 2201,
parametersConsumer);
abstractRegistry.subscribe(url2, listener2);
NotifyListener listener3 = urls -> notified.set(Boolean.TRUE);
- URL url3 = new URL("dubbo", "192.168.0.3", 2202,
parametersConsumer);
+ URL url3 = new ServiceConfigURL("dubbo", "192.168.0.3", 2202,
parametersConsumer);
abstractRegistry.subscribe(url3, listener3);
List<URL> urls = new ArrayList<>();
urls.add(url1);
@@ -386,13 +387,13 @@ public class AbstractRegistryTest {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
final AtomicReference<Boolean> notified = new
AtomicReference<Boolean>(false);
NotifyListener listener1 = urls -> notified.set(Boolean.TRUE);
- URL url1 = new URL("dubbo", "192.168.0.1", 2200,
parametersConsumer);
+ URL url1 = new ServiceConfigURL("dubbo", "192.168.0.1", 2200,
parametersConsumer);
abstractRegistry.subscribe(url1, listener1);
NotifyListener listener2 = urls -> notified.set(Boolean.TRUE);
- URL url2 = new URL("dubbo", "192.168.0.2", 2201,
parametersConsumer);
+ URL url2 = new ServiceConfigURL("dubbo", "192.168.0.2", 2201,
parametersConsumer);
abstractRegistry.subscribe(url2, listener2);
NotifyListener listener3 = urls -> notified.set(Boolean.TRUE);
- URL url3 = new URL("dubbo", "192.168.0.3", 2202,
parametersConsumer);
+ URL url3 = new ServiceConfigURL("dubbo", "192.168.0.3", 2202,
parametersConsumer);
abstractRegistry.subscribe(url3, listener3);
List<URL> urls = new ArrayList<>();
urls.add(url1);
@@ -532,9 +533,9 @@ public class AbstractRegistryTest {
private List<URL> getList() {
List<URL> list = new ArrayList<>();
- URL url1 = new URL("dubbo", "192.168.0.1", 1000);
- URL url2 = new URL("dubbo", "192.168.0.2", 1001);
- URL url3 = new URL("dubbo", "192.168.0.3", 1002);
+ URL url1 = new ServiceConfigURL("dubbo", "192.168.0.1", 1000);
+ URL url2 = new ServiceConfigURL("dubbo", "192.168.0.2", 1001);
+ URL url3 = new ServiceConfigURL("dubbo", "192.168.0.3", 1002);
list.add(url1);
list.add(url2);
list.add(url3);
diff --git
a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java
b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java
index abebd64..c3d7b2a 100644
---
a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java
+++
b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java
@@ -22,6 +22,7 @@ import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.url.component.DubboServiceAddressURL;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.common.utils.UrlUtils;
import org.apache.dubbo.registry.NotifyListener;
@@ -530,7 +531,7 @@ public class NacosRegistry extends FailbackRegistry {
Map<String, String> metadata = instance.getMetadata();
String protocol = metadata.get(PROTOCOL_KEY);
String path = metadata.get(PATH_KEY);
- URL url = new URL(protocol,
+ URL url = new ServiceConfigURL(protocol,
instance.getIp(),
instance.getPort(),
path,
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/api/NettyServerTest.java
b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/api/NettyServerTest.java
index 32d8bf6..bac9c2f 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/api/NettyServerTest.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/api/NettyServerTest.java
@@ -17,13 +17,14 @@
package org.apache.dubbo.remoting.api;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.remoting.Constants;
import org.apache.dubbo.remoting.RemotingException;
public class NettyServerTest {
public static void main(String[] args) throws RemotingException {
- URL url = new URL("transport", "localhost", 8898,
+ URL url = new ServiceConfigURL("transport", "localhost", 8898,
new String[]{Constants.BIND_PORT_KEY, String.valueOf(8898)});
final PortUnificationServer server = new PortUnificationServer(url);
diff --git
a/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinderTest.java
b/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinderTest.java
index 1741292..c849950 100644
---
a/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinderTest.java
+++
b/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinderTest.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.remoting.http.jetty;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.remoting.Constants;
import org.apache.dubbo.remoting.http.HttpHandler;
@@ -36,7 +37,7 @@ public class JettyHttpBinderTest {
@Test
public void shouldAbleHandleRequestForJettyBinder() throws Exception {
int port = NetUtils.getAvailablePort();
- URL url = new URL("http", "localhost", port,
+ URL url = new ServiceConfigURL("http", "localhost", port,
new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)});
HttpServer httpServer = new JettyHttpServer(url, new HttpHandler() {
@Override
diff --git
a/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinderTest.java
b/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinderTest.java
index f31b6ce..8c815b9 100644
---
a/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinderTest.java
+++
b/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinderTest.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.remoting.http.tomcat;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.remoting.Constants;
import org.apache.dubbo.remoting.http.HttpHandler;
@@ -36,7 +37,7 @@ public class TomcatHttpBinderTest {
@Test
public void shouldAbleHandleRequestForTomcatBinder() throws Exception {
int port = NetUtils.getAvailablePort();
- URL url = new URL("http", "localhost", port,
+ URL url = new ServiceConfigURL("http", "localhost", port,
new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)});
HttpServer httpServer = new TomcatHttpBinder().bind(url, new
HttpHandler() {
diff --git
a/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyTransporterTest.java
b/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyTransporterTest.java
index 0b13de1..c755857 100644
---
a/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyTransporterTest.java
+++
b/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyTransporterTest.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.remoting.transport.netty4;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.Constants;
@@ -35,7 +36,7 @@ public class NettyTransporterTest {
@Test
public void shouldAbleToBindNetty4() throws Exception {
int port = NetUtils.getAvailablePort();
- URL url = new URL("telnet", "localhost", port,
+ URL url = new ServiceConfigURL("telnet", "localhost", port,
new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)});
RemotingServer server = new NettyTransporter().bind(url, new
ChannelHandlerAdapter());
@@ -48,7 +49,7 @@ public class NettyTransporterTest {
final CountDownLatch lock = new CountDownLatch(1);
int port = NetUtils.getAvailablePort();
- URL url = new URL("telnet", "localhost", port,
+ URL url = new ServiceConfigURL("telnet", "localhost", port,
new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)});
new NettyTransporter().bind(url, new ChannelHandlerAdapter() {
diff --git
a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/support/AbstractZookeeperTransporter.java
b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/support/AbstractZookeeperTransporter.java
index b861c15..bdefa70 100644
---
a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/support/AbstractZookeeperTransporter.java
+++
b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/support/AbstractZookeeperTransporter.java
@@ -20,6 +20,7 @@ import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.remoting.zookeeper.ZookeeperClient;
import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter;
@@ -167,7 +168,7 @@ public abstract class AbstractZookeeperTransporter
implements ZookeeperTransport
parameterMap.put(RemotingConstants.BACKUP_KEY,
url.getParameter(RemotingConstants.BACKUP_KEY));
}
- return new URL(url.getProtocol(), url.getUsername(),
url.getPassword(), url.getHost(), url.getPort(),
+ return new ServiceConfigURL(url.getProtocol(), url.getUsername(),
url.getPassword(), url.getHost(), url.getPort(),
ZookeeperTransporter.class.getName(), parameterMap);
}
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 e2634f1..7378831 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
@@ -21,6 +21,7 @@ import org.apache.dubbo.common.bytecode.Wrapper;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.ConcurrentHashSet;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.remoting.Channel;
@@ -117,7 +118,7 @@ class CallbackServiceCodec {
tmpMap.remove(VERSION_KEY);// doesn't need to distinguish version for
callback
tmpMap.remove(Constants.BIND_PORT_KEY); //callback doesn't needs
bind.port
tmpMap.put(INTERFACE_KEY, clazz.getName());
- URL exportUrl = new URL(DubboProtocol.NAME,
channel.getLocalAddress().getAddress().getHostAddress(),
channel.getLocalAddress().getPort(), clazz.getName() + "." + instid, tmpMap);
+ URL exportUrl = new ServiceConfigURL(DubboProtocol.NAME,
channel.getLocalAddress().getAddress().getHostAddress(),
channel.getLocalAddress().getPort(), clazz.getName() + "." + instid, tmpMap);
// no need to generate multiple exporters for different channel in the
same JVM, cache key cannot collide.
String cacheKey = getClientSideCallbackServiceCacheKey(instid);
diff --git
a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/decode/DubboTelnetDecodeTest.java
b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/decode/DubboTelnetDecodeTest.java
index 3c66d75..2270bcb 100644
---
a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/decode/DubboTelnetDecodeTest.java
+++
b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/decode/DubboTelnetDecodeTest.java
@@ -18,6 +18,7 @@ package org.apache.dubbo.rpc.protocol.dubbo.decode;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.ReflectUtils;
import org.apache.dubbo.remoting.Codec2;
import org.apache.dubbo.remoting.buffer.ChannelBuffer;
@@ -88,7 +89,7 @@ public class DubboTelnetDecodeTest {
EmbeddedChannel ch = null;
try {
Codec2 codec =
ExtensionLoader.getExtensionLoader(Codec2.class).getExtension("dubbo");
- URL url = new URL("dubbo", "localhost", 22226);
+ URL url = new ServiceConfigURL("dubbo", "localhost", 22226);
NettyCodecAdapter adapter = new NettyCodecAdapter(codec, url, new
MockChannelHandler());
MockHandler mockHandler = new MockHandler(null,
@@ -135,7 +136,7 @@ public class DubboTelnetDecodeTest {
EmbeddedChannel ch = null;
try {
Codec2 codec =
ExtensionLoader.getExtensionLoader(Codec2.class).getExtension("dubbo");
- URL url = new URL("dubbo", "localhost", 22226);
+ URL url = new ServiceConfigURL("dubbo", "localhost", 22226);
NettyCodecAdapter adapter = new NettyCodecAdapter(codec, url, new
MockChannelHandler());
MockHandler mockHandler = new MockHandler((msg) -> {
@@ -198,7 +199,7 @@ public class DubboTelnetDecodeTest {
EmbeddedChannel ch = null;
try {
Codec2 codec =
ExtensionLoader.getExtensionLoader(Codec2.class).getExtension("dubbo");
- URL url = new URL("dubbo", "localhost", 22226);
+ URL url = new ServiceConfigURL("dubbo", "localhost", 22226);
NettyCodecAdapter adapter = new NettyCodecAdapter(codec, url, new
MockChannelHandler());
MockHandler mockHandler = new MockHandler((msg) -> {
@@ -269,7 +270,7 @@ public class DubboTelnetDecodeTest {
EmbeddedChannel ch = null;
try {
Codec2 codec =
ExtensionLoader.getExtensionLoader(Codec2.class).getExtension("dubbo");
- URL url = new URL("dubbo", "localhost", 22226);
+ URL url = new ServiceConfigURL("dubbo", "localhost", 22226);
NettyCodecAdapter adapter = new NettyCodecAdapter(codec, url, new
MockChannelHandler());
MockHandler mockHandler = new MockHandler((msg) -> {
@@ -340,7 +341,7 @@ public class DubboTelnetDecodeTest {
EmbeddedChannel ch = null;
try {
Codec2 codec =
ExtensionLoader.getExtensionLoader(Codec2.class).getExtension("dubbo");
- URL url = new URL("dubbo", "localhost", 22226);
+ URL url = new ServiceConfigURL("dubbo", "localhost", 22226);
NettyCodecAdapter adapter = new NettyCodecAdapter(codec, url, new
MockChannelHandler());
MockHandler mockHandler = new MockHandler(null,
@@ -407,7 +408,7 @@ public class DubboTelnetDecodeTest {
EmbeddedChannel ch = null;
try {
Codec2 codec =
ExtensionLoader.getExtensionLoader(Codec2.class).getExtension("dubbo");
- URL url = new URL("dubbo", "localhost", 22226);
+ URL url = new ServiceConfigURL("dubbo", "localhost", 22226);
NettyCodecAdapter adapter = new NettyCodecAdapter(codec, url, new
MockChannelHandler());
MockHandler mockHandler = new MockHandler((msg) -> {
diff --git
a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/decode/MockChannel.java
b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/decode/MockChannel.java
index 80a2dc5..4667000 100644
---
a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/decode/MockChannel.java
+++
b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/decode/MockChannel.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.rpc.protocol.dubbo.decode;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.ChannelHandler;
@@ -68,7 +69,7 @@ public class MockChannel implements Channel {
@Override
public URL getUrl() {
- return new URL("dubbo", "localhost", 20880);
+ return new ServiceConfigURL("dubbo", "localhost", 20880);
}
@Override
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/UnaryClientStreamTest.java
b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/UnaryClientStreamTest.java
index 54eedac..345f873 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/UnaryClientStreamTest.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/UnaryClientStreamTest.java
@@ -19,6 +19,7 @@ package org.apache.dubbo.rpc.protocol.tri;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.stream.StreamObserver;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcInvocation;
import org.apache.dubbo.rpc.model.MethodDescriptor;
@@ -39,7 +40,7 @@ class UnaryClientStreamTest {
@Test
@SuppressWarnings("all")
public void testInit() {
- URL url = new URL("test", "1.2.3.4", 8080);
+ URL url = new ServiceConfigURL("test", "1.2.3.4", 8080);
final Executor executor = Mockito.mock(Executor.class);
final UnaryClientStream stream = UnaryClientStream.unary(url,
executor);
final StreamObserver<Object> observer = stream.asStreamObserver();
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/UnaryServerStreamTest.java
b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/UnaryServerStreamTest.java
index ba32a36..2221e7b 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/UnaryServerStreamTest.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/UnaryServerStreamTest.java
@@ -18,6 +18,7 @@
package org.apache.dubbo.rpc.protocol.tri;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.junit.jupiter.api.Test;
@@ -26,6 +27,6 @@ class UnaryServerStreamTest {
@Test
@SuppressWarnings("all")
public void testInit() {
- URL url = new URL("test", "1.2.3.4", 8080);
+ URL url = new ServiceConfigURL("test", "1.2.3.4", 8080);
}
}
\ No newline at end of file