Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #3123. support metadata xml config and support dubbo.properties format 'dubbo.metadata-report.address=XXx' #3138

Merged
merged 4 commits into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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