You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/05/05 02:52:00 UTC
[GitHub] [shardingsphere] zjcnb commented on a diff in pull request #17322: Fix load metadata by database type from governance center
zjcnb commented on code in PR #17322:
URL: https://github.com/apache/shardingsphere/pull/17322#discussion_r865523270
##########
shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java:
##########
@@ -130,17 +132,25 @@ private MetaDataContextsBuilder createMetaDataContextsBuilder(final MetaDataPers
Collection<RuleConfiguration> globalRuleConfigs = metaDataPersistService.getGlobalRuleService().load();
Properties props = metaDataPersistService.getPropsService().load();
MetaDataContextsBuilder result = new MetaDataContextsBuilder(globalRuleConfigs, props);
- DatabaseType databaseType = DatabaseTypeFactory.getDatabaseType(parameter.getDatabaseConfigs(), new ConfigurationProperties(parameter.getProps()));
- for (String each : databaseNames) {
- if (databaseType.getSystemSchemas().contains(each)) {
+ Map<String, ? extends DatabaseConfiguration> databaseConfigMap = getDatabaseConfigMap(databaseNames, metaDataPersistService, parameter);
+ DatabaseType databaseType = DatabaseTypeFactory.getDatabaseType(databaseConfigMap, new ConfigurationProperties(props));
+ for (Entry<String, ? extends DatabaseConfiguration> entry : databaseConfigMap.entrySet()) {
+ if (databaseType.getSystemSchemas().contains(entry.getKey())) {
continue;
}
- result.addDatabase(each, databaseType, createDatabaseConfiguration(each, metaDataPersistService, parameter), props);
+ result.addDatabase(entry.getKey(), databaseType, entry.getValue(), props);
}
result.addSystemDatabases(databaseType);
return result;
}
+ private Map<String, DatabaseConfiguration> getDatabaseConfigMap(final Collection<String> databaseNames, final MetaDataPersistService metaDataPersistService,
+ final ContextManagerBuilderParameter parameter) {
+ Map<String, DatabaseConfiguration> result = new HashMap<>(databaseNames.size());
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org