Skip to content

Commit

Permalink
Merge branch '2.7.0-release' into ConfigCenter-optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj committed Jan 6, 2019
2 parents daab283 + 5c971c1 commit e6b340d
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 11 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 @@ -140,7 +140,7 @@ private static String getTagName(Class<?> cls) {
break;
}
}
return tag.substring(0, 1).toLowerCase() + tag.substring(1);
return StringUtils.camelToSplitName(tag, "-");
}

protected static void appendParameters(Map<String, String> parameters, Object config) {
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 @@ -810,7 +810,7 @@ private void checkProtocol() {
}
protocolConfig.refresh();
if (StringUtils.isNotEmpty(protocolConfig.getId())) {
protocolConfig.setPrefix("dubbo.protocols.");
protocolConfig.setPrefix(Constants.PROTOCOLS_SUFFIX);
protocolConfig.refresh();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.dubbo.config;

import junit.framework.TestCase;
import org.junit.Test;

public class ConfigCenterConfigTest {
@Test
public void testPrefix() {
ConfigCenterConfig config = new ConfigCenterConfig();
TestCase.assertEquals("dubbo.config-center", config.getPrefix());
}
}
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 e6b340d

Please sign in to comment.