[#5297] Only one of the multiple registration centers using nacos can register (#5756)

* Polish /apache/dubbo#5745 : Increasing the stack size in the start.sh

* Polish /apache/dubbo#5297 : Only one of the multiple registration centers using nacos can register
This commit is contained in:
Mercy Ma 2020-02-19 14:30:33 +08:00 committed by GitHub
parent f4af3ded4b
commit eda947a8df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 5 deletions

View File

@ -213,7 +213,7 @@ public class RegistryConfig extends AbstractConfig {
URL url = URL.valueOf(address);
setUsername(url.getUsername());
setPassword(url.getPassword());
updateIdIfAbsent(url.getProtocol());
// updateIdIfAbsent(url.getProtocol());
updateProtocolIfAbsent(url.getProtocol());
updatePortIfAbsent(url.getPort());
updateParameters(url.getParameters());

View File

@ -26,6 +26,7 @@ import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcess
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
import javax.annotation.PostConstruct;
import java.beans.PropertyDescriptor;
@ -43,7 +44,7 @@ import static org.springframework.util.ReflectionUtils.invokeMethod;
* @since 2.7.6
*/
public class DubboConfigDefaultPropertyValueBeanPostProcessor extends GenericBeanPostProcessorAdapter<AbstractConfig>
implements MergedBeanDefinitionPostProcessor, Ordered {
implements MergedBeanDefinitionPostProcessor, PriorityOrdered {
/**
* The bean name of {@link DubboConfigDefaultPropertyValueBeanPostProcessor}

View File

@ -82,7 +82,7 @@ public class EnableDubboConfigTest {
Assertions.assertEquals("netty", consumerConfig.getClient());
// asserts aliases
assertTrue(hasAlias(context, "org.apache.dubbo.config.RegistryConfig#0", "zookeeper"));
assertFalse(hasAlias(context, "org.apache.dubbo.config.RegistryConfig#0", "zookeeper"));
assertFalse(hasAlias(context, "org.apache.dubbo.config.MonitorConfig#0", "zookeeper"));
}

View File

@ -109,7 +109,7 @@ public abstract class AbstractRegistryFactory implements RegistryFactory {
.addParameter(INTERFACE_KEY, RegistryService.class.getName())
.removeParameters(EXPORT_KEY, REFER_KEY)
.build();
String key = url.toServiceStringWithoutResolving();
String key = createRegistryCacheKey(url);
// Lock the registry access process to ensure a single instance of the registry
LOCK.lock();
try {
@ -130,6 +130,17 @@ public abstract class AbstractRegistryFactory implements RegistryFactory {
}
}
/**
* Create the key for the registries cache.
* This method may be override by the sub-class.
*
* @param url the registration {@link URL url}
* @return non-null
*/
protected String createRegistryCacheKey(URL url) {
return url.toServiceStringWithoutResolving();
}
protected abstract Registry createRegistry(URL url);
@ -175,7 +186,7 @@ public abstract class AbstractRegistryFactory implements RegistryFactory {
}
};
public static void removeDestroyedRegistry(Registry toRm){
public static void removeDestroyedRegistry(Registry toRm) {
LOCK.lock();
try {
REGISTRIES.entrySet().removeIf(entry -> entry.getValue().equals(toRm));

View File

@ -30,6 +30,11 @@ import static org.apache.dubbo.registry.nacos.util.NacosNamingServiceUtils.creat
*/
public class NacosRegistryFactory extends AbstractRegistryFactory {
@Override
protected String createRegistryCacheKey(URL url) {
return url.toFullString();
}
@Override
protected Registry createRegistry(URL url) {
return new NacosRegistry(url, createNamingService(url));