Skip to content

Commit

Permalink
fix #3123. support metadata xml config and support dubbo.properties f…
Browse files Browse the repository at this point in the history
…ormat 'dubbo.metadata-report.address=XXx' (#3138)

* fix #3124 . move RegistryDataConfig configuration into RegistryConfig and remove RegistryDataConfig

* fix #3123.  support metadata xml configuration; support configuration format dubbo.metadata-report.address=xxx
  • Loading branch information
cvictory authored and beiwei30 committed Jan 4, 2019
1 parent 83b54a8 commit de76413
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ public class Constants {

public static final String REMOVE_VALUE_PREFIX = "-";

public static final String PROPERTIES_CHAR_SEPERATOR = "-";

public static final String HIDE_KEY_PREFIX = ".";

public static final String DEFAULT_KEY_PREFIX = "default.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
*/
package org.apache.dubbo.config;

import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.config.support.Parameter;

import java.util.Map;

import static org.apache.dubbo.common.Constants.PROPERTIES_CHAR_SEPERATOR;

/**
* RegistryConfig
*
Expand All @@ -29,6 +32,12 @@
public class MetadataReportConfig extends AbstractConfig {

private static final long serialVersionUID = 55233L;
/**
* the value is : metadata-report
*/
private static final String PREFIX_TAG = StringUtils.camelToSplitName(
MetadataReportConfig.class.getSimpleName().substring(0, MetadataReportConfig.class.getSimpleName().length() - 6), PROPERTIES_CHAR_SEPERATOR);

// Register center address
private String address;

Expand Down Expand Up @@ -104,6 +113,7 @@ public void setParameters(Map<String, String> parameters) {
this.parameters = parameters;
}

@Parameter(key = "retry-times")
public Integer getRetryTimes() {
return retryTimes;
}
Expand All @@ -112,6 +122,7 @@ public void setRetryTimes(Integer retryTimes) {
this.retryTimes = retryTimes;
}

@Parameter(key = "retry-period")
public Integer getRetryPeriod() {
return retryPeriod;
}
Expand All @@ -120,6 +131,7 @@ public void setRetryPeriod(Integer retryPeriod) {
this.retryPeriod = retryPeriod;
}

@Parameter(key = "cycle-report")
public Boolean getCycleReport() {
return cycleReport;
}
Expand All @@ -128,17 +140,24 @@ public void setCycleReport(Boolean cycleReport) {
this.cycleReport = cycleReport;
}

@Override
@Parameter(excluded = true)
public boolean isValid() {
return StringUtils.isNotEmpty(address);
}

@Parameter(key = "sync-report")
public Boolean getSyncReport() {
return syncReport;
}

public void setSyncReport(Boolean syncReport) {
this.syncReport = syncReport;
}


@Parameter(excluded = true)
public String getPrefix() {
return StringUtils.isNotEmpty(prefix) ? prefix : (Constants.DUBBO + "." + PREFIX_TAG);
}

@Override
@Parameter(excluded = true)
public boolean isValid() {
return StringUtils.isNotEmpty(address);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public static class Single {
@EnableDubboConfigBinding(prefix = "dubbo.monitors", type = MonitorConfig.class, multiple = true),
@EnableDubboConfigBinding(prefix = "dubbo.providers", type = ProviderConfig.class, multiple = true),
@EnableDubboConfigBinding(prefix = "dubbo.consumers", type = ConsumerConfig.class, multiple = true),
@EnableDubboConfigBinding(prefix = "dubbo.config-centers", type = ConfigCenterBean.class, multiple = true)
@EnableDubboConfigBinding(prefix = "dubbo.config-centers", type = ConfigCenterBean.class, multiple = true),
@EnableDubboConfigBinding(prefix = "dubbo.metadata-reports", type = MetadataReportConfig.class, multiple = true)
})
public static class Multiple {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.dubbo.common.Version;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ConsumerConfig;
import org.apache.dubbo.config.MetadataReportConfig;
import org.apache.dubbo.config.ModuleConfig;
import org.apache.dubbo.config.MonitorConfig;
import org.apache.dubbo.config.ProtocolConfig;
Expand Down Expand Up @@ -47,6 +48,7 @@ public void init() {
registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
registerBeanDefinitionParser("config-center", new DubboBeanDefinitionParser(ConfigCenterBean.class, true));
registerBeanDefinitionParser("metadata-report", new DubboBeanDefinitionParser(MetadataReportConfig.class, true));
registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,26 @@
<xsd:documentation><![CDATA[ The request timeout. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="retry-times" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ if fail, retry times. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="retry-period" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ if fail, retry period. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="cycle-report" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ report cyclely. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="sync-report" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ Sync or Async report. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>

<xsd:complexType name="configCenterType">
Expand Down Expand Up @@ -1342,7 +1362,7 @@
</xsd:annotation>
</xsd:element>

<xsd:element name="metadata" type="metadataReportType">
<xsd:element name="metadata-report" type="metadataReportType">
<xsd:annotation>
<xsd:documentation><![CDATA[ The metadataReport config ]]></xsd:documentation>
<xsd:appinfo>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,27 @@
<xsd:documentation><![CDATA[ The request timeout. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>

<xsd:attribute name="retry-times" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ if fail, retry times. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="retry-period" type="xsd:integer" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ if fail, retry period. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="cycle-report" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ report cyclely. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="sync-report" type="xsd:boolean" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ Sync or Async report. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>

<xsd:complexType name="configCenterType">
Expand Down Expand Up @@ -1336,7 +1357,7 @@
</xsd:annotation>
</xsd:element>

<xsd:element name="metadata" type="metadataReportType">
<xsd:element name="metadata-report" type="metadataReportType">
<xsd:annotation>
<xsd:documentation><![CDATA[ The metadataReport config ]]></xsd:documentation>
</xsd:annotation>
Expand Down

0 comments on commit de76413

Please sign in to comment.