This is an automated email from the ASF dual-hosted git repository.
panjuan 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 483c9d329e0 Refactor ShardingSphereRuleMetaData (#17857)
483c9d329e0 is described below
commit 483c9d329e032f3cafa35704773de32cfe568128
Author: Liang Zhang <[email protected]>
AuthorDate: Sun May 22 20:21:40 2022 +0800
Refactor ShardingSphereRuleMetaData (#17857)
---
.../DatabaseDiscoveryHeartbeatQueryResultSet.java | 2 +-
.../query/DatabaseDiscoveryTypeQueryResultSet.java | 2 +-
...tabaseDiscoveryHeartbeatQueryResultSetTest.java | 2 +-
...scoveryProviderAlgorithmQueryResultSetTest.java | 2 +-
.../handler/query/EncryptRuleQueryResultSet.java | 2 +-
.../query/EncryptRuleQueryResultSetTest.java | 2 +-
.../ReadwriteSplittingRuleQueryResultSet.java | 2 +-
...DropReadwriteSplittingRuleStatementUpdater.java | 2 +-
.../ReadwriteSplittingRuleQueryResultSetTest.java | 6 ++---
...ReadwriteSplittingRuleStatementUpdaterTest.java | 4 ++--
.../DefaultShardingStrategyQueryResultSet.java | 2 +-
.../query/ShardingKeyGeneratorsQueryResultSet.java | 2 +-
...rdingTableRulesUsedAlgorithmQueryResultSet.java | 2 +-
...ngTableRulesUsedKeyGeneratorQueryResultSet.java | 2 +-
...gDefaultShardingStrategyQueryResultSetTest.java | 4 ++--
.../ShardingKeyGeneratorsQueryResultSetTest.java | 2 +-
...gTableRulesUsedAlgorithmQueryResultSetTest.java | 2 +-
...bleRulesUsedKeyGeneratorQueryResultSetTest.java | 2 +-
.../metadata/rule/ShardingSphereRuleMetaData.java | 26 +++++++++++-----------
.../common/queryable/ShowAuthorityRuleHandler.java | 21 ++++++++---------
.../common/queryable/ShowSQLParserRuleHandler.java | 2 +-
.../common/queryable/ShowTrafficRulesHandler.java | 2 +-
.../queryable/ShowTransactionRuleHandler.java | 2 +-
.../updatable/AlterSQLParserRuleHandler.java | 2 +-
.../common/updatable/AlterTrafficRuleHandler.java | 2 +-
.../common/updatable/CreateTrafficRuleHandler.java | 2 +-
.../common/updatable/DropTrafficRuleHandler.java | 2 +-
.../SetReadwriteSplittingStatusHandler.java | 2 +-
.../queryable/ShowTrafficRulesHandlerTest.java | 2 +-
.../updatable/AlterSQLParserRuleHandlerTest.java | 23 +++++++------------
.../updatable/AlterTrafficRuleHandlerTest.java | 8 +++----
.../updatable/CreateTrafficRuleHandlerTest.java | 8 +++----
.../updatable/DropTrafficRuleHandlerTest.java | 18 +++++++--------
33 files changed, 80 insertions(+), 86 deletions(-)
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 6a1931c83b5..11f6ca601c2 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,7 +40,7 @@ public final class DatabaseDiscoveryHeartbeatQueryResultSet
implements DistSQLRe
@Override
public void init(final ShardingSphereDatabase database, final SQLStatement
sqlStatement) {
- Collection<DatabaseDiscoveryRuleConfiguration> ruleConfig =
database.getRuleMetaData().findRuleConfiguration(DatabaseDiscoveryRuleConfiguration.class);
+ Collection<DatabaseDiscoveryRuleConfiguration> ruleConfig =
database.getRuleMetaData().findRuleConfigurations(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 6609c902ca2..f232a84f9c3 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,7 +40,7 @@ public final class DatabaseDiscoveryTypeQueryResultSet
implements DistSQLResultS
@Override
public void init(final ShardingSphereDatabase database, final SQLStatement
sqlStatement) {
- Collection<DatabaseDiscoveryRuleConfiguration> ruleConfig =
database.getRuleMetaData().findRuleConfiguration(DatabaseDiscoveryRuleConfiguration.class);
+ Collection<DatabaseDiscoveryRuleConfiguration> ruleConfig =
database.getRuleMetaData().findRuleConfigurations(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/query/DatabaseDiscoveryHeartbeatQueryResultSetTest.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/query/DatabaseDiscover
[...]
index af3899c79b9..c4310b4a2ef 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/query/DatabaseDiscoveryHeartbeatQueryResultSetTest.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/query/DatabaseDiscoveryHeartbeatQueryResultSetTest.java
@@ -46,7 +46,7 @@ public final class
DatabaseDiscoveryHeartbeatQueryResultSetTest {
@Test
public void assertGetRowData() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
-
when(database.getRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createRuleConfiguration()));
+
when(database.getRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createRuleConfiguration()));
DistSQLResultSet resultSet = new
DatabaseDiscoveryHeartbeatQueryResultSet();
resultSet.init(database,
mock(ShowDatabaseDiscoveryRulesStatement.class));
Collection<String> columnNames = resultSet.getColumnNames();
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/query/DatabaseDiscoveryProviderAlgorithmQueryResultSetTest.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/query/Database
[...]
index 99dcb07945b..f2df000b305 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/query/DatabaseDiscoveryProviderAlgorithmQueryResultSetTest.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/query/DatabaseDiscoveryProviderAlgorithmQueryResultSetTest.java
@@ -46,7 +46,7 @@ public final class
DatabaseDiscoveryProviderAlgorithmQueryResultSetTest {
@Test
public void assertGetRowData() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
-
when(database.getRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createRuleConfiguration()));
+
when(database.getRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createRuleConfiguration()));
DistSQLResultSet resultSet = new DatabaseDiscoveryTypeQueryResultSet();
resultSet.init(database,
mock(ShowDatabaseDiscoveryRulesStatement.class));
Collection<String> columnNames = resultSet.getColumnNames();
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 a4029a33216..59f67f28496 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,7 +45,7 @@ public final class EncryptRuleQueryResultSet implements
DistSQLResultSet {
@Override
public void init(final ShardingSphereDatabase database, final SQLStatement
sqlStatement) {
- Optional<EncryptRuleConfiguration> ruleConfig =
database.getRuleMetaData().findRuleConfiguration(EncryptRuleConfiguration.class).stream().findAny();
+ Optional<EncryptRuleConfiguration> ruleConfig =
database.getRuleMetaData().findRuleConfigurations(EncryptRuleConfiguration.class).stream().findAny();
ruleConfig.ifPresent(optional -> data = buildData(optional,
(ShowEncryptRulesStatement) sqlStatement).iterator());
}
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptRuleQueryResultSetTest.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptRuleQueryResultSetTest.java
index 631fa35bba1..08478a185a7 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptRuleQueryResultSetTest.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptRuleQueryResultSetTest.java
@@ -44,7 +44,7 @@ public final class EncryptRuleQueryResultSetTest {
@Test
public void assertGetRowData() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
-
when(database.getRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(getRuleConfiguration()));
+
when(database.getRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(getRuleConfiguration()));
DistSQLResultSet resultSet = new EncryptRuleQueryResultSet();
resultSet.init(database, mock(ShowEncryptRulesStatement.class));
Collection<Object> actual = resultSet.getRowData();
diff --git
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ReadwriteSplittingRuleQueryResultSet.java
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwrite
[...]
index bff1422f728..c446b0e3905 100644
---
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ReadwriteSplittingRuleQueryResultSet.java
+++
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ReadwriteSplittingRuleQueryResultSet.java
@@ -51,7 +51,7 @@ public final class ReadwriteSplittingRuleQueryResultSet
implements DistSQLResult
@Override
public void init(final ShardingSphereDatabase database, final SQLStatement
sqlStatement) {
- Optional<ReadwriteSplittingRuleConfiguration> ruleConfig =
database.getRuleMetaData().findRuleConfiguration(ReadwriteSplittingRuleConfiguration.class).stream().findAny();
+ Optional<ReadwriteSplittingRuleConfiguration> ruleConfig =
database.getRuleMetaData().findRuleConfigurations(ReadwriteSplittingRuleConfiguration.class).stream().findAny();
buildExportableMap(database);
ruleConfig.ifPresent(optional -> data =
buildData(optional).iterator());
}
diff --git
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleStatementUpdater.java
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/re
[...]
index cefbfebaa41..5dbd5dda9f8 100644
---
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleStatementUpdater.java
+++
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleStatementUpdater.java
@@ -68,7 +68,7 @@ public final class DropReadwriteSplittingRuleStatementUpdater
implements RuleDef
}
private void checkToBeDroppedInUsed(final String databaseName, final
DropReadwriteSplittingRuleStatement sqlStatement, final ShardingSphereDatabase
database) throws RuleInUsedException {
- Collection<String> resourceBeUsed =
database.getRuleMetaData().findRuleConfiguration(ResourceRequiredRuleConfiguration.class).stream()
+ Collection<String> resourceBeUsed =
database.getRuleMetaData().findRuleConfigurations(ResourceRequiredRuleConfiguration.class).stream()
.map(ResourceRequiredRuleConfiguration::getRequiredResource).flatMap(Collection::stream).collect(Collectors.toSet());
Collection<String> ruleInUsed =
sqlStatement.getRuleNames().stream().filter(resourceBeUsed::contains).collect(Collectors.toSet());
if (!ruleInUsed.isEmpty()) {
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/query/ReadwriteSplittingRuleQueryResultSetTest.java
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingsphere/readw
[...]
index 418de31197b..f33c1f2112e 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/query/ReadwriteSplittingRuleQueryResultSetTest.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/query/ReadwriteSplittingRuleQueryResultSetTest.java
@@ -50,7 +50,7 @@ public final class ReadwriteSplittingRuleQueryResultSetTest {
ExportableRule exportableRule = mock(ExportableRule.class);
when(database.getRuleMetaData().findRules(any())).thenReturn(Collections.singletonList(exportableRule));
when(exportableRule.export(anyCollection())).thenReturn(Collections.emptyMap());
-
when(database.getRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createRuleConfiguration()));
+
when(database.getRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createRuleConfiguration()));
ReadwriteSplittingRuleQueryResultSet resultSet = new
ReadwriteSplittingRuleQueryResultSet();
resultSet.init(database,
mock(ShowReadwriteSplittingRulesStatement.class));
Collection<Object> actual = resultSet.getRowData();
@@ -76,7 +76,7 @@ public final class ReadwriteSplittingRuleQueryResultSetTest {
ExportableRule exportableRule = mock(ExportableRule.class);
when(database.getRuleMetaData().findRules(any())).thenReturn(Collections.singletonList(exportableRule));
when(exportableRule.export(anyCollection())).thenReturn(Collections.emptyMap());
-
when(database.getRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createRuleConfigurationWithoutLoadBalancer()));
+
when(database.getRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createRuleConfigurationWithoutLoadBalancer()));
ReadwriteSplittingRuleQueryResultSet resultSet = new
ReadwriteSplittingRuleQueryResultSet();
resultSet.init(database,
mock(ShowReadwriteSplittingRulesStatement.class));
Collection<Object> actual = resultSet.getRowData();
@@ -107,7 +107,7 @@ public final class ReadwriteSplittingRuleQueryResultSetTest
{
when(database.getRuleMetaData().findRules(any())).thenReturn(Collections.singletonList(exportableRule));
when(exportableRule.export(anyCollection())).thenReturn(
Collections.singletonMap(ExportableConstants.EXPORTABLE_KEY_AUTO_AWARE_DATA_SOURCE,
Collections.singletonMap("readwrite_ds", getAutoAwareDataSources())));
-
when(database.getRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createRuleConfigurationWithAutoAwareDataSource()));
+
when(database.getRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createRuleConfigurationWithAutoAwareDataSource()));
ReadwriteSplittingRuleQueryResultSet resultSet = new
ReadwriteSplittingRuleQueryResultSet();
resultSet.init(database,
mock(ShowReadwriteSplittingRulesStatement.class));
Collection<Object> actual = resultSet.getRowData();
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/update/DropReadwriteSplittingRuleStatementUpdaterTest.java
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/test/java/org/apache/shardingspher
[...]
index 667af1c2115..9232aa7fa1c 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/update/DropReadwriteSplittingRuleStatementUpdaterTest.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/update/DropReadwriteSplittingRuleStatementUpdaterTest.java
@@ -65,7 +65,7 @@ public final class
DropReadwriteSplittingRuleStatementUpdaterTest {
@Test
public void assertCheckSQLStatementWithIfExists() throws
RuleDefinitionViolationException {
-
when(database.getRuleMetaData().findRuleConfiguration(ResourceRequiredRuleConfiguration.class)).thenReturn(Collections.emptyList());
+
when(database.getRuleMetaData().findRuleConfigurations(ResourceRequiredRuleConfiguration.class)).thenReturn(Collections.emptyList());
updater.checkSQLStatement(database, new
DropReadwriteSplittingRuleStatement(true,
Collections.singleton("readwrite_ds")),
new
ReadwriteSplittingRuleConfiguration(Collections.emptyList(),
Collections.emptyMap()));
updater.checkSQLStatement(database, new
DropReadwriteSplittingRuleStatement(true,
Collections.singleton("readwrite_ds")), null);
@@ -73,7 +73,7 @@ public final class
DropReadwriteSplittingRuleStatementUpdaterTest {
@Test(expected = RuleInUsedException.class)
public void assertCheckSQLStatementWithInUsed() throws
RuleDefinitionViolationException {
- when(database.getRuleMetaData().findRuleConfiguration(any()))
+ when(database.getRuleMetaData().findRuleConfigurations(any()))
.thenReturn(Collections.singletonList((ResourceRequiredRuleConfiguration) () ->
Collections.singleton("readwrite_ds")));
updater.checkSQLStatement(database, createSQLStatement(),
createCurrentRuleConfiguration());
}
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 9511b62aafb..88392f84288 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
@@ -45,7 +45,7 @@ public final class DefaultShardingStrategyQueryResultSet
implements DistSQLResul
@Override
public void init(final ShardingSphereDatabase database, final SQLStatement
sqlStatement) {
- Optional<ShardingRuleConfiguration> shardingRuleConfig =
database.getRuleMetaData().findRuleConfiguration(ShardingRuleConfiguration.class).stream().findAny();
+ Optional<ShardingRuleConfiguration> shardingRuleConfig =
database.getRuleMetaData().findRuleConfigurations(ShardingRuleConfiguration.class).stream().findAny();
shardingRuleConfig.ifPresent(optional -> data =
buildData(optional).entrySet().iterator());
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingKeyGeneratorsQueryResultSet.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingKeyGeneratorsQueryResultSet.java
index 389efb0be5f..35a7a24e74e 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingKeyGeneratorsQueryResultSet.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingKeyGeneratorsQueryResultSet.java
@@ -40,7 +40,7 @@ public final class ShardingKeyGeneratorsQueryResultSet
implements DistSQLResultS
@Override
public void init(final ShardingSphereDatabase database, final SQLStatement
sqlStatement) {
-
database.getRuleMetaData().findRuleConfiguration(ShardingRuleConfiguration.class)
+
database.getRuleMetaData().findRuleConfigurations(ShardingRuleConfiguration.class)
.forEach(each -> data =
each.getKeyGenerators().entrySet().iterator());
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRulesUsedAlgorithmQueryResultSet.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRulesUsedAlgorithmQueryResultSet.java
index 2c7da1a11fd..b19691b8eec 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRulesUsedAlgorithmQueryResultSet.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRulesUsedAlgorithmQueryResultSet.java
@@ -40,7 +40,7 @@ public final class
ShardingTableRulesUsedAlgorithmQueryResultSet implements Dist
public void init(final ShardingSphereDatabase database, final SQLStatement
sqlStatement) {
ShowShardingTableRulesUsedAlgorithmStatement statement =
(ShowShardingTableRulesUsedAlgorithmStatement) sqlStatement;
Collection<Collection<Object>> data = new LinkedList<>();
- Collection<ShardingRuleConfiguration> shardingTableRules =
database.getRuleMetaData().findRuleConfiguration(ShardingRuleConfiguration.class);
+ Collection<ShardingRuleConfiguration> shardingTableRules =
database.getRuleMetaData().findRuleConfigurations(ShardingRuleConfiguration.class);
shardingTableRules.forEach(each -> requireResult(statement,
database.getName(), data, each));
this.data = data.iterator();
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRulesUsedKeyGeneratorQueryResultSet.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRulesUsedKeyGeneratorQueryRes
[...]
index 9533a0a923f..fea4bd2bfc4 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRulesUsedKeyGeneratorQueryResultSet.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRulesUsedKeyGeneratorQueryResultSet.java
@@ -41,7 +41,7 @@ public final class
ShardingTableRulesUsedKeyGeneratorQueryResultSet implements D
public void init(final ShardingSphereDatabase database, final SQLStatement
sqlStatement) {
ShowShardingTableRulesUsedKeyGeneratorStatement statement =
(ShowShardingTableRulesUsedKeyGeneratorStatement) sqlStatement;
List<Collection<Object>> result = new ArrayList<>();
- Collection<ShardingRuleConfiguration> shardingTableRules =
database.getRuleMetaData().findRuleConfiguration(ShardingRuleConfiguration.class);
+ Collection<ShardingRuleConfiguration> shardingTableRules =
database.getRuleMetaData().findRuleConfigurations(ShardingRuleConfiguration.class);
shardingTableRules.forEach(each -> requireResult(statement,
database.getName(), result, each));
data = result.iterator();
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShardingDefaultShardingStrategyQueryResultSetTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShardingDefaultShardingStrategyQueryResultSetTest.java
index 5a9d1465992..2daefd578bf 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShardingDefaultShardingStrategyQueryResultSetTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShardingDefaultShardingStrategyQueryResultSetTest.java
@@ -46,7 +46,7 @@ public final class
ShardingDefaultShardingStrategyQueryResultSetTest {
@Test
public void assertGetRowData() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
-
when(database.getRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createRuleConfiguration1()));
+
when(database.getRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createRuleConfiguration1()));
DefaultShardingStrategyQueryResultSet resultSet = new
DefaultShardingStrategyQueryResultSet();
resultSet.init(database, mock(ShowShardingAlgorithmsStatement.class));
List<Object> actual = new ArrayList<>(resultSet.getRowData());
@@ -65,7 +65,7 @@ public final class
ShardingDefaultShardingStrategyQueryResultSetTest {
assertThat(actual.get(3), is("database_inline"));
assertThat(actual.get(4), is("INLINE"));
assertThat(actual.get(5).toString(),
is("{algorithm-expression=ds_${user_id % 2}}"));
-
when(database.getRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createRuleConfiguration2()));
+
when(database.getRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createRuleConfiguration2()));
resultSet = new DefaultShardingStrategyQueryResultSet();
resultSet.init(database, mock(ShowShardingAlgorithmsStatement.class));
actual = new ArrayList<>(resultSet.getRowData());
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShardingKeyGeneratorsQueryResultSetTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShardingKeyGeneratorsQueryResultSetTest.java
index d39580b677f..65b20d6e2f5 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShardingKeyGeneratorsQueryResultSetTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShardingKeyGeneratorsQueryResultSetTest.java
@@ -41,7 +41,7 @@ public final class ShardingKeyGeneratorsQueryResultSetTest {
@Test
public void assertGetRowData() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
-
when(database.getRuleMetaData().findRuleConfiguration(ShardingRuleConfiguration.class)).thenReturn(createRuleConfigurations());
+
when(database.getRuleMetaData().findRuleConfigurations(ShardingRuleConfiguration.class)).thenReturn(createRuleConfigurations());
ShardingKeyGeneratorsQueryResultSet resultSet = new
ShardingKeyGeneratorsQueryResultSet();
resultSet.init(database,
mock(ShowShardingKeyGeneratorsStatement.class));
List<Object> actual = new ArrayList<>(resultSet.getRowData());
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedAlgorithmQueryResultSetTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedAlgorithmQueryResultSetTest.java
index 9cf2f171fd2..901531b51d5 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedAlgorithmQueryResultSetTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedAlgorithmQueryResultSetTest.java
@@ -47,7 +47,7 @@ public final class
ShowShardingTableRulesUsedAlgorithmQueryResultSetTest {
@Test
public void assertGetRowData() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
-
when(database.getRuleMetaData().findRuleConfiguration(ShardingRuleConfiguration.class)).thenReturn(Collections.singleton(createRuleConfiguration()));
+
when(database.getRuleMetaData().findRuleConfigurations(ShardingRuleConfiguration.class)).thenReturn(Collections.singleton(createRuleConfiguration()));
when(database.getName()).thenReturn("sharding_db");
DistSQLResultSet resultSet = new
ShardingTableRulesUsedAlgorithmQueryResultSet();
ShowShardingTableRulesUsedAlgorithmStatement statement =
mock(ShowShardingTableRulesUsedAlgorithmStatement.class);
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedKeyGeneratorQueryResultSetTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedKeyGeneratorQueryResultS
[...]
index 1d46d887791..304461d4a65 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedKeyGeneratorQueryResultSetTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedKeyGeneratorQueryResultSetTest.java
@@ -47,7 +47,7 @@ public final class
ShowShardingTableRulesUsedKeyGeneratorQueryResultSetTest {
@Test
public void assertGetRowData() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
-
when(database.getRuleMetaData().findRuleConfiguration(ShardingRuleConfiguration.class)).thenReturn(Collections.singleton(createRuleConfiguration()));
+
when(database.getRuleMetaData().findRuleConfigurations(ShardingRuleConfiguration.class)).thenReturn(Collections.singleton(createRuleConfiguration()));
when(database.getName()).thenReturn("sharding_db");
DistSQLResultSet resultSet = new
ShardingTableRulesUsedKeyGeneratorQueryResultSet();
ShowShardingTableRulesUsedKeyGeneratorStatement statement =
mock(ShowShardingTableRulesUsedKeyGeneratorStatement.class);
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/rule/ShardingSphereRuleMetaData.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/rule/ShardingSphereRuleMetaData.java
index 73a3a0d84a1..e7ff03d3119 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/rule/ShardingSphereRuleMetaData.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/rule/ShardingSphereRuleMetaData.java
@@ -62,7 +62,7 @@ public final class ShardingSphereRuleMetaData {
* @param <T> type of rule configuration
* @return found rule configurations
*/
- public <T extends RuleConfiguration> Collection<T>
findRuleConfiguration(final Class<T> clazz) {
+ public <T extends RuleConfiguration> Collection<T>
findRuleConfigurations(final Class<T> clazz) {
Collection<T> result = new LinkedList<>();
for (RuleConfiguration each : configurations) {
if (clazz.isAssignableFrom(each.getClass())) {
@@ -72,18 +72,6 @@ public final class ShardingSphereRuleMetaData {
return result;
}
- /**
- * Find single rule configuration by class.
- *
- * @param clazz target class
- * @param <T> type of rule configuration
- * @return found rule configuration
- */
- public <T extends RuleConfiguration> Optional<T>
findSingleRuleConfiguration(final Class<T> clazz) {
- Collection<T> foundRuleConfig = findRuleConfiguration(clazz);
- return foundRuleConfig.isEmpty() ? Optional.empty() :
Optional.of(foundRuleConfig.iterator().next());
- }
-
/**
* Find single rule by class.
*
@@ -95,4 +83,16 @@ public final class ShardingSphereRuleMetaData {
Collection<T> foundRules = findRules(clazz);
return foundRules.isEmpty() ? Optional.empty() :
Optional.of(foundRules.iterator().next());
}
+
+ /**
+ * Find single rule configuration by class.
+ *
+ * @param clazz target class
+ * @param <T> type of rule configuration
+ * @return found rule configuration
+ */
+ public <T extends RuleConfiguration> Optional<T>
findSingleRuleConfiguration(final Class<T> clazz) {
+ Collection<T> foundRuleConfig = findRuleConfigurations(clazz);
+ return foundRuleConfig.isEmpty() ? Optional.empty() :
Optional.of(foundRuleConfig.iterator().next());
+ }
}
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 9ee3d1588a1..47170279b4e 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
@@ -49,18 +49,19 @@ public final class ShowAuthorityRuleHandler extends
QueryableRALBackendHandler<S
@Override
protected Collection<List<Object>> getRows(final ContextManager
contextManager) {
- Optional<AuthorityRuleConfiguration>
authorityRuleConfigurationOptional =
ProxyContext.getInstance().getContextManager()
-
.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(AuthorityRuleConfiguration.class).stream().findFirst();
- if (!authorityRuleConfigurationOptional.isPresent()) {
+ Optional<AuthorityRuleConfiguration> authorityRuleConfig =
ProxyContext.getInstance().getContextManager()
+
.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(AuthorityRuleConfiguration.class).stream().findFirst();
+ if (!authorityRuleConfig.isPresent()) {
return Collections.emptyList();
}
- AuthorityRuleConfiguration ruleConfig =
authorityRuleConfigurationOptional.get();
- List<Object> row = new LinkedList<>();
- 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 Collections.singleton(getRow(authorityRuleConfig.get()));
+ }
+
+ private List<Object> getRow(final AuthorityRuleConfiguration
authorityRuleConfig) {
+ List<Object> result = new LinkedList<>();
+ result.add(authorityRuleConfig.getUsers().stream().map(each ->
each.getGrantee().toString()).collect(Collectors.joining("; ")));
+ result.add(authorityRuleConfig.getProvider().getType());
+ result.add(authorityRuleConfig.getProvider().getProps().size() == 0 ?
"" : authorityRuleConfig.getProvider().getProps());
return result;
}
}
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 9767ae6929a..6f817a5670e 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
@@ -52,7 +52,7 @@ public final class ShowSQLParserRuleHandler extends
QueryableRALBackendHandler<S
@Override
protected Collection<List<Object>> getRows(final ContextManager
contextManager) {
Optional<SQLParserRuleConfiguration>
sqlParserRuleConfigurationOptional =
ProxyContext.getInstance().getContextManager()
-
.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(SQLParserRuleConfiguration.class).stream().findAny();
+
.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(SQLParserRuleConfiguration.class).stream().findAny();
if (!sqlParserRuleConfigurationOptional.isPresent()) {
return Collections.emptyList();
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandler.java
index c8969fa63f6..67f1e6cf0e3 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandler.java
@@ -60,7 +60,7 @@ public final class ShowTrafficRulesHandler extends
QueryableRALBackendHandler<Sh
@Override
protected Collection<List<Object>> getRows(final ContextManager
contextManager) {
Optional<TrafficRuleConfiguration> config =
ProxyContext.getInstance().getContextManager().getMetaDataContexts()
-
.getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
+
.getGlobalRuleMetaData().findRuleConfigurations(TrafficRuleConfiguration.class).stream().findAny();
Collection<List<Object>> result = new LinkedList<>();
Optional<String> ruleName =
Optional.ofNullable(sqlStatement.getRuleName());
config.ifPresent(optional -> {
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 9086feed225..f5e029ca55b 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
@@ -52,7 +52,7 @@ public final class ShowTransactionRuleHandler extends
QueryableRALBackendHandler
@Override
protected Collection<List<Object>> getRows(final ContextManager
contextManager) {
Optional<TransactionRuleConfiguration> ruleConfig =
ProxyContext.getInstance().getContextManager()
-
.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TransactionRuleConfiguration.class).stream().findAny();
+
.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(TransactionRuleConfiguration.class).stream().findAny();
if (!ruleConfig.isPresent()) {
return Collections.emptyList();
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandler.java
index 4b69509a6b5..e060a17a348 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandler.java
@@ -47,7 +47,7 @@ public final class AlterSQLParserRuleHandler extends
UpdatableRALBackendHandler<
}
private Optional<SQLParserRuleConfiguration> findCurrentConfiguration() {
- return
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(SQLParserRuleConfiguration.class).stream().findAny();
+ return
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(SQLParserRuleConfiguration.class).stream().findAny();
}
private SQLParserRuleConfiguration createSQLParserRuleConfiguration(final
SQLParserRuleConfiguration currentConfig) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandler.java
index 475669fabf5..f113eac663a 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandler.java
@@ -54,7 +54,7 @@ public final class AlterTrafficRuleHandler extends
UpdatableRALBackendHandler<Al
}
private Optional<TrafficRuleConfiguration> findCurrentConfiguration() {
- return
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
+ return
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(TrafficRuleConfiguration.class).stream().findAny();
}
private void check(final AlterTrafficRuleStatement sqlStatement, final
TrafficRuleConfiguration currentConfig) throws DistSQLException {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandler.java
index cd0f2cce1cb..87e61f24143 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandler.java
@@ -48,7 +48,7 @@ public final class CreateTrafficRuleHandler extends
UpdatableRALBackendHandler<C
@Override
protected void update(final ContextManager contextManager, final
CreateTrafficRuleStatement sqlStatement) throws DistSQLException {
Optional<TrafficRuleConfiguration> trafficRuleConfig =
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData()
-
.findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
+
.findRuleConfigurations(TrafficRuleConfiguration.class).stream().findAny();
if (trafficRuleConfig.isPresent()) {
checkTrafficRuleConfiguration(sqlStatement,
trafficRuleConfig.get());
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandler.java
index a33d92aad8d..885a8b7d92a 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandler.java
@@ -41,7 +41,7 @@ public final class DropTrafficRuleHandler extends
UpdatableRALBackendHandler<Dro
@Override
protected void update(final ContextManager contextManager, final
DropTrafficRuleStatement sqlStatement) throws DistSQLException {
Optional<TrafficRuleConfiguration> config =
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData()
-
.findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
+
.findRuleConfigurations(TrafficRuleConfiguration.class).stream().findAny();
if (!sqlStatement.isContainsIfExistClause()) {
DistSQLException.predictionThrow(config.isPresent(), () -> new
RequiredRuleMissedException("Traffic"));
checkTrafficRuleConfiguration(sqlStatement, config.get());
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetReadwriteSplittingStatusHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetReadwriteSplittingStatusHandler.java
index 1ec3d9ae56d..e3e5ef6fb20 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetReadwriteSplittingStatusHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetReadwriteSplittingStatusHandler.java
@@ -87,7 +87,7 @@ public final class SetReadwriteSplittingStatusHandler extends
UpdatableRALBacken
private ReadwriteSplittingRuleConfiguration
checkReadwriteSplittingRule(final ContextManager contextManager, final String
databaseName) {
Optional<ReadwriteSplittingRuleConfiguration> result =
contextManager.getMetaDataContexts().getDatabaseMetaData(databaseName)
-
.getRuleMetaData().findRuleConfiguration(ReadwriteSplittingRuleConfiguration.class).stream().findAny();
+
.getRuleMetaData().findRuleConfigurations(ReadwriteSplittingRuleConfiguration.class).stream().findAny();
if (!result.isPresent()) {
throw new UnsupportedOperationException("The current schema has no
read_write splitting rules");
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java
index 5a95bff418e..b1afe3e04c4 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java
@@ -50,7 +50,7 @@ public class ShowTrafficRulesHandlerTest extends
ProxyContextRestorer {
showTrafficRuleStatement.setRuleName("rule_name_1");
ShowTrafficRulesHandler handler = new
ShowTrafficRulesHandler().initStatement(showTrafficRuleStatement);
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(createTrafficRule());
ProxyContext.init(contextManager);
handler.execute();
handler.next();
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandlerTest.java
index 8a50b3a0a96..d3da8a8d498 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandlerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandlerTest.java
@@ -26,8 +26,6 @@ import
org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigu
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.util.ProxyContextRestorer;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
import java.sql.SQLException;
import java.util.Collection;
@@ -41,16 +39,15 @@ import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public final class AlterSQLParserRuleHandlerTest extends ProxyContextRestorer {
@Test
public void assertExecuteWithoutCurrentRuleConfiguration() throws
SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(SQLParserRuleConfiguration.class)).thenReturn(Collections.emptyList());
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(SQLParserRuleConfiguration.class)).thenReturn(Collections.emptyList());
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().getConfigurations()).thenReturn(new
LinkedList<>());
ProxyContext.init(contextManager);
- new
AlterSQLParserRuleHandler().initStatement(getSQLStatement()).execute();
+ new
AlterSQLParserRuleHandler().initStatement(createSQLStatement()).execute();
SQLParserRuleConfiguration actual = (SQLParserRuleConfiguration)
contextManager.getMetaDataContexts().getGlobalRuleMetaData().getConfigurations().iterator().next();
assertTrue(actual.isSqlCommentParseEnabled());
assertThat(actual.getSqlStatementCache().getInitialCapacity(),
is(1000));
@@ -64,10 +61,10 @@ public final class AlterSQLParserRuleHandlerTest extends
ProxyContextRestorer {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
SQLParserRuleConfiguration sqlParserRuleConfig = new
DefaultSQLParserRuleConfigurationBuilder().build();
Collection<RuleConfiguration> globalRuleConfigs = new
LinkedList<>(Collections.singleton(sqlParserRuleConfig));
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(SQLParserRuleConfiguration.class)).thenReturn(Collections.singleton(sqlParserRuleConfig));
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(SQLParserRuleConfiguration.class)).thenReturn(Collections.singleton(sqlParserRuleConfig));
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().getConfigurations()).thenReturn(globalRuleConfigs);
ProxyContext.init(contextManager);
- new
AlterSQLParserRuleHandler().initStatement(getSQLStatement()).execute();
+ new
AlterSQLParserRuleHandler().initStatement(createSQLStatement()).execute();
SQLParserRuleConfiguration actual = (SQLParserRuleConfiguration)
contextManager.getMetaDataContexts().getGlobalRuleMetaData().getConfigurations().iterator().next();
assertTrue(actual.isSqlCommentParseEnabled());
assertThat(actual.getSqlStatementCache().getInitialCapacity(),
is(1000));
@@ -76,15 +73,11 @@ public final class AlterSQLParserRuleHandlerTest extends
ProxyContextRestorer {
assertThat(actual.getParseTreeCache().getMaximumSize(), is(512L));
}
- private AlterSQLParserRuleStatement getSQLStatement() {
+ private AlterSQLParserRuleStatement createSQLStatement() {
AlterSQLParserRuleStatement result = new AlterSQLParserRuleStatement();
- result.setSqlCommentParseEnable(Boolean.TRUE);
- result.setSqlStatementCache(getCacheOption(1000, 1000L));
- result.setParseTreeCache(getCacheOption(64, 512L));
+ result.setSqlCommentParseEnable(true);
+ result.setSqlStatementCache(new CacheOptionSegment(1000, 1000L));
+ result.setParseTreeCache(new CacheOptionSegment(64, 512L));
return result;
}
-
- private CacheOptionSegment getCacheOption(final Integer initialCapacity,
final Long maximumSize) {
- return new CacheOptionSegment(initialCapacity, maximumSize);
- }
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java
index 8c3558ec237..965e8ebb4eb 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java
@@ -48,7 +48,7 @@ public final class AlterTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test(expected = RequiredRuleMissedException.class)
public void assertCheckWithEmptyRule() throws SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(new
LinkedList<>());
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(new
LinkedList<>());
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new
TrafficRuleSegment("input_rule_name", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("invalid", new Properties()), new
AlgorithmSegment("invalid", new Properties()));
@@ -58,7 +58,7 @@ public final class AlterTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test(expected = InvalidAlgorithmConfigurationException.class)
public void assertCheckWithInvalidAlgorithmType() throws SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(createTrafficRule());
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new
TrafficRuleSegment("rule_name_1", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("invalid", new Properties()), new
AlgorithmSegment("invalid", new Properties()));
@@ -68,7 +68,7 @@ public final class AlterTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test(expected = RequiredRuleMissedException.class)
public void assertCheckWithNotExistRuleName() throws SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(createTrafficRule());
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new
TrafficRuleSegment("rule_name_3", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
@@ -78,7 +78,7 @@ public final class AlterTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test
public void assertCheckSuccess() throws SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(createTrafficRule());
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment1 = new
TrafficRuleSegment("rule_name_1", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java
index e33181d5aa6..6dced44f200 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java
@@ -46,7 +46,7 @@ public final class CreateTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test(expected = InvalidAlgorithmConfigurationException.class)
public void assertCheckWithEmptyRuleAndInvalidAlgorithmType() throws
SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.emptyList());
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.emptyList());
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new
TrafficRuleSegment("input_rule_name", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("invalid", new Properties()), new
AlgorithmSegment("invalid", new Properties()));
@@ -56,7 +56,7 @@ public final class CreateTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test(expected = InvalidAlgorithmConfigurationException.class)
public void assertCheckWithInvalidAlgorithmType() throws SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new
TrafficRuleSegment("input_rule_name", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("invalid", new Properties()), new
AlgorithmSegment("invalid", new Properties()));
@@ -66,7 +66,7 @@ public final class CreateTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test(expected = DuplicateRuleException.class)
public void assertCheckWithDuplicatedRuleName() throws SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new
TrafficRuleSegment("rule_name_1", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
@@ -76,7 +76,7 @@ public final class CreateTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test
public void assertCheckSuccess() throws SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment1 = new
TrafficRuleSegment("rule_name_3", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
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 5e3b80c418b..8f08d6967d4 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
@@ -50,7 +50,7 @@ public final class DropTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test(expected = RequiredRuleMissedException.class)
public void assertExecuteWithEmptyRuleConfigurationAndNotExistRule()
throws SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(new
LinkedList<>());
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(new
LinkedList<>());
ProxyContext.init(contextManager);
new DropTrafficRuleHandler().initStatement(new
DropTrafficRuleStatement(Collections.singletonList("rule_name"),
false)).execute();
}
@@ -58,7 +58,7 @@ public final class DropTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test
public void
assertExecuteWithEmptyRuleConfigurationAndNotExistRuleAndIfExists() throws
SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(new
LinkedList<>());
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(new
LinkedList<>());
ProxyContext.init(contextManager);
new DropTrafficRuleHandler().initStatement(new
DropTrafficRuleStatement(Collections.singletonList("rule_name"),
true)).execute();
}
@@ -66,7 +66,7 @@ public final class DropTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test(expected = RequiredRuleMissedException.class)
public void assertExecuteWithNotExistRule() throws SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
ProxyContext.init(contextManager);
new DropTrafficRuleHandler().initStatement(new
DropTrafficRuleStatement(Collections.singletonList("rule_name"),
false)).execute();
}
@@ -74,10 +74,10 @@ public final class DropTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test
public void assertExecute() throws SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
ProxyContext.init(contextManager);
new DropTrafficRuleHandler().initStatement(new
DropTrafficRuleStatement(Collections.singletonList("rule_name_1"),
false)).execute();
- Optional<TrafficRuleConfiguration> ruleConfig =
contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
+ Optional<TrafficRuleConfiguration> ruleConfig =
contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(TrafficRuleConfiguration.class).stream().findAny();
assertTrue(ruleConfig.isPresent());
assertThat(ruleConfig.get().getTrafficStrategies().size(), is(1));
assertThat(ruleConfig.get().getLoadBalancers().size(), is(1));
@@ -90,10 +90,10 @@ public final class DropTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test
public void assertExecuteWithIfExists() throws SQLException {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
ProxyContext.init(contextManager);
new DropTrafficRuleHandler().initStatement(new
DropTrafficRuleStatement(Collections.singletonList("rule_name_1"),
false)).execute();
- Optional<TrafficRuleConfiguration> ruleConfig =
contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
+ Optional<TrafficRuleConfiguration> ruleConfig =
contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(TrafficRuleConfiguration.class).stream().findAny();
assertTrue(ruleConfig.isPresent());
assertThat(ruleConfig.get().getTrafficStrategies().size(), is(1));
assertThat(ruleConfig.get().getLoadBalancers().size(), is(1));
@@ -106,10 +106,10 @@ public final class DropTrafficRuleHandlerTest extends
ProxyContextRestorer {
@Test
public void assertExecuteWithNotExistRuleAndIfExists() throws SQLException
{
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
-
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
+
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
ProxyContext.init(contextManager);
new DropTrafficRuleHandler().initStatement(new
DropTrafficRuleStatement(Collections.singletonList("rule_name_3"),
true)).execute();
- Optional<TrafficRuleConfiguration> ruleConfig =
contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
+ Optional<TrafficRuleConfiguration> ruleConfig =
contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfigurations(TrafficRuleConfiguration.class).stream().findAny();
assertTrue(ruleConfig.isPresent());
assertThat(ruleConfig.get().getTrafficStrategies().size(), is(2));
assertThat(ruleConfig.get().getLoadBalancers().size(), is(2));