diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/constant/Constants.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/constant/Constants.java index 1d9805cb97e2b..5deccc9913170 100644 --- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/constant/Constants.java +++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/constant/Constants.java @@ -20,7 +20,6 @@ /** * ShardingSphere of constants. */ -@Deprecated // TODO remove the class, ref #6546 public final class Constants { diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java index 10be97a278622..6d1f6f8c2c97c 100644 --- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java +++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java @@ -35,7 +35,6 @@ import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType; import org.apache.shardingsphere.infra.exception.ShardingSphereException; import org.apache.shardingsphere.infra.log.ConfigurationLogger; -import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine; import org.apache.shardingsphere.kernel.context.SchemaContextsBuilder; import org.apache.shardingsphere.kernel.context.schema.DataSourceParameter; import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration; @@ -48,7 +47,6 @@ import org.apache.shardingsphere.proxy.config.YamlProxyConfiguration; import org.apache.shardingsphere.proxy.config.converter.ProxyConfigurationConverter; import org.apache.shardingsphere.proxy.config.converter.ProxyConfigurationConverterFactory; -import org.apache.shardingsphere.proxy.config.yaml.YamlProxyRuleConfiguration; import org.apache.shardingsphere.proxy.frontend.bootstrap.ShardingSphereProxy; import javax.sql.DataSource; @@ -83,37 +81,30 @@ public static void main(final String[] args) throws Exception { int port = bootstrapArgs.getPort(); System.setProperty(Constants.PORT_KEY, String.valueOf(port)); YamlProxyConfiguration yamlConfig = ProxyConfigurationLoader.load(bootstrapArgs.getConfigurationPath()); - logRuleConfigurations(getRuleConfigurations(yamlConfig.getRuleConfigurations()).values()); try (ProxyConfigurationConverter converter = ProxyConfigurationConverterFactory.newInstances(null != yamlConfig.getServerConfiguration().getOrchestration())) { ProxyConfiguration proxyConfiguration = converter.convert(yamlConfig); + log(proxyConfiguration); initialize(proxyConfiguration, port, converter); } } - private static void logRuleConfigurations(final Collection> ruleConfigurations) { + private static void log(final ProxyConfiguration proxyConfiguration) { + Collection> ruleConfigurations = proxyConfiguration.getSchemaRules().values(); if (CollectionUtils.isNotEmpty(ruleConfigurations)) { ruleConfigurations.forEach(ConfigurationLogger::log); } - } - - private static Map> getRuleConfigurations(final Map localRuleConfigs) { - YamlRuleConfigurationSwapperEngine swapperEngine = new YamlRuleConfigurationSwapperEngine(); - return localRuleConfigs.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry -> swapperEngine.swapToRuleConfigurations(entry.getValue().getRules()))); + ConfigurationLogger.log(proxyConfiguration.getAuthentication()); + ConfigurationLogger.log(proxyConfiguration.getProps()); } private static void initialize(final ProxyConfiguration proxyConfiguration, final int port, final ProxyConfigurationConverter converter) throws SQLException { Authentication authentication = proxyConfiguration.getAuthentication(); Properties props = proxyConfiguration.getProps(); - log(authentication, props); initProxySchemaContexts(proxyConfiguration.getSchemaDataSources(), proxyConfiguration.getSchemaRules(), authentication, props, converter); initControlPanelFacade(proxyConfiguration.getMetrics(), proxyConfiguration.getCluster()); updateServerInfo(); ShardingSphereProxy.getInstance().start(port); } - private static void log(final Authentication authentication, final Properties properties) { - ConfigurationLogger.log(authentication); - ConfigurationLogger.log(properties); - } private static void initProxySchemaContexts(final Map> schemaDataSources, final Map> schemaRules, final Authentication authentication, final Properties properties, final ProxyConfigurationConverter converter) throws SQLException { diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java index 63e096b064a46..3a321757d44d8 100644 --- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java +++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java @@ -59,7 +59,7 @@ public static YamlProxyConfiguration load(final String path) throws IOException YamlProxyServerConfiguration serverConfig = loadServerConfiguration(getResourceFile(path + "/" + SERVER_CONFIG_FILE)); File configPath = getResourceFile(path); Collection ruleConfigurations = loadRuleConfigurations(schemaNames, configPath); - Preconditions.checkState(!ruleConfigurations.isEmpty() || null != serverConfig.getOrchestration(), "Can not find any sharding rule configuration file in path `%s`.", configPath.getPath()); + Preconditions.checkState(!ruleConfigurations.isEmpty() || null != serverConfig.getOrchestration(), "Can not find any rule configurations file in path `%s`.", configPath.getPath()); return new YamlProxyConfiguration(serverConfig, ruleConfigurations.stream().collect(Collectors.toMap(YamlProxyRuleConfiguration::getSchemaName, each -> each))); }