Merge changes from 2.7.2-release (#4259)
This commit is contained in:
parent
d3a5166436
commit
5d32b86f2a
89
CHANGES.md
89
CHANGES.md
|
|
@ -1,5 +1,94 @@
|
|||
# Release Notes
|
||||
|
||||
## 2.7.2
|
||||
|
||||
### New Features
|
||||
|
||||
- nacos config center / metadata center support. [#3846](https://github.com/apache/dubbo/issues/3846)
|
||||
- Etcd support as config center and metadata center [#3653](https://github.com/apache/dubbo/issues/3653)
|
||||
- Support Redis cluster in Metadata Report. [#3817](https://github.com/apache/dubbo/issues/3817)
|
||||
- add new module for Dubbo Event. [#4096](https://github.com/apache/dubbo/issues/4096)
|
||||
- Support multiple registry that including some effective registry, such as zk, redis [#3599](https://github.com/apache/dubbo/issues/3599)
|
||||
- support nacos metadata [#4025](https://github.com/apache/dubbo/issues/4025)
|
||||
- Dubbo support Google Protobuf generic reference [#3829](https://github.com/apache/dubbo/issues/3829)
|
||||
- Merge serialization-native-hessian-for-apache-dubbo into incubator-dubbo [#3961](https://github.com/apache/dubbo/issues/3961)
|
||||
- Merge rpc-native-thrift-for-apache-dubbo into incubator-dubbo [#3960](https://github.com/apache/dubbo/issues/3960)
|
||||
- add socks5 proxy support [#3624](https://github.com/apache/dubbo/issues/3624)
|
||||
- Integrate with SOFARegistry [#3874](https://github.com/apache/dubbo/issues/3874)
|
||||
- Introduce CompletableFuture $invokeAsync for GenericService, now, for generic call, you can use:
|
||||
$invoke for sync method call with normal return type.
|
||||
$invokeAsync for async method call with CompletableFuture<T> signature. [#3163](https://github.com/apache/dubbo/issues/3163)
|
||||
|
||||
### Enhancement
|
||||
|
||||
- Performance tuning for TimeoutTask in DefaultFuture. [#4129](https://github.com/apache/dubbo/issues/4129)
|
||||
- Add a script to check dependencies license. [#3840](https://github.com/apache/dubbo/issues/3840)
|
||||
- Change DynamicConfiguration definition to better adapt to Apollo's namespace storage model.[#3266](https://github.com/apache/dubbo/issues/3266)
|
||||
- use equal explicit class to replace anonymous class [#4027](https://github.com/apache/dubbo/issues/4027)
|
||||
- Seperate Constants.java into some SubConstants Class [#3137](https://github.com/apache/dubbo/issues/3137)
|
||||
- Need to enhance DecodeableRpcResult error message [#3994](https://github.com/apache/dubbo/issues/3994)
|
||||
- Provide more meaningful binary releases. [#2491](https://github.com/apache/dubbo/issues/2491)
|
||||
- remove useless module-dubbo-test-integration [#3573](https://github.com/apache/dubbo/issues/3573)
|
||||
- complete lookup method of consul registry and add integration test [#3890](https://github.com/apache/dubbo/issues/3890)
|
||||
- Metrics Service [#3702](https://github.com/apache/dubbo/issues/3702)
|
||||
- Update nacos-client to 1.0.0 [#3804](https://github.com/apache/dubbo/issues/3804)
|
||||
- Fluent style builder API support [#3431](https://github.com/apache/dubbo/issues/3431)
|
||||
- Update readme to remove the incubator prefix [#4159](https://github.com/apache/dubbo/issues/4159)
|
||||
- update erlang link [#4100](https://github.com/apache/dubbo/issues/4100)
|
||||
- optimize array code style [#4031](https://github.com/apache/dubbo/issues/4031)
|
||||
- optimize some code style [#4006](https://github.com/apache/dubbo/issues/4006)
|
||||
- remove useless module-dubbo-test-integration [#3989](https://github.com/apache/dubbo/issues/3989)
|
||||
- optimize constant naming style [#3970](https://github.com/apache/dubbo/issues/3970)
|
||||
- Use maven CI friendly versions: revision. [#3851](https://github.com/apache/dubbo/issues/3851)
|
||||
- remove-parse-error-log [#3862](https://github.com/apache/dubbo/issues/3862)
|
||||
- Complete xsd definition for ConfigCenterConfig. [#3854](https://github.com/apache/dubbo/issues/3854)
|
||||
- add remoteApplicationName field in RpcContext [#3816](https://github.com/apache/dubbo/issues/3816)
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- @Reference can't match the local @Service beans. [#4071](https://github.com/apache/dubbo/issues/4071)
|
||||
- remove some illegal licence: jcip-annotations, jsr173_api. [#3790](https://github.com/apache/dubbo/issues/3790)
|
||||
- Qos port can't be disabled by externalized property. [#3958](https://github.com/apache/dubbo/issues/3958)
|
||||
- Fix consumer will generate wrong stackTrace. [#4137](https://github.com/apache/dubbo/issues/4137)
|
||||
- nacos registry serviceName may conflict. [#4111](https://github.com/apache/dubbo/issues/4111)
|
||||
- The client loses the listener when the network is reconnected. [#4115](https://github.com/apache/dubbo/issues/4115)
|
||||
- fix registery urls increase forever when recreate reference proxy. [#4109](https://github.com/apache/dubbo/issues/4109)
|
||||
- In dubbo 2.7.1,the watcher processor of zookeeper client throw Nullpointexception. [#3866](https://github.com/apache/dubbo/issues/3866)
|
||||
- ReferenceConfig initialized not changed to false once subscribe throws exception [#4068](https://github.com/apache/dubbo/issues/4068)
|
||||
- dubbo registry extension compatibility with dubbo 2.6.x. [#3882](https://github.com/apache/dubbo/issues/3882)
|
||||
- Annotation mode cannot set service parameters in 2.7.0. [#3778](https://github.com/apache/dubbo/issues/3778)
|
||||
- compatibility with Zipkin. [#3728](https://github.com/apache/dubbo/issues/3728)
|
||||
- do local export before register any listener. [#3669](https://github.com/apache/dubbo/issues/3669)
|
||||
- Cannot recognize 2.6.x compatible rules from dubbo-admin. [#4059](https://github.com/apache/dubbo/issues/4059)
|
||||
- In Dubbo 2.7.0, the provider can't be configured to async [#3650](https://github.com/apache/dubbo/issues/3650)
|
||||
- dubbox compatibility [#3991](https://github.com/apache/dubbo/issues/3991)
|
||||
- dubbo-2.7.1 providers repeat register [#3785](https://github.com/apache/dubbo/issues/3785)
|
||||
- consul registry: NullPointerException [#3923](https://github.com/apache/dubbo/issues/3923)
|
||||
- cannot publish local ip address when local ip and public ip exist at the same time [#3802](https://github.com/apache/dubbo/issues/3802)
|
||||
- roll back change made by 3520. [#3935](https://github.com/apache/dubbo/issues/3935)
|
||||
- dubbo-registry-nacos module is not bundled into Apache Dubbo 2.7.1 [#3797](https://github.com/apache/dubbo/issues/3797)
|
||||
- switch from CopyOnWriteArrayList to regular list in order to avoid potential UnsupportedOperationException [#3242](https://github.com/apache/dubbo/issues/3242)
|
||||
- Serialization ContentTypeId conflict between avro protocol and protocoluff protocol [#3926](https://github.com/apache/dubbo/issues/3926)
|
||||
- delay export function doesn't work. [#3952](https://github.com/apache/dubbo/issues/3952)
|
||||
- org.apache.dubbo.rpc.support.MockInvoker#getInterface should not return null [#3713](https://github.com/apache/dubbo/issues/3713)
|
||||
- dubbo TagRouter does not work with dubbo:parameter [#3875](https://github.com/apache/dubbo/issues/3875)
|
||||
- make protocols a mutable list (a concrete ArrayList) [#3841](https://github.com/apache/dubbo/issues/3841)
|
||||
- javadoc lint issue [#3646](https://github.com/apache/dubbo/issues/3646)
|
||||
- The etcd3 lease should be recycled correctly [#3684](https://github.com/apache/dubbo/issues/3684)
|
||||
- telnet can't work when parameter has no nullary constructor and some fields is primitive [#4007](https://github.com/apache/dubbo/issues/4007)
|
||||
- Sort added router list before set the 'routers' field of the RouterChain [#3969](https://github.com/apache/dubbo/issues/3969)
|
||||
- fix injvm and local call [#3638](https://github.com/apache/dubbo/issues/3638)
|
||||
- spelling error in org.apache.dubbo.common.extension.AdaptiveClassCodeGenerator#generateReturnAndInovation [#3933](https://github.com/apache/dubbo/issues/3933)
|
||||
- metadata report doesn't support redis with password [#3826](https://github.com/apache/dubbo/issues/3826)
|
||||
- The dubbo protostuff protocol serializes the bug of java.sql.Timestamp [#3914](https://github.com/apache/dubbo/issues/3914)
|
||||
- do not filter thread pool by port [#3919](https://github.com/apache/dubbo/issues/3919)
|
||||
- 'dubbo-serialization-gson' maven package error [#3903](https://github.com/apache/dubbo/issues/3903)
|
||||
- AbstractRegistry will be endless loop, when doSaveProperties method have no permission to save the file [#3746](https://github.com/apache/dubbo/issues/3746)
|
||||
- fix fastjson serialization with generic return type [#3771](https://github.com/apache/dubbo/issues/3771)
|
||||
- The dubbo-serialization -api modules should not dependency on third-party jar packages [#3762](https://github.com/apache/dubbo/issues/3762)
|
||||
- when using protostuff to serialize, there is not to check whether the data is null [#3727](https://github.com/apache/dubbo/issues/3727)
|
||||
- bugfix and enhancement for async [#3287](https://github.com/apache/dubbo/issues/3287)
|
||||
|
||||
## 2.7.1
|
||||
|
||||
### Notice
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ There's a [README](https://github.com/apache/dubbo-samples/tree/master/dubbo-sam
|
|||
|
||||
```xml
|
||||
<properties>
|
||||
<dubbo.version>2.7.1</dubbo.version>
|
||||
<dubbo.version>2.7.2</dubbo.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import com.alibaba.dubbo.common.URL;
|
|||
import com.alibaba.dubbo.rpc.Invocation;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 2019-04-18
|
||||
|
|
@ -76,8 +75,4 @@ public class RpcUtils extends org.apache.dubbo.rpc.support.RpcUtils {
|
|||
public static boolean isOneway(URL url, Invocation inv) {
|
||||
return org.apache.dubbo.rpc.support.RpcUtils.isOneway(url.getOriginalURL(), inv);
|
||||
}
|
||||
|
||||
public static Map<String, String> getNecessaryAttachments(Invocation inv) {
|
||||
return org.apache.dubbo.rpc.support.RpcUtils.getNecessaryAttachments(inv);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,9 +46,6 @@ import static com.alibaba.nacos.api.PropertyKeyConst.NAMESPACE;
|
|||
import static com.alibaba.nacos.api.PropertyKeyConst.SECRET_KEY;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR;
|
||||
import static com.alibaba.nacos.client.naming.utils.UtilAndComs.NACOS_NAMING_LOG_NAME;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_CHAR_SEPERATOR;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROPERTIES_CHAR_SEPERATOR;
|
||||
import static org.apache.dubbo.configcenter.Constants.CONFIG_NAMESPACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY;
|
||||
|
||||
/**
|
||||
|
|
@ -57,11 +54,10 @@ import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY;
|
|||
public class NacosDynamicConfiguration implements DynamicConfiguration {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
/**
|
||||
* The final root path would be: /$NAME_SPACE/config
|
||||
* the default timeout in millis to get config from nacos
|
||||
*/
|
||||
private String rootPath;
|
||||
private static final long DEFAULT_TIMEOUT = 5000L;
|
||||
|
||||
/**
|
||||
* The nacos configService
|
||||
|
|
@ -75,7 +71,6 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
|
|||
private final ConcurrentMap<String, NacosConfigListener> watchListenerMap;
|
||||
|
||||
NacosDynamicConfiguration(URL url) {
|
||||
rootPath = url.getParameter(CONFIG_NAMESPACE_KEY, DEFAULT_GROUP) + "-config";
|
||||
buildConfigService(url);
|
||||
watchListenerMap = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
|
@ -93,24 +88,6 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
|
|||
return configService;
|
||||
}
|
||||
|
||||
public void publishNacosConfig(String key, String value) {
|
||||
try {
|
||||
String[] keyAndGroup = getKeyAndGroup(key);
|
||||
configService.publishConfig(keyAndGroup[0], keyAndGroup[1], value);
|
||||
} catch (NacosException e) {
|
||||
logger.error(e.getErrMsg());
|
||||
}
|
||||
}
|
||||
|
||||
private String[] getKeyAndGroup(String key) {
|
||||
int i = key.lastIndexOf(GROUP_CHAR_SEPERATOR);
|
||||
if (i < 0) {
|
||||
return new String[]{key, null};
|
||||
} else {
|
||||
return new String[]{key.substring(0, i), key.substring(i+1)};
|
||||
}
|
||||
}
|
||||
|
||||
private Properties buildNacosProperties(URL url) {
|
||||
Properties properties = new Properties();
|
||||
setServerAddr(url, properties);
|
||||
|
|
@ -162,43 +139,70 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
|
|||
return configListener;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FIXME: 2019-05-30 to remove this function
|
||||
* Nacos server does not support * as valid character of data-id.
|
||||
* If a Dubbo service specifies group. For example:
|
||||
*
|
||||
* <dubbo:service interface="org.apache.dubbo.demo.DemoService" ref="demoService"
|
||||
* version="1.0.0.test" group="test"/>
|
||||
*
|
||||
* The key passed to NacosDynamicConfiguration will be sth. like:
|
||||
* test*org.apache.dubbo.demo.DemoService:1.0.0.test.configurators
|
||||
*
|
||||
* See logic in org.apache.dubbo.common.URL#getEncodedServiceKey()
|
||||
*
|
||||
* The purpose of this function is to convert the * into :, to keep align with
|
||||
* the implementation in NacosRegistry.
|
||||
*
|
||||
* In the future this logic should be removed if Dubbo core can handle this.
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
private String normalizedKey(String key) {
|
||||
return key.replaceFirst("\\*", ":");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(String key, String group, ConfigurationListener listener) {
|
||||
String[] keyAndGroup = getKeyAndGroup(key);
|
||||
if (keyAndGroup[1] != null) {
|
||||
group = keyAndGroup[1];
|
||||
}
|
||||
String finalGroup = group;
|
||||
NacosConfigListener nacosConfigListener = watchListenerMap.computeIfAbsent(generateKey(key, group), k -> createTargetListener(key, finalGroup));
|
||||
String keyInNacos = rootPath + PROPERTIES_CHAR_SEPERATOR + key;
|
||||
String normalizedKey = normalizedKey(key);
|
||||
NacosConfigListener nacosConfigListener = watchListenerMap.computeIfAbsent(normalizedKey, k -> createTargetListener(normalizedKey, group));
|
||||
nacosConfigListener.addListener(listener);
|
||||
try {
|
||||
configService.addListener(keyInNacos, group, nacosConfigListener);
|
||||
System.out.println("1");
|
||||
configService.addListener(normalizedKey, group, nacosConfigListener);
|
||||
} catch (NacosException e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String generateKey(String key, String group) {
|
||||
if (StringUtils.isNotEmpty(group)) {
|
||||
key = key + GROUP_CHAR_SEPERATOR + group;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(String key, String group, ConfigurationListener listener) {
|
||||
NacosConfigListener eventListener = watchListenerMap.get(generateKey(key, group));
|
||||
String normalizedKey = normalizedKey(key);
|
||||
NacosConfigListener eventListener = watchListenerMap.get(normalizedKey);
|
||||
if (eventListener != null) {
|
||||
eventListener.removeListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME the model of Zookeeper and Nacos is inconsistent, need to remove this function in next release.
|
||||
*/
|
||||
@Override
|
||||
public String getConfig(String key) {
|
||||
return getConfig(key, DEFAULT_GROUP, -1L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfig(String key, String group, long timeout) throws IllegalStateException {
|
||||
key = generateKey(key, group);
|
||||
return (String) getInternalProperty(rootPath + PROPERTIES_CHAR_SEPERATOR + key);
|
||||
try {
|
||||
String normalizedKey = normalizedKey(key);
|
||||
long nacosTimeout = timeout < 0 ? DEFAULT_TIMEOUT : timeout;
|
||||
return configService.getConfig(normalizedKey, group, nacosTimeout);
|
||||
} catch (NacosException e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -209,8 +213,8 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
|
|||
@Override
|
||||
public Object getInternalProperty(String key) {
|
||||
try {
|
||||
String[] keyAndGroup = getKeyAndGroup(key);
|
||||
return configService.getConfig(keyAndGroup[0], keyAndGroup[1], 5000L);
|
||||
String normalizedKey = normalizedKey(key);
|
||||
return configService.getConfig(normalizedKey, DEFAULT_GROUP, DEFAULT_TIMEOUT);
|
||||
} catch (NacosException e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,10 +17,14 @@
|
|||
|
||||
package org.apache.dubbo.configcenter.support.nacos;
|
||||
|
||||
import com.alibaba.nacos.api.NacosFactory;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.configcenter.ConfigChangeEvent;
|
||||
import org.apache.dubbo.configcenter.ConfigurationListener;
|
||||
|
||||
import org.apache.dubbo.configcenter.DynamicConfiguration;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
|
@ -42,15 +46,22 @@ public class NacosDynamicConfigurationTest {
|
|||
|
||||
private static NacosDynamicConfiguration config;
|
||||
|
||||
/**
|
||||
* A test client to put data to Nacos server for testing purpose
|
||||
*/
|
||||
private static ConfigService nacosClient;
|
||||
|
||||
@Test
|
||||
public void testGetConfig() throws Exception {
|
||||
|
||||
put("dubbo-config-org.apache.dubbo.nacos.testService.configurators", "hello");
|
||||
put("org.apache.dubbo.nacos.testService.configurators", "hello");
|
||||
Thread.sleep(200);
|
||||
put("dubbo-config-dubbo.properties:test", "aaa=bbb");
|
||||
put("dubbo.properties", "test", "aaa=bbb");
|
||||
Thread.sleep(200);
|
||||
put("xxxx:org.apache.dubbo.demo.DemoService:1.0.0.test.configurators", "helloworld");
|
||||
Thread.sleep(200);
|
||||
Assertions.assertEquals("hello", config.getConfig("org.apache.dubbo.nacos.testService.configurators"));
|
||||
Assertions.assertEquals("aaa=bbb", config.getConfig("dubbo.properties", "test"));
|
||||
Assertions.assertEquals("helloworld", config.getConfig("xxxx*org.apache.dubbo.demo.DemoService:1.0.0.test.configurators"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -67,19 +78,19 @@ public class NacosDynamicConfigurationTest {
|
|||
config.addListener("testapp.tagrouters", listener3);
|
||||
config.addListener("testapp.tagrouters", listener4);
|
||||
|
||||
put("dubbo-config-AService.configurators", "new value1");
|
||||
put("AService.configurators", "new value1");
|
||||
Thread.sleep(200);
|
||||
put("dubbo-config-testapp.tagrouters", "new value2");
|
||||
put("testapp.tagrouters", "new value2");
|
||||
Thread.sleep(200);
|
||||
put("dubbo-config-testapp", "new value3");
|
||||
put("testapp", "new value3");
|
||||
Thread.sleep(5000);
|
||||
|
||||
latch.await();
|
||||
|
||||
Assertions.assertEquals(1, listener1.getCount("dubbo-config-AService.configurators"));
|
||||
Assertions.assertEquals(1, listener2.getCount("dubbo-config-AService.configurators"));
|
||||
Assertions.assertEquals(1, listener3.getCount("dubbo-config-testapp.tagrouters"));
|
||||
Assertions.assertEquals(1, listener4.getCount("dubbo-config-testapp.tagrouters"));
|
||||
Assertions.assertEquals(1, listener1.getCount("AService.configurators"));
|
||||
Assertions.assertEquals(1, listener2.getCount("AService.configurators"));
|
||||
Assertions.assertEquals(1, listener3.getCount("testapp.tagrouters"));
|
||||
Assertions.assertEquals(1, listener4.getCount("testapp.tagrouters"));
|
||||
|
||||
Assertions.assertEquals("new value1", listener1.getValue());
|
||||
Assertions.assertEquals("new value1", listener2.getValue());
|
||||
|
|
@ -89,8 +100,12 @@ public class NacosDynamicConfigurationTest {
|
|||
}
|
||||
|
||||
private void put(String key, String value) {
|
||||
put(key, DynamicConfiguration.DEFAULT_GROUP, value);
|
||||
}
|
||||
|
||||
private void put(String key, String group, String value) {
|
||||
try {
|
||||
config.publishNacosConfig(key, value);
|
||||
nacosClient.publishConfig(key, group, value);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error put value to nacos.");
|
||||
}
|
||||
|
|
@ -103,10 +118,18 @@ public class NacosDynamicConfigurationTest {
|
|||
URL url = URL.valueOf(urlForDubbo)
|
||||
.addParameter(SESSION_TIMEOUT_KEY, 15000);
|
||||
config = new NacosDynamicConfiguration(url);
|
||||
|
||||
|
||||
try {
|
||||
nacosClient = NacosFactory.createConfigService("127.0.0.1:8848");
|
||||
} catch (NacosException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void tearDown() {
|
||||
|
||||
}
|
||||
|
||||
private class TestListener implements ConfigurationListener {
|
||||
|
|
@ -121,7 +144,7 @@ public class NacosDynamicConfigurationTest {
|
|||
@Override
|
||||
public void process(ConfigChangeEvent event) {
|
||||
System.out.println(this + ": " + event);
|
||||
Integer count = countMap.computeIfAbsent(event.getKey(), k -> new Integer(0));
|
||||
Integer count = countMap.computeIfAbsent(event.getKey(), k -> 0);
|
||||
countMap.put(event.getKey(), ++count);
|
||||
value = event.getValue();
|
||||
latch.countDown();
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@
|
|||
<mortbay_jetty_version>6.1.26</mortbay_jetty_version>
|
||||
<portlet_version>2.0</portlet_version>
|
||||
<maven_flatten_version>1.1.0</maven_flatten_version>
|
||||
<revision>2.7.2-SNAPSHOT</revision>
|
||||
<revision>2.7.3-SNAPSHOT</revision>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
|
@ -597,6 +597,12 @@
|
|||
<groupId>io.etcd</groupId>
|
||||
<artifactId>jetcd-launcher</artifactId>
|
||||
<version>${etcd_launcher_version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.github.spotbugs</groupId>
|
||||
<artifactId>spotbugs-annotations</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<revision>2.7.2-SNAPSHOT</revision>
|
||||
<revision>2.7.3-SNAPSHOT</revision>
|
||||
<maven_flatten_version>1.1.0</maven_flatten_version>
|
||||
</properties>
|
||||
|
||||
|
|
|
|||
|
|
@ -37,18 +37,28 @@ import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT;
|
|||
import static com.alibaba.nacos.api.PropertyKeyConst.NAMESPACE;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.CLUSTER_NAME;
|
||||
import static com.alibaba.nacos.client.naming.utils.UtilAndComs.NACOS_NAMING_LOG_NAME;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY;
|
||||
|
||||
/**
|
||||
* metadata report impl for nacos
|
||||
*/
|
||||
public class NacosMetadataReport extends AbstractMetadataReport {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NacosMetadataReport.class);
|
||||
|
||||
private ConfigService configService;
|
||||
|
||||
/**
|
||||
* The group used to store metadata in Nacos
|
||||
*/
|
||||
private String group;
|
||||
|
||||
|
||||
public NacosMetadataReport(URL url) {
|
||||
super(url);
|
||||
this.configService = buildConfigService(url);
|
||||
group = url.getParameter(GROUP_KEY, DEFAULT_ROOT);
|
||||
}
|
||||
|
||||
public ConfigService buildConfigService(URL url) {
|
||||
|
|
@ -113,7 +123,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
|
|||
|
||||
private void storeMetadata(MetadataIdentifier identifier, String value) {
|
||||
try {
|
||||
boolean publishResult = configService.publishConfig(identifier.getUniqueKey(MetadataIdentifier.KeyTypeEnum.UNIQUE_KEY), identifier.getGroup(), value);
|
||||
boolean publishResult = configService.publishConfig(identifier.getUniqueKey(MetadataIdentifier.KeyTypeEnum.UNIQUE_KEY), group, value);
|
||||
if (!publishResult) {
|
||||
throw new RuntimeException("publish nacos metadata failed");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,10 +45,12 @@ public class NacosMetadataReportTest {
|
|||
private NacosMetadataReportFactory nacosMetadataReportFactory;
|
||||
private ConfigService configService;
|
||||
|
||||
private static final String NACOS_GROUP = "zzz";
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
// timeout in 15 seconds.
|
||||
URL url = URL.valueOf("nacos://127.0.0.1:8848")
|
||||
URL url = URL.valueOf("nacos://127.0.0.1:8848?group=" + NACOS_GROUP)
|
||||
.addParameter(SESSION_TIMEOUT_KEY, 15000);
|
||||
nacosMetadataReportFactory = new NacosMetadataReportFactory();
|
||||
this.nacosMetadataReport = (NacosMetadataReport) nacosMetadataReportFactory.createMetadataReport(url);
|
||||
|
|
@ -66,7 +68,7 @@ public class NacosMetadataReportTest {
|
|||
String application = "nacos-metdata-report-test";
|
||||
MetadataIdentifier providerIdentifier =
|
||||
storeProvider(nacosMetadataReport, TEST_SERVICE, version, group, application);
|
||||
String serverContent = configService.getConfig(providerIdentifier.getUniqueKey(MetadataIdentifier.KeyTypeEnum.UNIQUE_KEY), group, 5000L);
|
||||
String serverContent = configService.getConfig(providerIdentifier.getUniqueKey(MetadataIdentifier.KeyTypeEnum.UNIQUE_KEY), NACOS_GROUP, 5000L);
|
||||
Assertions.assertNotNull(serverContent);
|
||||
|
||||
Gson gson = new Gson();
|
||||
|
|
@ -81,7 +83,7 @@ public class NacosMetadataReportTest {
|
|||
String application = "nacos-metadata-report-consumer-test";
|
||||
MetadataIdentifier consumerIdentifier = storeConsumer(nacosMetadataReport, TEST_SERVICE, version, group, application);
|
||||
|
||||
String serverContent = configService.getConfig(consumerIdentifier.getUniqueKey(MetadataIdentifier.KeyTypeEnum.UNIQUE_KEY), group, 5000L);
|
||||
String serverContent = configService.getConfig(consumerIdentifier.getUniqueKey(MetadataIdentifier.KeyTypeEnum.UNIQUE_KEY), NACOS_GROUP, 5000L);
|
||||
Assertions.assertNotNull(serverContent);
|
||||
Assertions.assertEquals(serverContent, "{\"paramConsumerTest\":\"nacosConsumer\"}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -383,7 +383,7 @@ public class NacosRegistry extends FailbackRegistry {
|
|||
*/
|
||||
private String[] getCategories(URL url) {
|
||||
return ANY_VALUE.equals(url.getServiceInterface()) ?
|
||||
ALL_SUPPORTED_CATEGORIES : of(DEFAULT_CATEGORY);
|
||||
ALL_SUPPORTED_CATEGORIES : url.getParameter(CATEGORY_KEY,new String[]{DEFAULT_CATEGORY});
|
||||
}
|
||||
|
||||
private URL buildURL(Instance instance) {
|
||||
|
|
|
|||
|
|
@ -84,10 +84,6 @@ public interface Constants {
|
|||
|
||||
String ASYNC_KEY = "async";
|
||||
|
||||
String FUTURE_GENERATED_KEY = "future_generated";
|
||||
|
||||
String FUTURE_RETURNTYPE_KEY = "future_returntype";
|
||||
|
||||
String RETURN_KEY = "return";
|
||||
|
||||
String TOKEN_KEY = "token";
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public class RpcInvocation implements Invocation, Serializable {
|
|||
}
|
||||
|
||||
public RpcInvocation(Method method, Object[] arguments) {
|
||||
this(method.getName(), method.getParameterTypes(), arguments, null, null);
|
||||
this(method, arguments, null);
|
||||
}
|
||||
|
||||
public RpcInvocation(Method method, Object[] arguments, Map<String, String> attachment) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ 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.lang.reflect.InvocationTargetException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
|
@ -112,10 +111,7 @@ public abstract class AbstractProxyInvoker<T> implements Invoker<T> {
|
|||
private CompletableFuture<Object> wrapWithFuture (Object value, Invocation invocation) {
|
||||
if (RpcContext.getContext().isAsyncStarted()) {
|
||||
return ((AsyncContextImpl)(RpcContext.getContext().getAsyncContext())).getInternalFuture();
|
||||
} else if (RpcUtils.isReturnTypeFuture(invocation)) {
|
||||
if (value == null) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
} else if (value instanceof CompletableFuture) {
|
||||
return (CompletableFuture<Object>) value;
|
||||
}
|
||||
return CompletableFuture.completedFuture(value);
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@ import org.apache.dubbo.rpc.RpcInvocation;
|
|||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
|
|
@ -36,7 +34,6 @@ import static org.apache.dubbo.rpc.Constants.$INVOKE;
|
|||
import static org.apache.dubbo.rpc.Constants.$INVOKE_ASYNC;
|
||||
import static org.apache.dubbo.rpc.Constants.ASYNC_KEY;
|
||||
import static org.apache.dubbo.rpc.Constants.AUTO_ATTACH_INVOCATIONID_KEY;
|
||||
import static org.apache.dubbo.rpc.Constants.FUTURE_GENERATED_KEY;
|
||||
import static org.apache.dubbo.rpc.Constants.ID_KEY;
|
||||
import static org.apache.dubbo.rpc.Constants.RETURN_KEY;
|
||||
/**
|
||||
|
|
@ -171,7 +168,12 @@ public class RpcUtils {
|
|||
}
|
||||
|
||||
public static boolean isReturnTypeFuture(Invocation inv) {
|
||||
Class<?> clazz = getReturnType(inv);
|
||||
Class<?> clazz;
|
||||
if (inv instanceof RpcInvocation) {
|
||||
clazz = ((RpcInvocation) inv).getReturnType();
|
||||
} else {
|
||||
clazz = getReturnType(inv);
|
||||
}
|
||||
return (clazz != null && CompletableFuture.class.isAssignableFrom(clazz)) || isGenericAsync(inv);
|
||||
}
|
||||
|
||||
|
|
@ -198,12 +200,4 @@ public class RpcUtils {
|
|||
}
|
||||
return isOneway;
|
||||
}
|
||||
|
||||
public static Map<String, String> getNecessaryAttachments(Invocation inv) {
|
||||
Map<String, String> attachments = new HashMap<>(inv.getAttachments());
|
||||
attachments.remove(ASYNC_KEY);
|
||||
attachments.remove(FUTURE_GENERATED_KEY);
|
||||
return attachments;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,17 +33,16 @@ import org.apache.dubbo.remoting.transport.CodecSupport;
|
|||
import org.apache.dubbo.rpc.Invocation;
|
||||
import org.apache.dubbo.rpc.Result;
|
||||
import org.apache.dubbo.rpc.RpcInvocation;
|
||||
import org.apache.dubbo.rpc.support.RpcUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.DUBBO_VERSION_KEY;
|
||||
import static org.apache.dubbo.rpc.protocol.dubbo.CallbackServiceCodec.encodeInvocationArgument;
|
||||
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.DECODE_IN_IO_THREAD_KEY;
|
||||
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.DEFAULT_DECODE_IN_IO_THREAD;
|
||||
import static org.apache.dubbo.remoting.Constants.DUBBO_VERSION_KEY;
|
||||
|
||||
/**
|
||||
* Dubbo codec.
|
||||
|
|
@ -186,7 +185,7 @@ public class DubboCodec extends ExchangeCodec {
|
|||
out.writeObject(encodeInvocationArgument(channel, inv, i));
|
||||
}
|
||||
}
|
||||
out.writeObject(RpcUtils.getNecessaryAttachments(inv));
|
||||
out.writeObject(inv.getAttachments());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import org.apache.dubbo.remoting.Constants;
|
|||
import org.apache.dubbo.remoting.RemotingException;
|
||||
import org.apache.dubbo.remoting.TimeoutException;
|
||||
import org.apache.dubbo.remoting.exchange.ExchangeClient;
|
||||
import org.apache.dubbo.rpc.AppResponse;
|
||||
import org.apache.dubbo.rpc.AsyncRpcResult;
|
||||
import org.apache.dubbo.rpc.Invocation;
|
||||
import org.apache.dubbo.rpc.Invoker;
|
||||
|
|
@ -97,13 +96,7 @@ public class DubboInvoker<T> extends AbstractInvoker<T> {
|
|||
} else {
|
||||
AsyncRpcResult asyncRpcResult = new AsyncRpcResult(inv);
|
||||
CompletableFuture<Object> responseFuture = currentClient.request(inv, timeout);
|
||||
responseFuture.whenComplete((obj, t) -> {
|
||||
if (t != null) {
|
||||
asyncRpcResult.completeExceptionally(t);
|
||||
} else {
|
||||
asyncRpcResult.complete((AppResponse) obj);
|
||||
}
|
||||
});
|
||||
asyncRpcResult.subscribeTo(responseFuture);
|
||||
RpcContext.getContext().setFuture(new FutureAdapter(asyncRpcResult));
|
||||
return asyncRpcResult;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue