Skip to content

Commit

Permalink
fix config-center configured in dubbo.properties does not work. (apac…
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj authored Feb 28, 2020
1 parent 2a7b5d1 commit ca28815
Showing 1 changed file with 30 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -507,16 +507,12 @@ private void initialize() {

useRegistryAsConfigCenterIfNecessary();

startMetadataReport();

loadRemoteConfigs();

checkGlobalConfigs();

initMetadataService();

initMetadataServiceExporter();

initEventListener();

if (logger.isInfoEnabled()) {
Expand All @@ -527,17 +523,22 @@ private void initialize() {
private void checkGlobalConfigs() {
// check Application
ConfigValidationUtils.validateApplicationConfig(getApplication());
// check Config Center
Collection<ConfigCenterConfig> configCenters = configManager.getConfigCenters();
if (CollectionUtils.isNotEmpty(configCenters)) {
for (ConfigCenterConfig configCenterConfig : configCenters) {
ConfigValidationUtils.validateConfigCenterConfig(configCenterConfig);
}
}

// check Metadata
Collection<MetadataReportConfig> metadatas = configManager.getMetadataConfigs();
for (MetadataReportConfig metadataReportConfig : metadatas) {
ConfigValidationUtils.validateMetadataConfig(metadataReportConfig);
if (CollectionUtils.isEmpty(metadatas)) {
MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
metadataReportConfig.refresh();
if (metadataReportConfig.isValid()) {
configManager.addMetadataReport(metadataReportConfig);
metadatas = configManager.getMetadataConfigs();
}
}
if (CollectionUtils.isNotEmpty(metadatas)) {
for (MetadataReportConfig metadataReportConfig : metadatas) {
metadataReportConfig.refresh();
ConfigValidationUtils.validateMetadataConfig(metadataReportConfig);
}
}

// check Provider
Expand Down Expand Up @@ -580,11 +581,24 @@ private void checkGlobalConfigs() {
private void startConfigCenter() {
Collection<ConfigCenterConfig> configCenters = configManager.getConfigCenters();

// check Config Center
if (CollectionUtils.isEmpty(configCenters)) {
ConfigCenterConfig configCenterConfig = new ConfigCenterConfig();
configCenterConfig.refresh();
if (configCenterConfig.isValid()) {
configManager.addConfigCenter(configCenterConfig);
configCenters = configManager.getConfigCenters();
}
} else {
for (ConfigCenterConfig configCenterConfig : configCenters) {
configCenterConfig.refresh();
ConfigValidationUtils.validateConfigCenterConfig(configCenterConfig);
}
}

if (CollectionUtils.isNotEmpty(configCenters)) {
CompositeDynamicConfiguration compositeDynamicConfiguration = new CompositeDynamicConfiguration();
for (ConfigCenterConfig configCenter : configCenters) {
configCenter.refresh();
ConfigValidationUtils.validateConfigCenterConfig(configCenter);
compositeDynamicConfiguration.addConfiguration(prepareEnvironment(configCenter));
}
environment.setDynamicConfiguration(compositeDynamicConfiguration);
Expand Down Expand Up @@ -695,13 +709,8 @@ private void loadRemoteConfigs() {
* Initialize {@link MetadataService} from {@link WritableMetadataService}'s extension
*/
private void initMetadataService() {
startMetadataReport();
this.metadataService = getExtension(getMetadataType());
}

/**
* Initialize {@link MetadataServiceExporter}
*/
private void initMetadataServiceExporter() {
this.metadataServiceExporter = new ConfigurableMetadataServiceExporter(metadataService);
}

Expand Down

0 comments on commit ca28815

Please sign in to comment.