You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/05/02 05:35:12 UTC
[shardingsphere] branch master updated: Unify variable name from xxxConfiguration to xxxConfig @terrymanu (#17263)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 6aee70057c6 Unify variable name from xxxConfiguration to xxxConfig @terrymanu (#17263)
6aee70057c6 is described below
commit 6aee70057c665385047b4159af9959b843d4c78c
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon May 2 13:34:55 2022 +0800
Unify variable name from xxxConfiguration to xxxConfig @terrymanu (#17263)
* Unify variable name from xxxConfiguration to xxxConfig
* Unify variable name from xxxConfiguration to xxxConfig
* Unify variable name from xxxConfiguration to xxxConfig
* Unify variable name from xxxConfiguration to xxxConfig
* Unify variable name from xxxConfiguration to xxxConfig
* Unify variable name from xxxConfiguration to xxxConfig
* Unify variable name from xxxConfiguration to xxxConfig
---
.../raw/jdbc/config/ShadowConfiguration.java | 5 +-
.../ShadowDefaultAlgorithmConfiguration.java | 5 +-
.../jdbc/config/ShadowEncryptConfiguration.java | 5 +-
.../ShardingDatabasesConfigurationRange.java | 6 +-
pom.xml | 2 +-
.../config/loader/AgentConfigurationLoader.java | 3 +-
.../service/JaegerTracingPluginBootService.java | 8 +--
.../JaegerTracingPluginBootServiceTest.java | 10 +--
.../ZipkinTracingPluginBootServiceTest.java | 24 +++----
.../DatabaseDiscoveryRuleStatementConverter.java | 4 +-
.../DatabaseDiscoveryHeartbeatQueryResultSet.java | 4 +-
.../query/DatabaseDiscoveryTypeQueryResultSet.java | 4 +-
...overyProviderAlgorithmStatementUpdaterTest.java | 10 +--
...rDatabaseDiscoveryRuleStatementUpdaterTest.java | 30 ++++----
.../shardingsphere/encrypt/rule/EncryptRule.java | 4 +-
.../handler/query/EncryptRuleQueryResultSet.java | 22 +++---
.../EncryptRuleStatementConverterTest.java | 16 ++---
.../spring/boot/EncryptSpringBootStarterTest.java | 8 +--
...adwriteSplittingRuleStatementConverterTest.java | 34 ++++-----
.../AbstractShadowRuleConfigurationChecker.java | 10 +--
.../checker/ShadowRuleConfigurationChecker.java | 8 +--
...orithmProviderConfigurationYamlSwapperTest.java | 36 +++++-----
.../ShadowDataSourcePropertiesYamlSwapperTest.java | 6 +-
.../ShadowTableConfigurationYamlSwapperTest.java | 16 ++---
.../checker/ShadowRuleStatementChecker.java | 6 +-
.../query/ShadowAlgorithmQueryResultSet.java | 6 +-
.../handler/query/ShadowRuleQueryResultSet.java | 14 ++--
.../query/ShadowTableRuleQueryResultSet.java | 2 +-
.../supporter/ShadowRuleStatementSupporter.java | 80 +++++++++++-----------
.../update/AlterShadowRuleStatementUpdater.java | 2 +-
.../AlterShadowAlgorithmStatementUpdaterTest.java | 8 +--
.../AlterShadowRuleStatementUpdaterTest.java | 16 ++---
...DefaultShadowAlgorithmStatementUpdaterTest.java | 10 +--
.../CreateShadowRuleStatementUpdaterTest.java | 16 ++---
...DefaultShadowAlgorithmStatementUpdaterTest.java | 18 ++---
.../DropShadowAlgorithmStatementUpdaterTest.java | 10 +--
.../update/DropShadowRuleStatementUpdaterTest.java | 16 ++---
.../shardingsphere/sharding/rule/ShardingRule.java | 8 +--
.../ShardingTableBroadcastRoutingEngineTest.java | 8 +--
.../dml/ShardingInsertStatementValidatorTest.java | 8 +--
.../dml/ShardingUpdateStatementValidatorTest.java | 8 +--
.../strategy/ShardingStrategyFactoryTest.java | 16 ++---
.../sharding/rule/ShardingRuleTest.java | 16 ++---
.../ShardingScalingRuleStatementConverter.java | 6 +-
.../handler/enums/ShardingStrategyType.java | 22 +++---
.../DefaultShardingStrategyQueryResultSet.java | 8 +--
.../ShardingBindingTableRuleQueryResultSet.java | 2 +-
.../query/ShardingTableNodesQueryResultSet.java | 4 +-
.../query/ShardingTableRuleQueryResultSet.java | 4 +-
...terDefaultShardingStrategyStatementUpdater.java | 4 +-
...ateDefaultShardingStrategyStatementUpdater.java | 27 ++++----
.../DropDefaultStrategyStatementUpdater.java | 4 +-
.../ShardingScalingRulesQueryResultSetTest.java | 6 +-
...ateShardingScalingRuleStatementUpdaterTest.java | 4 +-
...bleShardingScalingRuleStatementUpdaterTest.java | 4 +-
.../checker/ShardingRuleStatementCheckerTest.java | 14 ++--
...AlterShardingAlgorithmStatementUpdaterTest.java | 12 ++--
...erShardingKeyGeneratorStatementUpdaterTest.java | 12 ++--
...AlterShardingTableRuleStatementUpdaterTest.java | 8 +--
...efaultShardingStrategyStatementUpdaterTest.java | 8 +--
...reateShardingAlgorithmStatementUpdaterTest.java | 17 +++--
...reateShardingTableRuleStatementUpdaterTest.java | 16 ++---
.../DropShardingAlgorithmStatementUpdaterTest.java | 8 +--
...ardingBindingTableRuleStatementUpdaterTest.java | 6 +-
.../DropShardingTableRuleStatementUpdaterTest.java | 6 +-
.../namespace/ShardingSpringNamespaceTest.java | 6 +-
.../infra/instance/InstanceContextTest.java | 18 ++---
.../rule/ShardingSphereRuleMetaDataTest.java | 34 ++-------
.../statement/ShardingSpherePreparedStatement.java | 4 +-
.../datasource/MySQLDataSourcePreparerTest.java | 10 +--
.../singletable/rule/SingleTableRuleTest.java | 6 +-
...ingleTableRuleConfigurationYamlSwapperTest.java | 28 +++-----
...DefaultTrafficRuleConfigurationBuilderTest.java | 23 ++-----
...rafficStrategyConfigurationYamlSwapperTest.java | 20 +++---
.../spi/TransactionConfigurationFileGenerator.java | 4 +-
.../config/NarayanaConfigurationFileGenerator.java | 8 +--
.../mode/manager/ContextManager.java | 10 +--
.../ContextManagerBuilderParameterTest.java | 30 ++++----
.../backend/config/ProxyConfigurationLoader.java | 9 ++-
.../ShardingRuleConfigurationImportChecker.java | 4 +-
.../queryable/CountInstanceRulesHandler.java | 4 +-
.../ExportDatabaseConfigurationHandler.java | 21 ++----
.../common/queryable/ShowAuthorityRuleHandler.java | 8 +--
.../common/queryable/ShowInstanceModeHandler.java | 6 +-
.../common/queryable/ShowSQLParserRuleHandler.java | 8 +--
.../queryable/ShowTransactionRuleHandler.java | 15 ++--
.../updatable/AlterTransactionRuleHandler.java | 8 +--
.../ImportDatabaseConfigurationHandler.java | 32 ++++-----
.../rql/rule/RulesUsedResourceQueryResultSet.java | 47 +++++--------
.../rql/rule/SchemaRulesCountResultSet.java | 4 +-
.../rql/rule/SingleTableRulesQueryResultSet.java | 4 +-
.../config/ProxyConfigurationLoaderTest.java | 17 ++---
.../distsql/DistSQLBackendHandlerFactoryTest.java | 6 +-
.../queryable/ShowAuthorityRuleHandlerTest.java | 6 +-
.../queryable/ShowSQLParserRuleHandlerTest.java | 3 +-
.../queryable/ShowTransactionRuleHandlerTest.java | 4 +-
.../updatable/DropTrafficRuleHandlerTest.java | 61 ++++++++---------
.../AlterDefaultSingleTableRuleUpdaterTest.java | 11 +--
.../CreateDefaultSingleTableRuleUpdaterTest.java | 17 +++--
.../rql/SingleTableRulesQueryResultSetTest.java | 4 +-
.../OpenGaussAuthenticationHandlerTest.java | 6 +-
.../PostgreSQLAuthenticationEngineTest.java | 6 +-
.../PostgreSQLAuthenticationHandlerTest.java | 6 +-
.../pipeline/env/config/SourceConfiguration.java | 6 +-
104 files changed, 582 insertions(+), 692 deletions(-)
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowConfiguration.java b/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowConfiguration.java
index 25f858af9a3..f79ca95d50a 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowConfiguration.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowConfiguration.java
@@ -35,11 +35,10 @@ public final class ShadowConfiguration extends BaseShadowConfiguration {
@Override
public DataSource getDataSource() throws SQLException {
Map<String, DataSource> dataSourceMap = createDataSourceMap();
- Collection<RuleConfiguration> ruleConfigurations = createRuleConfiguration();
- return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, ruleConfigurations, createShardingSphereProps());
+ return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, createRuleConfigurations(), createShardingSphereProps());
}
- private Collection<RuleConfiguration> createRuleConfiguration() {
+ private Collection<RuleConfiguration> createRuleConfigurations() {
Collection<RuleConfiguration> result = new LinkedList<>();
result.add(createShadowRuleConfiguration());
result.add(createSQLParserRuleConfiguration());
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowDefaultAlgorithmConfiguration.java b/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowDefaultAlgorithmConfiguration.java
index 06b0e888d2e..670ec46ec27 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowDefaultAlgorithmConfiguration.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowDefaultAlgorithmConfiguration.java
@@ -35,11 +35,10 @@ public final class ShadowDefaultAlgorithmConfiguration extends BaseShadowConfigu
@Override
public DataSource getDataSource() throws SQLException {
Map<String, DataSource> dataSourceMap = createDataSourceMap();
- Collection<RuleConfiguration> ruleConfigurations = createRuleConfiguration();
- return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, ruleConfigurations, createShardingSphereProps());
+ return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, createRuleConfigurations(), createShardingSphereProps());
}
- private Collection<RuleConfiguration> createRuleConfiguration() {
+ private Collection<RuleConfiguration> createRuleConfigurations() {
Collection<RuleConfiguration> result = new LinkedList<>();
result.add(createShadowRuleConfiguration());
result.add(createSQLParserRuleConfiguration());
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowEncryptConfiguration.java b/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowEncryptConfiguration.java
index fcbbe1e2593..2998b9e0547 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowEncryptConfiguration.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/raw/jdbc/config/ShadowEncryptConfiguration.java
@@ -40,11 +40,10 @@ public final class ShadowEncryptConfiguration extends BaseShadowConfiguration {
@Override
public DataSource getDataSource() throws SQLException {
Map<String, DataSource> dataSourceMap = createDataSourceMap();
- Collection<RuleConfiguration> ruleConfigurations = createRuleConfiguration();
- return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, ruleConfigurations, createShardingSphereProps());
+ return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, createRuleConfigurations(), createShardingSphereProps());
}
- private Collection<RuleConfiguration> createRuleConfiguration() {
+ private Collection<RuleConfiguration> createRuleConfigurations() {
Collection<RuleConfiguration> result = new LinkedList<>();
result.add(new EncryptRuleConfiguration(getEncryptTableRuleConfigurations(), getEncryptAlgorithmConfigurations()));
result.add(createShadowRuleConfiguration());
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationRange.java b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationRange.java
index fdfed850f14..8272c870e55 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationRange.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationRange.java
@@ -40,9 +40,9 @@ public final class ShardingDatabasesConfigurationRange implements ExampleConfigu
@Override
public DataSource getDataSource() throws SQLException {
ShardingRuleConfiguration shardingRuleConfig = createShardingRuleConfiguration();
- Collection<RuleConfiguration> configurations = new LinkedList<>();
- configurations.add(shardingRuleConfig);
- return ShardingSphereDataSourceFactory.createDataSource(createDataSourceMap(), configurations, new Properties());
+ Collection<RuleConfiguration> configs = new LinkedList<>();
+ configs.add(shardingRuleConfig);
+ return ShardingSphereDataSourceFactory.createDataSource(createDataSourceMap(), configs, new Properties());
}
private ShardingRuleConfiguration createShardingRuleConfiguration() {
diff --git a/pom.xml b/pom.xml
index abde02b310f..89bd62a41f6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -737,7 +737,7 @@
</exclusion>
</exclusions>
</dependency>
-
+
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
diff --git a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/config/loader/AgentConfigurationLoader.java b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/config/loader/AgentConfigurationLoader.java
index 7e7c30c4c7d..0ce0ed296ae 100644
--- a/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/config/loader/AgentConfigurationLoader.java
+++ b/shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/config/loader/AgentConfigurationLoader.java
@@ -45,8 +45,7 @@ public final class AgentConfigurationLoader {
*/
public static AgentConfiguration load() throws IOException {
File configFile = new File(AgentPathBuilder.getAgentPath(), DEFAULT_CONFIG_PATH);
- YamlAgentConfiguration yamlAgentConfiguration = load(configFile);
- return YamlAgentConfigurationSwapper.swap(yamlAgentConfiguration);
+ return YamlAgentConfigurationSwapper.swap(load(configFile));
}
private static YamlAgentConfiguration load(final File yamlFile) throws IOException {
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootService.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootService.java
index 4902cd9bb74..716fb01eb44 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootService.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootService.java
@@ -35,7 +35,7 @@ public final class JaegerTracingPluginBootService implements PluginBootService {
@SuppressWarnings("AccessOfSystemProperties")
@Override
public void start(final PluginConfiguration pluginConfig) {
- if (!checkConfig(pluginConfig)) {
+ if (!checkConfiguration(pluginConfig)) {
throw new PluginConfigurationException("jaeger config error, host is null or port is %s", pluginConfig.getPort());
}
pluginConfig.getProps().forEach((key, value) -> System.setProperty(String.valueOf(key), String.valueOf(value)));
@@ -49,9 +49,9 @@ public final class JaegerTracingPluginBootService implements PluginBootService {
}
}
- private boolean checkConfig(final PluginConfiguration pluginConfiguration) {
- String host = pluginConfiguration.getHost();
- int port = pluginConfiguration.getPort();
+ private boolean checkConfiguration(final PluginConfiguration pluginConfig) {
+ String host = pluginConfig.getHost();
+ int port = pluginConfig.getPort();
return null != host && !"".equalsIgnoreCase(host) && port > 0;
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootServiceTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootServiceTest.java
index dcd27e7d15a..007d729eea7 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootServiceTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootServiceTest.java
@@ -27,8 +27,6 @@ import org.junit.Test;
import java.lang.reflect.Field;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public final class JaegerTracingPluginBootServiceTest {
@@ -42,16 +40,10 @@ public final class JaegerTracingPluginBootServiceTest {
props.setProperty("JAEGER_SAMPLER_PARAM", "1");
props.setProperty("JAEGER_REPORTER_LOG_SPANS", "true");
props.setProperty("JAEGER_REPORTER_FLUSH_INTERVAL", "1");
- PluginConfiguration configuration = new PluginConfiguration("localhost", 5775, "", props);
- jaegerTracingPluginBootService.start(configuration);
+ jaegerTracingPluginBootService.start(new PluginConfiguration("localhost", 5775, "", props));
assertTrue(GlobalTracer.isRegistered());
}
- @Test
- public void assertType() {
- assertThat(jaegerTracingPluginBootService.getType(), is("Jaeger"));
- }
-
@SneakyThrows
@After
public void close() {
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/service/ZipkinTracingPluginBootServiceTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/service/ZipkinTracingPluginBootServiceTest.java
index a991789666b..3708e2760e2 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/service/ZipkinTracingPluginBootServiceTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/service/ZipkinTracingPluginBootServiceTest.java
@@ -18,40 +18,32 @@
package org.apache.shardingsphere.agent.plugin.tracing.zipkin.service;
import brave.Tracing;
-import java.lang.reflect.Field;
-import java.util.Properties;
import lombok.SneakyThrows;
import org.apache.shardingsphere.agent.config.PluginConfiguration;
-
-import org.junit.AfterClass;
+import org.junit.After;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
+import java.lang.reflect.Field;
+import java.util.Properties;
+
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
public final class ZipkinTracingPluginBootServiceTest {
- private static ZipkinTracingPluginBootService zipkinTracingPluginBootService = new ZipkinTracingPluginBootService();
+ private final ZipkinTracingPluginBootService zipkinTracingPluginBootService = new ZipkinTracingPluginBootService();
@SneakyThrows
@Test
public void assertStart() {
- PluginConfiguration configuration = new PluginConfiguration("localhost", 9441, "", new Properties());
- zipkinTracingPluginBootService.start(configuration);
+ zipkinTracingPluginBootService.start(new PluginConfiguration("localhost", 9441, "", new Properties()));
Field field = ZipkinTracingPluginBootService.class.getDeclaredField("tracing");
field.setAccessible(true);
Tracing tracing = (Tracing) field.get(zipkinTracingPluginBootService);
assertNotNull(tracing.tracer());
}
- @Test
- public void assertType() {
- assertThat(zipkinTracingPluginBootService.getType(), is("Zipkin"));
- }
-
- @AfterClass
- public static void close() {
+ @After
+ public void close() {
zipkinTracingPluginBootService.close();
}
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/converter/DatabaseDiscoveryRuleStatementConverter.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/converter/DatabaseDisco [...]
index 4834306b734..2ce601df975 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/converter/DatabaseDiscoveryRuleStatementConverter.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/converter/DatabaseDiscoveryRuleStatementConverter.java
@@ -72,9 +72,9 @@ public final class DatabaseDiscoveryRuleStatementConverter {
}
private static void addRuleConfiguration(final DatabaseDiscoveryRuleConfiguration ruleConfig, final DatabaseDiscoveryConstructionSegment segment) {
- DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfiguration =
+ DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig =
new DatabaseDiscoveryDataSourceRuleConfiguration(segment.getName(), new LinkedList<>(segment.getDataSources()), segment.getDiscoveryHeartbeatName(), segment.getDiscoveryTypeName());
- ruleConfig.getDataSources().add(dataSourceRuleConfiguration);
+ ruleConfig.getDataSources().add(dataSourceRuleConfig);
}
private static String getName(final String ruleName, final String type) {
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryHeartbeatQueryResultSet.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryHea [...]
index 91c08d0055f..e4adf5d3468 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryHeartbeatQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryHeartbeatQueryResultSet.java
@@ -40,8 +40,8 @@ public final class DatabaseDiscoveryHeartbeatQueryResultSet implements DistSQLRe
@Override
public void init(final ShardingSphereMetaData metaData, final SQLStatement sqlStatement) {
- Collection<DatabaseDiscoveryRuleConfiguration> ruleConfiguration = metaData.getRuleMetaData().findRuleConfiguration(DatabaseDiscoveryRuleConfiguration.class);
- data = ruleConfiguration.stream().map(DatabaseDiscoveryRuleConfiguration::getDiscoveryHeartbeats)
+ Collection<DatabaseDiscoveryRuleConfiguration> ruleConfig = metaData.getRuleMetaData().findRuleConfiguration(DatabaseDiscoveryRuleConfiguration.class);
+ data = ruleConfig.stream().map(DatabaseDiscoveryRuleConfiguration::getDiscoveryHeartbeats)
.flatMap(each -> each.entrySet().stream()).collect(Collectors.toMap(Entry::getKey, Entry::getValue)).entrySet().iterator();
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryTypeQueryResultSet.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryTypeQuer [...]
index 2c519948c11..98b7d68d44c 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryTypeQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryTypeQueryResultSet.java
@@ -40,8 +40,8 @@ public final class DatabaseDiscoveryTypeQueryResultSet implements DistSQLResultS
@Override
public void init(final ShardingSphereMetaData metaData, final SQLStatement sqlStatement) {
- Collection<DatabaseDiscoveryRuleConfiguration> ruleConfiguration = metaData.getRuleMetaData().findRuleConfiguration(DatabaseDiscoveryRuleConfiguration.class);
- data = ruleConfiguration.stream().map(DatabaseDiscoveryRuleConfiguration::getDiscoveryTypes)
+ Collection<DatabaseDiscoveryRuleConfiguration> ruleConfig = metaData.getRuleMetaData().findRuleConfiguration(DatabaseDiscoveryRuleConfiguration.class);
+ data = ruleConfig.stream().map(DatabaseDiscoveryRuleConfiguration::getDiscoveryTypes)
.flatMap(each -> each.entrySet().stream()).collect(Collectors.toMap(Entry::getKey, Entry::getValue)).entrySet().iterator();
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update [...]
index cf421056a60..d1e99ea5c77 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest.java
@@ -94,10 +94,10 @@ public final class AlterDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest {
updater.checkSQLStatement(shardingSphereMetaData, new AlterDatabaseDiscoveryTypeStatement(algorithmSegments), currentRuleConfig);
DatabaseDiscoveryRuleConfiguration databaseDiscoveryRuleConfig =
(DatabaseDiscoveryRuleConfiguration) updater.buildToBeAlteredRuleConfiguration(new AlterDatabaseDiscoveryTypeStatement(algorithmSegments));
- DatabaseDiscoveryRuleConfiguration currentConfiguration = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>(), new LinkedHashMap<>());
- updater.updateCurrentRuleConfiguration(currentConfiguration, databaseDiscoveryRuleConfig);
- assertThat(currentConfiguration.getDiscoveryTypes().size(), is(1));
- assertThat(currentConfiguration.getDiscoveryTypes().get("discovery_type").getType(), is("DISTSQL.FIXTURE"));
- assertThat(currentConfiguration.getDiscoveryTypes().get("discovery_type").getProps().get("key"), is("value_1"));
+ DatabaseDiscoveryRuleConfiguration currentConfig = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>(), new LinkedHashMap<>());
+ updater.updateCurrentRuleConfiguration(currentConfig, databaseDiscoveryRuleConfig);
+ assertThat(currentConfig.getDiscoveryTypes().size(), is(1));
+ assertThat(currentConfig.getDiscoveryTypes().get("discovery_type").getType(), is("DISTSQL.FIXTURE"));
+ assertThat(currentConfig.getDiscoveryTypes().get("discovery_type").getProps().get("key"), is("value_1"));
}
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabas [...]
index 8286faef19b..030542bfc8f 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java
@@ -82,9 +82,9 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdaterTest {
when(resource.getNotExistedResources(any())).thenReturn(Collections.singleton("ds0"));
DatabaseDiscoveryConstructionSegment segment = new DatabaseDiscoveryConstructionSegment("readwrite_ds", Arrays.asList("ds_read_0", "ds_read_1"), "readwrite_ds_mgr", "readwrite_ds_heartbeat");
DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("readwrite_ds", Collections.emptyList(), "ha-heartbeat", "TEST");
- DatabaseDiscoveryRuleConfiguration databaseDiscoveryRuleConfiguration = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Collections.singleton(dataSourceRuleConfig)),
+ DatabaseDiscoveryRuleConfiguration ruleConfig = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Collections.singleton(dataSourceRuleConfig)),
Collections.singletonMap("readwrite_ds_mgr", null), Collections.singletonMap("readwrite_ds_heartbeat", null));
- updater.checkSQLStatement(shardingSphereMetaData, new AlterDatabaseDiscoveryRuleStatement(Collections.singletonList(segment)), databaseDiscoveryRuleConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, new AlterDatabaseDiscoveryRuleStatement(Collections.singletonList(segment)), ruleConfig);
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
@@ -92,18 +92,18 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdaterTest {
AlgorithmSegment algorithmSegment = new AlgorithmSegment("INVALID_TYPE", new Properties());
DatabaseDiscoveryDefinitionSegment segment = new DatabaseDiscoveryDefinitionSegment("readwrite_ds", Arrays.asList("ds_read_0", "ds_read_1"), algorithmSegment, new Properties());
DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("readwrite_ds", Collections.emptyList(), "ha-heartbeat", "TEST");
- DatabaseDiscoveryRuleConfiguration databaseDiscoveryRuleConfiguration = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Collections.singleton(dataSourceRuleConfig)),
+ DatabaseDiscoveryRuleConfiguration ruleConfig = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Collections.singleton(dataSourceRuleConfig)),
Collections.singletonMap("readwrite_ds_mgr", null), Collections.singletonMap("readwrite_ds_heartbeat", null));
- updater.checkSQLStatement(shardingSphereMetaData, new AlterDatabaseDiscoveryRuleStatement(Collections.singleton(segment)), databaseDiscoveryRuleConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, new AlterDatabaseDiscoveryRuleStatement(Collections.singleton(segment)), ruleConfig);
}
@Test(expected = RequiredAlgorithmMissedException.class)
public void assertCheckSQLStatementWithNotExistDiscoveryTypeName() throws DistSQLException {
DatabaseDiscoveryConstructionSegment segment = new DatabaseDiscoveryConstructionSegment("readwrite_ds", Arrays.asList("ds_read_0", "ds_read_1"), "not_exist_discovery_type_name", "");
DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("readwrite_ds", Collections.emptyList(), "ha-heartbeat", "TEST");
- DatabaseDiscoveryRuleConfiguration databaseDiscoveryRuleConfiguration = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Collections.singleton(dataSourceRuleConfig)),
+ DatabaseDiscoveryRuleConfiguration ruleConfig = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Collections.singleton(dataSourceRuleConfig)),
Collections.singletonMap("readwrite_ds_mgr", null), Collections.singletonMap("readwrite_ds_heartbeat", null));
- updater.checkSQLStatement(shardingSphereMetaData, new AlterDatabaseDiscoveryRuleStatement(Collections.singleton(segment)), databaseDiscoveryRuleConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, new AlterDatabaseDiscoveryRuleStatement(Collections.singleton(segment)), ruleConfig);
}
@Test(expected = RequiredAlgorithmMissedException.class)
@@ -111,9 +111,9 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdaterTest {
DatabaseDiscoveryConstructionSegment segment = new DatabaseDiscoveryConstructionSegment(
"readwrite_ds", Arrays.asList("ds_read_0", "ds_read_1"), "discovery_type_name", "not_exist_heartbeat_name");
DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("readwrite_ds", Collections.emptyList(), "ha-heartbeat", "TEST");
- DatabaseDiscoveryRuleConfiguration databaseDiscoveryRuleConfiguration = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Collections.singleton(dataSourceRuleConfig)),
+ DatabaseDiscoveryRuleConfiguration ruleConfig = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Collections.singleton(dataSourceRuleConfig)),
Collections.singletonMap("readwrite_ds_mgr", null), Collections.singletonMap("readwrite_ds_heartbeat", null));
- updater.checkSQLStatement(shardingSphereMetaData, new AlterDatabaseDiscoveryRuleStatement(Collections.singleton(segment)), databaseDiscoveryRuleConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, new AlterDatabaseDiscoveryRuleStatement(Collections.singleton(segment)), ruleConfig);
}
@Test
@@ -143,15 +143,15 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdaterTest {
(DatabaseDiscoveryRuleConfiguration) updater.buildToBeAlteredRuleConfiguration(new AlterDatabaseDiscoveryRuleStatement(Arrays.asList(constructionSegment, definitionSegment)));
DatabaseDiscoveryDataSourceRuleConfiguration constructionRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("readwrite_ds_1", Collections.emptyList(), "", "");
DatabaseDiscoveryDataSourceRuleConfiguration definitionRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("readwrite_ds_2", Collections.emptyList(), "", "");
- DatabaseDiscoveryRuleConfiguration currentConfiguration = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Arrays.asList(constructionRuleConfig, definitionRuleConfig)),
+ DatabaseDiscoveryRuleConfiguration currentConfig = new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Arrays.asList(constructionRuleConfig, definitionRuleConfig)),
new HashMap<>(Collections.singletonMap("discovery_type_name", null)), new HashMap<>(Collections.singletonMap("heartbeat_name", null)));
- updater.updateCurrentRuleConfiguration(currentConfiguration, toBeCreatedRuleConfig);
- assertThat(currentConfiguration.getDataSources().size(), is(2));
- assertTrue(currentConfiguration.getDataSources().stream().map(DatabaseDiscoveryDataSourceRuleConfiguration::getGroupName)
+ updater.updateCurrentRuleConfiguration(currentConfig, toBeCreatedRuleConfig);
+ assertThat(currentConfig.getDataSources().size(), is(2));
+ assertTrue(currentConfig.getDataSources().stream().map(DatabaseDiscoveryDataSourceRuleConfiguration::getGroupName)
.collect(Collectors.toList()).removeAll(Collections.singletonList("readwrite_ds_1")));
- assertTrue(currentConfiguration.getDataSources().stream().map(DatabaseDiscoveryDataSourceRuleConfiguration::getGroupName)
+ assertTrue(currentConfig.getDataSources().stream().map(DatabaseDiscoveryDataSourceRuleConfiguration::getGroupName)
.collect(Collectors.toList()).removeAll(Collections.singletonList("readwrite_ds_2")));
- assertTrue(currentConfiguration.getDiscoveryTypes().containsKey("readwrite_ds_2_MySQL.MGR"));
- assertTrue(currentConfiguration.getDiscoveryHeartbeats().containsKey("readwrite_ds_2_heartbeat"));
+ assertTrue(currentConfig.getDiscoveryTypes().containsKey("readwrite_ds_2_MySQL.MGR"));
+ assertTrue(currentConfig.getDiscoveryHeartbeats().containsKey("readwrite_ds_2_heartbeat"));
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
index d1ab6c665f8..818cb3b9860 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
@@ -130,8 +130,8 @@ public final class EncryptRule implements SchemaRule, TableContainedRule {
return Collections.emptyMap();
}
- private boolean containsConfigDataTypeColumn(final Collection<EncryptTableRuleConfiguration> tableRuleConfigurations) {
- for (EncryptTableRuleConfiguration each : tableRuleConfigurations) {
+ private boolean containsConfigDataTypeColumn(final Collection<EncryptTableRuleConfiguration> tableRuleConfigs) {
+ for (EncryptTableRuleConfiguration each : tableRuleConfigs) {
for (EncryptColumnRuleConfiguration column : each.getColumns()) {
if (null != column.getLogicDataType() && !column.getLogicDataType().isEmpty()) {
return true;
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptRuleQueryResultSet.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptRuleQueryResultSet.java
index c7feade6dc6..17963d2df27 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptRuleQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptRuleQueryResultSet.java
@@ -45,25 +45,25 @@ public final class EncryptRuleQueryResultSet implements DistSQLResultSet {
@Override
public void init(final ShardingSphereMetaData metaData, final SQLStatement sqlStatement) {
- Optional<EncryptRuleConfiguration> ruleConfiguration = metaData.getRuleMetaData().findRuleConfiguration(EncryptRuleConfiguration.class).stream().findAny();
- ruleConfiguration.ifPresent(optional -> data = buildData(optional, (ShowEncryptRulesStatement) sqlStatement).iterator());
+ Optional<EncryptRuleConfiguration> ruleConfig = metaData.getRuleMetaData().findRuleConfiguration(EncryptRuleConfiguration.class).stream().findAny();
+ ruleConfig.ifPresent(optional -> data = buildData(optional, (ShowEncryptRulesStatement) sqlStatement).iterator());
}
- private Collection<Collection<Object>> buildData(final EncryptRuleConfiguration configuration, final ShowEncryptRulesStatement sqlStatement) {
- return configuration.getTables().stream().filter(each -> Objects.isNull(sqlStatement.getTableName()) || each.getName().equals(sqlStatement.getTableName()))
- .map(each -> buildColumnData(each, configuration.getEncryptors())).flatMap(Collection::stream).collect(Collectors.toList());
+ private Collection<Collection<Object>> buildData(final EncryptRuleConfiguration ruleConfig, final ShowEncryptRulesStatement sqlStatement) {
+ return ruleConfig.getTables().stream().filter(each -> Objects.isNull(sqlStatement.getTableName()) || each.getName().equals(sqlStatement.getTableName()))
+ .map(each -> buildColumnData(each, ruleConfig.getEncryptors())).flatMap(Collection::stream).collect(Collectors.toList());
}
- private Collection<Collection<Object>> buildColumnData(final EncryptTableRuleConfiguration tableRuleConfiguration, final Map<String, ShardingSphereAlgorithmConfiguration> algorithmMap) {
+ private Collection<Collection<Object>> buildColumnData(final EncryptTableRuleConfiguration tableRuleConfig, final Map<String, ShardingSphereAlgorithmConfiguration> algorithmMap) {
Collection<Collection<Object>> result = new LinkedList<>();
- tableRuleConfiguration.getColumns().forEach(each -> {
- ShardingSphereAlgorithmConfiguration algorithmConfiguration = algorithmMap.get(each.getEncryptorName());
- result.add(Arrays.asList(tableRuleConfiguration.getName(), each.getLogicColumn(), nullToEmptyString(each.getLogicDataType()),
+ tableRuleConfig.getColumns().forEach(each -> {
+ ShardingSphereAlgorithmConfiguration algorithmConfig = algorithmMap.get(each.getEncryptorName());
+ result.add(Arrays.asList(tableRuleConfig.getName(), each.getLogicColumn(), nullToEmptyString(each.getLogicDataType()),
each.getCipherColumn(), nullToEmptyString(each.getCipherDataType()),
nullToEmptyString(each.getPlainColumn()), nullToEmptyString(each.getPlainDataType()),
nullToEmptyString(each.getAssistedQueryColumn()), nullToEmptyString(each.getAssistedQueryDataType()),
- algorithmConfiguration.getType(), PropertiesConverter.convert(algorithmConfiguration.getProps()),
- Objects.isNull(tableRuleConfiguration.getQueryWithCipherColumn()) ? Boolean.TRUE.toString() : tableRuleConfiguration.getQueryWithCipherColumn().toString()));
+ algorithmConfig.getType(), PropertiesConverter.convert(algorithmConfig.getProps()),
+ Objects.isNull(tableRuleConfig.getQueryWithCipherColumn()) ? Boolean.TRUE.toString() : tableRuleConfig.getQueryWithCipherColumn().toString()));
});
return result;
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleStatementConverterTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleStatementConverterTest.java
index 9dbb98a37b9..1478f8cb9aa 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleStatementConverterTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleStatementConverterTest.java
@@ -35,14 +35,14 @@ public final class EncryptRuleStatementConverterTest {
@Test
public void assertCovert() {
- EncryptRuleConfiguration encryptRuleConfiguration = EncryptRuleStatementConverter.convert(Collections.singleton(new EncryptRuleSegment("t_encrypt", buildColumns(), null)));
- assertNotNull(encryptRuleConfiguration);
- assertThat(encryptRuleConfiguration.getTables().iterator().next().getName(), is("t_encrypt"));
- assertThat(encryptRuleConfiguration.getTables().iterator().next().getColumns().iterator().next().getLogicColumn(), is("user_id"));
- assertThat(encryptRuleConfiguration.getTables().iterator().next().getColumns().iterator().next().getCipherColumn(), is("user_cipher"));
- assertThat(encryptRuleConfiguration.getTables().iterator().next().getColumns().iterator().next().getPlainColumn(), is("user_plain"));
- assertThat(encryptRuleConfiguration.getTables().iterator().next().getColumns().iterator().next().getAssistedQueryColumn(), is("assisted_column"));
- assertThat(encryptRuleConfiguration.getTables().iterator().next().getColumns().iterator().next().getEncryptorName(), is("t_encrypt_user_id"));
+ EncryptRuleConfiguration ruleConfig = EncryptRuleStatementConverter.convert(Collections.singleton(new EncryptRuleSegment("t_encrypt", buildColumns(), null)));
+ assertNotNull(ruleConfig);
+ assertThat(ruleConfig.getTables().iterator().next().getName(), is("t_encrypt"));
+ assertThat(ruleConfig.getTables().iterator().next().getColumns().iterator().next().getLogicColumn(), is("user_id"));
+ assertThat(ruleConfig.getTables().iterator().next().getColumns().iterator().next().getCipherColumn(), is("user_cipher"));
+ assertThat(ruleConfig.getTables().iterator().next().getColumns().iterator().next().getPlainColumn(), is("user_plain"));
+ assertThat(ruleConfig.getTables().iterator().next().getColumns().iterator().next().getAssistedQueryColumn(), is("assisted_column"));
+ assertThat(ruleConfig.getTables().iterator().next().getColumns().iterator().next().getEncryptorName(), is("t_encrypt_user_id"));
}
private Collection<EncryptColumnSegment> buildColumns() {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-boot-starter/src/test/java/org/apache/shardingsphere/encrypt/spring/boot/EncryptSpringBootStarterTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-boot-starter/src/test/java/org/apache/shardingsphere/encrypt/spring/boot/EncryptSpringBootStarterTest.java
index b4299b6c688..2a70c8e0123 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-boot-starter/src/test/java/org/apache/shardingsphere/encrypt/spring/boot/EncryptSpringBootStarterTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-boot-starter/src/test/java/org/apache/shardingsphere/encrypt/spring/boot/EncryptSpringBootStarterTest.java
@@ -49,7 +49,7 @@ public class EncryptSpringBootStarterTest {
private AESEncryptAlgorithm aesEncryptor;
@Resource
- private AlgorithmProvidedEncryptRuleConfiguration encryptRuleConfiguration;
+ private AlgorithmProvidedEncryptRuleConfiguration encryptRuleConfig;
@Test
public void assertAesEncryptor() {
@@ -58,9 +58,9 @@ public class EncryptSpringBootStarterTest {
@Test
public void assertEncryptRuleConfiguration() {
- assertEncryptors(encryptRuleConfiguration.getEncryptors());
- assertThat(encryptRuleConfiguration.getTables().size(), is(1));
- assertEncryptTable(encryptRuleConfiguration.getTables().iterator().next());
+ assertEncryptors(encryptRuleConfig.getEncryptors());
+ assertThat(encryptRuleConfig.getTables().size(), is(1));
+ assertEncryptTable(encryptRuleConfig.getTables().iterator().next());
}
private void assertEncryptors(final Map<String, EncryptAlgorithm<?, ?>> encryptors) {
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/converter/ReadwriteSplittingRuleStatementConverterTest.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphe [...]
index eb0c7206fd3..8fc8fa0e974 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/converter/ReadwriteSplittingRuleStatementConverterTest.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/converter/ReadwriteSplittingRuleStatementConverterTest.java
@@ -61,17 +61,17 @@ public final class ReadwriteSplittingRuleStatementConverterTest {
Map<String, ShardingSphereAlgorithmConfiguration> actualSingleRuleSegmentConvertResultLoadBalancers = actualSingleRuleSegmentConvertResult.getLoadBalancers();
assertThat(actualSingleRuleSegmentConvertResultDataSources.size(), is(1));
assertThat(actualSingleRuleSegmentConvertResultLoadBalancers.size(), is(1));
- ReadwriteSplittingDataSourceRuleConfiguration actualRuleConfiguration = actualSingleRuleSegmentConvertResultDataSources.iterator().next();
- assertThat(actualRuleConfiguration.getName(), is(expectedSingleReadwriteSplittingRuleSegment.getName()));
+ ReadwriteSplittingDataSourceRuleConfiguration actualRuleConfig = actualSingleRuleSegmentConvertResultDataSources.iterator().next();
+ assertThat(actualRuleConfig.getName(), is(expectedSingleReadwriteSplittingRuleSegment.getName()));
String expectedLoadBalancerName = String.format("%s_%s", expectedSingleReadwriteSplittingRuleSegment.getName(), expectedSingleReadwriteSplittingRuleSegment.getLoadBalancer());
- assertThat(actualRuleConfiguration.getLoadBalancerName(), is(expectedLoadBalancerName));
- assertThat(actualRuleConfiguration.getWriteDataSourceName(), is(Optional.ofNullable(expectedSingleReadwriteSplittingRuleSegment.getWriteDataSource())));
- assertThat(convertToList(actualRuleConfiguration.getReadDataSourceNames().orElse(null)), is(expectedSingleReadwriteSplittingRuleSegment.getReadDataSources()));
+ assertThat(actualRuleConfig.getLoadBalancerName(), is(expectedLoadBalancerName));
+ assertThat(actualRuleConfig.getWriteDataSourceName(), is(Optional.ofNullable(expectedSingleReadwriteSplittingRuleSegment.getWriteDataSource())));
+ assertThat(convertToList(actualRuleConfig.getReadDataSourceNames().orElse(null)), is(expectedSingleReadwriteSplittingRuleSegment.getReadDataSources()));
String actualLoadBalancerName = actualSingleRuleSegmentConvertResultLoadBalancers.keySet().iterator().next();
assertThat(actualLoadBalancerName, is(expectedLoadBalancerName));
- ShardingSphereAlgorithmConfiguration actualSphereAlgorithmConfiguration = actualSingleRuleSegmentConvertResultLoadBalancers.get(actualLoadBalancerName);
- assertThat(actualSphereAlgorithmConfiguration.getType(), containsString(expectedSingleReadwriteSplittingRuleSegment.getLoadBalancer()));
- assertThat(actualSphereAlgorithmConfiguration.getProps(), is(expectedSingleReadwriteSplittingRuleSegment.getProps()));
+ ShardingSphereAlgorithmConfiguration actualSphereAlgorithmConfig = actualSingleRuleSegmentConvertResultLoadBalancers.get(actualLoadBalancerName);
+ assertThat(actualSphereAlgorithmConfig.getType(), containsString(expectedSingleReadwriteSplittingRuleSegment.getLoadBalancer()));
+ assertThat(actualSphereAlgorithmConfig.getProps(), is(expectedSingleReadwriteSplittingRuleSegment.getProps()));
}
@Test
@@ -84,24 +84,24 @@ public final class ReadwriteSplittingRuleStatementConverterTest {
Map<String, ShardingSphereAlgorithmConfiguration> actualMultipleRuleSegmentConvertResultLoadBalancers = actualMultipleRuleSegmentConvertResult.getLoadBalancers();
assertThat(actualMultipleRuleSegmentConvertResultDataSources.size(), is(expectedMultipleReadwriteSplittingRuleSegments.size()));
assertThat(actualMultipleRuleSegmentConvertResultLoadBalancers.size(), is(expectedMultipleReadwriteSplittingRuleSegments.size()));
- List<ReadwriteSplittingDataSourceRuleConfiguration> actualRuleConfigurations = new ArrayList<>(actualMultipleRuleSegmentConvertResultDataSources);
+ List<ReadwriteSplittingDataSourceRuleConfiguration> actualRuleConfigs = new ArrayList<>(actualMultipleRuleSegmentConvertResultDataSources);
Stream.iterate(0, i -> i + 1)
.limit(expectedMultipleReadwriteSplittingRuleSegments.size())
.forEach(i -> {
ReadwriteSplittingRuleSegment expectedReadwriteSplittingRuleSegment = expectedMultipleReadwriteSplittingRuleSegments.get(i);
- ReadwriteSplittingDataSourceRuleConfiguration actualRuleConfiguration = actualRuleConfigurations.get(i);
- assertThat(actualRuleConfiguration.getName(), is(expectedReadwriteSplittingRuleSegment.getName()));
+ ReadwriteSplittingDataSourceRuleConfiguration actualRuleConfig = actualRuleConfigs.get(i);
+ assertThat(actualRuleConfig.getName(), is(expectedReadwriteSplittingRuleSegment.getName()));
String expectedLoadBalancerName = String.format("%s_%s", expectedReadwriteSplittingRuleSegment.getName(), expectedReadwriteSplittingRuleSegment.getLoadBalancer());
- assertThat(actualRuleConfiguration.getLoadBalancerName(), is(expectedLoadBalancerName));
- assertThat(actualRuleConfiguration.getWriteDataSourceName().orElse(null), is(expectedReadwriteSplittingRuleSegment.getWriteDataSource()));
- assertThat(convertToList(actualRuleConfiguration.getReadDataSourceNames().orElse(null)),
+ assertThat(actualRuleConfig.getLoadBalancerName(), is(expectedLoadBalancerName));
+ assertThat(actualRuleConfig.getWriteDataSourceName().orElse(null), is(expectedReadwriteSplittingRuleSegment.getWriteDataSource()));
+ assertThat(convertToList(actualRuleConfig.getReadDataSourceNames().orElse(null)),
equalTo(expectedReadwriteSplittingRuleSegment.getReadDataSources() == null
? Collections.emptyList()
: expectedReadwriteSplittingRuleSegment.getReadDataSources()));
assertTrue(actualMultipleRuleSegmentConvertResultLoadBalancers.containsKey(expectedLoadBalancerName));
- ShardingSphereAlgorithmConfiguration actualSphereAlgorithmConfiguration = actualMultipleRuleSegmentConvertResultLoadBalancers.get(actualRuleConfiguration.getLoadBalancerName());
- assertThat(actualSphereAlgorithmConfiguration.getType(), containsString(expectedReadwriteSplittingRuleSegment.getLoadBalancer()));
- assertThat(actualSphereAlgorithmConfiguration.getProps(), is(expectedReadwriteSplittingRuleSegment.getProps()));
+ ShardingSphereAlgorithmConfiguration actualSphereAlgorithmConfig = actualMultipleRuleSegmentConvertResultLoadBalancers.get(actualRuleConfig.getLoadBalancerName());
+ assertThat(actualSphereAlgorithmConfig.getType(), containsString(expectedReadwriteSplittingRuleSegment.getLoadBalancer()));
+ assertThat(actualSphereAlgorithmConfig.getProps(), is(expectedReadwriteSplittingRuleSegment.getProps()));
});
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/checker/AbstractShadowRuleConfigurationChecker.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/checker/AbstractShadowRuleConfigurationChecker.java
index 43545882870..c8f3054a0d8 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/checker/AbstractShadowRuleConfigurationChecker.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/checker/AbstractShadowRuleConfigurationChecker.java
@@ -56,8 +56,8 @@ public abstract class AbstractShadowRuleConfigurationChecker<T extends RuleConfi
Preconditions.checkState(!shadowAlgorithms.isEmpty(), "No available shadow algorithms in shadow configuration.");
}
- protected void shadowAlgorithmConfigurationsSizeCheck(final Map<String, ShardingSphereAlgorithmConfiguration> shadowAlgorithmConfigurations) {
- Preconditions.checkState(!shadowAlgorithmConfigurations.isEmpty(), "No available shadow data algorithms in shadow configuration.");
+ protected void shadowAlgorithmConfigurationsSizeCheck(final Map<String, ShardingSphereAlgorithmConfiguration> shadowAlgorithmConfigs) {
+ Preconditions.checkState(!shadowAlgorithmConfigs.isEmpty(), "No available shadow data algorithms in shadow configuration.");
}
protected void shadowTableDataSourcesAutoReferences(final Map<String, ShadowTableConfiguration> shadowTables, final Map<String, ShadowDataSourceConfiguration> dataSources) {
@@ -76,10 +76,10 @@ public abstract class AbstractShadowRuleConfigurationChecker<T extends RuleConfi
});
}
- protected void defaultShadowAlgorithmConfigurationCheck(final String defaultShadowAlgorithmName, final Map<String, ShardingSphereAlgorithmConfiguration> shadowAlgorithmConfigurations) {
+ protected void defaultShadowAlgorithmConfigurationCheck(final String defaultShadowAlgorithmName, final Map<String, ShardingSphereAlgorithmConfiguration> shadowAlgorithmConfigs) {
if (null != defaultShadowAlgorithmName) {
- ShardingSphereAlgorithmConfiguration shardingSphereAlgorithmConfiguration = shadowAlgorithmConfigurations.get(defaultShadowAlgorithmName);
- boolean state = null != shardingSphereAlgorithmConfiguration && "SIMPLE_HINT".equals(shardingSphereAlgorithmConfiguration.getType());
+ ShardingSphereAlgorithmConfiguration algorithmConfig = shadowAlgorithmConfigs.get(defaultShadowAlgorithmName);
+ boolean state = null != algorithmConfig && "SIMPLE_HINT".equals(algorithmConfig.getType());
Preconditions.checkState(state, "Default shadow algorithm class should be implement HintShadowAlgorithm.");
}
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationChecker.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationChecker.java
index f5985225c56..06fb112ba98 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationChecker.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationChecker.java
@@ -34,14 +34,14 @@ public final class ShadowRuleConfigurationChecker extends AbstractShadowRuleConf
protected void checkShadowRuleConfiguration(final ShadowRuleConfiguration config) {
Map<String, ShadowDataSourceConfiguration> dataSources = config.getDataSources();
Map<String, ShadowTableConfiguration> shadowTables = config.getTables();
- Map<String, ShardingSphereAlgorithmConfiguration> shadowAlgorithmConfigurations = config.getShadowAlgorithms();
+ Map<String, ShardingSphereAlgorithmConfiguration> shadowAlgorithmConfigs = config.getShadowAlgorithms();
String defaultShadowAlgorithmName = config.getDefaultShadowAlgorithmName();
sizeCheck(dataSources, shadowTables, defaultShadowAlgorithmName);
- shadowAlgorithmConfigurationsSizeCheck(shadowAlgorithmConfigurations);
+ shadowAlgorithmConfigurationsSizeCheck(shadowAlgorithmConfigs);
shadowTableDataSourcesAutoReferences(shadowTables, dataSources);
shadowTableDataSourcesReferencesCheck(shadowTables, dataSources);
- defaultShadowAlgorithmConfigurationCheck(defaultShadowAlgorithmName, shadowAlgorithmConfigurations);
- shadowTableAlgorithmsAutoReferences(shadowTables, shadowAlgorithmConfigurations.keySet(), defaultShadowAlgorithmName);
+ defaultShadowAlgorithmConfigurationCheck(defaultShadowAlgorithmName, shadowAlgorithmConfigs);
+ shadowTableAlgorithmsAutoReferences(shadowTables, shadowAlgorithmConfigs.keySet(), defaultShadowAlgorithmName);
shadowTableAlgorithmsReferencesCheck(shadowTables);
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleAlgorithmProviderConfigurationYamlSwapperTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleAlgorithmProviderConfigurationYamlSwapperTest.java
index 1ef2fbd7a41..65a52596dd9 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleAlgorithmProviderConfigurationYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleAlgorithmProviderConfigurationYamlSwapperTest.java
@@ -47,21 +47,21 @@ public final class ShadowRuleAlgorithmProviderConfigurationYamlSwapperTest {
@Test
public void assertSwapToYamlConfiguration() {
- AlgorithmProvidedShadowRuleConfiguration expectedConfiguration = buildAlgorithmProvidedShadowRuleConfiguration();
- YamlShadowRuleConfiguration actualConfiguration = swapper.swapToYamlConfiguration(expectedConfiguration);
- actualConfiguration.getDataSources().forEach((key, value) -> {
- ShadowDataSourceConfiguration dataSourceConfiguration = expectedConfiguration.getDataSources().get(key);
- assertNotNull(dataSourceConfiguration);
- assertThat(value.getShadowDataSourceName(), is(dataSourceConfiguration.getShadowDataSourceName()));
- assertThat(value.getSourceDataSourceName(), is(dataSourceConfiguration.getSourceDataSourceName()));
+ AlgorithmProvidedShadowRuleConfiguration expected = buildAlgorithmProvidedShadowRuleConfiguration();
+ YamlShadowRuleConfiguration actual = swapper.swapToYamlConfiguration(expected);
+ actual.getDataSources().forEach((key, value) -> {
+ ShadowDataSourceConfiguration dataSourceConfig = expected.getDataSources().get(key);
+ assertNotNull(dataSourceConfig);
+ assertThat(value.getShadowDataSourceName(), is(dataSourceConfig.getShadowDataSourceName()));
+ assertThat(value.getSourceDataSourceName(), is(dataSourceConfig.getSourceDataSourceName()));
});
- actualConfiguration.getTables().forEach((key, value) -> {
- ShadowTableConfiguration shadowTableConfiguration = expectedConfiguration.getTables().get(key);
- assertNotNull(shadowTableConfiguration);
- assertThat(value.getShadowAlgorithmNames(), is(shadowTableConfiguration.getShadowAlgorithmNames()));
+ actual.getTables().forEach((key, value) -> {
+ ShadowTableConfiguration shadowTableConfig = expected.getTables().get(key);
+ assertNotNull(shadowTableConfig);
+ assertThat(value.getShadowAlgorithmNames(), is(shadowTableConfig.getShadowAlgorithmNames()));
});
- actualConfiguration.getShadowAlgorithms().forEach((key, value) -> {
- ShadowAlgorithm shadowAlgorithm = expectedConfiguration.getShadowAlgorithms().get(key);
+ actual.getShadowAlgorithms().forEach((key, value) -> {
+ ShadowAlgorithm shadowAlgorithm = expected.getShadowAlgorithms().get(key);
assertNotNull(shadowAlgorithm);
assertThat(value.getType(), is(shadowAlgorithm.getType()));
});
@@ -77,15 +77,15 @@ public final class ShadowRuleAlgorithmProviderConfigurationYamlSwapperTest {
@Test
public void assertSwapToObject() {
- YamlShadowRuleConfiguration expectedConfiguration = buildYamlShadowRuleConfiguration();
- AlgorithmProvidedShadowRuleConfiguration actual = swapper.swapToObject(expectedConfiguration);
+ YamlShadowRuleConfiguration expected = buildYamlShadowRuleConfiguration();
+ AlgorithmProvidedShadowRuleConfiguration actual = swapper.swapToObject(expected);
actual.getDataSources().forEach((key, value) -> {
- YamlShadowDataSourceConfiguration yamlShadowDataSourceConfig = expectedConfiguration.getDataSources().get(key);
+ YamlShadowDataSourceConfiguration yamlShadowDataSourceConfig = expected.getDataSources().get(key);
assertThat(value.getShadowDataSourceName(), is(yamlShadowDataSourceConfig.getShadowDataSourceName()));
assertThat(value.getSourceDataSourceName(), is(yamlShadowDataSourceConfig.getSourceDataSourceName()));
});
- actual.getTables().forEach((key, value) -> assertThat(value.getShadowAlgorithmNames(), is(expectedConfiguration.getTables().get(key).getShadowAlgorithmNames())));
- actual.getShadowAlgorithms().forEach((key, value) -> assertThat(value.getType(), is(expectedConfiguration.getShadowAlgorithms().get(key).getType())));
+ actual.getTables().forEach((key, value) -> assertThat(value.getShadowAlgorithmNames(), is(expected.getTables().get(key).getShadowAlgorithmNames())));
+ actual.getShadowAlgorithms().forEach((key, value) -> assertThat(value.getType(), is(expected.getShadowAlgorithms().get(key).getType())));
}
private YamlShadowRuleConfiguration buildYamlShadowRuleConfiguration() {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/datasource/ShadowDataSourcePropertiesYamlSwapperTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/datasource/ShadowDataSourcePropertiesYamlSwapperTest.java
index 78fec95a13f..a87cb11ac02 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/datasource/ShadowDataSourcePropertiesYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/datasource/ShadowDataSourcePropertiesYamlSwapperTest.java
@@ -30,9 +30,9 @@ public final class ShadowDataSourcePropertiesYamlSwapperTest {
public void assertSwapToYamlConfiguration() {
ShadowDataSourceConfiguration shadowDataSourceConfig = new ShadowDataSourceConfiguration("ds", "ds-shadow");
ShadowDataSourceConfigurationYamlSwapper swapper = new ShadowDataSourceConfigurationYamlSwapper();
- YamlShadowDataSourceConfiguration configuration = swapper.swapToYamlConfiguration(shadowDataSourceConfig);
- assertThat(shadowDataSourceConfig.getSourceDataSourceName(), is(configuration.getSourceDataSourceName()));
- assertThat(shadowDataSourceConfig.getShadowDataSourceName(), is(configuration.getShadowDataSourceName()));
+ YamlShadowDataSourceConfiguration yamlConfig = swapper.swapToYamlConfiguration(shadowDataSourceConfig);
+ assertThat(shadowDataSourceConfig.getSourceDataSourceName(), is(yamlConfig.getSourceDataSourceName()));
+ assertThat(shadowDataSourceConfig.getShadowDataSourceName(), is(yamlConfig.getShadowDataSourceName()));
}
@Test
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/table/ShadowTableConfigurationYamlSwapperTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/table/ShadowTableConfigurationYamlSwapperTest.java
index 9e57decec84..3b6f24e23d1 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/table/ShadowTableConfigurationYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/table/ShadowTableConfigurationYamlSwapperTest.java
@@ -31,11 +31,10 @@ public final class ShadowTableConfigurationYamlSwapperTest {
@Test
public void assertSwapToYamlConfiguration() {
- ShadowTableConfiguration shadowTableConfiguration = new ShadowTableConfiguration(Collections.singletonList("shadow-data-source"), Arrays.asList("t_order", "t_user"));
- ShadowTableConfigurationYamlSwapper swapper = new ShadowTableConfigurationYamlSwapper();
- YamlShadowTableConfiguration yamlShadowTableConfiguration = swapper.swapToYamlConfiguration(shadowTableConfiguration);
- assertThat(yamlShadowTableConfiguration.getShadowAlgorithmNames(), is(shadowTableConfiguration.getShadowAlgorithmNames()));
- assertThat(yamlShadowTableConfiguration.getDataSourceNames(), is(shadowTableConfiguration.getDataSourceNames()));
+ ShadowTableConfiguration shadowTableConfig = new ShadowTableConfiguration(Collections.singletonList("shadow-data-source"), Arrays.asList("t_order", "t_user"));
+ YamlShadowTableConfiguration yamlShadowTableConfig = new ShadowTableConfigurationYamlSwapper().swapToYamlConfiguration(shadowTableConfig);
+ assertThat(yamlShadowTableConfig.getShadowAlgorithmNames(), is(shadowTableConfig.getShadowAlgorithmNames()));
+ assertThat(yamlShadowTableConfig.getDataSourceNames(), is(shadowTableConfig.getDataSourceNames()));
}
@Test
@@ -43,9 +42,8 @@ public final class ShadowTableConfigurationYamlSwapperTest {
YamlShadowTableConfiguration yamlConfig = new YamlShadowTableConfiguration();
yamlConfig.setDataSourceNames(Collections.singletonList("shadow-data-source"));
yamlConfig.setShadowAlgorithmNames(Arrays.asList("user-id-match-algorithm", "note-algorithm"));
- ShadowTableConfigurationYamlSwapper swapper = new ShadowTableConfigurationYamlSwapper();
- ShadowTableConfiguration shadowTableConfiguration = swapper.swapToObject(yamlConfig);
- assertThat(shadowTableConfiguration.getDataSourceNames(), is(yamlConfig.getDataSourceNames()));
- assertThat(shadowTableConfiguration.getShadowAlgorithmNames(), is(yamlConfig.getShadowAlgorithmNames()));
+ ShadowTableConfiguration shadowTableConfig = new ShadowTableConfigurationYamlSwapper().swapToObject(yamlConfig);
+ assertThat(shadowTableConfig.getDataSourceNames(), is(yamlConfig.getDataSourceNames()));
+ assertThat(shadowTableConfig.getShadowAlgorithmNames(), is(yamlConfig.getShadowAlgorithmNames()));
}
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
index 2931bdec651..0521f40b71d 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
@@ -42,11 +42,11 @@ public class ShadowRuleStatementChecker {
* Check if the configuration exists.
*
* @param databaseName database name
- * @param configuration configuration
+ * @param config configuration
* @throws DistSQLException DistSQL exception
*/
- public static void checkConfigurationExist(final String databaseName, final SchemaRuleConfiguration configuration) throws DistSQLException {
- DistSQLException.predictionThrow(null != configuration, () -> new RequiredRuleMissedException(SHADOW, databaseName));
+ public static void checkConfigurationExist(final String databaseName, final SchemaRuleConfiguration config) throws DistSQLException {
+ DistSQLException.predictionThrow(null != config, () -> new RequiredRuleMissedException(SHADOW, databaseName));
}
/**
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowAlgorithmQueryResultSet.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowAlgorithmQueryResultSet.java
index 2a225f0f682..85b47c0888c 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowAlgorithmQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowAlgorithmQueryResultSet.java
@@ -55,9 +55,9 @@ public final class ShadowAlgorithmQueryResultSet implements DistSQLResultSet {
public void init(final ShardingSphereMetaData metaData, final SQLStatement sqlStatement) {
Optional<ShadowRuleConfiguration> rule = metaData.getRuleMetaData().getConfigurations()
.stream().filter(each -> each instanceof ShadowRuleConfiguration).map(each -> (ShadowRuleConfiguration) each).findAny();
- rule.ifPresent(configuration -> {
- data = configuration.getShadowAlgorithms().entrySet().iterator();
- defaultAlgorithm = configuration.getDefaultShadowAlgorithmName();
+ rule.ifPresent(each -> {
+ data = each.getShadowAlgorithms().entrySet().iterator();
+ defaultAlgorithm = each.getDefaultShadowAlgorithmName();
});
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowRuleQueryResultSet.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowRuleQueryResultSet.java
index 24456753d24..9aeab9c352c 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowRuleQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowRuleQueryResultSet.java
@@ -53,16 +53,16 @@ public final class ShadowRuleQueryResultSet implements DistSQLResultSet {
@Override
public void init(final ShardingSphereMetaData metaData, final SQLStatement sqlStatement) {
- Optional<ShadowRuleConfiguration> ruleConfigurations = metaData.getRuleMetaData().getConfigurations().stream()
+ Optional<ShadowRuleConfiguration> ruleConfigs = metaData.getRuleMetaData().getConfigurations().stream()
.filter(each -> each instanceof ShadowRuleConfiguration).map(each -> (ShadowRuleConfiguration) each).findAny();
- ruleConfigurations.ifPresent(configuration -> buildDataSourceIterator(configuration, (ShowShadowRulesStatement) sqlStatement));
+ ruleConfigs.ifPresent(each -> buildDataSourceIterator(each, (ShowShadowRulesStatement) sqlStatement));
}
- private void buildDataSourceIterator(final ShadowRuleConfiguration configuration, final ShowShadowRulesStatement sqlStatement) {
- Map<String, Map<String, ShadowTableConfiguration>> dataSourceTableMap = convertToDataSourceTableMap(configuration.getTables());
- Collection<Entry<String, ShadowDataSourceConfiguration>> specifiedConfigurations = !isSpecified(sqlStatement) ? configuration.getDataSources().entrySet()
- : configuration.getDataSources().entrySet().stream().filter(entry -> entry.getKey().equalsIgnoreCase(sqlStatement.getRuleName())).collect(Collectors.toList());
- data = specifiedConfigurations.stream().map(each -> buildDataItem(each, dataSourceTableMap)).collect(Collectors.toList()).iterator();
+ private void buildDataSourceIterator(final ShadowRuleConfiguration ruleConfig, final ShowShadowRulesStatement sqlStatement) {
+ Map<String, Map<String, ShadowTableConfiguration>> dataSourceTableMap = convertToDataSourceTableMap(ruleConfig.getTables());
+ Collection<Entry<String, ShadowDataSourceConfiguration>> specifiedConfigs = !isSpecified(sqlStatement) ? ruleConfig.getDataSources().entrySet()
+ : ruleConfig.getDataSources().entrySet().stream().filter(entry -> entry.getKey().equalsIgnoreCase(sqlStatement.getRuleName())).collect(Collectors.toList());
+ data = specifiedConfigs.stream().map(each -> buildDataItem(each, dataSourceTableMap)).collect(Collectors.toList()).iterator();
}
private Map<String, Map<String, ShadowTableConfiguration>> convertToDataSourceTableMap(final Map<String, ShadowTableConfiguration> tables) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowTableRuleQueryResultSet.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowTableRuleQueryResultSet.java
index 301b28900b5..c5b1603816c 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowTableRuleQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShadowTableRuleQueryResultSet.java
@@ -48,7 +48,7 @@ public final class ShadowTableRuleQueryResultSet implements DistSQLResultSet {
public void init(final ShardingSphereMetaData metaData, final SQLStatement sqlStatement) {
Optional<ShadowRuleConfiguration> rule = metaData.getRuleMetaData().getConfigurations()
.stream().filter(each -> each instanceof ShadowRuleConfiguration).map(each -> (ShadowRuleConfiguration) each).findAny();
- rule.ifPresent(configuration -> data = buildData(configuration).iterator());
+ rule.ifPresent(each -> data = buildData(each).iterator());
}
private List<Map<String, String>> buildData(final ShadowRuleConfiguration shadowRuleConfiguration) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/supporter/ShadowRuleStatementSupporter.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/supporter/ShadowRuleStatementSupporter.java
index 6d8a2639d7c..0dde5c47b49 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/supporter/ShadowRuleStatementSupporter.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/supporter/ShadowRuleStatementSupporter.java
@@ -36,116 +36,116 @@ import java.util.stream.Collectors;
public final class ShadowRuleStatementSupporter {
/**
- * Get rule names from the configuration.
+ * Get rule names from the shadow rule configuration.
*
- * @param configuration configuration
+ * @param ruleConfig shadow rule configuration
* @return rule names
*/
- public static List<String> getRuleNames(final ShadowRuleConfiguration configuration) {
- if (null == configuration) {
+ public static List<String> getRuleNames(final ShadowRuleConfiguration ruleConfig) {
+ if (null == ruleConfig) {
return Collections.emptyList();
}
- return new ArrayList<>(configuration.getDataSources().keySet());
+ return new ArrayList<>(ruleConfig.getDataSources().keySet());
}
/**
* Get rule names from the rules.
*
- * @param rules rules
+ * @param segments shadow rule segments
* @return rule names
*/
- public static List<String> getRuleNames(final Collection<ShadowRuleSegment> rules) {
- if (rules.isEmpty()) {
+ public static List<String> getRuleNames(final Collection<ShadowRuleSegment> segments) {
+ if (segments.isEmpty()) {
return Collections.emptyList();
}
- return rules.stream().map(ShadowRuleSegment::getRuleName).collect(Collectors.toList());
+ return segments.stream().map(ShadowRuleSegment::getRuleName).collect(Collectors.toList());
}
/**
- * Get table names from the configuration.
+ * Get table names from the shadow rule configuration.
*
- * @param configuration configuration
+ * @param ruleConfig shadow rule configuration
* @return table names
*/
- public static List<String> getTableNames(final ShadowRuleConfiguration configuration) {
- if (null == configuration) {
+ public static List<String> getTableNames(final ShadowRuleConfiguration ruleConfig) {
+ if (null == ruleConfig) {
return Collections.emptyList();
}
- return new ArrayList<>(configuration.getTables().keySet());
+ return new ArrayList<>(ruleConfig.getTables().keySet());
}
/**
* Get the table names from the rules.
*
- * @param rules rules
+ * @param segments shadow rule segments
* @return table names
*/
- public static List<String> getTableNames(final Collection<ShadowRuleSegment> rules) {
- if (rules.isEmpty()) {
+ public static List<String> getTableNames(final Collection<ShadowRuleSegment> segments) {
+ if (segments.isEmpty()) {
return Collections.emptyList();
}
- return rules.stream().flatMap(each -> each.getShadowTableRules().keySet().stream()).collect(Collectors.toList());
+ return segments.stream().flatMap(each -> each.getShadowTableRules().keySet().stream()).collect(Collectors.toList());
}
/**
* Get the resource names from the rules.
*
- * @param rules rules
+ * @param segments shadow rule segments
* @return resource names
*/
- public static List<String> getResourceNames(final Collection<ShadowRuleSegment> rules) {
- if (rules.isEmpty()) {
+ public static List<String> getResourceNames(final Collection<ShadowRuleSegment> segments) {
+ if (segments.isEmpty()) {
return Collections.emptyList();
}
- return rules.stream().map(each -> Arrays.asList(each.getSource(), each.getShadow())).flatMap(Collection::stream).filter(Objects::nonNull).collect(Collectors.toList());
+ return segments.stream().map(each -> Arrays.asList(each.getSource(), each.getShadow())).flatMap(Collection::stream).filter(Objects::nonNull).collect(Collectors.toList());
}
/**
- * Get the algorithm names from the configuration.
+ * Get the algorithm names from the shadow rule configuration.
*
- * @param configuration configuration
+ * @param ruleConfig shadow rule configuration
* @return algorithm names
*/
- public static List<String> getAlgorithmNames(final ShadowRuleConfiguration configuration) {
- if (null == configuration) {
+ public static List<String> getAlgorithmNames(final ShadowRuleConfiguration ruleConfig) {
+ if (null == ruleConfig) {
return Collections.emptyList();
}
- return new ArrayList<>(configuration.getShadowAlgorithms().keySet());
+ return new ArrayList<>(ruleConfig.getShadowAlgorithms().keySet());
}
/**
* Get the algorithm names from the rules.
*
- * @param rules configuration
+ * @param segments shadow rule segments
* @return algorithm names
*/
- public static List<String> getAlgorithmNames(final Collection<ShadowRuleSegment> rules) {
- if (rules.isEmpty()) {
+ public static List<String> getAlgorithmNames(final Collection<ShadowRuleSegment> segments) {
+ if (segments.isEmpty()) {
return Collections.emptyList();
}
- return rules.stream().flatMap(each -> each.getShadowTableRules().values().stream()).flatMap(Collection::stream).map(ShadowAlgorithmSegment::getAlgorithmName).collect(Collectors.toList());
+ return segments.stream().flatMap(each -> each.getShadowTableRules().values().stream()).flatMap(Collection::stream).map(ShadowAlgorithmSegment::getAlgorithmName).collect(Collectors.toList());
}
/**
* Get the algorithm segments from the rules.
*
- * @param rules configuration
+ * @param segments shadow rule segments
* @return algorithm segments
*/
- public static List<ShadowAlgorithmSegment> getShadowAlgorithmSegment(final Collection<ShadowRuleSegment> rules) {
- return rules.stream().flatMap(each -> each.getShadowTableRules().values().stream()).flatMap(Collection::stream).collect(Collectors.toList());
+ public static List<ShadowAlgorithmSegment> getShadowAlgorithmSegment(final Collection<ShadowRuleSegment> segments) {
+ return segments.stream().flatMap(each -> each.getShadowTableRules().values().stream()).flatMap(Collection::stream).collect(Collectors.toList());
}
/**
* Merge configuration.
*
- * @param existingConfiguration already existing configuration
- * @param newConfiguration new shadow table configuration
+ * @param existingTableConfig existing shadow table configuration
+ * @param newTableConfig new shadow table configuration
* @return shadow table configuration
*/
- public static ShadowTableConfiguration mergeConfiguration(final ShadowTableConfiguration existingConfiguration, final ShadowTableConfiguration newConfiguration) {
- existingConfiguration.getDataSourceNames().addAll(newConfiguration.getDataSourceNames());
- existingConfiguration.getShadowAlgorithmNames().addAll(newConfiguration.getShadowAlgorithmNames());
- return existingConfiguration;
+ public static ShadowTableConfiguration mergeConfiguration(final ShadowTableConfiguration existingTableConfig, final ShadowTableConfiguration newTableConfig) {
+ existingTableConfig.getDataSourceNames().addAll(newTableConfig.getDataSourceNames());
+ existingTableConfig.getShadowAlgorithmNames().addAll(newTableConfig.getShadowAlgorithmNames());
+ return existingTableConfig;
}
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleStatementUpdater.java
index d0b27c47938..d9ca6f1993b 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleStatementUpdater.java
@@ -58,7 +58,7 @@ public final class AlterShadowRuleStatementUpdater implements RuleDefinitionAlte
}
private void updateDataSources(final ShadowRuleConfiguration currentRuleConfig, final Map<String, ShadowDataSourceConfiguration> toBeAlteredDataSources) {
- currentRuleConfig.getTables().values().forEach(tableConfig -> tableConfig.getDataSourceNames().removeIf(toBeAlteredDataSources::containsKey));
+ currentRuleConfig.getTables().values().forEach(each -> each.getDataSourceNames().removeIf(toBeAlteredDataSources::containsKey));
currentRuleConfig.getDataSources().putAll(toBeAlteredDataSources);
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowAlgorithmStatementUpdaterTest.java
index 94ab0875ea7..2c09615169e 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowAlgorithmStatementUpdaterTest.java
@@ -46,7 +46,7 @@ public final class AlterShadowAlgorithmStatementUpdaterTest {
private ShardingSphereMetaData shardingSphereMetaData;
@Mock
- private ShadowRuleConfiguration currentConfiguration;
+ private ShadowRuleConfiguration currentConfig;
private final AlterShadowAlgorithmStatementUpdater updater = new AlterShadowAlgorithmStatementUpdater();
@@ -56,7 +56,7 @@ public final class AlterShadowAlgorithmStatementUpdaterTest {
prop.setProperty("type", "value");
AlterShadowAlgorithmStatement sqlStatement = createSQLStatement(new ShadowAlgorithmSegment("simpleHintAlgorithm", new AlgorithmSegment("SIMPLE_HINT", prop)),
new ShadowAlgorithmSegment("simpleHintAlgorithm", new AlgorithmSegment("SIMPLE_HINT", prop)));
- updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfig);
}
@Test(expected = RequiredRuleMissedException.class)
@@ -71,9 +71,9 @@ public final class AlterShadowAlgorithmStatementUpdaterTest {
public void assertExecuteAlgorithmNotInMetaData() throws DistSQLException {
Properties prop = new Properties();
prop.setProperty("type", "value");
- when(currentConfiguration.getShadowAlgorithms()).thenReturn(Collections.singletonMap("simpleHintAlgorithm", new ShardingSphereAlgorithmConfiguration("type", prop)));
+ when(currentConfig.getShadowAlgorithms()).thenReturn(Collections.singletonMap("simpleHintAlgorithm", new ShardingSphereAlgorithmConfiguration("type", prop)));
AlterShadowAlgorithmStatement sqlStatement = createSQLStatement(new ShadowAlgorithmSegment("simpleHintAlgorithm1", new AlgorithmSegment("SIMPLE_HINT", prop)));
- updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfig);
}
private AlterShadowAlgorithmStatement createSQLStatement(final ShadowAlgorithmSegment... ruleSegments) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
index 2000e5fa20b..14cb0128ce5 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
@@ -58,7 +58,7 @@ public final class AlterShadowRuleStatementUpdaterTest {
private ShardingSphereResource resource;
@Mock
- private ShadowRuleConfiguration currentConfiguration;
+ private ShadowRuleConfiguration currentConfig;
private final AlterShadowRuleStatementUpdater updater = new AlterShadowRuleStatementUpdater();
@@ -68,7 +68,7 @@ public final class AlterShadowRuleStatementUpdaterTest {
map.put("initRuleName1", new ShadowDataSourceConfiguration("ds1", "ds_shadow1"));
map.put("initRuleName2", new ShadowDataSourceConfiguration("ds2", "ds_shadow2"));
when(shardingSphereMetaData.getResource()).thenReturn(resource);
- when(currentConfiguration.getDataSources()).thenReturn(map);
+ when(currentConfig.getDataSources()).thenReturn(map);
}
@Test(expected = RequiredRuleMissedException.class)
@@ -80,13 +80,13 @@ public final class AlterShadowRuleStatementUpdaterTest {
@Test(expected = DuplicateRuleException.class)
public void assertExecuteWithDuplicateRuleName() throws DistSQLException {
ShadowRuleSegment ruleSegment = new ShadowRuleSegment("ruleName", null, null, null);
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(ruleSegment, ruleSegment), currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(ruleSegment, ruleSegment), currentConfig);
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
public void assertExecuteWithRuleNameNotInMetaData() throws DistSQLException {
ShadowRuleSegment ruleSegment = new ShadowRuleSegment("ruleName", null, null, null);
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(ruleSegment), currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(ruleSegment), currentConfig);
}
@Test(expected = RequiredResourceMissedException.class)
@@ -94,7 +94,7 @@ public final class AlterShadowRuleStatementUpdaterTest {
List<String> dataSources = Arrays.asList("ds", "ds0");
when(resource.getNotExistedResources(any())).thenReturn(dataSources);
AlterShadowRuleStatement sqlStatement = createSQLStatement(new ShadowRuleSegment("initRuleName1", "ds3", null, null));
- updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfig);
}
@Test(expected = AlgorithmInUsedException.class)
@@ -104,7 +104,7 @@ public final class AlterShadowRuleStatementUpdaterTest {
ShadowAlgorithmSegment segment = new ShadowAlgorithmSegment("algorithmName", new AlgorithmSegment("name", prop));
AlterShadowRuleStatement sqlStatement = createSQLStatement(new ShadowRuleSegment("initRuleName1", "ds", null, Collections.singletonMap("t_order", Collections.singleton(segment))),
new ShadowRuleSegment("initRuleName2", "ds1", null, Collections.singletonMap("t_order_1", Collections.singletonList(segment))));
- updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfig);
}
@Test(expected = AlgorithmInUsedException.class)
@@ -114,7 +114,7 @@ public final class AlterShadowRuleStatementUpdaterTest {
ShadowAlgorithmSegment segment = new ShadowAlgorithmSegment("algorithmName", new AlgorithmSegment("name", prop));
AlterShadowRuleStatement sqlStatement = createSQLStatement(new ShadowRuleSegment("initRuleName1", "ds", null, Collections.singletonMap("t_order", Collections.singleton(segment))),
new ShadowRuleSegment("initRuleName2", "ds1", null, Collections.singletonMap("t_order_1", Collections.singletonList(segment))));
- updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfig);
}
@Test
@@ -125,7 +125,7 @@ public final class AlterShadowRuleStatementUpdaterTest {
ShadowAlgorithmSegment segment2 = new ShadowAlgorithmSegment("algorithmName2", new AlgorithmSegment("name", prop));
AlterShadowRuleStatement sqlStatement = createSQLStatement(new ShadowRuleSegment("initRuleName1", "ds", null, Collections.singletonMap("t_order", Collections.singleton(segment1))),
new ShadowRuleSegment("initRuleName2", "ds1", null, Collections.singletonMap("t_order_1", Collections.singletonList(segment2))));
- updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfig);
}
private AlterShadowRuleStatement createSQLStatement(final ShadowRuleSegment... ruleSegments) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateDefaultShadowAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateDefaultShadowAlgorithmStatementUpdaterTest.java
index 6f01c407873..04a97f8cdfd 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateDefaultShadowAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateDefaultShadowAlgorithmStatementUpdaterTest.java
@@ -39,17 +39,13 @@ public final class CreateDefaultShadowAlgorithmStatementUpdaterTest {
private ShardingSphereMetaData shardingSphereMetaData;
@Mock
- private ShadowRuleConfiguration currentConfiguration;
+ private ShadowRuleConfiguration currentConfig;
private final CreateDefaultShadowAlgorithmStatementUpdater updater = new CreateDefaultShadowAlgorithmStatementUpdater();
@Test(expected = RequiredAlgorithmMissedException.class)
public void assertExecuteWithNotExistAlgorithm() throws DistSQLException {
- when(currentConfiguration.getShadowAlgorithms()).thenReturn(Collections.singletonMap("default_name", null));
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement("input_default_name"), currentConfiguration);
- }
-
- private CreateDefaultShadowAlgorithmStatement createSQLStatement(final String defaultShadowAlgorithmName) {
- return new CreateDefaultShadowAlgorithmStatement(defaultShadowAlgorithmName);
+ when(currentConfig.getShadowAlgorithms()).thenReturn(Collections.singletonMap("default_name", null));
+ updater.checkSQLStatement(shardingSphereMetaData, new CreateDefaultShadowAlgorithmStatement("input_default_name"), currentConfig);
}
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
index 0c6094301b2..c47941cc0b5 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
@@ -54,14 +54,14 @@ public final class CreateShadowRuleStatementUpdaterTest {
private ShardingSphereResource resource;
@Mock
- private ShadowRuleConfiguration currentConfiguration;
+ private ShadowRuleConfiguration currentConfig;
private final CreateShadowRuleStatementUpdater updater = new CreateShadowRuleStatementUpdater();
@Before
public void before() {
when(shardingSphereMetaData.getResource()).thenReturn(resource);
- when(currentConfiguration.getDataSources()).thenReturn(Collections.singletonMap("initRuleName", new ShadowDataSourceConfiguration("initDs0", "initDs0Shadow")));
+ when(currentConfig.getDataSources()).thenReturn(Collections.singletonMap("initRuleName", new ShadowDataSourceConfiguration("initDs0", "initDs0Shadow")));
}
@Test(expected = DuplicateRuleException.class)
@@ -72,9 +72,9 @@ public final class CreateShadowRuleStatementUpdaterTest {
@Test(expected = DuplicateRuleException.class)
public void assertExecuteWithDuplicateRuleNameInMetaData() throws DistSQLException {
- when(currentConfiguration.getDataSources()).thenReturn(Collections.singletonMap("ruleName", null));
+ when(currentConfig.getDataSources()).thenReturn(Collections.singletonMap("ruleName", null));
ShadowRuleSegment ruleSegment = new ShadowRuleSegment("ruleName", null, null, null);
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(ruleSegment), currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(ruleSegment), currentConfig);
}
@Test(expected = RequiredResourceMissedException.class)
@@ -82,7 +82,7 @@ public final class CreateShadowRuleStatementUpdaterTest {
List<String> dataSources = Arrays.asList("ds0", "ds1");
when(resource.getNotExistedResources(any())).thenReturn(dataSources);
CreateShadowRuleStatement sqlStatement = createSQLStatement(new ShadowRuleSegment("ruleName", "ds1", null, null));
- updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfig);
}
@Test(expected = DuplicateRuleException.class)
@@ -92,7 +92,7 @@ public final class CreateShadowRuleStatementUpdaterTest {
ShadowAlgorithmSegment segment = new ShadowAlgorithmSegment("algorithmName", new AlgorithmSegment("name", prop));
CreateShadowRuleStatement sqlStatement = createSQLStatement(new ShadowRuleSegment("ruleName", "ds", null, Collections.singletonMap("t_order", Collections.singleton(segment))),
new ShadowRuleSegment("ruleName1", "ds1", null, Collections.singletonMap("t_order_1", Collections.singletonList(segment))));
- updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfig);
}
@Test(expected = DuplicateRuleException.class)
@@ -109,10 +109,10 @@ public final class CreateShadowRuleStatementUpdaterTest {
public void assertExecuteDuplicateAlgorithmInMetaData() throws DistSQLException {
Properties prop = new Properties();
prop.setProperty("type", "value");
- when(currentConfiguration.getShadowAlgorithms()).thenReturn(Collections.singletonMap("algorithmName", new ShardingSphereAlgorithmConfiguration("type", prop)));
+ when(currentConfig.getShadowAlgorithms()).thenReturn(Collections.singletonMap("algorithmName", new ShardingSphereAlgorithmConfiguration("type", prop)));
ShadowAlgorithmSegment segment = new ShadowAlgorithmSegment("algorithmName", new AlgorithmSegment("type", prop));
CreateShadowRuleStatement sqlStatement = createSQLStatement(new ShadowRuleSegment("ruleName", "ds", null, Collections.singletonMap("t_order", Collections.singleton(segment))));
- updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, currentConfig);
}
private CreateShadowRuleStatement createSQLStatement(final ShadowRuleSegment... ruleSegments) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropDefaultShadowAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropDefaultShadowAlgorithmStatementUpdaterTest.java
index 4c8bb98ae90..39ab62e8e2f 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropDefaultShadowAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropDefaultShadowAlgorithmStatementUpdaterTest.java
@@ -38,29 +38,29 @@ public final class DropDefaultShadowAlgorithmStatementUpdaterTest {
private ShardingSphereMetaData shardingSphereMetaData;
@Mock
- private ShadowRuleConfiguration currentConfiguration;
+ private ShadowRuleConfiguration currentConfig;
private final DropDefaultShadowAlgorithmStatementUpdater updater = new DropDefaultShadowAlgorithmStatementUpdater();
@Test(expected = RequiredAlgorithmMissedException.class)
public void assertCheckWithoutDefaultAlgorithm() throws DistSQLException {
- updater.checkSQLStatement(shardingSphereMetaData, new DropDefaultShadowAlgorithmStatement(), currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, new DropDefaultShadowAlgorithmStatement(), currentConfig);
}
@Test
public void assertCheckWithIfExists() throws DistSQLException {
- updater.checkSQLStatement(shardingSphereMetaData, new DropDefaultShadowAlgorithmStatement(true), currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, new DropDefaultShadowAlgorithmStatement(true), currentConfig);
updater.checkSQLStatement(shardingSphereMetaData, new DropDefaultShadowAlgorithmStatement(true), null);
}
@Test
public void assertUpdate() throws DistSQLException {
- ShadowRuleConfiguration configuration = new ShadowRuleConfiguration();
- configuration.setDefaultShadowAlgorithmName("default");
+ ShadowRuleConfiguration ruleConfig = new ShadowRuleConfiguration();
+ ruleConfig.setDefaultShadowAlgorithmName("default");
DropDefaultShadowAlgorithmStatement statement = new DropDefaultShadowAlgorithmStatement();
- updater.checkSQLStatement(shardingSphereMetaData, new DropDefaultShadowAlgorithmStatement(true), configuration);
- assertTrue(updater.hasAnyOneToBeDropped(statement, configuration));
- updater.updateCurrentRuleConfiguration(statement, configuration);
- assertNull(configuration.getDefaultShadowAlgorithmName());
+ updater.checkSQLStatement(shardingSphereMetaData, new DropDefaultShadowAlgorithmStatement(true), ruleConfig);
+ assertTrue(updater.hasAnyOneToBeDropped(statement, ruleConfig));
+ updater.updateCurrentRuleConfiguration(statement, ruleConfig);
+ assertNull(ruleConfig.getDefaultShadowAlgorithmName());
}
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowAlgorithmStatementUpdaterTest.java
index 9142afc7a9f..27b0aacf16b 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowAlgorithmStatementUpdaterTest.java
@@ -60,11 +60,11 @@ public final class DropShadowAlgorithmStatementUpdaterTest {
public void assertUpdate() throws DistSQLException {
DropShadowAlgorithmStatement sqlStatement = createSQLStatement("ds_0");
sqlStatement.setContainsExistClause(true);
- ShadowRuleConfiguration configuration = new ShadowRuleConfiguration();
- configuration.getTables().put("t_order", new ShadowTableConfiguration(new ArrayList<>(Collections.singletonList("ds_0")), Collections.emptyList()));
- updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, configuration);
- updater.updateCurrentRuleConfiguration(sqlStatement, configuration);
- assertFalse(configuration.getTables().containsKey("ds_0"));
+ ShadowRuleConfiguration ruleConfig = new ShadowRuleConfiguration();
+ ruleConfig.getTables().put("t_order", new ShadowTableConfiguration(new ArrayList<>(Collections.singletonList("ds_0")), Collections.emptyList()));
+ updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, ruleConfig);
+ updater.updateCurrentRuleConfiguration(sqlStatement, ruleConfig);
+ assertFalse(ruleConfig.getTables().containsKey("ds_0"));
}
private DropShadowAlgorithmStatement createSQLStatement(final String... ruleName) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowRuleStatementUpdaterTest.java
index 396273dc987..b0526c99864 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowRuleStatementUpdaterTest.java
@@ -45,13 +45,13 @@ public final class DropShadowRuleStatementUpdaterTest {
private ShardingSphereMetaData shardingSphereMetaData;
@Mock
- private ShadowRuleConfiguration currentConfiguration;
+ private ShadowRuleConfiguration currentConfig;
private final DropShadowRuleStatementUpdater updater = new DropShadowRuleStatementUpdater();
@Before
public void before() {
- when(currentConfiguration.getDataSources()).thenReturn(Collections.singletonMap("initRuleName", null));
+ when(currentConfig.getDataSources()).thenReturn(Collections.singletonMap("initRuleName", null));
}
@Test(expected = RequiredRuleMissedException.class)
@@ -70,16 +70,16 @@ public final class DropShadowRuleStatementUpdaterTest {
public void assertUpdate() throws DistSQLException {
DropShadowRuleStatement sqlStatement = createSQLStatement("ds_0");
sqlStatement.setContainsExistClause(true);
- ShadowRuleConfiguration configuration = new ShadowRuleConfiguration();
- configuration.getTables().put("t_order", new ShadowTableConfiguration(new ArrayList<>(Collections.singletonList("ds_0")), Collections.emptyList()));
- updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, configuration);
- updater.updateCurrentRuleConfiguration(sqlStatement, configuration);
- assertFalse(configuration.getTables().containsKey("ds_0"));
+ ShadowRuleConfiguration ruleConfig = new ShadowRuleConfiguration();
+ ruleConfig.getTables().put("t_order", new ShadowTableConfiguration(new ArrayList<>(Collections.singletonList("ds_0")), Collections.emptyList()));
+ updater.checkSQLStatement(shardingSphereMetaData, sqlStatement, ruleConfig);
+ updater.updateCurrentRuleConfiguration(sqlStatement, ruleConfig);
+ assertFalse(ruleConfig.getTables().containsKey("ds_0"));
}
@Test
public void assertExecuteSuccess() throws DistSQLException {
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement("initRuleName"), currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement("initRuleName"), currentConfig);
}
private DropShadowRuleStatement createSQLStatement(final String... ruleName) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
index e6418aa39b3..ea183a10fc2 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
@@ -716,14 +716,14 @@ public final class ShardingRule implements SchemaRule, DataNodeContainedRule, Ta
if (!leftTableRule.isPresent() || !rightTableRule.isPresent()) {
continue;
}
- ShardingStrategyConfiguration leftConfiguration = isDatabaseJoinCondition
+ ShardingStrategyConfiguration leftConfig = isDatabaseJoinCondition
? getDatabaseShardingStrategyConfiguration(leftTableRule.get())
: getTableShardingStrategyConfiguration(leftTableRule.get());
- ShardingStrategyConfiguration rightConfiguration = isDatabaseJoinCondition
+ ShardingStrategyConfiguration rightConfig = isDatabaseJoinCondition
? getDatabaseShardingStrategyConfiguration(rightTableRule.get())
: getTableShardingStrategyConfiguration(rightTableRule.get());
- if (findShardingColumn(leftConfiguration, leftColumn.getIdentifier().getValue()).isPresent()
- && findShardingColumn(rightConfiguration, rightColumn.getIdentifier().getValue()).isPresent()) {
+ if (findShardingColumn(leftConfig, leftColumn.getIdentifier().getValue()).isPresent()
+ && findShardingColumn(rightConfig, rightColumn.getIdentifier().getValue()).isPresent()) {
result.add(columnExpressionTableNames.get(leftColumn.getExpression()));
result.add(columnExpressionTableNames.get(rightColumn.getExpression()));
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRoutingEngineTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRoutingEngineTest.java
index e646eb43ae9..89f8fdee72b 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRoutingEngineTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRoutingEngineTest.java
@@ -135,12 +135,12 @@ public final class ShardingTableBroadcastRoutingEngineTest extends AbstractRouti
}
private ShardingRule createShardingRule(final boolean isContainBroadcastTable) {
- ShardingRuleConfiguration shardingRuleConfiguration = new ShardingRuleConfiguration();
- shardingRuleConfiguration.getTables().add(new ShardingTableRuleConfiguration("t_order", "ds${0..1}.t_order_${0..1}"));
+ ShardingRuleConfiguration ruleConfig = new ShardingRuleConfiguration();
+ ruleConfig.getTables().add(new ShardingTableRuleConfiguration("t_order", "ds${0..1}.t_order_${0..1}"));
if (isContainBroadcastTable) {
- shardingRuleConfiguration.getBroadcastTables().add("t_order");
+ ruleConfig.getBroadcastTables().add("t_order");
}
- return new ShardingRule(shardingRuleConfiguration, Arrays.asList("ds_0", "ds_1"));
+ return new ShardingRule(ruleConfig, Arrays.asList("ds_0", "ds_1"));
}
private SQLStatementContext<?> createSQLStatementContext(final Collection<String> tableNames) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
index 61ec273128a..96cd043da53 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
@@ -208,10 +208,10 @@ public final class ShardingInsertStatementValidatorTest {
when(tableRule.getActualTableNames("ds_1")).thenReturn(Collections.singletonList("user"));
when(shardingRule.findShardingColumn("id", "user")).thenReturn(Optional.of("id"));
when(shardingRule.getTableRule("user")).thenReturn(tableRule);
- StandardShardingStrategyConfiguration databaseStrategyConfiguration = mock(StandardShardingStrategyConfiguration.class);
- when(databaseStrategyConfiguration.getShardingColumn()).thenReturn("id");
- when(databaseStrategyConfiguration.getShardingAlgorithmName()).thenReturn("database_inline");
- when(shardingRule.getDatabaseShardingStrategyConfiguration(tableRule)).thenReturn(databaseStrategyConfiguration);
+ StandardShardingStrategyConfiguration databaseStrategyConfig = mock(StandardShardingStrategyConfiguration.class);
+ when(databaseStrategyConfig.getShardingColumn()).thenReturn("id");
+ when(databaseStrategyConfig.getShardingAlgorithmName()).thenReturn("database_inline");
+ when(shardingRule.getDatabaseShardingStrategyConfiguration(tableRule)).thenReturn(databaseStrategyConfig);
when(shardingRule.getShardingAlgorithms()).thenReturn(createShardingAlgorithmMap());
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingUpdateStatementValidatorTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingUpdateStatementValidatorTest.java
index c497b8bf7dd..23aabbe35dc 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingUpdateStatementValidatorTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingUpdateStatementValidatorTest.java
@@ -118,10 +118,10 @@ public final class ShardingUpdateStatementValidatorTest {
when(tableRule.getActualTableNames("ds_1")).thenReturn(Collections.singletonList("user"));
when(shardingRule.findShardingColumn("id", "user")).thenReturn(Optional.of("id"));
when(shardingRule.getTableRule("user")).thenReturn(tableRule);
- StandardShardingStrategyConfiguration databaseStrategyConfiguration = mock(StandardShardingStrategyConfiguration.class);
- when(databaseStrategyConfiguration.getShardingColumn()).thenReturn("id");
- when(databaseStrategyConfiguration.getShardingAlgorithmName()).thenReturn("database_inline");
- when(shardingRule.getDatabaseShardingStrategyConfiguration(tableRule)).thenReturn(databaseStrategyConfiguration);
+ StandardShardingStrategyConfiguration databaseStrategyConfig = mock(StandardShardingStrategyConfiguration.class);
+ when(databaseStrategyConfig.getShardingColumn()).thenReturn("id");
+ when(databaseStrategyConfig.getShardingAlgorithmName()).thenReturn("database_inline");
+ when(shardingRule.getDatabaseShardingStrategyConfiguration(tableRule)).thenReturn(databaseStrategyConfig);
when(shardingRule.getShardingAlgorithms()).thenReturn(createShardingAlgorithmMap());
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/strategy/ShardingStrategyFactoryTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/strategy/ShardingStrategyFactoryTest.java
index 684ebeb749a..f92d45bb1fa 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/strategy/ShardingStrategyFactoryTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/strategy/ShardingStrategyFactoryTest.java
@@ -40,32 +40,32 @@ import static org.mockito.Mockito.when;
public final class ShardingStrategyFactoryTest {
@Mock
- private StandardShardingStrategyConfiguration standardShardingStrategyConfiguration;
+ private StandardShardingStrategyConfiguration standardShardingStrategyConfig;
@Mock
private StandardShardingAlgorithmFixture standardShardingAlgorithmFixture;
@Mock
- private ComplexShardingStrategyConfiguration complexShardingStrategyConfiguration;
+ private ComplexShardingStrategyConfiguration complexShardingStrategyConfig;
@Mock
private ComplexKeysShardingAlgorithmFixture complexKeysShardingAlgorithmFixture;
@Mock
- private HintShardingStrategyConfiguration hintShardingStrategyConfiguration;
+ private HintShardingStrategyConfiguration hintShardingStrategyConfig;
@Mock
private HintShardingAlgorithmFixture hintShardingAlgorithmFixture;
@Test
public void assertNewInstance() {
- when(standardShardingStrategyConfiguration.getShardingColumn()).thenReturn("standard_sharding_column");
- ShardingStrategy actualStandardShardingStrategy = ShardingStrategyFactory.newInstance(standardShardingStrategyConfiguration, standardShardingAlgorithmFixture, null);
+ when(standardShardingStrategyConfig.getShardingColumn()).thenReturn("standard_sharding_column");
+ ShardingStrategy actualStandardShardingStrategy = ShardingStrategyFactory.newInstance(standardShardingStrategyConfig, standardShardingAlgorithmFixture, null);
assertTrue(actualStandardShardingStrategy instanceof StandardShardingStrategy);
- when(complexShardingStrategyConfiguration.getShardingColumns()).thenReturn("complex_sharding_column");
- ShardingStrategy actualComplexShardingStrategy = ShardingStrategyFactory.newInstance(complexShardingStrategyConfiguration, complexKeysShardingAlgorithmFixture, null);
+ when(complexShardingStrategyConfig.getShardingColumns()).thenReturn("complex_sharding_column");
+ ShardingStrategy actualComplexShardingStrategy = ShardingStrategyFactory.newInstance(complexShardingStrategyConfig, complexKeysShardingAlgorithmFixture, null);
assertTrue(actualComplexShardingStrategy instanceof ComplexShardingStrategy);
- ShardingStrategy actualHintShardingStrategy = ShardingStrategyFactory.newInstance(hintShardingStrategyConfiguration, hintShardingAlgorithmFixture, null);
+ ShardingStrategy actualHintShardingStrategy = ShardingStrategyFactory.newInstance(hintShardingStrategyConfig, hintShardingAlgorithmFixture, null);
assertTrue(actualHintShardingStrategy instanceof HintShardingStrategy);
ShardingStrategy actualNoneShardingStrategy = ShardingStrategyFactory.newInstance(null, null, null);
assertTrue(actualNoneShardingStrategy instanceof NoneShardingStrategy);
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
index 5b499398307..d4a2099aed2 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
@@ -728,16 +728,16 @@ public final class ShardingRuleTest {
public void assertGetDatabaseShardingStrategyConfiguration() {
ShardingRule actual = createMaximumShardingRule();
TableRule logicTable = actual.getTableRule("Logic_Table");
- ShardingStrategyConfiguration databaseShardingStrategyConfiguration = actual.getDatabaseShardingStrategyConfiguration(logicTable);
- assertThat(databaseShardingStrategyConfiguration.getShardingAlgorithmName(), is("database_inline"));
+ ShardingStrategyConfiguration databaseShardingStrategyConfig = actual.getDatabaseShardingStrategyConfiguration(logicTable);
+ assertThat(databaseShardingStrategyConfig.getShardingAlgorithmName(), is("database_inline"));
}
@Test
public void assertGetTableShardingStrategyConfiguration() {
ShardingRule actual = createMaximumShardingRule();
TableRule logicTable = actual.getTableRule("Logic_Table");
- ShardingStrategyConfiguration tableShardingStrategyConfiguration = actual.getTableShardingStrategyConfiguration(logicTable);
- assertThat(tableShardingStrategyConfiguration.getShardingAlgorithmName(), is("table_inline"));
+ ShardingStrategyConfiguration tableShardingStrategyConfig = actual.getTableShardingStrategyConfiguration(logicTable);
+ assertThat(tableShardingStrategyConfig.getShardingAlgorithmName(), is("table_inline"));
}
@Test
@@ -776,11 +776,9 @@ public final class ShardingRuleTest {
private void assertGetDataNodes(final Collection<DataNode> dataNodes, final String tableNamePrefix) {
int dataSourceNameSuffix = 0;
int tableNameSuffix = 0;
- Iterator<DataNode> dataNodeIterator = dataNodes.iterator();
- while (dataNodeIterator.hasNext()) {
- DataNode dataNode = dataNodeIterator.next();
- assertThat(dataNode.getDataSourceName(), is("ds_" + dataSourceNameSuffix));
- assertThat(dataNode.getTableName(), is(tableNamePrefix + tableNameSuffix));
+ for (final DataNode each : dataNodes) {
+ assertThat(each.getDataSourceName(), is("ds_" + dataSourceNameSuffix));
+ assertThat(each.getTableName(), is(tableNamePrefix + tableNameSuffix));
if (++tableNameSuffix == (dataNodes.size() / 2)) {
tableNameSuffix = 0;
dataSourceNameSuffix++;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/converter/ShardingScalingRuleStatementConverter.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/converter/ShardingScalingRuleStatementConverter.java
index 738d0d35be3..2294572c42e 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/converter/ShardingScalingRuleStatementConverter.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/scaling/distsql/handler/converter/ShardingScalingRuleStatementConverter.java
@@ -40,12 +40,12 @@ public final class ShardingScalingRuleStatementConverter {
* @return on rule altered action configuration
*/
public static OnRuleAlteredActionConfiguration convert(final ShardingScalingRuleConfigurationSegment segment) {
- InputConfiguration inputConfiguration = convertToInputConfiguration(segment.getInputSegment());
- OutputConfiguration outputConfiguration = convertToOutputConfiguration(segment.getOutputSegment());
+ InputConfiguration inputConfig = convertToInputConfiguration(segment.getInputSegment());
+ OutputConfiguration outputConfig = convertToOutputConfiguration(segment.getOutputSegment());
ShardingSphereAlgorithmConfiguration streamChannel = convertToAlgorithm(segment.getStreamChannel());
ShardingSphereAlgorithmConfiguration completionDetector = convertToAlgorithm(segment.getCompletionDetector());
ShardingSphereAlgorithmConfiguration dataConsistencyChecker = convertToAlgorithm(segment.getDataConsistencyCalculator());
- return new OnRuleAlteredActionConfiguration(inputConfiguration, outputConfiguration, streamChannel, completionDetector, dataConsistencyChecker);
+ return new OnRuleAlteredActionConfiguration(inputConfig, outputConfig, streamChannel, completionDetector, dataConsistencyChecker);
}
private static InputConfiguration convertToInputConfiguration(final InputOrOutputSegment inputSegment) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/enums/ShardingStrategyType.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/enums/ShardingStrategyType.java
index e3df6bcd870..91f31bef739 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/enums/ShardingStrategyType.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/enums/ShardingStrategyType.java
@@ -65,8 +65,8 @@ public enum ShardingStrategyType {
}
@Override
- public Collection<String> getConfigurationContents(final ShardingStrategyConfiguration strategyConfiguration) {
- return Arrays.asList("", strategyConfiguration.getShardingAlgorithmName());
+ public Collection<String> getConfigurationContents(final ShardingStrategyConfiguration strategyConfig) {
+ return Arrays.asList("", strategyConfig.getShardingAlgorithmName());
}
@Override
@@ -86,8 +86,8 @@ public enum ShardingStrategyType {
}
@Override
- public Collection<String> getConfigurationContents(final ShardingStrategyConfiguration strategyConfiguration) {
- return Arrays.asList("", strategyConfiguration.getShardingAlgorithmName());
+ public Collection<String> getConfigurationContents(final ShardingStrategyConfiguration strategyConfig) {
+ return Arrays.asList("", strategyConfig.getShardingAlgorithmName());
}
@Override
@@ -136,10 +136,10 @@ public enum ShardingStrategyType {
/**
* Get the content in the configuration.
*
- * @param strategyConfiguration sharding strategy configuration.
- * @return Content list
+ * @param strategyConfig sharding strategy configuration.
+ * @return contents
*/
- public abstract Collection<String> getConfigurationContents(ShardingStrategyConfiguration strategyConfiguration);
+ public abstract Collection<String> getConfigurationContents(ShardingStrategyConfiguration strategyConfig);
/**
* Check whether the configuration is valid.
@@ -166,13 +166,13 @@ public enum ShardingStrategyType {
/**
* Returns the sharding strategy type.
*
- * @param shardingStrategyConfiguration Implementation class of sharding strategy configuration
+ * @param shardingStrategyConfig Implementation class of sharding strategy configuration
* @return sharding strategy type
*/
- public static ShardingStrategyType getValueOf(final ShardingStrategyConfiguration shardingStrategyConfiguration) {
+ public static ShardingStrategyType getValueOf(final ShardingStrategyConfiguration shardingStrategyConfig) {
Optional<ShardingStrategyType> type = Arrays.stream(values())
- .filter(each -> shardingStrategyConfiguration.getClass().getCanonicalName().equals(each.getImplementedClass().getCanonicalName())).findFirst();
- type.orElseThrow(() -> new UnsupportedOperationException(String.format("unsupported strategy type %s", shardingStrategyConfiguration.getClass().getName())));
+ .filter(each -> shardingStrategyConfig.getClass().getCanonicalName().equals(each.getImplementedClass().getCanonicalName())).findFirst();
+ type.orElseThrow(() -> new UnsupportedOperationException(String.format("unsupported strategy type %s", shardingStrategyConfig.getClass().getName())));
return type.get();
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/DefaultShardingStrategyQueryResultSet.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/DefaultShardingStrategyQueryResultSet.java
index cafe9cb9900..731006b361f 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/DefaultShardingStrategyQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/DefaultShardingStrategyQueryResultSet.java
@@ -56,7 +56,7 @@ public final class DefaultShardingStrategyQueryResultSet implements DistSQLResul
return result;
}
- private LinkedList<Object> buildDataItem(final ShardingRuleConfiguration ruleConfiguration, final ShardingStrategyConfiguration strategyConfig) {
+ private LinkedList<Object> buildDataItem(final ShardingRuleConfiguration ruleConfig, final ShardingStrategyConfiguration strategyConfig) {
if (null == strategyConfig) {
return new LinkedList<>(Arrays.asList("NONE", "", "", "", ""));
}
@@ -66,9 +66,9 @@ public final class DefaultShardingStrategyQueryResultSet implements DistSQLResul
}
LinkedList<Object> result = new LinkedList<>(Collections.singleton(strategyType.name()));
result.addAll(strategyType.getConfigurationContents(strategyConfig));
- ShardingSphereAlgorithmConfiguration algorithmConfiguration = ruleConfiguration.getShardingAlgorithms().get(strategyConfig.getShardingAlgorithmName());
- result.add(algorithmConfiguration.getType());
- result.add(algorithmConfiguration.getProps());
+ ShardingSphereAlgorithmConfiguration algorithmConfig = ruleConfig.getShardingAlgorithms().get(strategyConfig.getShardingAlgorithmName());
+ result.add(algorithmConfig.getType());
+ result.add(algorithmConfig.getProps());
return result;
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingBindingTableRuleQueryResultSet.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingBindingTableRuleQueryResultSet.java
index a04fb0e7fc7..ef7a9248f7e 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingBindingTableRuleQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingBindingTableRuleQueryResultSet.java
@@ -39,7 +39,7 @@ public final class ShardingBindingTableRuleQueryResultSet implements DistSQLResu
public void init(final ShardingSphereMetaData metaData, final SQLStatement sqlStatement) {
Optional<ShardingRuleConfiguration> shardingRuleConfig = metaData.getRuleMetaData().getConfigurations()
.stream().filter(each -> each instanceof ShardingRuleConfiguration).map(each -> (ShardingRuleConfiguration) each).findFirst();
- data = shardingRuleConfig.map(shardingRuleConfiguration -> shardingRuleConfiguration.getBindingTableGroups().iterator()).orElseGet(Collections::emptyIterator);
+ data = shardingRuleConfig.map(each -> each.getBindingTableGroups().iterator()).orElseGet(Collections::emptyIterator);
}
@Override
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableNodesQueryResultSet.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableNodesQueryResultSet.java
index 5a9e69321d0..38591ca42fe 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableNodesQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableNodesQueryResultSet.java
@@ -85,9 +85,9 @@ public final class ShardingTableNodesQueryResultSet implements DistSQLResultSet
return getShardingCount(shardingAlgorithms.get(shardingStrategy.getShardingAlgorithmName()));
}
- private boolean useDefaultStrategy(final ShardingStrategyConfiguration currentShardingStrategy, final ShardingRuleConfiguration ruleConfiguration) {
+ private boolean useDefaultStrategy(final ShardingStrategyConfiguration currentShardingStrategy, final ShardingRuleConfiguration ruleConfig) {
return (null == currentShardingStrategy || Strings.isNullOrEmpty(currentShardingStrategy.getShardingAlgorithmName()))
- && null != ruleConfiguration.getDefaultDatabaseShardingStrategy() && null != ruleConfiguration.getDefaultTableShardingStrategy();
+ && null != ruleConfig.getDefaultDatabaseShardingStrategy() && null != ruleConfig.getDefaultTableShardingStrategy();
}
private int getShardingCount(final ShardingSphereAlgorithmConfiguration algorithmConfig) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRuleQueryResultSet.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRuleQueryResultSet.java
index add167fa3a5..543855fcad2 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRuleQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRuleQueryResultSet.java
@@ -191,8 +191,8 @@ public final class ShardingTableRuleQueryResultSet implements DistSQLResultSet {
return getKeyGenerateStrategyConfiguration(keyGenerateStrategyConfig).isPresent() ? getKeyGenerateStrategyConfiguration(keyGenerateStrategyConfig).get().getColumn() : "";
}
- private String getKeyGeneratorType(final KeyGenerateStrategyConfiguration keyGenerateStrategyConfiguration) {
- Optional<KeyGenerateStrategyConfiguration> keyGenerateStrategyConfig = getKeyGenerateStrategyConfiguration(keyGenerateStrategyConfiguration);
+ private String getKeyGeneratorType(final KeyGenerateStrategyConfiguration originalKeyGenerateStrategyConfig) {
+ Optional<KeyGenerateStrategyConfiguration> keyGenerateStrategyConfig = getKeyGenerateStrategyConfiguration(originalKeyGenerateStrategyConfig);
return keyGenerateStrategyConfig.isPresent() ? shardingRuleConfig.getKeyGenerators().get(keyGenerateStrategyConfig.get().getKeyGeneratorName()).getType() : "";
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyStatementUpdater.java
index 25b6dce6709..3c6d1512237 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyStatementUpdater.java
@@ -72,8 +72,8 @@ public final class AlterDefaultShardingStrategyStatementUpdater implements RuleD
}
private void checkExist(final String databaseName, final AlterDefaultShardingStrategyStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
- Optional<ShardingStrategyConfiguration> strategyConfiguration = getStrategyConfiguration(currentRuleConfig, sqlStatement.getDefaultType());
- DistSQLException.predictionThrow(strategyConfiguration.isPresent(), () -> new RequiredRuleMissedException(
+ Optional<ShardingStrategyConfiguration> strategyConfig = getStrategyConfiguration(currentRuleConfig, sqlStatement.getDefaultType());
+ DistSQLException.predictionThrow(strategyConfig.isPresent(), () -> new RequiredRuleMissedException(
String.format("Default sharding %s strategy", sqlStatement.getDefaultType().toLowerCase()), databaseName));
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyStatementUpdater.java
index 7e3d517f825..0b6c3edcc9e 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyStatementUpdater.java
@@ -73,8 +73,8 @@ public final class CreateDefaultShardingStrategyStatementUpdater implements Rule
}
private void checkExist(final String databaseName, final CreateDefaultShardingStrategyStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
- Optional<ShardingStrategyConfiguration> strategyConfiguration = getStrategyConfiguration(currentRuleConfig, sqlStatement.getDefaultType());
- DistSQLException.predictionThrow(!strategyConfiguration.isPresent(), () -> new DuplicateRuleException(
+ Optional<ShardingStrategyConfiguration> strategyConfig = getStrategyConfiguration(currentRuleConfig, sqlStatement.getDefaultType());
+ DistSQLException.predictionThrow(!strategyConfig.isPresent(), () -> new DuplicateRuleException(
String.format("default sharding %s strategy", sqlStatement.getDefaultType().toLowerCase()), databaseName));
}
@@ -89,22 +89,19 @@ public final class CreateDefaultShardingStrategyStatementUpdater implements Rule
public ShardingRuleConfiguration buildToBeCreatedRuleConfiguration(final CreateDefaultShardingStrategyStatement sqlStatement) {
ShardingRuleConfiguration result = new ShardingRuleConfiguration();
String shardingAlgorithmName = getShardingAlgorithmName(sqlStatement, result);
- ShardingStrategyConfiguration strategyConfiguration = ShardingTableRuleStatementConverter.createStrategyConfiguration(sqlStatement.getStrategyType(),
- sqlStatement.getShardingColumn(), shardingAlgorithmName);
- setStrategyConfiguration(result, sqlStatement.getDefaultType(), strategyConfiguration);
+ ShardingStrategyConfiguration strategyConfig = ShardingTableRuleStatementConverter.createStrategyConfiguration(
+ sqlStatement.getStrategyType(), sqlStatement.getShardingColumn(), shardingAlgorithmName);
+ setStrategyConfiguration(result, sqlStatement.getDefaultType(), strategyConfig);
return result;
}
- private String getShardingAlgorithmName(final CreateDefaultShardingStrategyStatement sqlStatement, final ShardingRuleConfiguration shardingRuleConfiguration) {
- if (null != sqlStatement.getShardingAlgorithmName()) {
- return sqlStatement.getShardingAlgorithmName();
- }
- return createDefaultAlgorithm(sqlStatement, shardingRuleConfiguration);
+ private String getShardingAlgorithmName(final CreateDefaultShardingStrategyStatement sqlStatement, final ShardingRuleConfiguration ruleConfig) {
+ return null == sqlStatement.getShardingAlgorithmName() ? createDefaultAlgorithm(sqlStatement, ruleConfig) : sqlStatement.getShardingAlgorithmName();
}
- private String createDefaultAlgorithm(final CreateDefaultShardingStrategyStatement sqlStatement, final ShardingRuleConfiguration shardingRuleConfiguration) {
+ private String createDefaultAlgorithm(final CreateDefaultShardingStrategyStatement sqlStatement, final ShardingRuleConfiguration ruleConfig) {
String result = getDefaultShardingAlgorithmName(sqlStatement.getDefaultType(), sqlStatement.getAlgorithmSegment().getName());
- shardingRuleConfiguration.getShardingAlgorithms().put(result, createAlgorithmConfiguration(sqlStatement.getAlgorithmSegment()));
+ ruleConfig.getShardingAlgorithms().put(result, createAlgorithmConfiguration(sqlStatement.getAlgorithmSegment()));
return result;
}
@@ -116,11 +113,11 @@ public final class CreateDefaultShardingStrategyStatementUpdater implements Rule
return String.format("default_%s_%s", defaultType.toLowerCase(), algorithmType);
}
- private void setStrategyConfiguration(final ShardingRuleConfiguration configuration, final String type, final ShardingStrategyConfiguration shardingStrategyConfig) {
+ private void setStrategyConfiguration(final ShardingRuleConfiguration ruleConfig, final String type, final ShardingStrategyConfiguration shardingStrategyConfig) {
if (type.equalsIgnoreCase(ShardingStrategyLevelType.TABLE.name())) {
- configuration.setDefaultTableShardingStrategy(shardingStrategyConfig);
+ ruleConfig.setDefaultTableShardingStrategy(shardingStrategyConfig);
} else {
- configuration.setDefaultDatabaseShardingStrategy(shardingStrategyConfig);
+ ruleConfig.setDefaultDatabaseShardingStrategy(shardingStrategyConfig);
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultStrategyStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultStrategyStatementUpdater.java
index 3dfecea2104..b9ebe8baa55 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultStrategyStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultStrategyStatementUpdater.java
@@ -48,8 +48,8 @@ public final class DropDefaultStrategyStatementUpdater implements RuleDefinition
if (sqlStatement.isContainsExistClause()) {
return;
}
- Optional<ShardingStrategyConfiguration> strategyConfiguration = getStrategyConfiguration(currentRuleConfig, sqlStatement.getDefaultType());
- DistSQLException.predictionThrow(strategyConfiguration.isPresent(), () -> new RequiredRuleMissedException(
+ Optional<ShardingStrategyConfiguration> strategyConfig = getStrategyConfiguration(currentRuleConfig, sqlStatement.getDefaultType());
+ DistSQLException.predictionThrow(strategyConfig.isPresent(), () -> new RequiredRuleMissedException(
String.format("Default sharding %s strategy", sqlStatement.getDefaultType().toLowerCase()), databaseName));
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/query/ShardingScalingRulesQueryResultSetTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/query/ShardingScalingRulesQueryResultSetTest.java
index 913e638c547..2443c5d4ebf 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/query/ShardingScalingRulesQueryResultSetTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/query/ShardingScalingRulesQueryResultSetTest.java
@@ -72,12 +72,12 @@ public final class ShardingScalingRulesQueryResultSetTest {
}
private OnRuleAlteredActionConfiguration buildCompleteConfiguration() {
- InputConfiguration inputConfiguration = createInputConfiguration("QPS", newProperties("qps", "50"));
- OutputConfiguration outputConfiguration = createOutputConfiguration("TPS", newProperties("tps", "2000"));
+ InputConfiguration inputConfig = createInputConfiguration("QPS", newProperties("qps", "50"));
+ OutputConfiguration outputConfig = createOutputConfiguration("TPS", newProperties("tps", "2000"));
ShardingSphereAlgorithmConfiguration streamChannel = createAlgorithm("MEMORY", newProperties("block-queue-size", "10000"));
ShardingSphereAlgorithmConfiguration completionDetector = createAlgorithm("IDLE", newProperties("incremental-task-idle-minute-threshold", "30"));
ShardingSphereAlgorithmConfiguration dataConsistencyChecker = createAlgorithm("DATA_MATCH", newProperties("chunk-size", "1000"));
- return new OnRuleAlteredActionConfiguration(inputConfiguration, outputConfiguration, streamChannel, completionDetector, dataConsistencyChecker);
+ return new OnRuleAlteredActionConfiguration(inputConfig, outputConfig, streamChannel, completionDetector, dataConsistencyChecker);
}
private InputConfiguration createInputConfiguration(final String type, final Properties props) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/update/CreateShardingScalingRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/update/CreateShardingScalingRuleStatementUpdaterTest.java
index 874afc86172..fd9e105c0a4 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/update/CreateShardingScalingRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/update/CreateShardingScalingRuleStatementUpdaterTest.java
@@ -136,8 +136,8 @@ public final class CreateShardingScalingRuleStatementUpdaterTest {
ShardingRuleConfiguration currentRuleConfig = new ShardingRuleConfiguration();
CreateShardingScalingRuleStatement statement = new CreateShardingScalingRuleStatement("default_scaling");
statement.setConfigurationSegment(createCompleteConfiguration());
- ShardingRuleConfiguration toBeCreatedRuleConfiguration = updater.buildToBeCreatedRuleConfiguration(statement);
- updater.updateCurrentRuleConfiguration(currentRuleConfig, toBeCreatedRuleConfiguration);
+ ShardingRuleConfiguration toBeCreatedRuleConfig = updater.buildToBeCreatedRuleConfiguration(statement);
+ updater.updateCurrentRuleConfiguration(currentRuleConfig, toBeCreatedRuleConfig);
assertThat(currentRuleConfig.getScalingName(), is("default_scaling"));
assertThat(currentRuleConfig.getScaling().size(), is(1));
String key = currentRuleConfig.getScaling().keySet().iterator().next();
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/update/EnableShardingScalingRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/update/EnableShardingScalingRuleStatementUpdaterTest.java
index 8a886d82007..595c1ffd5f1 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/update/EnableShardingScalingRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/scaling/distsql/handler/update/EnableShardingScalingRuleStatementUpdaterTest.java
@@ -84,8 +84,8 @@ public final class EnableShardingScalingRuleStatementUpdaterTest {
String scalingName = "new_scaling";
currentRuleConfig.getScaling().put("default_scaling", null);
currentRuleConfig.getScaling().put(scalingName, null);
- ShardingRuleConfiguration toBeCreatedRuleConfiguration = updater.buildToBeAlteredRuleConfiguration(createSQLStatement(scalingName));
- updater.updateCurrentRuleConfiguration(currentRuleConfig, toBeCreatedRuleConfiguration);
+ ShardingRuleConfiguration toBeCreatedRuleConfig = updater.buildToBeAlteredRuleConfiguration(createSQLStatement(scalingName));
+ updater.updateCurrentRuleConfiguration(currentRuleConfig, toBeCreatedRuleConfig);
assertThat(currentRuleConfig.getScalingName(), is("new_scaling"));
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
index 6c5160070c9..4253f83aac0 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
@@ -191,13 +191,13 @@ public final class ShardingRuleStatementCheckerTest {
private static ShardingRuleConfiguration createShardingRuleConfiguration() {
ShardingRuleConfiguration result = new ShardingRuleConfiguration();
- ShardingTableRuleConfiguration tableRuleConfiguration = new ShardingTableRuleConfiguration("t_order", "ds_${0..1}.t_order${0..1}");
- tableRuleConfiguration.setTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "t_order_algorithm"));
- result.getTables().add(tableRuleConfiguration);
- ShardingAutoTableRuleConfiguration autoTableRuleConfiguration = new ShardingAutoTableRuleConfiguration("t_order_item", "ds_0");
- autoTableRuleConfiguration.setShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "t_order_item_algorithm"));
- autoTableRuleConfiguration.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("order_item_id", "t_order_item_snowflake"));
- result.getAutoTables().add(autoTableRuleConfiguration);
+ ShardingTableRuleConfiguration tableRuleConfig = new ShardingTableRuleConfiguration("t_order", "ds_${0..1}.t_order${0..1}");
+ tableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "t_order_algorithm"));
+ result.getTables().add(tableRuleConfig);
+ ShardingAutoTableRuleConfiguration autoTableRuleConfig = new ShardingAutoTableRuleConfiguration("t_order_item", "ds_0");
+ autoTableRuleConfig.setShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "t_order_item_algorithm"));
+ autoTableRuleConfig.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("order_item_id", "t_order_item_snowflake"));
+ result.getAutoTables().add(autoTableRuleConfig);
result.getShardingAlgorithms().put("t_order_algorithm", new ShardingSphereAlgorithmConfiguration("hash_mod", newProperties("sharding-count", "4")));
result.getKeyGenerators().put("t_order_item_snowflake", new ShardingSphereAlgorithmConfiguration("snowflake", new Properties()));
return result;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingAlgorithmStatementUpdaterTest.java
index 5b06634d8dd..5f99a7ddb1b 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingAlgorithmStatementUpdaterTest.java
@@ -65,9 +65,9 @@ public final class AlterShardingAlgorithmStatementUpdaterTest {
Properties properties = new Properties();
properties.put("inputKey", "inputValue");
ShardingAlgorithmSegment algorithmSegment = new ShardingAlgorithmSegment("notExistAlgorithmName", new AlgorithmSegment("inputAlgorithmName", properties));
- ShardingRuleConfiguration shardingRuleConfiguration = new ShardingRuleConfiguration();
- shardingRuleConfiguration.getShardingAlgorithms().put("existAlgorithmName", new ShardingSphereAlgorithmConfiguration("hash_mod", properties));
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(algorithmSegment), shardingRuleConfiguration);
+ ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
+ shardingRuleConfig.getShardingAlgorithms().put("existAlgorithmName", new ShardingSphereAlgorithmConfiguration("hash_mod", properties));
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(algorithmSegment), shardingRuleConfig);
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
@@ -75,9 +75,9 @@ public final class AlterShardingAlgorithmStatementUpdaterTest {
Properties properties = new Properties();
properties.put("inputKey", "inputValue");
ShardingAlgorithmSegment algorithmSegment = new ShardingAlgorithmSegment("existAlgorithmName", new AlgorithmSegment("inputAlgorithmName", properties));
- ShardingRuleConfiguration shardingRuleConfiguration = new ShardingRuleConfiguration();
- shardingRuleConfiguration.getShardingAlgorithms().put("existAlgorithmName", new ShardingSphereAlgorithmConfiguration("InvalidAlgorithm", properties));
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(algorithmSegment), shardingRuleConfiguration);
+ ShardingRuleConfiguration ruleConfig = new ShardingRuleConfiguration();
+ ruleConfig.getShardingAlgorithms().put("existAlgorithmName", new ShardingSphereAlgorithmConfiguration("InvalidAlgorithm", properties));
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(algorithmSegment), ruleConfig);
}
private AlterShardingAlgorithmStatement createSQLStatement(final ShardingAlgorithmSegment... ruleSegments) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingKeyGeneratorStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingKeyGeneratorStatementUpdaterTest.java
index 68379adb107..f8230035b82 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingKeyGeneratorStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingKeyGeneratorStatementUpdaterTest.java
@@ -65,9 +65,9 @@ public final class AlterShardingKeyGeneratorStatementUpdaterTest {
Properties properties = new Properties();
properties.put("inputKey", "inputValue");
ShardingKeyGeneratorSegment keyGeneratorSegment = new ShardingKeyGeneratorSegment("notExistAlgorithmName", new AlgorithmSegment("inputAlgorithmName", properties));
- ShardingRuleConfiguration shardingRuleConfiguration = new ShardingRuleConfiguration();
- shardingRuleConfiguration.getShardingAlgorithms().put("existAlgorithmName", new ShardingSphereAlgorithmConfiguration("hash_mod", properties));
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(keyGeneratorSegment), shardingRuleConfiguration);
+ ShardingRuleConfiguration ruleConfig = new ShardingRuleConfiguration();
+ ruleConfig.getShardingAlgorithms().put("existAlgorithmName", new ShardingSphereAlgorithmConfiguration("hash_mod", properties));
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(keyGeneratorSegment), ruleConfig);
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
@@ -75,9 +75,9 @@ public final class AlterShardingKeyGeneratorStatementUpdaterTest {
Properties properties = new Properties();
properties.put("inputKey", "inputValue");
ShardingKeyGeneratorSegment keyGeneratorSegment = new ShardingKeyGeneratorSegment("existAlgorithmName", new AlgorithmSegment("inputAlgorithmName", properties));
- ShardingRuleConfiguration shardingRuleConfiguration = new ShardingRuleConfiguration();
- shardingRuleConfiguration.getKeyGenerators().put("existAlgorithmName", new ShardingSphereAlgorithmConfiguration("InvalidAlgorithm", properties));
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(keyGeneratorSegment), shardingRuleConfiguration);
+ ShardingRuleConfiguration ruleConfig = new ShardingRuleConfiguration();
+ ruleConfig.getKeyGenerators().put("existAlgorithmName", new ShardingSphereAlgorithmConfiguration("InvalidAlgorithm", properties));
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(keyGeneratorSegment), ruleConfig);
}
private AlterShardingKeyGeneratorStatement createSQLStatement(final ShardingKeyGeneratorSegment... ruleSegments) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
index d496ad74c8b..e7b777a0b08 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
@@ -87,8 +87,8 @@ public final class AlterShardingTableRuleStatementUpdaterTest {
rules.add(createCompleteTableRule("t_order"));
AlterShardingTableRuleStatement statement = new AlterShardingTableRuleStatement(rules);
updater.checkSQLStatement(shardingSphereMetaData, statement, currentRuleConfig);
- ShardingRuleConfiguration toBeAlteredRuleConfiguration = updater.buildToBeAlteredRuleConfiguration(statement);
- updater.updateCurrentRuleConfiguration(currentRuleConfig, toBeAlteredRuleConfiguration);
+ ShardingRuleConfiguration toBeAlteredRuleConfig = updater.buildToBeAlteredRuleConfiguration(statement);
+ updater.updateCurrentRuleConfiguration(currentRuleConfig, toBeAlteredRuleConfig);
assertThat(currentRuleConfig.getTables().size(), is(1));
ShardingTableRuleConfiguration tableRule = currentRuleConfig.getTables().iterator().next();
assertThat(tableRule.getLogicTable(), is("t_order"));
@@ -115,8 +115,8 @@ public final class AlterShardingTableRuleStatementUpdaterTest {
rules.add(createCompleteTableRule("t_order_item"));
AlterShardingTableRuleStatement statement = new AlterShardingTableRuleStatement(rules);
updater.checkSQLStatement(shardingSphereMetaData, statement, currentRuleConfig);
- ShardingRuleConfiguration toBeAlteredRuleConfiguration = updater.buildToBeAlteredRuleConfiguration(statement);
- updater.updateCurrentRuleConfiguration(currentRuleConfig, toBeAlteredRuleConfiguration);
+ ShardingRuleConfiguration toBeAlteredRuleConfig = updater.buildToBeAlteredRuleConfiguration(statement);
+ updater.updateCurrentRuleConfiguration(currentRuleConfig, toBeAlteredRuleConfig);
assertThat(currentRuleConfig.getTables().size(), is(1));
ShardingTableRuleConfiguration tableRule = currentRuleConfig.getTables().iterator().next();
assertThat(tableRule.getLogicTable(), is("t_order_item"));
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateDefaultShardingStrategyStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateDefaultShardingStrategyStatementUpdaterTest.java
index bf816944283..eecbbca9f85 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateDefaultShardingStrategyStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateDefaultShardingStrategyStatementUpdaterTest.java
@@ -88,8 +88,8 @@ public final class CreateDefaultShardingStrategyStatementUpdaterTest {
currentRuleConfig.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "orderAlgorithm"));
currentRuleConfig.getShardingAlgorithms().put("order_id_algorithm", null);
updater.checkSQLStatement(shardingSphereMetaData, statement, currentRuleConfig);
- ShardingRuleConfiguration toBeCreatedRuleConfiguration = updater.buildToBeCreatedRuleConfiguration(statement);
- updater.updateCurrentRuleConfiguration(currentRuleConfig, toBeCreatedRuleConfiguration);
+ ShardingRuleConfiguration toBeCreatedRuleConfig = updater.buildToBeCreatedRuleConfiguration(statement);
+ updater.updateCurrentRuleConfiguration(currentRuleConfig, toBeCreatedRuleConfig);
StandardShardingStrategyConfiguration defaultTableShardingStrategy = (StandardShardingStrategyConfiguration) currentRuleConfig.getDefaultTableShardingStrategy();
assertThat(defaultTableShardingStrategy.getShardingAlgorithmName(), is("order_id_algorithm"));
assertThat(defaultTableShardingStrategy.getShardingColumn(), is("order_id"));
@@ -101,8 +101,8 @@ public final class CreateDefaultShardingStrategyStatementUpdaterTest {
CreateDefaultShardingStrategyStatement statement = new CreateDefaultShardingStrategyStatement("DATABASE", "standard", "user_id", null, databaseAlgorithmSegment);
ShardingRuleConfiguration currentRuleConfig = new ShardingRuleConfiguration();
updater.checkSQLStatement(shardingSphereMetaData, statement, currentRuleConfig);
- ShardingRuleConfiguration toBeCreatedRuleConfiguration = updater.buildToBeCreatedRuleConfiguration(statement);
- updater.updateCurrentRuleConfiguration(currentRuleConfig, toBeCreatedRuleConfiguration);
+ ShardingRuleConfiguration toBeCreatedRuleConfig = updater.buildToBeCreatedRuleConfiguration(statement);
+ updater.updateCurrentRuleConfiguration(currentRuleConfig, toBeCreatedRuleConfig);
StandardShardingStrategyConfiguration defaultDatabaseShardingStrategy = (StandardShardingStrategyConfiguration) currentRuleConfig.getDefaultDatabaseShardingStrategy();
assertThat(defaultDatabaseShardingStrategy.getShardingAlgorithmName(), is("default_database_inline"));
assertThat(defaultDatabaseShardingStrategy.getShardingColumn(), is("user_id"));
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingAlgorithmStatementUpdaterTest.java
index 1724c0426a5..1a966f6352c 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingAlgorithmStatementUpdaterTest.java
@@ -44,7 +44,7 @@ public final class CreateShardingAlgorithmStatementUpdaterTest {
@Mock
private ShardingSphereMetaData shardingSphereMetaData;
- private CreateShardingAlgorithmStatementUpdater updater = new CreateShardingAlgorithmStatementUpdater();
+ private final CreateShardingAlgorithmStatementUpdater updater = new CreateShardingAlgorithmStatementUpdater();
@Before
public void before() {
@@ -64,9 +64,9 @@ public final class CreateShardingAlgorithmStatementUpdaterTest {
Properties properties = new Properties();
properties.put("inputKey", "inputValue");
ShardingAlgorithmSegment algorithmSegment = new ShardingAlgorithmSegment("existAlgorithmName", new AlgorithmSegment("inputAlgorithmName", properties));
- ShardingRuleConfiguration shardingRuleConfiguration = new ShardingRuleConfiguration();
- shardingRuleConfiguration.getShardingAlgorithms().put("existAlgorithmName", new ShardingSphereAlgorithmConfiguration("hash_mod", properties));
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(algorithmSegment), shardingRuleConfiguration);
+ ShardingRuleConfiguration ruleConfig = new ShardingRuleConfiguration();
+ ruleConfig.getShardingAlgorithms().put("existAlgorithmName", new ShardingSphereAlgorithmConfiguration("hash_mod", properties));
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(algorithmSegment), ruleConfig);
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
@@ -74,8 +74,7 @@ public final class CreateShardingAlgorithmStatementUpdaterTest {
Properties properties = new Properties();
properties.put("inputKey", "inputValue");
ShardingAlgorithmSegment algorithmSegment = new ShardingAlgorithmSegment("inputAlgorithmName", new AlgorithmSegment("inputAlgorithmName", properties));
- ShardingRuleConfiguration shardingRuleConfiguration = null;
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(algorithmSegment), shardingRuleConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(algorithmSegment), null);
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
@@ -83,9 +82,9 @@ public final class CreateShardingAlgorithmStatementUpdaterTest {
Properties properties = new Properties();
properties.put("inputKey", "inputValue");
ShardingAlgorithmSegment algorithmSegment = new ShardingAlgorithmSegment("inputAlgorithmName", new AlgorithmSegment("inputAlgorithmName", properties));
- ShardingRuleConfiguration shardingRuleConfiguration = new ShardingRuleConfiguration();
- shardingRuleConfiguration.getShardingAlgorithms().put("existAlgorithmName", new ShardingSphereAlgorithmConfiguration("InvalidAlgorithm", properties));
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(algorithmSegment), shardingRuleConfiguration);
+ ShardingRuleConfiguration ruleConfig = new ShardingRuleConfiguration();
+ ruleConfig.getShardingAlgorithms().put("existAlgorithmName", new ShardingSphereAlgorithmConfiguration("InvalidAlgorithm", properties));
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(algorithmSegment), ruleConfig);
}
private CreateShardingAlgorithmStatement createSQLStatement(final ShardingAlgorithmSegment... ruleSegments) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
index 2d797fc3dcd..455edceb0f7 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
@@ -67,7 +67,7 @@ public final class CreateShardingTableRuleStatementUpdaterTest {
@Mock
private ShardingSphereRuleMetaData shardingSphereRuleMetaData;
- private final ShardingRuleConfiguration currentRuleConfiguration = createCurrentShardingRuleConfiguration();
+ private final ShardingRuleConfiguration currentRuleConfig = createCurrentShardingRuleConfiguration();
private final ShardingSphereResource shardingSphereResource = new ShardingSphereResource(createDataSource(), null, null, null);
@@ -87,11 +87,11 @@ public final class CreateShardingTableRuleStatementUpdaterTest {
rules.add(createCompleteAutoTableRule());
rules.add(createCompleteTableRule());
CreateShardingTableRuleStatement statement = new CreateShardingTableRuleStatement(rules);
- updater.checkSQLStatement(shardingSphereMetaData, statement, currentRuleConfiguration);
- ShardingRuleConfiguration toBeAlteredRuleConfiguration = updater.buildToBeCreatedRuleConfiguration(statement);
- updater.updateCurrentRuleConfiguration(currentRuleConfiguration, toBeAlteredRuleConfiguration);
- assertThat(currentRuleConfiguration.getTables().size(), is(2));
- Iterator<ShardingTableRuleConfiguration> tableRuleIterator = currentRuleConfiguration.getTables().iterator();
+ updater.checkSQLStatement(shardingSphereMetaData, statement, currentRuleConfig);
+ ShardingRuleConfiguration toBeAlteredRuleConfig = updater.buildToBeCreatedRuleConfiguration(statement);
+ updater.updateCurrentRuleConfiguration(currentRuleConfig, toBeAlteredRuleConfig);
+ assertThat(currentRuleConfig.getTables().size(), is(2));
+ Iterator<ShardingTableRuleConfiguration> tableRuleIterator = currentRuleConfig.getTables().iterator();
ShardingTableRuleConfiguration tableRule = tableRuleIterator.next();
assertTrue(tableRule.getTableShardingStrategy() instanceof StandardShardingStrategyConfiguration);
assertThat(tableRule.getLogicTable(), is("t_order"));
@@ -106,8 +106,8 @@ public final class CreateShardingTableRuleStatementUpdaterTest {
assertThat(tableRule.getTableShardingStrategy().getShardingAlgorithmName(), is("t_order_algorithm"));
assertTrue(tableRule.getDatabaseShardingStrategy() instanceof StandardShardingStrategyConfiguration);
assertThat(tableRule.getDatabaseShardingStrategy().getShardingAlgorithmName(), is("t_order_input_database_inline"));
- assertThat(currentRuleConfiguration.getTables().size(), is(2));
- Iterator<ShardingAutoTableRuleConfiguration> autoTableIterator = currentRuleConfiguration.getAutoTables().iterator();
+ assertThat(currentRuleConfig.getTables().size(), is(2));
+ Iterator<ShardingAutoTableRuleConfiguration> autoTableIterator = currentRuleConfig.getAutoTables().iterator();
ShardingAutoTableRuleConfiguration autoTableRule = autoTableIterator.next();
assertThat(autoTableRule.getLogicTable(), is("t_order_item"));
assertThat(autoTableRule.getActualDataSources(), is("ds_0"));
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmStatementUpdaterTest.java
index 4c7ae54504d..6c756635673 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmStatementUpdaterTest.java
@@ -116,10 +116,10 @@ public final class DropShardingAlgorithmStatementUpdaterTest {
private ShardingRuleConfiguration createCurrentRuleConfiguration() {
ShardingRuleConfiguration result = new ShardingRuleConfiguration();
- ShardingTableRuleConfiguration tableRuleConfiguration = new ShardingTableRuleConfiguration("t_order");
- tableRuleConfiguration.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("column", "t_order_db_inline"));
- tableRuleConfiguration.setTableShardingStrategy(new StandardShardingStrategyConfiguration("column", "t_order_tb_inline"));
- result.getTables().add(tableRuleConfiguration);
+ ShardingTableRuleConfiguration tableRuleConfig = new ShardingTableRuleConfiguration("t_order");
+ tableRuleConfig.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("column", "t_order_db_inline"));
+ tableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("column", "t_order_tb_inline"));
+ result.getTables().add(tableRuleConfig);
result.getShardingAlgorithms().put("t_order_db_inline", new ShardingSphereAlgorithmConfiguration("standard", new Properties()));
result.getShardingAlgorithms().put("t_order_tb_inline", new ShardingSphereAlgorithmConfiguration("standard", new Properties()));
result.getShardingAlgorithms().put("t_test", new ShardingSphereAlgorithmConfiguration("standard", new Properties()));
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBindingTableRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBindingTableRuleStatementUpdaterTest.java
index 21394b09c43..77ed0a6d3a1 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBindingTableRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBindingTableRuleStatementUpdaterTest.java
@@ -62,9 +62,9 @@ public final class DropShardingBindingTableRuleStatementUpdaterTest {
@Test
public void assertCheckSQLStatementWithIfExists() throws DistSQLException {
updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(true, "t_1,t_2"), null);
- ShardingRuleConfiguration shardingRuleConfiguration = new ShardingRuleConfiguration();
- shardingRuleConfiguration.setBindingTableGroups(Collections.singletonList("t_3,t_4"));
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(true, "t_1,t_2"), shardingRuleConfiguration);
+ ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
+ shardingRuleConfig.setBindingTableGroups(Collections.singletonList("t_3,t_4"));
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(true, "t_1,t_2"), shardingRuleConfig);
}
@Test(expected = RequiredRuleMissedException.class)
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableRuleStatementUpdaterTest.java
index 6df785fb606..14d238d3101 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableRuleStatementUpdaterTest.java
@@ -100,9 +100,9 @@ public final class DropShardingTableRuleStatementUpdaterTest {
private ShardingRuleConfiguration createCurrentRuleConfiguration() {
ShardingRuleConfiguration result = new ShardingRuleConfiguration();
- ShardingTableRuleConfiguration tableRuleConfiguration = new ShardingTableRuleConfiguration("t_order_item");
- tableRuleConfiguration.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "t_order_item_algorithm"));
- result.getTables().add(tableRuleConfiguration);
+ ShardingTableRuleConfiguration tableRuleConfig = new ShardingTableRuleConfiguration("t_order_item");
+ tableRuleConfig.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "t_order_item_algorithm"));
+ result.getTables().add(tableRuleConfig);
result.getAutoTables().add(new ShardingAutoTableRuleConfiguration("t_order"));
result.setBindingTableGroups(Collections.singleton("t_order_item"));
result.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("user_id", "default_table_strategy"));
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java
index 7821adc2135..3223f6723b1 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java
@@ -240,9 +240,9 @@ public final class ShardingSpringNamespaceTest extends AbstractJUnit4SpringConte
@Test
public void assertAutoRule() {
- Collection<ShardingAutoTableRuleConfiguration> actualAutoTableConfigurations = autoRule.getAutoTables();
- assertThat(actualAutoTableConfigurations.size(), is(1));
- ShardingAutoTableRuleConfiguration actualAutoTableRuleConfig = actualAutoTableConfigurations.iterator().next();
+ Collection<ShardingAutoTableRuleConfiguration> actualAutoTableConfigs = autoRule.getAutoTables();
+ assertThat(actualAutoTableConfigs.size(), is(1));
+ ShardingAutoTableRuleConfiguration actualAutoTableRuleConfig = actualAutoTableConfigs.iterator().next();
assertThat(actualAutoTableRuleConfig.getLogicTable(), is("t_order"));
assertThat(actualAutoTableRuleConfig.getActualDataSources(), is("ds_0, ds_1"));
assertThat(actualAutoTableRuleConfig.getShardingStrategy().getShardingAlgorithmName(), is("modShardingAlgorithm"));
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/InstanceContextTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/InstanceContextTest.java
index 59d5f32403e..d0d96dea696 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/InstanceContextTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/InstanceContextTest.java
@@ -41,7 +41,7 @@ import static org.mockito.Mockito.when;
public final class InstanceContextTest {
- private final ModeConfiguration modeConfiguration = new ModeConfiguration("Memory", null, false);
+ private final ModeConfiguration modeConfig = new ModeConfiguration("Memory", null, false);
private final LockContext lockContext = mock(LockContext.class);
@@ -49,7 +49,7 @@ public final class InstanceContextTest {
public void assertUpdateInstanceStatus() {
InstanceDefinition instanceDefinition = mock(InstanceDefinition.class);
when(instanceDefinition.getInstanceId()).thenReturn(new InstanceId("127.0.0.1@3307"));
- InstanceContext context = new InstanceContext(new ComputeNodeInstance(instanceDefinition), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfiguration, lockContext);
+ InstanceContext context = new InstanceContext(new ComputeNodeInstance(instanceDefinition), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
StateType actual = context.getInstance().getState().getCurrentState();
assertThat(actual, is(StateType.OK));
context.updateInstanceStatus(instanceDefinition.getInstanceId().getId(), Lists.newArrayList(StateType.CIRCUIT_BREAK.name()));
@@ -62,7 +62,7 @@ public final class InstanceContextTest {
@Test
public void assertUpdateWorkerId() {
- InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfiguration, lockContext);
+ InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
long actual = context.getWorkerId();
assertThat(actual, is(Long.MIN_VALUE));
Random random = new Random();
@@ -76,7 +76,7 @@ public final class InstanceContextTest {
public void assertUpdateLabel() {
InstanceDefinition instanceDefinition = mock(InstanceDefinition.class);
when(instanceDefinition.getInstanceId()).thenReturn(new InstanceId("127.0.0.1@3307"));
- InstanceContext context = new InstanceContext(new ComputeNodeInstance(instanceDefinition), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfiguration, lockContext);
+ InstanceContext context = new InstanceContext(new ComputeNodeInstance(instanceDefinition), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
Set<String> expected = new LinkedHashSet<>(Arrays.asList("label_1", "label_2"));
context.updateLabel("127.0.0.1@3307", expected);
Collection<String> actual = context.getInstance().getLabels();
@@ -86,14 +86,14 @@ public final class InstanceContextTest {
@Test
public void assertGetInstance() {
ComputeNodeInstance expected = new ComputeNodeInstance(mock(InstanceDefinition.class));
- InstanceContext context = new InstanceContext(expected, new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfiguration, lockContext);
+ InstanceContext context = new InstanceContext(expected, new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
ComputeNodeInstance actual = context.getInstance();
assertThat(actual, is(expected));
}
@Test
public void assertGetState() {
- InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfiguration, lockContext);
+ InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
StateContext actual = context.getInstance().getState();
assertNotNull(actual);
}
@@ -101,15 +101,15 @@ public final class InstanceContextTest {
@Test
public void assertGetWorkerIdGenerator() {
WorkerIdGeneratorFixture expected = new WorkerIdGeneratorFixture(Long.MIN_VALUE);
- InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), expected, modeConfiguration, lockContext);
+ InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), expected, modeConfig, lockContext);
WorkerIdGeneratorFixture actual = (WorkerIdGeneratorFixture) context.getWorkerIdGenerator();
assertThat(actual, is(expected));
}
@Test
public void assertGetModeConfiguration() {
- InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfiguration, lockContext);
+ InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
ModeConfiguration actual = context.getModeConfiguration();
- assertThat(actual, is(modeConfiguration));
+ assertThat(actual, is(modeConfig));
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/rule/ShardingSphereRuleMetaDataTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/rule/ShardingSphereRuleMetaDataTest.java
index 79b8220edd0..a36a85b3b0d 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/rule/ShardingSphereRuleMetaDataTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/rule/ShardingSphereRuleMetaDataTest.java
@@ -17,49 +17,25 @@
package org.apache.shardingsphere.infra.metadata.rule;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.junit.Before;
import org.junit.Test;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Optional;
+import java.util.Collections;
-import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public final class ShardingSphereRuleMetaDataTest {
- private Collection<RuleConfiguration> configurations;
-
- private Collection<ShardingSphereRule> rules;
-
- private ShardingSphereRuleMetaData shardingSphereRuleMetaData;
-
- @Before
- public void init() {
- rules = Arrays.asList(new ShardingSphereRuleFixture());
- shardingSphereRuleMetaData = new ShardingSphereRuleMetaData(configurations, rules);
- }
+ private final ShardingSphereRuleMetaData shardingSphereRuleMetaData = new ShardingSphereRuleMetaData(Collections.emptyList(), Collections.singleton(new ShardingSphereRuleFixture()));
@Test
public void assertFilterRulesReturnOneItem() {
- Collection<ShardingSphereRuleFixture> clazzList = shardingSphereRuleMetaData.findRules(ShardingSphereRuleFixture.class);
- assertThat(1, equalTo(clazzList.size()));
+ assertThat(shardingSphereRuleMetaData.findRules(ShardingSphereRuleFixture.class).size(), is(1));
}
@Test
public void assertFindSingleRuleReturnsIsPresent() {
- Optional<ShardingSphereRuleFixture> clazzOptional = shardingSphereRuleMetaData.findSingleRule(ShardingSphereRuleFixture.class);
- assertTrue(clazzOptional.isPresent());
- }
-
- @Test
- public void assertFindSingleRuleHasValue() {
- Optional<ShardingSphereRuleFixture> clazzOptional = shardingSphereRuleMetaData.findSingleRule(ShardingSphereRuleFixture.class);
- assertTrue(clazzOptional.isPresent());
- assertThat("ShardingSphereRuleFixture", equalTo(clazzOptional.get().getType()));
+ assertTrue(shardingSphereRuleMetaData.findSingleRule(ShardingSphereRuleFixture.class).isPresent());
}
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
index 3a3e382c100..0f2e4690f8e 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
@@ -190,9 +190,9 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
statementManager = new StatementManager();
}
- private boolean isStatementsCacheable(final Collection<RuleConfiguration> configurations) {
+ private boolean isStatementsCacheable(final Collection<RuleConfiguration> configs) {
// TODO Consider cache statements with more case
- return 1 == configurations.size() && configurations.iterator().next() instanceof ReadwriteSplittingRuleConfiguration && !HintManager.isInstantiated();
+ return 1 == configs.size() && configs.iterator().next() instanceof ReadwriteSplittingRuleConfiguration && !HintManager.isInstantiated();
}
@Override
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/prepare/datasource/MySQLDataSourcePreparerTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/prepare/datasource/MySQLDataSourcePreparerTest.java
index 9ae4828f30e..294010311c0 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/prepare/datasource/MySQLDataSourcePreparerTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/prepare/datasource/MySQLDataSourcePreparerTest.java
@@ -53,10 +53,10 @@ public final class MySQLDataSourcePreparerTest {
private RuleAlteredJobConfiguration jobConfig;
@Mock
- private YamlPipelineDataSourceConfiguration sourceYamlPipelineDataSourceConfiguration;
+ private YamlPipelineDataSourceConfiguration sourceYamlPipelineDataSourceConfig;
@Mock
- private YamlPipelineDataSourceConfiguration targetYamlPipelineDataSourceConfiguration;
+ private YamlPipelineDataSourceConfiguration targetYamlPipelineDataSourceConfig;
@Mock
private ShardingSpherePipelineDataSourceConfiguration sourceScalingDataSourceConfig;
@@ -76,10 +76,10 @@ public final class MySQLDataSourcePreparerTest {
when(mockPipelineDataSourceManager.getDataSource(same(sourceScalingDataSourceConfig))).thenReturn(sourceDataSourceWrapper);
when(mockPipelineDataSourceManager.getDataSource(same(targetScalingDataSourceConfig))).thenReturn(targetDataSourceWrapper);
when(prepareTargetTablesParameter.getDataSourceManager()).thenReturn(mockPipelineDataSourceManager);
- when(jobConfig.getSource()).thenReturn(sourceYamlPipelineDataSourceConfiguration);
+ when(jobConfig.getSource()).thenReturn(sourceYamlPipelineDataSourceConfig);
when(jobConfig.getSource().getType()).thenReturn("ShardingSphereJDBC");
when(jobConfig.getSource().getParameter()).thenReturn("source");
- when(jobConfig.getTarget()).thenReturn(targetYamlPipelineDataSourceConfiguration);
+ when(jobConfig.getTarget()).thenReturn(targetYamlPipelineDataSourceConfig);
when(jobConfig.getTarget().getType()).thenReturn("ShardingSphereJDBC");
when(jobConfig.getTarget().getParameter()).thenReturn("target");
when(prepareTargetTablesParameter.getJobConfig()).thenReturn(jobConfig);
@@ -88,7 +88,7 @@ public final class MySQLDataSourcePreparerTest {
@Test
public void assertGetConnection() throws SQLException {
- try (MockedStatic<PipelineDataSourceConfigurationFactory> mockedStaticPipelineDataSourceConfigurationFactory = mockStatic(PipelineDataSourceConfigurationFactory.class);) {
+ try (MockedStatic<PipelineDataSourceConfigurationFactory> mockedStaticPipelineDataSourceConfigurationFactory = mockStatic(PipelineDataSourceConfigurationFactory.class)) {
mockedStaticPipelineDataSourceConfigurationFactory.when(() -> PipelineDataSourceConfigurationFactory.newInstance(eq("ShardingSphereJDBC"), eq("source")))
.thenReturn(sourceScalingDataSourceConfig);
mockedStaticPipelineDataSourceConfigurationFactory.when(() -> PipelineDataSourceConfigurationFactory.newInstance(eq("ShardingSphereJDBC"), eq("target")))
diff --git a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/rule/SingleTableRuleTest.java b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/rule/SingleTableRuleTest.java
index a2589f20d60..611e88f1539 100644
--- a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/rule/SingleTableRuleTest.java
+++ b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/rule/SingleTableRuleTest.java
@@ -166,9 +166,9 @@ public final class SingleTableRuleTest {
@Test
public void assertGetDefaultDataSource() {
DataNodeContainedRule dataNodeContainedRule = mock(DataNodeContainedRule.class);
- SingleTableRuleConfiguration singleTableRuleConfiguration = new SingleTableRuleConfiguration();
- singleTableRuleConfiguration.setDefaultDataSource("ds_0");
- SingleTableRule singleTableRule = new SingleTableRule(singleTableRuleConfiguration, mock(DatabaseType.class), dataSourceMap,
+ SingleTableRuleConfiguration singleTableRuleConfig = new SingleTableRuleConfiguration();
+ singleTableRuleConfig.setDefaultDataSource("ds_0");
+ SingleTableRule singleTableRule = new SingleTableRule(singleTableRuleConfig, mock(DatabaseType.class), dataSourceMap,
Collections.singletonList(dataNodeContainedRule), new ConfigurationProperties(new Properties()));
assertTrue(singleTableRule.getDefaultDataSource().isPresent());
assertThat(singleTableRule.getDefaultDataSource().get(), is("ds_0"));
diff --git a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/swapper/SingleTableRuleConfigurationYamlSwapperTest.java b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/swapper/SingleTableRuleConfigurationYamlSwapperTest.java
index 4b31f62aa97..ee407a8117a 100644
--- a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/swapper/SingleTableRuleConfigurationYamlSwapperTest.java
+++ b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/swapper/SingleTableRuleConfigurationYamlSwapperTest.java
@@ -21,8 +21,6 @@ import org.apache.shardingsphere.singletable.config.SingleTableRuleConfiguration
import org.apache.shardingsphere.singletable.yaml.config.pojo.YamlSingleTableRuleConfiguration;
import org.apache.shardingsphere.singletable.yaml.config.swapper.SingleTableRuleConfigurationYamlSwapper;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
@@ -30,39 +28,29 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-@RunWith(MockitoJUnitRunner.class)
public final class SingleTableRuleConfigurationYamlSwapperTest {
- private final SingleTableRuleConfigurationYamlSwapper swapper = new SingleTableRuleConfigurationYamlSwapper();
-
@Test
public void assertSwapToObject() {
- YamlSingleTableRuleConfiguration yamlConfiguration = new YamlSingleTableRuleConfiguration();
- yamlConfiguration.setDefaultDataSource("ds_0");
- SingleTableRuleConfiguration configuration = swapper.swapToObject(yamlConfiguration);
- assertTrue(configuration.getDefaultDataSource().isPresent());
- assertThat(configuration.getDefaultDataSource().get(), is("ds_0"));
+ YamlSingleTableRuleConfiguration yamlConfig = new YamlSingleTableRuleConfiguration();
+ yamlConfig.setDefaultDataSource("ds_0");
+ SingleTableRuleConfiguration ruleConfig = new SingleTableRuleConfigurationYamlSwapper().swapToObject(yamlConfig);
+ assertTrue(ruleConfig.getDefaultDataSource().isPresent());
+ assertThat(ruleConfig.getDefaultDataSource().get(), is("ds_0"));
}
@Test
public void assertSwapToObjectWithoutDataSource() {
- YamlSingleTableRuleConfiguration yamlConfiguration = new YamlSingleTableRuleConfiguration();
- SingleTableRuleConfiguration configuration = swapper.swapToObject(yamlConfiguration);
- assertFalse(configuration.getDefaultDataSource().isPresent());
+ assertFalse(new SingleTableRuleConfigurationYamlSwapper().swapToObject(new YamlSingleTableRuleConfiguration()).getDefaultDataSource().isPresent());
}
@Test
public void assertSwapToYaml() {
- SingleTableRuleConfiguration configuration = new SingleTableRuleConfiguration();
- configuration.setDefaultDataSource("ds_0");
- YamlSingleTableRuleConfiguration yamlSingleTableRuleConfiguration = swapper.swapToYamlConfiguration(configuration);
- assertThat(yamlSingleTableRuleConfiguration.getDefaultDataSource(), is("ds_0"));
+ assertThat(new SingleTableRuleConfigurationYamlSwapper().swapToYamlConfiguration(new SingleTableRuleConfiguration("ds_0")).getDefaultDataSource(), is("ds_0"));
}
@Test
public void assertSwapToYamlWithoutDataSource() {
- SingleTableRuleConfiguration configuration = new SingleTableRuleConfiguration();
- YamlSingleTableRuleConfiguration yamlSingleTableRuleConfiguration = swapper.swapToYamlConfiguration(configuration);
- assertNull(yamlSingleTableRuleConfiguration.getDefaultDataSource());
+ assertNull(new SingleTableRuleConfigurationYamlSwapper().swapToYamlConfiguration(new SingleTableRuleConfiguration()).getDefaultDataSource());
}
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/rule/builder/DefaultTrafficRuleConfigurationBuilderTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/rule/builder/DefaultTrafficRuleConfigurationBuilderTest.java
index 205fb628884..9c2fabd43c0 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/rule/builder/DefaultTrafficRuleConfigurationBuilderTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/rule/builder/DefaultTrafficRuleConfigurationBuilderTest.java
@@ -20,31 +20,18 @@ package org.apache.shardingsphere.traffic.rule.builder;
import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
public final class DefaultTrafficRuleConfigurationBuilderTest {
- private final DefaultTrafficRuleConfigurationBuilder builder = new DefaultTrafficRuleConfigurationBuilder();
-
@Test
public void assertBuild() {
- TrafficRuleConfiguration configuration = builder.build();
- assertNotNull(configuration);
- assertThat(configuration.getTrafficStrategies().size(), is(0));
- assertThat(configuration.getTrafficAlgorithms().size(), is(0));
- assertThat(configuration.getLoadBalancers().size(), is(0));
- }
-
- @Test
- public void assertGetOrder() {
- assertThat(builder.getOrder(), is(800));
- }
-
- @Test
- public void assertGetTypeClass() {
- assertThat(builder.getTypeClass(), equalTo(TrafficRuleBuilder.class));
+ TrafficRuleConfiguration actual = new DefaultTrafficRuleConfigurationBuilder().build();
+ assertNotNull(actual);
+ assertThat(actual.getTrafficStrategies().size(), is(0));
+ assertThat(actual.getTrafficAlgorithms().size(), is(0));
+ assertThat(actual.getLoadBalancers().size(), is(0));
}
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficStrategyConfigurationYamlSwapperTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficStrategyConfigurationYamlSwapperTest.java
index 19c6e980f2b..edb01f03035 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficStrategyConfigurationYamlSwapperTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficStrategyConfigurationYamlSwapperTest.java
@@ -48,11 +48,11 @@ public final class TrafficStrategyConfigurationYamlSwapperTest {
@Test
public void swapToYamlConfiguration() {
- YamlTrafficStrategyConfiguration yamlTrafficStrategyConfiguration = yamlSwapper.swapToYamlConfiguration(createTrafficStrategyConfiguration());
- assertThat(yamlTrafficStrategyConfiguration.getName(), is(NAME));
- assertThat(yamlTrafficStrategyConfiguration.getLabels(), is(LABELS));
- assertThat(yamlTrafficStrategyConfiguration.getAlgorithmName(), is(ALGORITHM_NAME));
- assertThat(yamlTrafficStrategyConfiguration.getLoadBalancerName(), is(LOAD_BALANCER_NAME));
+ YamlTrafficStrategyConfiguration yamlStrategyConfig = yamlSwapper.swapToYamlConfiguration(createTrafficStrategyConfiguration());
+ assertThat(yamlStrategyConfig.getName(), is(NAME));
+ assertThat(yamlStrategyConfig.getLabels(), is(LABELS));
+ assertThat(yamlStrategyConfig.getAlgorithmName(), is(ALGORITHM_NAME));
+ assertThat(yamlStrategyConfig.getLoadBalancerName(), is(LOAD_BALANCER_NAME));
}
private TrafficStrategyConfiguration createTrafficStrategyConfiguration() {
@@ -61,11 +61,11 @@ public final class TrafficStrategyConfigurationYamlSwapperTest {
@Test
public void swapToObject() {
- TrafficStrategyConfiguration trafficStrategyConfiguration = yamlSwapper.swapToObject(createYamlTrafficStrategyConfiguration());
- assertThat(trafficStrategyConfiguration.getName(), is(NAME));
- assertThat(trafficStrategyConfiguration.getLabels(), is(LABELS));
- assertThat(trafficStrategyConfiguration.getAlgorithmName(), is(ALGORITHM_NAME));
- assertThat(trafficStrategyConfiguration.getLoadBalancerName(), is(LOAD_BALANCER_NAME));
+ TrafficStrategyConfiguration strategyConfig = yamlSwapper.swapToObject(createYamlTrafficStrategyConfiguration());
+ assertThat(strategyConfig.getName(), is(NAME));
+ assertThat(strategyConfig.getLabels(), is(LABELS));
+ assertThat(strategyConfig.getAlgorithmName(), is(ALGORITHM_NAME));
+ assertThat(strategyConfig.getLoadBalancerName(), is(LOAD_BALANCER_NAME));
}
private YamlTrafficStrategyConfiguration createYamlTrafficStrategyConfiguration() {
diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/spi/TransactionConfigurationFileGenerator.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/spi/TransactionConfigurationFileGenerator.java
index b8790e7a107..4a1ba03c2d7 100644
--- a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/spi/TransactionConfigurationFileGenerator.java
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/spi/TransactionConfigurationFileGenerator.java
@@ -40,9 +40,9 @@ public interface TransactionConfigurationFileGenerator extends StatelessTypedSPI
* Get transaction rule props.
*
* @param originTransactionProps origin transaction properties
- * @param databaseConfiguration database configuration
+ * @param databaseConfig database configuration
* @param modeType mode type
* @return transaction rule props
*/
- Properties getTransactionProps(Properties originTransactionProps, DatabaseConfiguration databaseConfiguration, String modeType);
+ Properties getTransactionProps(Properties originTransactionProps, DatabaseConfiguration databaseConfig, String modeType);
}
diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/config/NarayanaConfigurationFileGenerator.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-x [...]
index aab399d5063..a2fceaf4a14 100644
--- a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/config/NarayanaConfigurationFileGenerator.java
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/config/NarayanaConfigurationFileGenerator.java
@@ -140,12 +140,12 @@ public final class NarayanaConfigurationFileGenerator implements TransactionConf
}
@Override
- public Properties getTransactionProps(final Properties originTransactionProps, final DatabaseConfiguration databaseConfiguration, final String modeType) {
+ public Properties getTransactionProps(final Properties originTransactionProps, final DatabaseConfiguration databaseConfig, final String modeType) {
Properties result = new Properties();
if (!originTransactionProps.isEmpty()) {
generateUserDefinedJdbcStoreConfiguration(originTransactionProps, result);
} else if ("Cluster".equals(modeType)) {
- generateDefaultJdbcStoreConfiguration(databaseConfiguration, result);
+ generateDefaultJdbcStoreConfiguration(databaseConfig, result);
}
return result;
}
@@ -158,8 +158,8 @@ public final class NarayanaConfigurationFileGenerator implements TransactionConf
generateTransactionProps(url, user, password, dataSourceClass, props);
}
- private void generateDefaultJdbcStoreConfiguration(final DatabaseConfiguration databaseConfiguration, final Properties props) {
- Map<String, DataSource> datasourceMap = databaseConfiguration.getDataSources();
+ private void generateDefaultJdbcStoreConfiguration(final DatabaseConfiguration databaseConfig, final Properties props) {
+ Map<String, DataSource> datasourceMap = databaseConfig.getDataSources();
Optional<DataSource> dataSource = datasourceMap.values().stream().findFirst();
if (!dataSource.isPresent()) {
return;
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
index 4838bbe104c..b192727e8cb 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
@@ -525,20 +525,20 @@ public final class ContextManager implements AutoCloseable {
Map<String, DataSource> dataSourceMap = new HashMap<>(originalMetaData.getResource().getDataSources());
dataSourceMap.putAll(DataSourcePoolCreator.create(addedDataSourceProps));
Properties props = metaDataContexts.getProps().getProps();
- DatabaseConfiguration databaseConfiguration = new DataSourceProvidedDatabaseConfiguration(dataSourceMap, originalMetaData.getRuleMetaData().getConfigurations());
+ DatabaseConfiguration databaseConfig = new DataSourceProvidedDatabaseConfiguration(dataSourceMap, originalMetaData.getRuleMetaData().getConfigurations());
Optional<MetaDataPersistService> metaDataPersistService = metaDataContexts.getMetaDataPersistService();
- metaDataPersistService.ifPresent(optional -> persistTransactionConfiguration(databaseConfiguration, optional));
+ metaDataPersistService.ifPresent(optional -> persistTransactionConfiguration(databaseConfig, optional));
MetaDataContextsBuilder metaDataContextsBuilder = new MetaDataContextsBuilder(metaDataContexts.getGlobalRuleMetaData().getConfigurations(), props);
- metaDataContextsBuilder.addDatabase(originalMetaData.getDatabaseName(), originalMetaData.getResource().getDatabaseType(), databaseConfiguration, props);
+ metaDataContextsBuilder.addDatabase(originalMetaData.getDatabaseName(), originalMetaData.getResource().getDatabaseType(), databaseConfig, props);
metaDataContexts.getMetaDataPersistService().ifPresent(optional -> optional.getSchemaMetaDataService()
.persistTables(originalMetaData.getDatabaseName(), originalMetaData.getDatabaseName(), metaDataContextsBuilder.getSchemaMap(originalMetaData.getDatabaseName())));
return metaDataContextsBuilder.build(metaDataContexts.getMetaDataPersistService().orElse(null));
}
- private void persistTransactionConfiguration(final DatabaseConfiguration databaseConfiguration, final MetaDataPersistService metaDataPersistService) {
+ private void persistTransactionConfiguration(final DatabaseConfiguration databaseConfig, final MetaDataPersistService metaDataPersistService) {
Optional<TransactionConfigurationFileGenerator> fileGenerator = TransactionConfigurationFileGeneratorFactory.newInstance(getTransactionRule().getProviderType());
if (fileGenerator.isPresent()) {
- Properties transactionProps = fileGenerator.get().getTransactionProps(getTransactionRule().getProps(), databaseConfiguration, instanceContext.getModeConfiguration().getType());
+ Properties transactionProps = fileGenerator.get().getTransactionProps(getTransactionRule().getProps(), databaseConfig, instanceContext.getModeConfiguration().getType());
metaDataPersistService.persistTransactionRule(transactionProps, true);
}
}
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameterTest.java b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameterTest.java
index da6b24818f7..372277866a9 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameterTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameterTest.java
@@ -20,11 +20,9 @@ package org.apache.shardingsphere.mode.manager;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration;
import org.junit.Test;
-import org.mockito.Mockito;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -39,7 +37,7 @@ public final class ContextManagerBuilderParameterTest {
@Test
public void assertIsEmpty() {
- Map<String, DatabaseConfiguration> mockDatabaseConfigs = getMockSchemaConfiguration(true, true);
+ Map<String, DatabaseConfiguration> mockDatabaseConfigs = mockSchemaConfigurations(true, true);
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(Collections.emptyList())
.props(new Properties())
@@ -65,7 +63,7 @@ public final class ContextManagerBuilderParameterTest {
when(mockProperties.isEmpty()).thenReturn(false);
Collection<RuleConfiguration> mockGlobalRuleConfigs = mock(Collection.class);
lenient().when(mockGlobalRuleConfigs.isEmpty()).thenReturn(false);
- Map<String, DatabaseConfiguration> mockDatabaseConfigs = getMockSchemaConfiguration(false, false);
+ Map<String, DatabaseConfiguration> mockDatabaseConfigs = mockSchemaConfigurations(false, false);
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(mockGlobalRuleConfigs)
.props(mockProperties)
@@ -101,7 +99,7 @@ public final class ContextManagerBuilderParameterTest {
@Test
public void assertIsEmptyWhenSchemaConfigsIsNotEmpty() {
- Map<String, DatabaseConfiguration> mockDatabaseConfigs = getMockSchemaConfiguration(false, false);
+ Map<String, DatabaseConfiguration> mockDatabaseConfigs = mockSchemaConfigurations(false, false);
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(Collections.emptyList())
.props(new Properties())
@@ -112,7 +110,7 @@ public final class ContextManagerBuilderParameterTest {
@Test
public void assertIsEmptyWhenDataSourcesIsNotEmpty() {
- Map<String, DatabaseConfiguration> mockDatabaseConfigs = getMockSchemaConfiguration(false, true);
+ Map<String, DatabaseConfiguration> mockDatabaseConfigs = mockSchemaConfigurations(false, true);
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(Collections.emptyList())
.props(new Properties())
@@ -123,11 +121,11 @@ public final class ContextManagerBuilderParameterTest {
@Test
public void assertIsEmptyWhenRuleConfigurationsIsNotEmpty() {
- Map<String, DatabaseConfiguration> mockDatabaseConfigs = getMockSchemaConfiguration(true, false);
+ Map<String, DatabaseConfiguration> databaseConfigs = mockSchemaConfigurations(true, false);
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
.globalRuleConfigs(Collections.emptyList())
.props(new Properties())
- .databaseConfigs(mockDatabaseConfigs)
+ .databaseConfigs(databaseConfigs)
.build();
assertFalse(contextManagerBuilderParameter.isEmpty());
}
@@ -135,7 +133,7 @@ public final class ContextManagerBuilderParameterTest {
@Test
@SuppressWarnings("unchecked")
public void assertIsEmptyWhenOnlyPropsIsEmpty() {
- Map<String, DatabaseConfiguration> mockDatabaseConfigs = getMockSchemaConfiguration(true, true);
+ Map<String, DatabaseConfiguration> mockDatabaseConfigs = mockSchemaConfigurations(true, true);
Collection<RuleConfiguration> mockGlobalRuleConfigs = mock(Collection.class);
lenient().when(mockGlobalRuleConfigs.isEmpty()).thenReturn(false);
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
@@ -148,7 +146,7 @@ public final class ContextManagerBuilderParameterTest {
@Test
public void assertIsEmptyWhenOnlyGlobalRuleConfigsIsEmpty() {
- Map<String, DatabaseConfiguration> mockDatabaseConfigs = getMockSchemaConfiguration(true, true);
+ Map<String, DatabaseConfiguration> mockDatabaseConfigs = mockSchemaConfigurations(true, true);
Properties mockProperties = mock(Properties.class);
lenient().when(mockProperties.isEmpty()).thenReturn(false);
ContextManagerBuilderParameter contextManagerBuilderParameter = ContextManagerBuilderParameter.builder()
@@ -174,12 +172,10 @@ public final class ContextManagerBuilderParameterTest {
assertFalse(contextManagerBuilderParameter.isEmpty());
}
- private Map<String, DatabaseConfiguration> getMockSchemaConfiguration(final boolean dataSourcesIsEmpty, final boolean ruleConfigurationsIsEmpty) {
- DatabaseConfiguration mockSchemaConfiguration = Mockito.mock(DatabaseConfiguration.class, RETURNS_DEEP_STUBS);
- lenient().when(mockSchemaConfiguration.getDataSources().isEmpty()).thenReturn(dataSourcesIsEmpty);
- lenient().when(mockSchemaConfiguration.getRuleConfigurations().isEmpty()).thenReturn(ruleConfigurationsIsEmpty);
- Map<String, DatabaseConfiguration> result = new HashMap<>();
- result.put("logic", mockSchemaConfiguration);
- return result;
+ private Map<String, DatabaseConfiguration> mockSchemaConfigurations(final boolean dataSourcesIsEmpty, final boolean ruleConfigurationsIsEmpty) {
+ DatabaseConfiguration result = mock(DatabaseConfiguration.class, RETURNS_DEEP_STUBS);
+ lenient().when(result.getDataSources().isEmpty()).thenReturn(dataSourcesIsEmpty);
+ lenient().when(result.getRuleConfigurations().isEmpty()).thenReturn(ruleConfigurationsIsEmpty);
+ return Collections.singletonMap("logic", result);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java
index bae9aadda27..95a05905348 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java
@@ -79,7 +79,7 @@ public final class ProxyConfigurationLoader {
result.getRules().removeIf(each -> each instanceof YamlAuthorityRuleConfiguration);
result.getRules().add(result.getAuthority().convertToYamlAuthorityRuleConfiguration());
}
- YamlRuleConfiguration authorityRuleConfig = result.getRules().stream().filter(ruleConfig -> ruleConfig instanceof YamlAuthorityRuleConfiguration).findAny().orElse(null);
+ YamlRuleConfiguration authorityRuleConfig = result.getRules().stream().filter(each -> each instanceof YamlAuthorityRuleConfiguration).findAny().orElse(null);
Preconditions.checkState(containsGovernance || null != authorityRuleConfig, "Authority configuration is invalid.");
return result;
}
@@ -88,10 +88,9 @@ public final class ProxyConfigurationLoader {
Collection<String> loadedDatabaseNames = new HashSet<>();
Collection<YamlProxyDatabaseConfiguration> result = new LinkedList<>();
for (File each : findRuleConfigurationFiles(configPath)) {
- loadDatabaseConfiguration(each).ifPresent(yamlProxyRuleConfig -> {
- Preconditions.checkState(
- loadedDatabaseNames.add(yamlProxyRuleConfig.getDatabaseName()), "Database name `%s` must unique at all database configurations.", yamlProxyRuleConfig.getDatabaseName());
- result.add(yamlProxyRuleConfig);
+ loadDatabaseConfiguration(each).ifPresent(optional -> {
+ Preconditions.checkState(loadedDatabaseNames.add(optional.getDatabaseName()), "Database name `%s` must unique at all database configurations.", optional.getDatabaseName());
+ result.add(optional);
});
}
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
index c6e8bb8c081..e33a0b2da85 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
@@ -97,8 +97,8 @@ public final class ShardingRuleConfigurationImportChecker {
checkInvalidAlgorithms(KEY_GENERATOR, currentRuleConfig.getKeyGenerators().values());
}
- private void checkInvalidAlgorithms(final String algorithmType, final Collection<ShardingSphereAlgorithmConfiguration> algorithmConfigurations) throws DistSQLException {
- Collection<String> invalidAlgorithms = algorithmConfigurations.stream()
+ private void checkInvalidAlgorithms(final String algorithmType, final Collection<ShardingSphereAlgorithmConfiguration> algorithmConfigs) throws DistSQLException {
+ Collection<String> invalidAlgorithms = algorithmConfigs.stream()
.filter(each -> !TypedSPIRegistry.findRegisteredService(ALGORITHM_TYPE_MAP.get(algorithmType), each.getType(), new Properties()).isPresent())
.map(ShardingSphereAlgorithmConfiguration::getType).collect(Collectors.toList());
DistSQLException.predictionThrow(invalidAlgorithms.isEmpty(), () -> new InvalidAlgorithmConfigurationException(algorithmType, invalidAlgorithms));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/CountInstanceRulesHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/CountInstanceRulesHandler.java
index 2535b74e963..1f1189fdd10 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/CountInstanceRulesHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/CountInstanceRulesHandler.java
@@ -97,8 +97,8 @@ public final class CountInstanceRulesHandler extends QueryableRALBackendHandler<
}
private boolean hasRuleConfiguration(final ShardingSphereMetaData metaData) {
- Collection<RuleConfiguration> configurations = metaData.getRuleMetaData().getConfigurations();
- return null != configurations && !configurations.isEmpty();
+ Collection<RuleConfiguration> configs = metaData.getRuleMetaData().getConfigurations();
+ return null != configs && !configs.isEmpty();
}
private void initData(final Map<String, List<Object>> dataMap) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ExportDatabaseConfigurationHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ExportDatabaseConfigurationHandler.java
index ea589739061..3df3733a705 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ExportDatabaseConfigurationHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ExportDatabaseConfigurationHandler.java
@@ -117,7 +117,7 @@ public final class ExportDatabaseConfigurationHandler extends QueryableRALBacken
StringBuilder result = new StringBuilder();
configItem(ZERO, "databaseName", databaseName, result);
getDataSourcesConfig(metaData, result);
- getRulesConfig(metaData.getRuleMetaData().getConfigurations(), result);
+ getRuleConfigurations(metaData.getRuleMetaData().getConfigurations(), result);
if (!sqlStatement.getFilePath().isPresent()) {
return Collections.singleton(Collections.singletonList(result.toString()));
}
@@ -142,21 +142,17 @@ public final class ExportDatabaseConfigurationHandler extends QueryableRALBacken
for (Entry<String, DataSource> each : metaData.getResource().getDataSources().entrySet()) {
configItem(ONE, each.getKey(), result);
DataSourceProperties dataSourceProps = DataSourcePropertiesCreator.create(each.getValue());
- dataSourceProps.getConnectionPropertySynonyms().getStandardProperties().entrySet().forEach(standard -> {
- configItem(TWO, standard.getKey(), standard.getValue(), result);
- });
- dataSourceProps.getPoolPropertySynonyms().getStandardProperties().entrySet().forEach(standard -> {
- configItem(TWO, standard.getKey(), standard.getValue(), result);
- });
+ dataSourceProps.getConnectionPropertySynonyms().getStandardProperties().forEach((key, value) -> configItem(TWO, key, value, result));
+ dataSourceProps.getPoolPropertySynonyms().getStandardProperties().forEach((key, value) -> configItem(TWO, key, value, result));
}
}
- private void getRulesConfig(final Collection<RuleConfiguration> ruleConfigurations, final StringBuilder result) {
- if (null == ruleConfigurations || ruleConfigurations.isEmpty()) {
+ private void getRuleConfigurations(final Collection<RuleConfiguration> ruleConfigs, final StringBuilder result) {
+ if (null == ruleConfigs || ruleConfigs.isEmpty()) {
return;
}
configItem(ZERO, "rules", result);
- ruleConfigurations.forEach(each -> {
+ ruleConfigs.forEach(each -> {
getRulesConfigForSharding(each, result);
getRulesConfigForReadwriteSplitting(each, result);
getRulesConfigForDBDiscovery(each, result);
@@ -166,10 +162,7 @@ public final class ExportDatabaseConfigurationHandler extends QueryableRALBacken
}
private boolean matchFeature(final RuleConfiguration ruleConfig, final String feature) {
- if (null != ruleConfig && ruleConfig.getClass().getCanonicalName().equalsIgnoreCase(FEATURE_MAP.get(feature).getCanonicalName())) {
- return true;
- }
- return false;
+ return null != ruleConfig && ruleConfig.getClass().getCanonicalName().equalsIgnoreCase(FEATURE_MAP.get(feature).getCanonicalName());
}
private void getRulesConfigForSharding(final RuleConfiguration ruleConfig, final StringBuilder result) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandler.java
index db20f994858..9ee3d1588a1 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandler.java
@@ -54,11 +54,11 @@ public final class ShowAuthorityRuleHandler extends QueryableRALBackendHandler<S
if (!authorityRuleConfigurationOptional.isPresent()) {
return Collections.emptyList();
}
- AuthorityRuleConfiguration authorityRuleConfiguration = authorityRuleConfigurationOptional.get();
+ AuthorityRuleConfiguration ruleConfig = authorityRuleConfigurationOptional.get();
List<Object> row = new LinkedList<>();
- row.add(authorityRuleConfiguration.getUsers().stream().map(each -> each.getGrantee().toString()).collect(Collectors.joining("; ")));
- row.add(authorityRuleConfiguration.getProvider().getType());
- row.add(authorityRuleConfiguration.getProvider().getProps().size() == 0 ? "" : authorityRuleConfiguration.getProvider().getProps());
+ row.add(ruleConfig.getUsers().stream().map(each -> each.getGrantee().toString()).collect(Collectors.joining("; ")));
+ row.add(ruleConfig.getProvider().getType());
+ row.add(ruleConfig.getProvider().getProps().size() == 0 ? "" : ruleConfig.getProvider().getProps());
Collection<List<Object>> result = new LinkedList<>();
result.add(row);
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandler.java
index 26c5554f58b..2dc4926d100 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandler.java
@@ -53,11 +53,11 @@ public final class ShowInstanceModeHandler extends QueryableRALBackendHandler<Sh
@Override
protected Collection<List<Object>> getRows(final ContextManager contextManager) {
InstanceContext instanceContext = ProxyContext.getInstance().getContextManager().getInstanceContext();
- PersistRepositoryConfiguration repositoryConfiguration = instanceContext.getModeConfiguration().getRepository();
+ PersistRepositoryConfiguration repositoryConfig = instanceContext.getModeConfiguration().getRepository();
String instanceId = instanceContext.getInstance().getInstanceDefinition().getInstanceId().getId();
String modeType = instanceContext.getModeConfiguration().getType();
- String repositoryType = null == repositoryConfiguration ? "" : repositoryConfiguration.getType();
- String props = null == repositoryConfiguration || null == repositoryConfiguration.getProps() ? "" : new Gson().toJson(repositoryConfiguration.getProps());
+ String repositoryType = null == repositoryConfig ? "" : repositoryConfig.getType();
+ String props = null == repositoryConfig || null == repositoryConfig.getProps() ? "" : new Gson().toJson(repositoryConfig.getProps());
String overwrite = String.valueOf(instanceContext.getModeConfiguration().isOverwrite());
return Collections.singleton(Arrays.asList(instanceId, modeType, repositoryType, props, overwrite));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandler.java
index 878b87d8b00..9767ae6929a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandler.java
@@ -56,11 +56,11 @@ public final class ShowSQLParserRuleHandler extends QueryableRALBackendHandler<S
if (!sqlParserRuleConfigurationOptional.isPresent()) {
return Collections.emptyList();
}
- SQLParserRuleConfiguration sqlParserRuleConfiguration = sqlParserRuleConfigurationOptional.get();
+ SQLParserRuleConfiguration sqlParserRuleConfig = sqlParserRuleConfigurationOptional.get();
List<Object> row = new LinkedList<>();
- row.add(String.valueOf(sqlParserRuleConfiguration.isSqlCommentParseEnabled()));
- row.add(GSON.toJson(sqlParserRuleConfiguration.getParseTreeCache()));
- row.add(GSON.toJson(sqlParserRuleConfiguration.getSqlStatementCache()));
+ row.add(String.valueOf(sqlParserRuleConfig.isSqlCommentParseEnabled()));
+ row.add(GSON.toJson(sqlParserRuleConfig.getParseTreeCache()));
+ row.add(GSON.toJson(sqlParserRuleConfig.getSqlStatementCache()));
Collection<List<Object>> result = new LinkedList<>();
result.add(row);
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandler.java
index 8aa9fdec428..9086feed225 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandler.java
@@ -51,18 +51,15 @@ public final class ShowTransactionRuleHandler extends QueryableRALBackendHandler
@Override
protected Collection<List<Object>> getRows(final ContextManager contextManager) {
- Optional<TransactionRuleConfiguration> optionalTransactionRuleConfiguration = ProxyContext.getInstance().getContextManager()
+ Optional<TransactionRuleConfiguration> ruleConfig = ProxyContext.getInstance().getContextManager()
.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TransactionRuleConfiguration.class).stream().findAny();
- if (!optionalTransactionRuleConfiguration.isPresent()) {
+ if (!ruleConfig.isPresent()) {
return Collections.emptyList();
}
- TransactionRuleConfiguration transactionRuleConfiguration = optionalTransactionRuleConfiguration.get();
List<Object> row = new LinkedList<>();
- row.add(transactionRuleConfiguration.getDefaultType());
- row.add(null == transactionRuleConfiguration.getProviderType() ? "" : transactionRuleConfiguration.getProviderType());
- row.add(null == transactionRuleConfiguration.getProps() ? "" : new Gson().toJson(transactionRuleConfiguration.getProps()));
- Collection<List<Object>> rows = new LinkedList<>();
- rows.add(row);
- return rows;
+ row.add(ruleConfig.get().getDefaultType());
+ row.add(null == ruleConfig.get().getProviderType() ? "" : ruleConfig.get().getProviderType());
+ row.add(null == ruleConfig.get().getProps() ? "" : new Gson().toJson(ruleConfig.get().getProps()));
+ return Collections.singleton(row);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandler.java
index cd769eb0b0f..9fa2f12d104 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandler.java
@@ -44,15 +44,15 @@ public final class AlterTransactionRuleHandler extends UpdatableRALBackendHandle
ShardingSphereRuleMetaData globalRuleMetaData = metaDataContexts.getGlobalRuleMetaData();
Collection<ShardingSphereRule> globalRules = globalRuleMetaData.getRules();
globalRules.removeIf(each -> each instanceof TransactionRule);
- Collection<RuleConfiguration> globalRuleConfigurations = new LinkedList<>(globalRuleMetaData.getConfigurations());
- globalRuleConfigurations.removeIf(each -> each instanceof TransactionRuleConfiguration);
+ Collection<RuleConfiguration> globalRuleConfigs = new LinkedList<>(globalRuleMetaData.getConfigurations());
+ globalRuleConfigs.removeIf(each -> each instanceof TransactionRuleConfiguration);
TransactionRuleConfiguration toBeAlteredRuleConfig = buildTransactionRuleConfiguration();
globalRules.add(new TransactionRule(toBeAlteredRuleConfig));
- globalRuleConfigurations.add(toBeAlteredRuleConfig);
+ globalRuleConfigs.add(toBeAlteredRuleConfig);
ProxyContext.getInstance().getContextManager().renewAllTransactionContext();
Optional<MetaDataPersistService> metaDataPersistService = metaDataContexts.getMetaDataPersistService();
if (metaDataPersistService.isPresent() && null != metaDataPersistService.get().getGlobalRuleService()) {
- metaDataPersistService.get().getGlobalRuleService().persist(globalRuleConfigurations, true);
+ metaDataPersistService.get().getGlobalRuleService().persist(globalRuleConfigs, true);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportDatabaseConfigurationHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportDatabaseConfigurationHandler.java
index 7e191f917f5..029163b5d0f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportDatabaseConfigurationHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportDatabaseConfigurationHandler.java
@@ -105,35 +105,35 @@ public final class ImportDatabaseConfigurationHandler extends UpdatableRALBacken
}
}
- private void alterRulesConfig(final String databaseName, final Collection<YamlRuleConfiguration> yamlRuleConfigurations) throws DistSQLException {
- if (null == yamlRuleConfigurations || yamlRuleConfigurations.isEmpty()) {
+ private void alterRulesConfig(final String databaseName, final Collection<YamlRuleConfiguration> yamlRuleConfigs) throws DistSQLException {
+ if (null == yamlRuleConfigs || yamlRuleConfigs.isEmpty()) {
return;
}
Collection<RuleConfiguration> toBeUpdatedRuleConfigs = new LinkedList<>();
MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
ShardingSphereMetaData shardingSphereMetaData = metaDataContexts.getMetaData(databaseName);
- for (YamlRuleConfiguration each : yamlRuleConfigurations) {
+ for (YamlRuleConfiguration each : yamlRuleConfigs) {
if (each instanceof YamlShardingRuleConfiguration) {
- ShardingRuleConfiguration shardingRuleConfiguration = new ShardingRuleConfigurationYamlSwapper().swapToObject((YamlShardingRuleConfiguration) each);
- shardingRuleConfigurationImportChecker.check(shardingSphereMetaData, shardingRuleConfiguration);
- toBeUpdatedRuleConfigs.add(shardingRuleConfiguration);
+ ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfigurationYamlSwapper().swapToObject((YamlShardingRuleConfiguration) each);
+ shardingRuleConfigurationImportChecker.check(shardingSphereMetaData, shardingRuleConfig);
+ toBeUpdatedRuleConfigs.add(shardingRuleConfig);
} else if (each instanceof YamlReadwriteSplittingRuleConfiguration) {
- ReadwriteSplittingRuleConfiguration readwriteSplittingRuleConfiguration = new ReadwriteSplittingRuleConfigurationYamlSwapper()
+ ReadwriteSplittingRuleConfiguration readwriteSplittingRuleConfig = new ReadwriteSplittingRuleConfigurationYamlSwapper()
.swapToObject((YamlReadwriteSplittingRuleConfiguration) each);
- readwriteSplittingRuleConfigurationImportChecker.check(shardingSphereMetaData, readwriteSplittingRuleConfiguration);
- toBeUpdatedRuleConfigs.add(readwriteSplittingRuleConfiguration);
+ readwriteSplittingRuleConfigurationImportChecker.check(shardingSphereMetaData, readwriteSplittingRuleConfig);
+ toBeUpdatedRuleConfigs.add(readwriteSplittingRuleConfig);
} else if (each instanceof YamlDatabaseDiscoveryRuleConfiguration) {
- DatabaseDiscoveryRuleConfiguration databaseDiscoveryRuleConfiguration = new DatabaseDiscoveryRuleConfigurationYamlSwapper().swapToObject((YamlDatabaseDiscoveryRuleConfiguration) each);
- databaseDiscoveryRuleConfigurationImportChecker.check(shardingSphereMetaData, databaseDiscoveryRuleConfiguration);
- toBeUpdatedRuleConfigs.add(databaseDiscoveryRuleConfiguration);
+ DatabaseDiscoveryRuleConfiguration databaseDiscoveryRuleConfig = new DatabaseDiscoveryRuleConfigurationYamlSwapper().swapToObject((YamlDatabaseDiscoveryRuleConfiguration) each);
+ databaseDiscoveryRuleConfigurationImportChecker.check(shardingSphereMetaData, databaseDiscoveryRuleConfig);
+ toBeUpdatedRuleConfigs.add(databaseDiscoveryRuleConfig);
} else if (each instanceof YamlEncryptRuleConfiguration) {
- EncryptRuleConfiguration encryptRuleConfiguration = new EncryptRuleConfigurationYamlSwapper().swapToObject((YamlEncryptRuleConfiguration) each);
+ EncryptRuleConfiguration encryptRuleConfig = new EncryptRuleConfigurationYamlSwapper().swapToObject((YamlEncryptRuleConfiguration) each);
// TODO check
- toBeUpdatedRuleConfigs.add(encryptRuleConfiguration);
+ toBeUpdatedRuleConfigs.add(encryptRuleConfig);
} else if (each instanceof YamlShadowRuleConfiguration) {
- ShadowRuleConfiguration shadowRuleConfiguration = new ShadowRuleConfigurationYamlSwapper().swapToObject((YamlShadowRuleConfiguration) each);
+ ShadowRuleConfiguration shadowRuleConfig = new ShadowRuleConfigurationYamlSwapper().swapToObject((YamlShadowRuleConfiguration) each);
// TODO check
- toBeUpdatedRuleConfigs.add(shadowRuleConfiguration);
+ toBeUpdatedRuleConfigs.add(shadowRuleConfig);
}
}
shardingSphereMetaData.getRuleMetaData().getConfigurations().clear();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/RulesUsedResourceQueryResultSet.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/RulesUsedResourceQueryResultSet.java
index ed327fde7f2..3b4dd40f797 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/RulesUsedResourceQueryResultSet.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/RulesUsedResourceQueryResultSet.java
@@ -69,22 +69,22 @@ public final class RulesUsedResourceQueryResultSet implements DistSQLResultSet {
@Override
public void init(final ShardingSphereMetaData metaData, final SQLStatement sqlStatement) {
- List<Collection<Object>> result = new ArrayList<>();
+ List<Collection<Object>> data = new ArrayList<>();
ShowRulesUsedResourceStatement statement = (ShowRulesUsedResourceStatement) sqlStatement;
- String resourceName = statement.getResourceName().get();
- if (hasRulesConfig(metaData) && metaData.getResource().getDataSources().keySet().contains(resourceName)) {
- getRulesConfig(metaData.getRuleMetaData().getConfigurations(), resourceName, result);
+ String resourceName = statement.getResourceName().orElse(null);
+ if (hasRulesConfiguration(metaData) && metaData.getResource().getDataSources().containsKey(resourceName)) {
+ getRulesConfig(metaData.getRuleMetaData().getConfigurations(), resourceName, data);
}
- data = result.iterator();
+ this.data = data.iterator();
}
- private void getRulesConfig(final Collection<RuleConfiguration> ruleConfigurations, final String resourceName, final List<Collection<Object>> result) {
- ruleConfigurations.forEach(each -> {
- getRulesConfigForSharding(each, result);
- getRulesConfigForReadwriteSplitting(each, resourceName, result);
- getRulesConfigForDBDiscovery(each, resourceName, result);
- getRulesConfigForEncrypt(each, result);
- getRulesConfigForShadow(each, resourceName, result);
+ private void getRulesConfig(final Collection<RuleConfiguration> ruleConfigs, final String resourceName, final List<Collection<Object>> data) {
+ ruleConfigs.forEach(each -> {
+ getRulesConfigForSharding(each, data);
+ getRulesConfigForReadwriteSplitting(each, resourceName, data);
+ getRulesConfigForDBDiscovery(each, resourceName, data);
+ getRulesConfigForEncrypt(each, data);
+ getRulesConfigForShadow(each, resourceName, data);
});
}
@@ -93,12 +93,8 @@ public final class RulesUsedResourceQueryResultSet implements DistSQLResultSet {
return;
}
ShardingRuleConfiguration config = (ShardingRuleConfiguration) ruleConfig;
- config.getAutoTables().forEach(each -> {
- result.add(buildRow(SHARDING, each.getLogicTable()));
- });
- config.getTables().forEach(each -> {
- result.add(buildRow(SHARDING, each.getLogicTable()));
- });
+ config.getAutoTables().forEach(each -> result.add(buildRow(SHARDING, each.getLogicTable())));
+ config.getTables().forEach(each -> result.add(buildRow(SHARDING, each.getLogicTable())));
}
private void getRulesConfigForReadwriteSplitting(final RuleConfiguration ruleConfig, final String resourceName, final List<Collection<Object>> result) {
@@ -133,9 +129,7 @@ public final class RulesUsedResourceQueryResultSet implements DistSQLResultSet {
return;
}
EncryptRuleConfiguration config = (EncryptRuleConfiguration) ruleConfig;
- config.getTables().forEach(each -> {
- result.add(buildRow(ENCRYPT, each.getName()));
- });
+ config.getTables().forEach(each -> result.add(buildRow(ENCRYPT, each.getName())));
}
private void getRulesConfigForShadow(final RuleConfiguration ruleConfig, final String resourceName, final List<Collection<Object>> result) {
@@ -151,19 +145,16 @@ public final class RulesUsedResourceQueryResultSet implements DistSQLResultSet {
}
private boolean matchFeature(final RuleConfiguration ruleConfig, final String feature) {
- if (null != ruleConfig && ruleConfig.getClass().getName().equals(FEATURE_MAP.get(feature).getName())) {
- return true;
- }
- return false;
+ return null != ruleConfig && ruleConfig.getClass().getName().equals(FEATURE_MAP.get(feature).getName());
}
private Collection<Object> buildRow(final String type, final String name) {
return Arrays.asList(type, name);
}
- private boolean hasRulesConfig(final ShardingSphereMetaData metaData) {
- Collection<RuleConfiguration> configurations = metaData.getRuleMetaData().getConfigurations();
- return null != configurations && !configurations.isEmpty();
+ private boolean hasRulesConfiguration(final ShardingSphereMetaData metaData) {
+ Collection<RuleConfiguration> configs = metaData.getRuleMetaData().getConfigurations();
+ return null != configs && !configs.isEmpty();
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/SchemaRulesCountResultSet.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/SchemaRulesCountResultSet.java
index ec960ae78d4..e6a88f1dc28 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/SchemaRulesCountResultSet.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/SchemaRulesCountResultSet.java
@@ -88,8 +88,8 @@ public final class SchemaRulesCountResultSet implements DistSQLResultSet {
}
private boolean hasRuleConfiguration(final ShardingSphereMetaData metaData) {
- Collection<RuleConfiguration> configurations = metaData.getRuleMetaData().getConfigurations();
- return null != configurations && !configurations.isEmpty();
+ Collection<RuleConfiguration> configs = metaData.getRuleMetaData().getConfigurations();
+ return null != configs && !configs.isEmpty();
}
private void initData(final Map<String, Collection<Object>> dataMap) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/SingleTableRulesQueryResultSet.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/SingleTableRulesQueryResultSet.java
index 866782e6885..00dff0cee5b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/SingleTableRulesQueryResultSet.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/SingleTableRulesQueryResultSet.java
@@ -38,9 +38,9 @@ public final class SingleTableRulesQueryResultSet implements DistSQLResultSet {
@Override
public void init(final ShardingSphereMetaData metaData, final SQLStatement sqlStatement) {
- Optional<SingleTableRuleConfiguration> ruleConfiguration = metaData.getRuleMetaData().getConfigurations().stream()
+ Optional<SingleTableRuleConfiguration> ruleConfig = metaData.getRuleMetaData().getConfigurations().stream()
.filter(each -> each instanceof SingleTableRuleConfiguration).map(each -> (SingleTableRuleConfiguration) each).findAny();
- ruleConfiguration.flatMap(SingleTableRuleConfiguration::getDefaultDataSource).ifPresent(optional -> data = Collections.singletonList(optional).iterator());
+ ruleConfig.flatMap(SingleTableRuleConfiguration::getDefaultDataSource).ifPresent(optional -> data = Collections.singletonList(optional).iterator());
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java
index 69df994cb6c..cbdb92dd548 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java
@@ -59,11 +59,10 @@ public final class ProxyConfigurationLoaderTest {
assertDataSourceConfiguration(actual.getDataSources().get("ds_0"), "jdbc:mysql://127.0.0.1:3306/ds_0");
assertDataSourceConfiguration(actual.getDataSources().get("ds_1"), "jdbc:mysql://127.0.0.1:3306/ds_1");
Optional<YamlShardingRuleConfiguration> shardingRuleConfig = actual.getRules().stream()
- .filter(each -> each instanceof YamlShardingRuleConfiguration).findFirst().map(config -> (YamlShardingRuleConfiguration) config);
+ .filter(each -> each instanceof YamlShardingRuleConfiguration).findFirst().map(each -> (YamlShardingRuleConfiguration) each);
assertTrue(shardingRuleConfig.isPresent());
assertShardingRuleConfiguration(shardingRuleConfig.get());
- assertFalse(actual.getRules().stream()
- .filter(each -> each instanceof YamlEncryptRuleConfiguration).findFirst().map(configuration -> (YamlEncryptRuleConfiguration) configuration).isPresent());
+ assertFalse(actual.getRules().stream().filter(each -> each instanceof YamlEncryptRuleConfiguration).findFirst().map(each -> (YamlEncryptRuleConfiguration) each).isPresent());
}
private void assertShardingRuleConfiguration(final YamlShardingRuleConfiguration actual) {
@@ -82,12 +81,10 @@ public final class ProxyConfigurationLoaderTest {
assertDataSourceConfiguration(actual.getDataSources().get("write_ds"), "jdbc:mysql://127.0.0.1:3306/write_ds");
assertDataSourceConfiguration(actual.getDataSources().get("read_ds_0"), "jdbc:mysql://127.0.0.1:3306/read_ds_0");
assertDataSourceConfiguration(actual.getDataSources().get("read_ds_1"), "jdbc:mysql://127.0.0.1:3306/read_ds_1");
- assertFalse(actual.getRules().stream()
- .filter(each -> each instanceof YamlShardingRuleConfiguration).findFirst().map(configuration -> (YamlShardingRuleConfiguration) configuration).isPresent());
- assertFalse(actual.getRules().stream()
- .filter(each -> each instanceof YamlEncryptRuleConfiguration).findFirst().map(configuration -> (YamlEncryptRuleConfiguration) configuration).isPresent());
+ assertFalse(actual.getRules().stream().filter(each -> each instanceof YamlShardingRuleConfiguration).findFirst().map(each -> (YamlShardingRuleConfiguration) each).isPresent());
+ assertFalse(actual.getRules().stream().filter(each -> each instanceof YamlEncryptRuleConfiguration).findFirst().map(each -> (YamlEncryptRuleConfiguration) each).isPresent());
Optional<YamlReadwriteSplittingRuleConfiguration> ruleConfig = actual.getRules().stream()
- .filter(each -> each instanceof YamlReadwriteSplittingRuleConfiguration).findFirst().map(configuration -> (YamlReadwriteSplittingRuleConfiguration) configuration);
+ .filter(each -> each instanceof YamlReadwriteSplittingRuleConfiguration).findFirst().map(each -> (YamlReadwriteSplittingRuleConfiguration) each);
assertTrue(ruleConfig.isPresent());
for (YamlReadwriteSplittingDataSourceRuleConfiguration each : ruleConfig.get().getDataSources().values()) {
assertReadwriteSplittingRuleConfiguration(each);
@@ -105,9 +102,9 @@ public final class ProxyConfigurationLoaderTest {
assertThat(actual.getDataSources().size(), is(1));
assertDataSourceConfiguration(actual.getDataSources().get("ds_0"), "jdbc:mysql://127.0.0.1:3306/encrypt_ds");
assertFalse(actual.getRules().stream()
- .filter(each -> each instanceof YamlShardingRuleConfiguration).findFirst().map(configuration -> (YamlShardingRuleConfiguration) configuration).isPresent());
+ .filter(each -> each instanceof YamlShardingRuleConfiguration).findFirst().map(each -> (YamlShardingRuleConfiguration) each).isPresent());
Optional<YamlEncryptRuleConfiguration> encryptRuleConfig = actual.getRules().stream()
- .filter(each -> each instanceof YamlEncryptRuleConfiguration).findFirst().map(configuration -> (YamlEncryptRuleConfiguration) configuration);
+ .filter(each -> each instanceof YamlEncryptRuleConfiguration).findFirst().map(each -> (YamlEncryptRuleConfiguration) each);
assertTrue(encryptRuleConfig.isPresent());
assertEncryptRuleConfiguration(encryptRuleConfig.get());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java
index bc70b22ad2c..c5e6d6680cd 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java
@@ -291,9 +291,9 @@ public final class DistSQLBackendHandlerFactoryTest {
}
private void mockScalingContext() {
- ModeConfiguration modeConfiguration = mock(ModeConfiguration.class);
- when(modeConfiguration.getType()).thenReturn("Cluster");
- PipelineContext.initModeConfig(modeConfiguration);
+ ModeConfiguration modeConfig = mock(ModeConfiguration.class);
+ when(modeConfig.getType()).thenReturn("Cluster");
+ PipelineContext.initModeConfig(modeConfig);
}
@After
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandlerTest.java
index 7c6a90d5b44..a0dc44d0d7f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandlerTest.java
@@ -58,8 +58,8 @@ public final class ShowAuthorityRuleHandlerTest {
private ShardingSphereRuleMetaData getGlobalRuleMetaData() {
ShardingSphereUser root = new ShardingSphereUser("root", "", "localhost");
- AuthorityRuleConfiguration authorityRuleConfiguration = new AuthorityRuleConfiguration(Collections.singletonList(root),
- new ShardingSphereAlgorithmConfiguration("ALL_PRIVILEGES_PERMITTED", new Properties()));
- return new ShardingSphereRuleMetaData(Collections.singleton(authorityRuleConfiguration), Collections.emptyList());
+ AuthorityRuleConfiguration ruleConfig = new AuthorityRuleConfiguration(
+ Collections.singletonList(root), new ShardingSphereAlgorithmConfiguration("ALL_PRIVILEGES_PERMITTED", new Properties()));
+ return new ShardingSphereRuleMetaData(Collections.singleton(ruleConfig), Collections.emptyList());
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandlerTest.java
index 69832c609c2..6370530fdf0 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandlerTest.java
@@ -63,7 +63,6 @@ public final class ShowSQLParserRuleHandlerTest {
private ShardingSphereRuleMetaData getGlobalRuleMetaData() {
CacheOption parseTreeCache = new CacheOption(128, 1024, 4);
CacheOption sqlStatementCache = new CacheOption(2000, 65535, 4);
- SQLParserRuleConfiguration sqlParserRuleConfiguration = new SQLParserRuleConfiguration(true, parseTreeCache, sqlStatementCache);
- return new ShardingSphereRuleMetaData(Collections.singleton(sqlParserRuleConfiguration), Collections.emptyList());
+ return new ShardingSphereRuleMetaData(Collections.singleton(new SQLParserRuleConfiguration(true, parseTreeCache, sqlStatementCache)), Collections.emptyList());
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java
index 5e3ae8126bb..1da43c5dbe0 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.queryable;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.queryable.ShowTransactionRuleStatement;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -73,8 +72,7 @@ public final class ShowTransactionRuleHandlerTest {
}
private ShardingSphereRuleMetaData getGlobalRuleMetaData(final String defaultType, final String providerType, final Properties props) {
- RuleConfiguration transactionRuleConfiguration = new TransactionRuleConfiguration(defaultType, providerType, props);
- return new ShardingSphereRuleMetaData(Collections.singleton(transactionRuleConfiguration), Collections.emptyList());
+ return new ShardingSphereRuleMetaData(Collections.singleton(new TransactionRuleConfiguration(defaultType, providerType, props)), Collections.emptyList());
}
private Properties getProperties() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandlerTest.java
index ef47d99aec0..7bc08819e88 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandlerTest.java
@@ -77,15 +77,14 @@ public final class DropTrafficRuleHandlerTest {
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
ProxyContext.getInstance().init(contextManager);
new DropTrafficRuleHandler().initStatement(getSQLStatement(Collections.singletonList("rule_name_1"), false)).execute();
- Optional<TrafficRuleConfiguration> ruleConfiguration = contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
- assertTrue(ruleConfiguration.isPresent());
- TrafficRuleConfiguration configuration = ruleConfiguration.get();
- assertThat(configuration.getTrafficStrategies().size(), is(1));
- assertThat(configuration.getLoadBalancers().size(), is(1));
- assertThat(configuration.getTrafficAlgorithms().size(), is(1));
- assertThat(new ArrayList<>(configuration.getTrafficStrategies()).get(0).getName(), is("rule_name_2"));
- assertNotNull(configuration.getTrafficAlgorithms().get("algorithm_2"));
- assertNotNull(configuration.getLoadBalancers().get("load_balancer_2"));
+ Optional<TrafficRuleConfiguration> ruleConfig = contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
+ assertTrue(ruleConfig.isPresent());
+ assertThat(ruleConfig.get().getTrafficStrategies().size(), is(1));
+ assertThat(ruleConfig.get().getLoadBalancers().size(), is(1));
+ assertThat(ruleConfig.get().getTrafficAlgorithms().size(), is(1));
+ assertThat(new ArrayList<>(ruleConfig.get().getTrafficStrategies()).get(0).getName(), is("rule_name_2"));
+ assertNotNull(ruleConfig.get().getTrafficAlgorithms().get("algorithm_2"));
+ assertNotNull(ruleConfig.get().getLoadBalancers().get("load_balancer_2"));
}
@Test
@@ -94,15 +93,14 @@ public final class DropTrafficRuleHandlerTest {
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
ProxyContext.getInstance().init(contextManager);
new DropTrafficRuleHandler().initStatement(getSQLStatement(Collections.singletonList("rule_name_1"), false)).execute();
- Optional<TrafficRuleConfiguration> ruleConfiguration = contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
- assertTrue(ruleConfiguration.isPresent());
- TrafficRuleConfiguration configuration = ruleConfiguration.get();
- assertThat(configuration.getTrafficStrategies().size(), is(1));
- assertThat(configuration.getLoadBalancers().size(), is(1));
- assertThat(configuration.getTrafficAlgorithms().size(), is(1));
- assertThat(new ArrayList<>(configuration.getTrafficStrategies()).get(0).getName(), is("rule_name_2"));
- assertNotNull(configuration.getTrafficAlgorithms().get("algorithm_2"));
- assertNotNull(configuration.getLoadBalancers().get("load_balancer_2"));
+ Optional<TrafficRuleConfiguration> ruleConfig = contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
+ assertTrue(ruleConfig.isPresent());
+ assertThat(ruleConfig.get().getTrafficStrategies().size(), is(1));
+ assertThat(ruleConfig.get().getLoadBalancers().size(), is(1));
+ assertThat(ruleConfig.get().getTrafficAlgorithms().size(), is(1));
+ assertThat(new ArrayList<>(ruleConfig.get().getTrafficStrategies()).get(0).getName(), is("rule_name_2"));
+ assertNotNull(ruleConfig.get().getTrafficAlgorithms().get("algorithm_2"));
+ assertNotNull(ruleConfig.get().getLoadBalancers().get("load_balancer_2"));
}
@Test
@@ -111,25 +109,24 @@ public final class DropTrafficRuleHandlerTest {
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
ProxyContext.getInstance().init(contextManager);
new DropTrafficRuleHandler().initStatement(getSQLStatement(Collections.singletonList("rule_name_3"), true)).execute();
- Optional<TrafficRuleConfiguration> ruleConfiguration = contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
- assertTrue(ruleConfiguration.isPresent());
- TrafficRuleConfiguration configuration = ruleConfiguration.get();
- assertThat(configuration.getTrafficStrategies().size(), is(2));
- assertThat(configuration.getLoadBalancers().size(), is(2));
- assertThat(configuration.getTrafficAlgorithms().size(), is(2));
+ Optional<TrafficRuleConfiguration> ruleConfig = contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
+ assertTrue(ruleConfig.isPresent());
+ assertThat(ruleConfig.get().getTrafficStrategies().size(), is(2));
+ assertThat(ruleConfig.get().getLoadBalancers().size(), is(2));
+ assertThat(ruleConfig.get().getTrafficAlgorithms().size(), is(2));
}
private Collection<RuleConfiguration> createTrafficRule() {
- TrafficRuleConfiguration trafficRuleConfiguration = new TrafficRuleConfiguration();
- trafficRuleConfiguration.getTrafficStrategies().add(new TrafficStrategyConfiguration("rule_name_1", Arrays.asList("olap", "order_by"), "algorithm_1", "load_balancer_1"));
- trafficRuleConfiguration.getTrafficStrategies().add(new TrafficStrategyConfiguration("rule_name_2", Collections.singletonList("oltp"), "algorithm_2", "load_balancer_2"));
+ TrafficRuleConfiguration trafficRuleConfig = new TrafficRuleConfiguration();
+ trafficRuleConfig.getTrafficStrategies().add(new TrafficStrategyConfiguration("rule_name_1", Arrays.asList("olap", "order_by"), "algorithm_1", "load_balancer_1"));
+ trafficRuleConfig.getTrafficStrategies().add(new TrafficStrategyConfiguration("rule_name_2", Collections.singletonList("oltp"), "algorithm_2", "load_balancer_2"));
Properties algorithmProperties = new Properties();
algorithmProperties.put("sql", "select * from t_order");
- trafficRuleConfiguration.getTrafficAlgorithms().put("algorithm_1", new ShardingSphereAlgorithmConfiguration("SQL_MATCH", algorithmProperties));
- trafficRuleConfiguration.getTrafficAlgorithms().put("algorithm_2", new ShardingSphereAlgorithmConfiguration("SQL_HINT", new Properties()));
- trafficRuleConfiguration.getLoadBalancers().put("load_balancer_1", new ShardingSphereAlgorithmConfiguration("RANDOM", new Properties()));
- trafficRuleConfiguration.getLoadBalancers().put("load_balancer_2", new ShardingSphereAlgorithmConfiguration("ROBIN", new Properties()));
- return Collections.singletonList(trafficRuleConfiguration);
+ trafficRuleConfig.getTrafficAlgorithms().put("algorithm_1", new ShardingSphereAlgorithmConfiguration("SQL_MATCH", algorithmProperties));
+ trafficRuleConfig.getTrafficAlgorithms().put("algorithm_2", new ShardingSphereAlgorithmConfiguration("SQL_HINT", new Properties()));
+ trafficRuleConfig.getLoadBalancers().put("load_balancer_1", new ShardingSphereAlgorithmConfiguration("RANDOM", new Properties()));
+ trafficRuleConfig.getLoadBalancers().put("load_balancer_2", new ShardingSphereAlgorithmConfiguration("ROBIN", new Properties()));
+ return Collections.singletonList(trafficRuleConfig);
}
private DropTrafficRuleStatement getSQLStatement(final Collection<String> ruleNames, final boolean containsIfExistClause) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/AlterDefaultSingleTableRuleUpdaterTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/AlterDefaultSingleTableRuleUpdaterTest.java
index 2a62b2af4db..3573e705745 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/AlterDefaultSingleTableRuleUpdaterTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/AlterDefaultSingleTableRuleUpdaterTest.java
@@ -35,6 +35,7 @@ import java.util.Optional;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -45,7 +46,7 @@ public final class AlterDefaultSingleTableRuleUpdaterTest {
private ShardingSphereMetaData shardingSphereMetaData;
@Mock
- private SingleTableRuleConfiguration currentConfiguration;
+ private SingleTableRuleConfiguration currentConfig;
private final AlterDefaultSingleTableRuleStatementUpdater updater = new AlterDefaultSingleTableRuleStatementUpdater();
@@ -64,20 +65,21 @@ public final class AlterDefaultSingleTableRuleUpdaterTest {
@Test(expected = RequiredResourceMissedException.class)
public void assertCheckWithInvalidResource() throws Exception {
AlterDefaultSingleTableRuleStatement statement = new AlterDefaultSingleTableRuleStatement("ds_1");
- updater.checkSQLStatement(shardingSphereMetaData, statement, currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, statement, currentConfig);
}
@Test(expected = RequiredRuleMissedException.class)
public void assertCheckWithNotExistResource() throws Exception {
- when(currentConfiguration.getDefaultDataSource()).thenReturn(Optional.empty());
+ when(currentConfig.getDefaultDataSource()).thenReturn(Optional.empty());
AlterDefaultSingleTableRuleStatement statement = new AlterDefaultSingleTableRuleStatement("ds_0");
- updater.checkSQLStatement(shardingSphereMetaData, statement, currentConfiguration);
+ updater.checkSQLStatement(shardingSphereMetaData, statement, currentConfig);
}
@Test
public void assertBuild() {
AlterDefaultSingleTableRuleStatement statement = new AlterDefaultSingleTableRuleStatement("ds_0");
SingleTableRuleConfiguration config = updater.buildToBeAlteredRuleConfiguration(statement);
+ assertTrue(config.getDefaultDataSource().isPresent());
assertThat(config.getDefaultDataSource().get(), is("ds_0"));
}
@@ -87,6 +89,7 @@ public final class AlterDefaultSingleTableRuleUpdaterTest {
SingleTableRuleConfiguration config = updater.buildToBeAlteredRuleConfiguration(statement);
SingleTableRuleConfiguration currentConfig = new SingleTableRuleConfiguration();
updater.updateCurrentRuleConfiguration(currentConfig, config);
+ assertTrue(currentConfig.getDefaultDataSource().isPresent());
assertThat(currentConfig.getDefaultDataSource().get(), is("ds_0"));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/CreateDefaultSingleTableRuleUpdaterTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/CreateDefaultSingleTableRuleUpdaterTest.java
index 5e4a5bc04ee..bdb84501b3d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/CreateDefaultSingleTableRuleUpdaterTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/CreateDefaultSingleTableRuleUpdaterTest.java
@@ -35,6 +35,7 @@ import java.util.Optional;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -47,7 +48,7 @@ public final class CreateDefaultSingleTableRuleUpdaterTest {
@Mock
private SingleTableRuleConfiguration currentConfig;
- private CreateDefaultSingleTableRuleStatementUpdater updater = new CreateDefaultSingleTableRuleStatementUpdater();
+ private final CreateDefaultSingleTableRuleStatementUpdater updater = new CreateDefaultSingleTableRuleStatementUpdater();
@Before
public void setUp() throws Exception {
@@ -71,16 +72,18 @@ public final class CreateDefaultSingleTableRuleUpdaterTest {
@Test
public void assertBuild() {
CreateDefaultSingleTableRuleStatement statement = new CreateDefaultSingleTableRuleStatement("ds_0");
- SingleTableRuleConfiguration configuration = updater.buildToBeCreatedRuleConfiguration(statement);
- assertThat(configuration.getDefaultDataSource().get(), is("ds_0"));
+ SingleTableRuleConfiguration toBeCreatedRuleConfig = updater.buildToBeCreatedRuleConfiguration(statement);
+ assertTrue(toBeCreatedRuleConfig.getDefaultDataSource().isPresent());
+ assertThat(toBeCreatedRuleConfig.getDefaultDataSource().get(), is("ds_0"));
}
@Test
public void assertUpdate() {
CreateDefaultSingleTableRuleStatement statement = new CreateDefaultSingleTableRuleStatement("ds_0");
- SingleTableRuleConfiguration configuration = updater.buildToBeCreatedRuleConfiguration(statement);
- SingleTableRuleConfiguration currentConfiguration = new SingleTableRuleConfiguration();
- updater.updateCurrentRuleConfiguration(currentConfiguration, configuration);
- assertThat(currentConfiguration.getDefaultDataSource().get(), is("ds_0"));
+ SingleTableRuleConfiguration toBeCreatedRuleConfig = updater.buildToBeCreatedRuleConfiguration(statement);
+ SingleTableRuleConfiguration currentConfig = new SingleTableRuleConfiguration();
+ updater.updateCurrentRuleConfiguration(currentConfig, toBeCreatedRuleConfig);
+ assertTrue(currentConfig.getDefaultDataSource().isPresent());
+ assertThat(currentConfig.getDefaultDataSource().get(), is("ds_0"));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/SingleTableRulesQueryResultSetTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/SingleTableRulesQueryResultSetTest.java
index e152f9a65f9..9bb98a361eb 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/SingleTableRulesQueryResultSetTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/SingleTableRulesQueryResultSetTest.java
@@ -46,9 +46,7 @@ public final class SingleTableRulesQueryResultSetTest {
@Before
public void before() {
- SingleTableRuleConfiguration configuration = new SingleTableRuleConfiguration();
- configuration.setDefaultDataSource("ds_0");
- when(shardingSphereMetaData.getRuleMetaData().getConfigurations()).thenReturn(Collections.singletonList(configuration));
+ when(shardingSphereMetaData.getRuleMetaData().getConfigurations()).thenReturn(Collections.singletonList(new SingleTableRuleConfiguration("ds_0")));
}
@Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java
index 22c1b9ff41f..cd92f5a5103 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java
@@ -151,9 +151,9 @@ public final class OpenGaussAuthenticationHandlerTest {
}
private ShardingSphereRuleMetaData buildGlobalRuleMetaData(final ShardingSphereUser user) {
- AuthorityRuleConfiguration authorityRuleConfiguration = new AuthorityRuleConfiguration(Collections.singletonList(user), new ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
- AuthorityRule rule = new AuthorityRuleBuilder().build(authorityRuleConfiguration, Collections.emptyMap());
- return new ShardingSphereRuleMetaData(Collections.singletonList(authorityRuleConfiguration), Collections.singleton(rule));
+ AuthorityRuleConfiguration ruleConfig = new AuthorityRuleConfiguration(Collections.singletonList(user), new ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
+ AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap());
+ return new ShardingSphereRuleMetaData(Collections.singletonList(ruleConfig), Collections.singleton(rule));
}
private String encodeDigest(final String password, final String random64code, final String token, final int serverIteration) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
index 53c3a4b28e5..bd393a2cde3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
@@ -181,9 +181,9 @@ public final class PostgreSQLAuthenticationEngineTest {
}
private ShardingSphereRuleMetaData buildGlobalRuleMetaData(final ShardingSphereUser user) {
- AuthorityRuleConfiguration authorityRuleConfiguration = new AuthorityRuleConfiguration(Collections.singletonList(user), new ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
- AuthorityRule rule = new AuthorityRuleBuilder().build(authorityRuleConfiguration, Collections.emptyMap());
- return new ShardingSphereRuleMetaData(Collections.singletonList(authorityRuleConfiguration), Collections.singletonList(rule));
+ AuthorityRuleConfiguration ruleConfig = new AuthorityRuleConfiguration(Collections.singletonList(user), new ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
+ AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap());
+ return new ShardingSphereRuleMetaData(Collections.singletonList(ruleConfig), Collections.singletonList(rule));
}
@SneakyThrows(ReflectiveOperationException.class)
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java
index c30eb52d29d..28504daa598 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java
@@ -167,9 +167,9 @@ public final class PostgreSQLAuthenticationHandlerTest {
}
private ShardingSphereRuleMetaData buildGlobalRuleMetaData(final ShardingSphereUser user) {
- AuthorityRuleConfiguration authorityRuleConfiguration = new AuthorityRuleConfiguration(Collections.singletonList(user), new ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
- AuthorityRule rule = new AuthorityRuleBuilder().build(authorityRuleConfiguration, Collections.emptyMap());
- return new ShardingSphereRuleMetaData(Collections.singletonList(authorityRuleConfiguration), Collections.singleton(rule));
+ AuthorityRuleConfiguration ruleConfig = new AuthorityRuleConfiguration(Collections.singletonList(user), new ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
+ AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap());
+ return new ShardingSphereRuleMetaData(Collections.singletonList(ruleConfig), Collections.singleton(rule));
}
@SneakyThrows(ReflectiveOperationException.class)
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/config/SourceConfiguration.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/config/SourceConfiguration.java
index 01f83e442be..7c0db2ee559 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/config/SourceConfiguration.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/config/SourceConfiguration.java
@@ -78,9 +78,9 @@ public final class SourceConfiguration {
dataSources.put("password", ENGINE_ENV_PROPS.getProperty("db.password"));
YamlRootConfiguration result = new YamlRootConfiguration();
result.setDataSources(Collections.singletonMap("ds_src", dataSources));
- YamlShardingRuleConfiguration shardingRuleConfiguration = new YamlShardingRuleConfiguration();
- shardingRuleConfiguration.setTables(tableRules);
- result.setRules(Collections.singleton(shardingRuleConfiguration));
+ YamlShardingRuleConfiguration shardingRuleConfig = new YamlShardingRuleConfiguration();
+ shardingRuleConfig.setTables(tableRules);
+ result.setRules(Collections.singleton(shardingRuleConfig));
return result;
}