Skip to content

Commit

Permalink
fix #3124 . move RegistryDataConfig configuration into RegistryConfig…
Browse files Browse the repository at this point in the history
… and remove RegistryDataConfig (#3129)
  • Loading branch information
cvictory authored and beiwei30 committed Jan 4, 2019
1 parent 3bf77ab commit 83b54a8
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 162 deletions.
16 changes: 3 additions & 13 deletions dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -482,23 +482,13 @@ public class Constants {
* simple the registry for provider.
* @since 2.7.0
*/
public static final String SIMPLE_PROVIDER_CONFIG_KEY = "simple.provider.config";
/**
* simple the registry for consumer.
* @since 2.7.0
*/
public static final String SIMPLE_CONSUMER_CONFIG_KEY = "simple.consumer.config";
public static final String SIMPLIFIED_KEY = "simplified";

/**
* After simplify the registry, should add some paramter individually for provider.
* @since 2.7.0
*/
public static final String EXTRA_PROVIDER_CONFIG_KEYS_KEY = "extra.provider.keys";
/**
* After simplify the registry, should add some paramter individually for consumer.
*
* @since 2.7.0
*/
public static final String EXTRA_CONSUMER_CONFIG_KEYS_KEY = "extra.consumer.keys";
public static final String EXTRA_KEYS_KEY = "extra-keys";

/**
* To decide whether to exclude unavailable invoker from the cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
*/
protected String ondisconnect;
protected MetadataReportConfig metadataReportConfig;
protected RegistryDataConfig registryDataConfig;
// callback limits
private Integer callbacks;
// the scope for referring/exporting a service, if it's local, it means searching in current JVM only.
Expand Down Expand Up @@ -219,16 +218,6 @@ protected void checkMetadataReport() {
}
}

protected void checkRegistryDataConfig() {
if (registryDataConfig == null) {
registryDataConfig = new RegistryDataConfig();
}
registryDataConfig.refresh();
if (!registryDataConfig.isValid()) {
logger.info("There's no valid registryData config found. So the registry will store full url parameter " +
"to registry server.");
}
}

/**
*
Expand All @@ -240,11 +229,8 @@ protected void checkRegistryDataConfig() {
protected List<URL> loadRegistries(boolean provider) {
// check && override if necessary
checkRegistry();
checkRegistryDataConfig();
List<URL> registryList = new ArrayList<URL>();
if (registries != null && !registries.isEmpty()) {
Map<String, String> registryDataConfigurationMap = new HashMap<>(4);
appendParameters(registryDataConfigurationMap, registryDataConfig);
for (RegistryConfig config : registries) {
String address = config.getAddress();
if (StringUtils.isEmpty(address)) {
Expand All @@ -264,8 +250,6 @@ protected List<URL> loadRegistries(boolean provider) {
for (URL url : urls) {
url = url.addParameter(Constants.REGISTRY_KEY, url.getProtocol());
url = url.setProtocol(Constants.REGISTRY_PROTOCOL);
// add parameter
url = url.addParametersIfAbsent(registryDataConfigurationMap);
if ((provider && url.getParameter(Constants.REGISTER_KEY, true))
|| (!provider && url.getParameter(Constants.SUBSCRIBE_KEY, true))) {
registryList.add(url);
Expand Down Expand Up @@ -711,14 +695,6 @@ public void setOwner(String owner) {
this.owner = owner;
}

public RegistryDataConfig getRegistryDataConfig() {
return registryDataConfig;
}

public void setRegistryDataConfig(RegistryDataConfig registryDataConfig) {
this.registryDataConfig = registryDataConfig;
}

public Integer getCallbacks() {
return callbacks;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ public void checkAndUpdateSubConfigs() {
}
checkApplication();
checkMetadataReport();
checkRegistryDataConfig();
}

public synchronized T get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,19 @@ public class RegistryConfig extends AbstractConfig {
private Boolean isDefault;

/**
* Simple the registry.
* Simple the registry. both useful for provider and consumer
*
* @since 2.7.0
*/
private Boolean simple;
private Boolean simplified;
/**
* After simplify the registry, should add some paramter individually.
* addionalParameterKeys = addParamKeys
* After simplify the registry, should add some paramter individually. just for provider.
* <p>
* such as: extra-keys = A,b,c,d
*
* @since 2.7.0
*/
private String addParamKeys;
private String extraKeys;

public RegistryConfig() {
}
Expand Down Expand Up @@ -380,6 +381,23 @@ public void setDefault(Boolean isDefault) {
this.isDefault = isDefault;
}

public Boolean getSimplified() {
return simplified;
}

public void setSimplified(Boolean simplified) {
this.simplified = simplified;
}

@Parameter(key = Constants.EXTRA_KEYS_KEY)
public String getExtraKeys() {
return extraKeys;
}

public void setExtraKeys(String extraKeys) {
this.extraKeys = extraKeys;
}

@Parameter(excluded = true)
public boolean isZookeeperProtocol() {
if (!isValid()) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ public void checkAndUpdateSubConfigs() {
checkProtocol();
this.refresh();
checkMetadataReport();
checkRegistryDataConfig();

if (interfaceName == null || interfaceName.length() == 0) {
throw new IllegalStateException("<dubbo:service interface=\"\" /> interface not allow null!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
import org.apache.dubbo.config.MonitorConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.RegistryDataConfig;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.spring.extension.SpringExtensionFactory;
import org.apache.dubbo.config.support.Parameter;

import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
Expand Down Expand Up @@ -188,16 +186,6 @@ public void afterPropertiesSet() throws Exception {
}
}


if (getRegistryDataConfig() == null) {
Map<String, RegistryDataConfig> registryDataConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RegistryDataConfig.class, false, false);
if (registryDataConfigMap != null && registryDataConfigMap.size() == 1) {
super.setRegistryDataConfig(registryDataConfigMap.values().iterator().next());
} else if (registryDataConfigMap != null && registryDataConfigMap.size() > 1) {
throw new IllegalStateException("Multiple RegistryData configs: " + registryDataConfigMap);
}
}

if (getMonitor() == null
&& (getConsumer() == null || getConsumer().getMonitor() == null)
&& (getApplication() == null || getApplication().getMonitor() == null)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ProviderConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.RegistryDataConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.config.spring.extension.SpringExtensionFactory;

import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.BeanNameAware;
Expand Down Expand Up @@ -220,15 +218,6 @@ public void afterPropertiesSet() throws Exception {
}
}

if (getRegistryDataConfig() == null) {
Map<String, RegistryDataConfig> registryDataConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RegistryDataConfig.class, false, false);
if (registryDataConfigMap != null && registryDataConfigMap.size() == 1) {
super.setRegistryDataConfig(registryDataConfigMap.values().iterator().next());
} else if (registryDataConfigMap != null && registryDataConfigMap.size() > 1) {
throw new IllegalStateException("Multiple RegistryData configs: " + registryDataConfigMap);
}
}

if (getMonitor() == null
&& (getProvider() == null || getProvider().getMonitor() == null)
&& (getApplication() == null || getApplication().getMonitor() == null)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ProviderConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.RegistryDataConfig;
import org.apache.dubbo.config.spring.ConfigCenterBean;

import org.springframework.context.annotation.Configuration;

/**
Expand Down Expand Up @@ -60,7 +58,6 @@ public class DubboConfigConfiguration {
@EnableDubboConfigBinding(prefix = "dubbo.provider", type = ProviderConfig.class),
@EnableDubboConfigBinding(prefix = "dubbo.consumer", type = ConsumerConfig.class),
@EnableDubboConfigBinding(prefix = "dubbo.config-center", type = ConfigCenterBean.class),
@EnableDubboConfigBinding(prefix = "dubbo.registry-data", type = RegistryDataConfig.class),
@EnableDubboConfigBinding(prefix = "dubbo.metadata-report", type = MetadataReportConfig.class)
})
public static class Single {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,16 +565,16 @@
<xsd:documentation><![CDATA[ Is default. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<!--<xsd:attribute name="simple" type="xsd:boolean">-->
<!--<xsd:annotation>-->
<!--<xsd:documentation><![CDATA[ Is simple. ]]></xsd:documentation>-->
<!--</xsd:annotation>-->
<!--</xsd:attribute>-->
<!--<xsd:attribute name="plusparamkeys" type="xsd:string">-->
<!--<xsd:annotation>-->
<!--<xsd:documentation><![CDATA[ Addtional Parameter Keys. ]]></xsd:documentation>-->
<!--</xsd:annotation>-->
<!--</xsd:attribute>-->
<xsd:attribute name="simplified" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation><![CDATA[ Is simple. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="extra-keys" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[ Extra Parameter Keys. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>

<xsd:complexType name="metadataReportType">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,16 +559,16 @@
<xsd:documentation><![CDATA[ Is default. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<!--<xsd:attribute name="simple" type="xsd:boolean">-->
<!--<xsd:annotation>-->
<!--<xsd:documentation><![CDATA[ Is simple. ]]></xsd:documentation>-->
<!--</xsd:annotation>-->
<!--</xsd:attribute>-->
<!--<xsd:attribute name="plusparamkeys" type="xsd:string">-->
<!--<xsd:annotation>-->
<!--<xsd:documentation><![CDATA[ Addtional Parameter Keys. ]]></xsd:documentation>-->
<!--</xsd:annotation>-->
<!--</xsd:attribute>-->
<xsd:attribute name="simplified" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation><![CDATA[ Is simple. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="extra-keys" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[ Extra Parameter Keys. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>

<xsd:complexType name="metadataReportType">
Expand Down
Loading

0 comments on commit 83b54a8

Please sign in to comment.