From fd6dd1fc6e9758d483604d7133e4af09473ecdc4 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Sun, 21 Jan 2024 19:06:57 +0800 Subject: [PATCH] Add GlobalRuleAwareRQLExecutor (#29796) * Add GlobalRuleAwareRQLExecutor * Add GlobalRuleAwareRQLExecutor * Add GlobalRuleAwareRQLExecutor --- ...tAlgorithmImplementationsExecutorTest.java | 11 ---- ...kAlgorithmImplementationsExecutorTest.java | 11 ---- ...eAlgorithmImplementationsExecutorTest.java | 11 ---- ...wAlgorithmImplementationsExecutorTest.java | 11 ---- ...gAlgorithmImplementationsExecutorTest.java | 11 ---- .../rql/aware/GlobalRuleAwareRQLExecutor.java | 43 +++++++++------- .../handler/ShowAuthorityRuleExecutor.java | 21 +++++--- ...here.distsql.handler.type.rql.RQLExecutor} | 0 .../ShowAuthorityRuleExecutorTest.java | 28 ++-------- .../statement/ShowAuthorityRuleStatement.java | 4 +- ...wMigrationCheckAlgorithmsExecutorTest.java | 41 --------------- .../ShowMigrationCheckStatusExecutorTest.java | 51 ------------------- .../ShowMigrationJobStatusExecutorTest.java | 47 ----------------- .../query/ShowMigrationListExecutorTest.java | 43 ---------------- ...grationSourceStorageUnitsExecutorTest.java | 49 ------------------ .../query/ShowGlobalClockRuleExecutor.java | 22 +++++--- ...here.distsql.handler.type.rql.RQLExecutor} | 0 .../ShowGlobalClockRuleExecutorTest.java | 33 ++---------- .../ShowGlobalClockRuleStatement.java | 4 +- .../query/ShowSQLFederationRuleExecutor.java | 22 +++++--- ...here.distsql.handler.type.rql.RQLExecutor} | 0 .../ShowSQLFederationRuleExecutorTest.java | 31 ++--------- .../ShowSQLFederationRuleStatement.java | 4 +- .../query/ShowSQLParserRuleExecutor.java | 22 +++++--- ...here.distsql.handler.type.rql.RQLExecutor} | 0 .../query/ShowSQLParserRuleExecutorTest.java | 30 ++--------- .../queryable/ShowSQLParserRuleStatement.java | 4 +- .../query/ShowSQLTranslatorRuleExecutor.java | 22 ++++---- ...here.distsql.handler.type.rql.RQLExecutor} | 0 .../ShowSQLTranslatorRuleExecutorTest.java | 30 ++--------- .../ShowSQLTranslatorRuleStatement.java | 4 +- .../query/ShowTrafficRuleExecutor.java | 24 +++++---- ...here.distsql.handler.type.rql.RQLExecutor} | 0 .../query/ShowTrafficRuleExecutorTest.java | 32 ++---------- .../queryable/ShowTrafficRulesStatement.java | 4 +- .../query/ShowTransactionRuleExecutor.java | 21 +++++--- ...here.distsql.handler.type.rql.RQLExecutor} | 0 .../ShowTransactionRuleExecutorTest.java | 35 +++---------- .../ShowTransactionRuleStatement.java | 4 +- .../distsql/rql/RQLBackendHandler.java | 14 +++++ .../ProxyBackendHandlerFactoryTest.java | 2 +- .../ConvertYamlConfigurationExecutorTest.java | 10 ---- .../ShowComputeNodeModeExecutorTest.java | 11 ---- ...eAlgorithmImplementationsExecutorTest.java | 11 ---- ...ceProviderImplementationsExecutorTest.java | 11 ---- .../ShowTableMetaDataExecutorTest.java | 13 ----- .../type/ShowLogicalTableExecutorTest.java | 8 --- .../ShowRulesUsedStorageUnitExecutorTest.java | 11 ---- .../ral/impl/QueryableRALStatementAssert.java | 17 ------- .../statement/rql/RQLStatementAssert.java | 24 +++++++-- .../ShowTrafficRulesStatementAssert.java | 4 +- .../parser/jaxb/RootSQLParserTestCases.java | 12 ++--- .../ShowAuthorityRuleStatementTestCase.java | 2 +- .../ShowGlobalClockRuleStatementTestCase.java | 2 +- .../ShowSQLParserRuleStatementTestCase.java | 2 +- .../ShowTrafficRulesStatementTestCase.java | 2 +- .../ShowTransactionRuleStatementTestCase.java | 2 +- ...howSQLTranslatorRuleStatementTestCase.java | 2 +- 58 files changed, 218 insertions(+), 672 deletions(-) rename proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowMigrationRuleExecutorTest.java => infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rql/aware/GlobalRuleAwareRQLExecutor.java (51%) rename kernel/authority/distsql/handler/src/main/resources/META-INF/services/{org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor => org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor} (100%) delete mode 100644 kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationCheckAlgorithmsExecutorTest.java delete mode 100644 kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationCheckStatusExecutorTest.java delete mode 100644 kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationJobStatusExecutorTest.java delete mode 100644 kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationListExecutorTest.java delete mode 100644 kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationSourceStorageUnitsExecutorTest.java rename kernel/global-clock/distsql/handler/src/main/resources/META-INF/services/{org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor => org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor} (100%) rename kernel/sql-federation/distsql/handler/src/main/resources/META-INF/services/{org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor => org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor} (100%) rename kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/{org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor => org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor} (100%) rename kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/{org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor => org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor} (100%) rename kernel/traffic/distsql/handler/src/main/resources/META-INF/services/{org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor => org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor} (100%) rename kernel/transaction/distsql/handler/src/main/resources/META-INF/services/{org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor => org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor} (100%) rename test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/{ral/impl/queryable => rql/impl}/ShowTrafficRulesStatementAssert.java (95%) rename test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/{ral => rql/rule/authority}/ShowAuthorityRuleStatementTestCase.java (95%) rename test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/{ral => rql/rule/globalclock}/ShowGlobalClockRuleStatementTestCase.java (95%) rename test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/{ral => rql/rule/parser}/ShowSQLParserRuleStatementTestCase.java (96%) rename test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/{ral => rql/rule/traffic}/ShowTrafficRulesStatementTestCase.java (96%) rename test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/{ral => rql/rule/transaction}/ShowTransactionRuleStatementTestCase.java (95%) rename test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/{ral => rql/rule/translator}/ShowSQLTranslatorRuleStatementTestCase.java (95%) diff --git a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmImplementationsExecutorTest.java b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmImplementationsExecutorTest.java index ec99452b7142d..f57b19228dd00 100644 --- a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmImplementationsExecutorTest.java +++ b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmImplementationsExecutorTest.java @@ -44,15 +44,4 @@ void assertGetRowData() { assertThat(row.getCell(2), is("DISTSQL.FIXTURE")); assertThat(row.getCell(3), is("org.apache.shardingsphere.encrypt.distsql.handler.fixture.DistSQLEncryptAlgorithmFixture")); } - - @Test - void assertGetColumnNames() { - QueryableRALExecutor executor = new ShowEncryptAlgorithmImplementationsExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("name")); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("class_path")); - } } diff --git a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmImplementationsExecutorTest.java b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmImplementationsExecutorTest.java index 41ad1e357ce54..dd5db6060f676 100644 --- a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmImplementationsExecutorTest.java +++ b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmImplementationsExecutorTest.java @@ -44,15 +44,4 @@ void assertGetRowData() { assertThat(row.getCell(2), is("DISTSQL.FIXTURE")); assertThat(row.getCell(3), is("org.apache.shardingsphere.mask.distsql.handler.fixture.DistSQLMaskAlgorithmFixture")); } - - @Test - void assertGetColumnNames() { - QueryableRALExecutor executor = new ShowMaskAlgorithmImplementationsExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("name")); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("class_path")); - } } diff --git a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadQueryLoadBalanceAlgorithmImplementationsExecutorTest.java b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadQueryLoadBalanceAlgorithmImplementationsExecutorTest.java index 76538cd1698af..3f07849b13087 100644 --- a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadQueryLoadBalanceAlgorithmImplementationsExecutorTest.java +++ b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadQueryLoadBalanceAlgorithmImplementationsExecutorTest.java @@ -44,15 +44,4 @@ void assertGetRowData() { assertThat(row.getCell(2), is("DISTSQL.FIXTURE")); assertThat(row.getCell(3), is("org.apache.shardingsphere.readwritesplitting.distsql.handler.fixture.DistSQLReadQueryLoadBalanceAlgorithmFixture")); } - - @Test - void assertGetColumnNames() { - QueryableRALExecutor executor = new ShowReadQueryLoadBalanceAlgorithmImplementationsExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("name")); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("class_path")); - } } diff --git a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowAlgorithmImplementationsExecutorTest.java b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowAlgorithmImplementationsExecutorTest.java index 0b242742c8d6f..ce6250227d256 100644 --- a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowAlgorithmImplementationsExecutorTest.java +++ b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowAlgorithmImplementationsExecutorTest.java @@ -45,15 +45,4 @@ void assertGetRowData() { assertThat(row.getCell(2), is("DISTSQL.FIXTURE")); assertThat(row.getCell(3), is("org.apache.shardingsphere.shadow.distsql.fixture.DistSQLShadowAlgorithmFixture")); } - - @Test - void assertGetColumnNames() { - QueryableRALExecutor executor = new ShowShadowAlgorithmImplementationsExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("name")); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("class_path")); - } } diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmImplementationsExecutorTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmImplementationsExecutorTest.java index 5286c7a4de3dd..15037fc6fbc70 100644 --- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmImplementationsExecutorTest.java +++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmImplementationsExecutorTest.java @@ -45,15 +45,4 @@ void assertGetRowData() { assertThat(row.getCell(2), is("FOO.DISTSQL.FIXTURE")); assertThat(row.getCell(3), is("org.apache.shardingsphere.sharding.distsql.fixture.sharding.FooDistSQLShardingAlgorithmFixture")); } - - @Test - void assertGetColumnNames() { - QueryableRALExecutor executor = new ShowShardingAlgorithmImplementationsExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("name")); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("class_path")); - } } diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowMigrationRuleExecutorTest.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rql/aware/GlobalRuleAwareRQLExecutor.java similarity index 51% rename from proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowMigrationRuleExecutorTest.java rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rql/aware/GlobalRuleAwareRQLExecutor.java index e49fd3050da83..5e2818edf13d8 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowMigrationRuleExecutorTest.java +++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rql/aware/GlobalRuleAwareRQLExecutor.java @@ -15,26 +15,31 @@ * limitations under the License. */ -package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable; +package org.apache.shardingsphere.distsql.handler.type.rql.aware; -import org.junit.jupiter.api.Test; +import org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor; +import org.apache.shardingsphere.distsql.statement.rql.RQLStatement; +import org.apache.shardingsphere.infra.rule.ShardingSphereRule; -import java.util.Collection; -import java.util.Iterator; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - -class ShowMigrationRuleExecutorTest { +/** + * Global rule aware RQL executor. + * + * @param type of SQL statement + * @param type of ShardingSphere rule + */ +public interface GlobalRuleAwareRQLExecutor extends RQLExecutor { + + /** + * Set ShardingSphere rule. + * + * @param rule rule + */ + void setRule(R rule); - @Test - void assertGetColumnNames() { - ShowMigrationRuleExecutor executor = new ShowMigrationRuleExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("read")); - assertThat(iterator.next(), is("write")); - assertThat(iterator.next(), is("stream_channel")); - } + /** + * Get rule class. + * + * @return rule class + */ + Class getRuleClass(); } diff --git a/kernel/authority/distsql/handler/src/main/java/org/apache/shardingsphere/authority/distsql/handler/ShowAuthorityRuleExecutor.java b/kernel/authority/distsql/handler/src/main/java/org/apache/shardingsphere/authority/distsql/handler/ShowAuthorityRuleExecutor.java index 31ab17218bac6..f6fae3d947549 100644 --- a/kernel/authority/distsql/handler/src/main/java/org/apache/shardingsphere/authority/distsql/handler/ShowAuthorityRuleExecutor.java +++ b/kernel/authority/distsql/handler/src/main/java/org/apache/shardingsphere/authority/distsql/handler/ShowAuthorityRuleExecutor.java @@ -17,12 +17,12 @@ package org.apache.shardingsphere.authority.distsql.handler; +import lombok.Setter; import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration; import org.apache.shardingsphere.authority.distsql.statement.ShowAuthorityRuleStatement; import org.apache.shardingsphere.authority.rule.AuthorityRule; -import org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor; +import org.apache.shardingsphere.distsql.handler.type.rql.aware.GlobalRuleAwareRQLExecutor; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; import java.util.Arrays; import java.util.Collection; @@ -32,19 +32,26 @@ /** * Show authority rule executor. */ -public final class ShowAuthorityRuleExecutor implements QueryableRALExecutor { +@Setter +public final class ShowAuthorityRuleExecutor implements GlobalRuleAwareRQLExecutor { + + private AuthorityRule rule; + + @Override + public Collection getColumnNames() { + return Arrays.asList("users", "provider", "props"); + } @Override - public Collection getRows(final ShowAuthorityRuleStatement sqlStatement, final ShardingSphereMetaData metaData) { - AuthorityRule rule = metaData.getGlobalRuleMetaData().getSingleRule(AuthorityRule.class); + public Collection getRows(final ShowAuthorityRuleStatement sqlStatement) { AuthorityRuleConfiguration ruleConfig = rule.getConfiguration(); return Collections.singleton(new LocalDataQueryResultRow(ruleConfig.getUsers().stream().map(each -> each.getGrantee().toString()).collect(Collectors.joining("; ")), ruleConfig.getPrivilegeProvider().getType(), ruleConfig.getPrivilegeProvider().getProps().isEmpty() ? "" : ruleConfig.getPrivilegeProvider().getProps())); } @Override - public Collection getColumnNames() { - return Arrays.asList("users", "provider", "props"); + public Class getRuleClass() { + return AuthorityRule.class; } @Override diff --git a/kernel/authority/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor b/kernel/authority/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor similarity index 100% rename from kernel/authority/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor rename to kernel/authority/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor diff --git a/kernel/authority/distsql/handler/src/test/java/org/apache/shardingsphere/authority/distsql/handler/ShowAuthorityRuleExecutorTest.java b/kernel/authority/distsql/handler/src/test/java/org/apache/shardingsphere/authority/distsql/handler/ShowAuthorityRuleExecutorTest.java index 1776e57b29274..f5cb086018ab1 100644 --- a/kernel/authority/distsql/handler/src/test/java/org/apache/shardingsphere/authority/distsql/handler/ShowAuthorityRuleExecutorTest.java +++ b/kernel/authority/distsql/handler/src/test/java/org/apache/shardingsphere/authority/distsql/handler/ShowAuthorityRuleExecutorTest.java @@ -21,18 +21,13 @@ import org.apache.shardingsphere.authority.distsql.statement.ShowAuthorityRuleStatement; import org.apache.shardingsphere.authority.rule.AuthorityRule; import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration; -import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; -import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData; -import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser; import org.junit.jupiter.api.Test; import java.util.Collection; import java.util.Collections; import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.Properties; import static org.hamcrest.CoreMatchers.is; @@ -44,9 +39,11 @@ class ShowAuthorityRuleExecutorTest { @Test void assertExecute() { - ShardingSphereMetaData metaData = mockMetaData(); + AuthorityRule rule = mock(AuthorityRule.class); + when(rule.getConfiguration()).thenReturn(createAuthorityRuleConfiguration()); ShowAuthorityRuleExecutor executor = new ShowAuthorityRuleExecutor(); - Collection actual = executor.getRows(mock(ShowAuthorityRuleStatement.class), metaData); + executor.setRule(rule); + Collection actual = executor.getRows(mock(ShowAuthorityRuleStatement.class)); assertThat(actual.size(), is(1)); Iterator iterator = actual.iterator(); LocalDataQueryResultRow row = iterator.next(); @@ -55,25 +52,8 @@ void assertExecute() { assertThat(row.getCell(3), is("")); } - private ShardingSphereMetaData mockMetaData() { - AuthorityRule authorityRule = mock(AuthorityRule.class); - when(authorityRule.getConfiguration()).thenReturn(createAuthorityRuleConfiguration()); - return new ShardingSphereMetaData(new LinkedHashMap<>(), mock(ResourceMetaData.class), new RuleMetaData(Collections.singleton(authorityRule)), new ConfigurationProperties(new Properties())); - } - private AuthorityRuleConfiguration createAuthorityRuleConfiguration() { ShardingSphereUser root = new ShardingSphereUser("root", "", "localhost"); return new AuthorityRuleConfiguration(Collections.singleton(root), new AlgorithmConfiguration("ALL_PERMITTED", new Properties()), Collections.emptyMap(), null); } - - @Test - void assertGetColumnNames() { - ShowAuthorityRuleExecutor executor = new ShowAuthorityRuleExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("users")); - assertThat(iterator.next(), is("provider")); - assertThat(iterator.next(), is("props")); - } } diff --git a/kernel/authority/distsql/statement/src/main/java/org/apache/shardingsphere/authority/distsql/statement/ShowAuthorityRuleStatement.java b/kernel/authority/distsql/statement/src/main/java/org/apache/shardingsphere/authority/distsql/statement/ShowAuthorityRuleStatement.java index 4ec06a41e7b9d..a4d440976d3ee 100644 --- a/kernel/authority/distsql/statement/src/main/java/org/apache/shardingsphere/authority/distsql/statement/ShowAuthorityRuleStatement.java +++ b/kernel/authority/distsql/statement/src/main/java/org/apache/shardingsphere/authority/distsql/statement/ShowAuthorityRuleStatement.java @@ -17,10 +17,10 @@ package org.apache.shardingsphere.authority.distsql.statement; -import org.apache.shardingsphere.distsql.statement.ral.QueryableRALStatement; +import org.apache.shardingsphere.distsql.statement.rql.RQLStatement; /** * Show authority rule statement. */ -public final class ShowAuthorityRuleStatement extends QueryableRALStatement { +public final class ShowAuthorityRuleStatement extends RQLStatement { } diff --git a/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationCheckAlgorithmsExecutorTest.java b/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationCheckAlgorithmsExecutorTest.java deleted file mode 100644 index 2f7cbf680cade..0000000000000 --- a/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationCheckAlgorithmsExecutorTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.data.pipeline.migration.distsql.handler.query; - -import org.junit.jupiter.api.Test; - -import java.util.Collection; -import java.util.Iterator; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - -class ShowMigrationCheckAlgorithmsExecutorTest { - - @Test - void assertGetColumnNames() { - ShowMigrationCheckAlgorithmsExecutor executor = new ShowMigrationCheckAlgorithmsExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(4)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("type_aliases")); - assertThat(iterator.next(), is("supported_database_types")); - assertThat(iterator.next(), is("description")); - } -} diff --git a/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationCheckStatusExecutorTest.java b/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationCheckStatusExecutorTest.java deleted file mode 100644 index c01122e7817d1..0000000000000 --- a/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationCheckStatusExecutorTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.data.pipeline.migration.distsql.handler.query; - -import org.junit.jupiter.api.Test; - -import java.util.Collection; -import java.util.Iterator; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - -class ShowMigrationCheckStatusExecutorTest { - - private final ShowMigrationCheckStatusExecutor executor = new ShowMigrationCheckStatusExecutor(); - - @Test - void assertGetColumnNames() { - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(13)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("tables")); - assertThat(iterator.next(), is("result")); - assertThat(iterator.next(), is("check_failed_tables")); - assertThat(iterator.next(), is("active")); - assertThat(iterator.next(), is("inventory_finished_percentage")); - assertThat(iterator.next(), is("inventory_remaining_seconds")); - assertThat(iterator.next(), is("incremental_idle_seconds")); - assertThat(iterator.next(), is("check_begin_time")); - assertThat(iterator.next(), is("check_end_time")); - assertThat(iterator.next(), is("duration_seconds")); - assertThat(iterator.next(), is("algorithm_type")); - assertThat(iterator.next(), is("algorithm_props")); - assertThat(iterator.next(), is("error_message")); - } -} diff --git a/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationJobStatusExecutorTest.java b/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationJobStatusExecutorTest.java deleted file mode 100644 index dca5f351c2cca..0000000000000 --- a/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationJobStatusExecutorTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.data.pipeline.migration.distsql.handler.query; - -import org.junit.jupiter.api.Test; - -import java.util.Collection; -import java.util.Iterator; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - -class ShowMigrationJobStatusExecutorTest { - - private final ShowMigrationJobStatusExecutor executor = new ShowMigrationJobStatusExecutor(); - - @Test - void assertGetColumnNames() { - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(9)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("item")); - assertThat(iterator.next(), is("data_source")); - assertThat(iterator.next(), is("tables")); - assertThat(iterator.next(), is("status")); - assertThat(iterator.next(), is("active")); - assertThat(iterator.next(), is("processed_records_count")); - assertThat(iterator.next(), is("inventory_finished_percentage")); - assertThat(iterator.next(), is("incremental_idle_seconds")); - assertThat(iterator.next(), is("error_message")); - } -} diff --git a/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationListExecutorTest.java b/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationListExecutorTest.java deleted file mode 100644 index 38323f29749cd..0000000000000 --- a/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationListExecutorTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.data.pipeline.migration.distsql.handler.query; - -import org.junit.jupiter.api.Test; - -import java.util.Collection; -import java.util.Iterator; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - -class ShowMigrationListExecutorTest { - - @Test - void assertGetColumnNames() { - ShowMigrationListExecutor executor = new ShowMigrationListExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(6)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("id")); - assertThat(iterator.next(), is("tables")); - assertThat(iterator.next(), is("job_item_count")); - assertThat(iterator.next(), is("active")); - assertThat(iterator.next(), is("create_time")); - assertThat(iterator.next(), is("stop_time")); - } -} diff --git a/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationSourceStorageUnitsExecutorTest.java b/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationSourceStorageUnitsExecutorTest.java deleted file mode 100644 index 1cf365eb17182..0000000000000 --- a/kernel/data-pipeline/distsql/handler/src/test/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationSourceStorageUnitsExecutorTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.data.pipeline.migration.distsql.handler.query; - -import org.junit.jupiter.api.Test; - -import java.util.Collection; -import java.util.Iterator; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - -class ShowMigrationSourceStorageUnitsExecutorTest { - - @Test - void assertGetColumnNames() { - ShowMigrationSourceStorageUnitsExecutor executor = new ShowMigrationSourceStorageUnitsExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(12)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("name")); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("host")); - assertThat(iterator.next(), is("port")); - assertThat(iterator.next(), is("db")); - assertThat(iterator.next(), is("connection_timeout_milliseconds")); - assertThat(iterator.next(), is("idle_timeout_milliseconds")); - assertThat(iterator.next(), is("max_lifetime_milliseconds")); - assertThat(iterator.next(), is("max_pool_size")); - assertThat(iterator.next(), is("min_pool_size")); - assertThat(iterator.next(), is("read_only")); - assertThat(iterator.next(), is("other_attributes")); - } -} diff --git a/kernel/global-clock/distsql/handler/src/main/java/org/apache/shardingsphere/globalclock/distsql/handler/query/ShowGlobalClockRuleExecutor.java b/kernel/global-clock/distsql/handler/src/main/java/org/apache/shardingsphere/globalclock/distsql/handler/query/ShowGlobalClockRuleExecutor.java index 7c401b557e892..da1463969bac8 100644 --- a/kernel/global-clock/distsql/handler/src/main/java/org/apache/shardingsphere/globalclock/distsql/handler/query/ShowGlobalClockRuleExecutor.java +++ b/kernel/global-clock/distsql/handler/src/main/java/org/apache/shardingsphere/globalclock/distsql/handler/query/ShowGlobalClockRuleExecutor.java @@ -17,12 +17,12 @@ package org.apache.shardingsphere.globalclock.distsql.handler.query; -import org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor; +import lombok.Setter; +import org.apache.shardingsphere.distsql.handler.type.rql.aware.GlobalRuleAwareRQLExecutor; import org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration; import org.apache.shardingsphere.globalclock.core.rule.GlobalClockRule; import org.apache.shardingsphere.globalclock.distsql.statement.queryable.ShowGlobalClockRuleStatement; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; import org.apache.shardingsphere.infra.props.PropertiesConverter; import java.util.Arrays; @@ -32,18 +32,26 @@ /** * Show global clock rule executor. */ -public final class ShowGlobalClockRuleExecutor implements QueryableRALExecutor { +@Setter +public final class ShowGlobalClockRuleExecutor implements GlobalRuleAwareRQLExecutor { + + private GlobalClockRule rule; + + @Override + public Collection getColumnNames() { + return Arrays.asList("type", "provider", "enable", "props"); + } @Override - public Collection getRows(final ShowGlobalClockRuleStatement sqlStatement, final ShardingSphereMetaData metaData) { - GlobalClockRuleConfiguration ruleConfig = metaData.getGlobalRuleMetaData().getSingleRule(GlobalClockRule.class).getConfiguration(); + public Collection getRows(final ShowGlobalClockRuleStatement sqlStatement) { + GlobalClockRuleConfiguration ruleConfig = rule.getConfiguration(); return Collections.singleton(new LocalDataQueryResultRow(ruleConfig.getType(), ruleConfig.getProvider(), String.valueOf(ruleConfig.isEnabled()), PropertiesConverter.convert(ruleConfig.getProps()))); } @Override - public Collection getColumnNames() { - return Arrays.asList("type", "provider", "enable", "props"); + public Class getRuleClass() { + return GlobalClockRule.class; } @Override diff --git a/kernel/global-clock/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor b/kernel/global-clock/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor similarity index 100% rename from kernel/global-clock/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor rename to kernel/global-clock/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor diff --git a/kernel/global-clock/distsql/handler/src/test/java/org/apache/shardingsphere/globalclock/distsql/handler/query/ShowGlobalClockRuleExecutorTest.java b/kernel/global-clock/distsql/handler/src/test/java/org/apache/shardingsphere/globalclock/distsql/handler/query/ShowGlobalClockRuleExecutorTest.java index 49b3effc6fd81..e2e87e33ad524 100644 --- a/kernel/global-clock/distsql/handler/src/test/java/org/apache/shardingsphere/globalclock/distsql/handler/query/ShowGlobalClockRuleExecutorTest.java +++ b/kernel/global-clock/distsql/handler/src/test/java/org/apache/shardingsphere/globalclock/distsql/handler/query/ShowGlobalClockRuleExecutorTest.java @@ -20,20 +20,13 @@ import org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration; import org.apache.shardingsphere.globalclock.core.rule.GlobalClockRule; import org.apache.shardingsphere.globalclock.distsql.statement.queryable.ShowGlobalClockRuleStatement; -import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; -import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData; -import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; import org.apache.shardingsphere.test.util.PropertiesBuilder; import org.apache.shardingsphere.test.util.PropertiesBuilder.Property; import org.junit.jupiter.api.Test; import java.util.Collection; -import java.util.Collections; import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Properties; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -44,9 +37,11 @@ class ShowGlobalClockRuleExecutorTest { @Test void assertGlobalClockRule() { - ShardingSphereMetaData metaData = mockMetaData(); ShowGlobalClockRuleExecutor executor = new ShowGlobalClockRuleExecutor(); - Collection actual = executor.getRows(mock(ShowGlobalClockRuleStatement.class), metaData); + GlobalClockRule rule = mock(GlobalClockRule.class); + when(rule.getConfiguration()).thenReturn(new GlobalClockRuleConfiguration("TSO", "local", false, PropertiesBuilder.build(new Property("key", "value")))); + executor.setRule(rule); + Collection actual = executor.getRows(mock(ShowGlobalClockRuleStatement.class)); assertThat(actual.size(), is(1)); Iterator iterator = actual.iterator(); LocalDataQueryResultRow row = iterator.next(); @@ -55,24 +50,4 @@ void assertGlobalClockRule() { assertThat(row.getCell(3), is("false")); assertThat(row.getCell(4), is("{\"key\":\"value\"}")); } - - @Test - void assertGetColumnNames() { - ShowGlobalClockRuleExecutor executor = new ShowGlobalClockRuleExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(4)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("provider")); - assertThat(iterator.next(), is("enable")); - assertThat(iterator.next(), is("props")); - } - - private ShardingSphereMetaData mockMetaData() { - GlobalClockRule sqlParserRule = mock(GlobalClockRule.class); - GlobalClockRuleConfiguration globalClockRuleConfig = new GlobalClockRuleConfiguration("TSO", "local", false, PropertiesBuilder.build(new Property("key", "value"))); - when(sqlParserRule.getConfiguration()).thenReturn(globalClockRuleConfig); - return new ShardingSphereMetaData(new LinkedHashMap<>(), mock(ResourceMetaData.class), - new RuleMetaData(Collections.singleton(sqlParserRule)), new ConfigurationProperties(new Properties())); - } } diff --git a/kernel/global-clock/distsql/statement/src/main/java/org/apache/shardingsphere/globalclock/distsql/statement/queryable/ShowGlobalClockRuleStatement.java b/kernel/global-clock/distsql/statement/src/main/java/org/apache/shardingsphere/globalclock/distsql/statement/queryable/ShowGlobalClockRuleStatement.java index bd6229c3dea1c..a2914d3358cfe 100644 --- a/kernel/global-clock/distsql/statement/src/main/java/org/apache/shardingsphere/globalclock/distsql/statement/queryable/ShowGlobalClockRuleStatement.java +++ b/kernel/global-clock/distsql/statement/src/main/java/org/apache/shardingsphere/globalclock/distsql/statement/queryable/ShowGlobalClockRuleStatement.java @@ -17,10 +17,10 @@ package org.apache.shardingsphere.globalclock.distsql.statement.queryable; -import org.apache.shardingsphere.distsql.statement.ral.QueryableRALStatement; +import org.apache.shardingsphere.distsql.statement.rql.RQLStatement; /** * Show global clock rule statement. */ -public final class ShowGlobalClockRuleStatement extends QueryableRALStatement { +public final class ShowGlobalClockRuleStatement extends RQLStatement { } diff --git a/kernel/sql-federation/distsql/handler/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/handler/query/ShowSQLFederationRuleExecutor.java b/kernel/sql-federation/distsql/handler/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/handler/query/ShowSQLFederationRuleExecutor.java index ddfd7723eae95..5e2aaa0a1b079 100644 --- a/kernel/sql-federation/distsql/handler/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/handler/query/ShowSQLFederationRuleExecutor.java +++ b/kernel/sql-federation/distsql/handler/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/handler/query/ShowSQLFederationRuleExecutor.java @@ -17,9 +17,9 @@ package org.apache.shardingsphere.sqlfederation.distsql.handler.query; -import org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor; +import lombok.Setter; +import org.apache.shardingsphere.distsql.handler.type.rql.aware.GlobalRuleAwareRQLExecutor; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; import org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration; import org.apache.shardingsphere.sqlfederation.distsql.statement.queryable.ShowSQLFederationRuleStatement; import org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule; @@ -31,11 +31,19 @@ /** * Show SQL federation rule executor. */ -public final class ShowSQLFederationRuleExecutor implements QueryableRALExecutor { +@Setter +public final class ShowSQLFederationRuleExecutor implements GlobalRuleAwareRQLExecutor { + + private SQLFederationRule rule; + + @Override + public Collection getColumnNames() { + return Arrays.asList("sql_federation_enabled", "all_query_use_sql_federation", "execution_plan_cache"); + } @Override - public Collection getRows(final ShowSQLFederationRuleStatement sqlStatement, final ShardingSphereMetaData metaData) { - SQLFederationRuleConfiguration ruleConfig = metaData.getGlobalRuleMetaData().getSingleRule(SQLFederationRule.class).getConfiguration(); + public Collection getRows(final ShowSQLFederationRuleStatement sqlStatement) { + SQLFederationRuleConfiguration ruleConfig = rule.getConfiguration(); String sqlFederationEnabled = String.valueOf(ruleConfig.isSqlFederationEnabled()); String allQueryUseSQLFederation = String.valueOf(ruleConfig.isAllQueryUseSQLFederation()); String executionPlanCache = null != ruleConfig.getExecutionPlanCache() ? ruleConfig.getExecutionPlanCache().toString() : ""; @@ -44,8 +52,8 @@ public Collection getRows(final ShowSQLFederationRuleSt } @Override - public Collection getColumnNames() { - return Arrays.asList("sql_federation_enabled", "all_query_use_sql_federation", "execution_plan_cache"); + public Class getRuleClass() { + return SQLFederationRule.class; } @Override diff --git a/kernel/sql-federation/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor b/kernel/sql-federation/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor similarity index 100% rename from kernel/sql-federation/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor rename to kernel/sql-federation/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor diff --git a/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/query/ShowSQLFederationRuleExecutorTest.java b/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/query/ShowSQLFederationRuleExecutorTest.java index 842528ac11371..3a847027a6640 100644 --- a/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/query/ShowSQLFederationRuleExecutorTest.java +++ b/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/query/ShowSQLFederationRuleExecutorTest.java @@ -17,11 +17,7 @@ package org.apache.shardingsphere.sqlfederation.distsql.handler.query; -import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; -import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData; -import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; import org.apache.shardingsphere.sql.parser.api.CacheOption; import org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration; import org.apache.shardingsphere.sqlfederation.distsql.statement.queryable.ShowSQLFederationRuleStatement; @@ -29,10 +25,7 @@ import org.junit.jupiter.api.Test; import java.util.Collection; -import java.util.Collections; import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Properties; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -43,9 +36,11 @@ class ShowSQLFederationRuleExecutorTest { @Test void assertSQLFederationRule() { - ShardingSphereMetaData metaData = mockMetaData(); ShowSQLFederationRuleExecutor executor = new ShowSQLFederationRuleExecutor(); - Collection actual = executor.getRows(mock(ShowSQLFederationRuleStatement.class), metaData); + SQLFederationRule rule = mock(SQLFederationRule.class); + when(rule.getConfiguration()).thenReturn(new SQLFederationRuleConfiguration(true, true, new CacheOption(2000, 65535L))); + executor.setRule(rule); + Collection actual = executor.getRows(mock(ShowSQLFederationRuleStatement.class)); assertThat(actual.size(), is(1)); Iterator iterator = actual.iterator(); LocalDataQueryResultRow row = iterator.next(); @@ -53,22 +48,4 @@ void assertSQLFederationRule() { assertThat(row.getCell(2), is("true")); assertThat(row.getCell(3), is("initialCapacity: 2000, maximumSize: 65535")); } - - @Test - void assertGetColumnNames() { - ShowSQLFederationRuleExecutor executor = new ShowSQLFederationRuleExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("sql_federation_enabled")); - assertThat(iterator.next(), is("all_query_use_sql_federation")); - assertThat(iterator.next(), is("execution_plan_cache")); - } - - private ShardingSphereMetaData mockMetaData() { - SQLFederationRule sqlFederationRule = mock(SQLFederationRule.class); - when(sqlFederationRule.getConfiguration()).thenReturn(new SQLFederationRuleConfiguration(true, true, new CacheOption(2000, 65535L))); - return new ShardingSphereMetaData(new LinkedHashMap<>(), mock(ResourceMetaData.class), - new RuleMetaData(Collections.singleton(sqlFederationRule)), new ConfigurationProperties(new Properties())); - } } diff --git a/kernel/sql-federation/distsql/statement/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/statement/queryable/ShowSQLFederationRuleStatement.java b/kernel/sql-federation/distsql/statement/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/statement/queryable/ShowSQLFederationRuleStatement.java index 14f3773401f6c..45c2beac8f7df 100644 --- a/kernel/sql-federation/distsql/statement/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/statement/queryable/ShowSQLFederationRuleStatement.java +++ b/kernel/sql-federation/distsql/statement/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/statement/queryable/ShowSQLFederationRuleStatement.java @@ -17,10 +17,10 @@ package org.apache.shardingsphere.sqlfederation.distsql.statement.queryable; -import org.apache.shardingsphere.distsql.statement.ral.QueryableRALStatement; +import org.apache.shardingsphere.distsql.statement.rql.RQLStatement; /** * Show SQL federation rule statement. */ -public final class ShowSQLFederationRuleStatement extends QueryableRALStatement { +public final class ShowSQLFederationRuleStatement extends RQLStatement { } diff --git a/kernel/sql-parser/distsql/handler/src/main/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutor.java b/kernel/sql-parser/distsql/handler/src/main/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutor.java index 0f2e823ae4e1f..81f3284b68961 100644 --- a/kernel/sql-parser/distsql/handler/src/main/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutor.java +++ b/kernel/sql-parser/distsql/handler/src/main/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutor.java @@ -17,9 +17,9 @@ package org.apache.shardingsphere.parser.distsql.handler.query; -import org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor; +import lombok.Setter; +import org.apache.shardingsphere.distsql.handler.type.rql.aware.GlobalRuleAwareRQLExecutor; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration; import org.apache.shardingsphere.parser.distsql.statement.queryable.ShowSQLParserRuleStatement; import org.apache.shardingsphere.parser.rule.SQLParserRule; @@ -31,18 +31,26 @@ /** * Show SQL parser rule executor. */ -public final class ShowSQLParserRuleExecutor implements QueryableRALExecutor { +@Setter +public final class ShowSQLParserRuleExecutor implements GlobalRuleAwareRQLExecutor { + + private SQLParserRule rule; + + @Override + public Collection getColumnNames() { + return Arrays.asList("parse_tree_cache", "sql_statement_cache"); + } @Override - public Collection getRows(final ShowSQLParserRuleStatement sqlStatement, final ShardingSphereMetaData metaData) { - SQLParserRuleConfiguration ruleConfig = metaData.getGlobalRuleMetaData().getSingleRule(SQLParserRule.class).getConfiguration(); + public Collection getRows(final ShowSQLParserRuleStatement sqlStatement) { + SQLParserRuleConfiguration ruleConfig = rule.getConfiguration(); return Collections.singleton(new LocalDataQueryResultRow(null != ruleConfig.getParseTreeCache() ? ruleConfig.getParseTreeCache().toString() : "", null != ruleConfig.getSqlStatementCache() ? ruleConfig.getSqlStatementCache().toString() : "")); } @Override - public Collection getColumnNames() { - return Arrays.asList("parse_tree_cache", "sql_statement_cache"); + public Class getRuleClass() { + return SQLParserRule.class; } @Override diff --git a/kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor b/kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor similarity index 100% rename from kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor rename to kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor diff --git a/kernel/sql-parser/distsql/handler/src/test/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutorTest.java b/kernel/sql-parser/distsql/handler/src/test/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutorTest.java index 15f1b9c002cc1..120c63f5db208 100644 --- a/kernel/sql-parser/distsql/handler/src/test/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutorTest.java +++ b/kernel/sql-parser/distsql/handler/src/test/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutorTest.java @@ -17,11 +17,7 @@ package org.apache.shardingsphere.parser.distsql.handler.query; -import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; -import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData; -import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration; import org.apache.shardingsphere.parser.distsql.statement.queryable.ShowSQLParserRuleStatement; import org.apache.shardingsphere.parser.rule.SQLParserRule; @@ -29,10 +25,7 @@ import org.junit.jupiter.api.Test; import java.util.Collection; -import java.util.Collections; import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Properties; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -43,30 +36,15 @@ class ShowSQLParserRuleExecutorTest { @Test void assertSQLParserRule() { - ShardingSphereMetaData metaData = mockMetaData(); ShowSQLParserRuleExecutor executor = new ShowSQLParserRuleExecutor(); - Collection actual = executor.getRows(mock(ShowSQLParserRuleStatement.class), metaData); + SQLParserRule rule = mock(SQLParserRule.class); + when(rule.getConfiguration()).thenReturn(new SQLParserRuleConfiguration(new CacheOption(128, 1024), new CacheOption(2000, 65535))); + executor.setRule(rule); + Collection actual = executor.getRows(mock(ShowSQLParserRuleStatement.class)); assertThat(actual.size(), is(1)); Iterator iterator = actual.iterator(); LocalDataQueryResultRow row = iterator.next(); assertThat(row.getCell(1), is("initialCapacity: 128, maximumSize: 1024")); assertThat(row.getCell(2), is("initialCapacity: 2000, maximumSize: 65535")); } - - @Test - void assertGetColumnNames() { - ShowSQLParserRuleExecutor executor = new ShowSQLParserRuleExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(2)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("parse_tree_cache")); - assertThat(iterator.next(), is("sql_statement_cache")); - } - - private ShardingSphereMetaData mockMetaData() { - SQLParserRule sqlParserRule = mock(SQLParserRule.class); - when(sqlParserRule.getConfiguration()).thenReturn(new SQLParserRuleConfiguration(new CacheOption(128, 1024), new CacheOption(2000, 65535))); - return new ShardingSphereMetaData(new LinkedHashMap<>(), mock(ResourceMetaData.class), - new RuleMetaData(Collections.singleton(sqlParserRule)), new ConfigurationProperties(new Properties())); - } } diff --git a/kernel/sql-parser/distsql/statement/src/main/java/org/apache/shardingsphere/parser/distsql/statement/queryable/ShowSQLParserRuleStatement.java b/kernel/sql-parser/distsql/statement/src/main/java/org/apache/shardingsphere/parser/distsql/statement/queryable/ShowSQLParserRuleStatement.java index cfa05f2b85072..ccd194bf5c763 100644 --- a/kernel/sql-parser/distsql/statement/src/main/java/org/apache/shardingsphere/parser/distsql/statement/queryable/ShowSQLParserRuleStatement.java +++ b/kernel/sql-parser/distsql/statement/src/main/java/org/apache/shardingsphere/parser/distsql/statement/queryable/ShowSQLParserRuleStatement.java @@ -17,10 +17,10 @@ package org.apache.shardingsphere.parser.distsql.statement.queryable; -import org.apache.shardingsphere.distsql.statement.ral.QueryableRALStatement; +import org.apache.shardingsphere.distsql.statement.rql.RQLStatement; /** * Show SQL parser rule statement. */ -public final class ShowSQLParserRuleStatement extends QueryableRALStatement { +public final class ShowSQLParserRuleStatement extends RQLStatement { } diff --git a/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutor.java b/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutor.java index a766069b3eea9..7697fefdf5131 100644 --- a/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutor.java +++ b/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutor.java @@ -17,9 +17,9 @@ package org.apache.shardingsphere.sqltranslator.distsql.handler.query; -import org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor; +import lombok.Setter; +import org.apache.shardingsphere.distsql.handler.type.rql.aware.GlobalRuleAwareRQLExecutor; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; import org.apache.shardingsphere.infra.props.PropertiesConverter; import org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration; import org.apache.shardingsphere.sqltranslator.distsql.statement.queryable.ShowSQLTranslatorRuleStatement; @@ -32,22 +32,26 @@ /** * Show SQL translator rule executor. */ -public final class ShowSQLTranslatorRuleExecutor implements QueryableRALExecutor { +@Setter +public final class ShowSQLTranslatorRuleExecutor implements GlobalRuleAwareRQLExecutor { + + private SQLTranslatorRule rule; @Override - public Collection getRows(final ShowSQLTranslatorRuleStatement sqlStatement, final ShardingSphereMetaData metaData) { - SQLTranslatorRule rule = metaData.getGlobalRuleMetaData().getSingleRule(SQLTranslatorRule.class); - return buildData(rule.getConfiguration()); + public Collection getColumnNames() { + return Arrays.asList("type", "props", "use_original_sql_when_translating_failed"); } - private Collection buildData(final SQLTranslatorRuleConfiguration ruleConfig) { + @Override + public Collection getRows(final ShowSQLTranslatorRuleStatement sqlStatement) { + SQLTranslatorRuleConfiguration ruleConfig = rule.getConfiguration(); return Collections.singleton(new LocalDataQueryResultRow(null == ruleConfig.getType() ? "" : ruleConfig.getType(), PropertiesConverter.convert(ruleConfig.getProps()), String.valueOf(ruleConfig.isUseOriginalSQLWhenTranslatingFailed()))); } @Override - public Collection getColumnNames() { - return Arrays.asList("type", "props", "use_original_sql_when_translating_failed"); + public Class getRuleClass() { + return SQLTranslatorRule.class; } @Override diff --git a/kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor b/kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor similarity index 100% rename from kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor rename to kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor diff --git a/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutorTest.java b/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutorTest.java index 1a1998daefcf0..69bce7f1bf85f 100644 --- a/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutorTest.java +++ b/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutorTest.java @@ -17,20 +17,14 @@ package org.apache.shardingsphere.sqltranslator.distsql.handler.query; -import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; -import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData; -import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; import org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration; import org.apache.shardingsphere.sqltranslator.distsql.statement.queryable.ShowSQLTranslatorRuleStatement; import org.apache.shardingsphere.sqltranslator.rule.SQLTranslatorRule; import org.junit.jupiter.api.Test; import java.util.Collection; -import java.util.Collections; import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.Properties; import static org.hamcrest.CoreMatchers.is; @@ -42,9 +36,11 @@ class ShowSQLTranslatorRuleExecutorTest { @Test void assertExecute() { - ShardingSphereMetaData metaData = mockMetaData(); ShowSQLTranslatorRuleExecutor executor = new ShowSQLTranslatorRuleExecutor(); - Collection actual = executor.getRows(mock(ShowSQLTranslatorRuleStatement.class), metaData); + SQLTranslatorRule rule = mock(SQLTranslatorRule.class); + when(rule.getConfiguration()).thenReturn(createSQLTranslatorRuleConfiguration()); + executor.setRule(rule); + Collection actual = executor.getRows(mock(ShowSQLTranslatorRuleStatement.class)); assertThat(actual.size(), is(1)); Iterator iterator = actual.iterator(); LocalDataQueryResultRow row = iterator.next(); @@ -53,24 +49,6 @@ void assertExecute() { assertThat(row.getCell(3), is("true")); } - @Test - void assertGetColumnNames() { - ShowSQLTranslatorRuleExecutor executor = new ShowSQLTranslatorRuleExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("props")); - assertThat(iterator.next(), is("use_original_sql_when_translating_failed")); - } - - private ShardingSphereMetaData mockMetaData() { - SQLTranslatorRule sqlTranslatorRule = mock(SQLTranslatorRule.class); - when(sqlTranslatorRule.getConfiguration()).thenReturn(createSQLTranslatorRuleConfiguration()); - return new ShardingSphereMetaData(new LinkedHashMap<>(), mock(ResourceMetaData.class), - new RuleMetaData(Collections.singleton(sqlTranslatorRule)), new ConfigurationProperties(new Properties())); - } - private SQLTranslatorRuleConfiguration createSQLTranslatorRuleConfiguration() { return new SQLTranslatorRuleConfiguration("NATIVE", new Properties(), true); } diff --git a/kernel/sql-translator/distsql/statement/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/statement/queryable/ShowSQLTranslatorRuleStatement.java b/kernel/sql-translator/distsql/statement/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/statement/queryable/ShowSQLTranslatorRuleStatement.java index 81b611a67a851..b0f135198d019 100644 --- a/kernel/sql-translator/distsql/statement/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/statement/queryable/ShowSQLTranslatorRuleStatement.java +++ b/kernel/sql-translator/distsql/statement/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/statement/queryable/ShowSQLTranslatorRuleStatement.java @@ -17,10 +17,10 @@ package org.apache.shardingsphere.sqltranslator.distsql.statement.queryable; -import org.apache.shardingsphere.distsql.statement.ral.QueryableRALStatement; +import org.apache.shardingsphere.distsql.statement.rql.RQLStatement; /** * Show SQL translator rule statement. */ -public final class ShowSQLTranslatorRuleStatement extends QueryableRALStatement { +public final class ShowSQLTranslatorRuleStatement extends RQLStatement { } diff --git a/kernel/traffic/distsql/handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutor.java b/kernel/traffic/distsql/handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutor.java index 40f868507660f..79f9ba88d6d7f 100644 --- a/kernel/traffic/distsql/handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutor.java +++ b/kernel/traffic/distsql/handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutor.java @@ -17,10 +17,10 @@ package org.apache.shardingsphere.traffic.distsql.handler.query; -import org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor; +import lombok.Setter; +import org.apache.shardingsphere.distsql.handler.type.rql.aware.GlobalRuleAwareRQLExecutor; import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; import org.apache.shardingsphere.infra.props.PropertiesConverter; import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration; import org.apache.shardingsphere.traffic.api.config.TrafficStrategyConfiguration; @@ -34,17 +34,21 @@ /** * Show traffic rule executor. */ -public final class ShowTrafficRuleExecutor implements QueryableRALExecutor { +@Setter +public final class ShowTrafficRuleExecutor implements GlobalRuleAwareRQLExecutor { + + private TrafficRule rule; @Override - public Collection getRows(final ShowTrafficRulesStatement sqlStatement, final ShardingSphereMetaData metaData) { - TrafficRule rule = metaData.getGlobalRuleMetaData().getSingleRule(TrafficRule.class); - return buildData(rule.getConfiguration(), sqlStatement.getRuleName()); + public Collection getColumnNames() { + return Arrays.asList("name", "labels", "algorithm_type", "algorithm_props", "load_balancer_type", "load_balancer_props"); } - private Collection buildData(final TrafficRuleConfiguration ruleConfig, final String ruleName) { + @Override + public Collection getRows(final ShowTrafficRulesStatement sqlStatement) { + TrafficRuleConfiguration ruleConfig = rule.getConfiguration(); Collection result = new LinkedList<>(); - ruleConfig.getTrafficStrategies().stream().filter(each -> null == ruleName || each.getName().equals(ruleName)) + ruleConfig.getTrafficStrategies().stream().filter(each -> null == sqlStatement.getRuleName() || each.getName().equals(sqlStatement.getRuleName())) .forEach(each -> result.add(buildRow(each, ruleConfig.getTrafficAlgorithms().get(each.getAlgorithmName()), ruleConfig.getLoadBalancers().get(each.getLoadBalancerName())))); return result; } @@ -56,8 +60,8 @@ private LocalDataQueryResultRow buildRow(final TrafficStrategyConfiguration stra } @Override - public Collection getColumnNames() { - return Arrays.asList("name", "labels", "algorithm_type", "algorithm_props", "load_balancer_type", "load_balancer_props"); + public Class getRuleClass() { + return TrafficRule.class; } @Override diff --git a/kernel/traffic/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor b/kernel/traffic/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor similarity index 100% rename from kernel/traffic/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor rename to kernel/traffic/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor diff --git a/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutorTest.java b/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutorTest.java index 700d295946fd5..98da703ce4405 100644 --- a/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutorTest.java +++ b/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutorTest.java @@ -18,11 +18,7 @@ package org.apache.shardingsphere.traffic.distsql.handler.query; import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration; -import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; -import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData; -import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; import org.apache.shardingsphere.test.util.PropertiesBuilder; import org.apache.shardingsphere.test.util.PropertiesBuilder.Property; import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration; @@ -35,7 +31,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.Properties; import static org.hamcrest.CoreMatchers.is; @@ -47,9 +42,11 @@ class ShowTrafficRuleExecutorTest { @Test void assertExecute() { - ShardingSphereMetaData metaData = mockMetaData(); ShowTrafficRuleExecutor executor = new ShowTrafficRuleExecutor(); - Collection actual = executor.getRows(mock(ShowTrafficRulesStatement.class), metaData); + TrafficRule rule = mock(TrafficRule.class); + when(rule.getConfiguration()).thenReturn(createTrafficRuleConfiguration()); + executor.setRule(rule); + Collection actual = executor.getRows(mock(ShowTrafficRulesStatement.class)); assertThat(actual.size(), is(2)); Iterator iterator = actual.iterator(); LocalDataQueryResultRow row = iterator.next(); @@ -68,27 +65,6 @@ void assertExecute() { assertThat(row.getCell(6), is("")); } - @Test - void assertGetColumnNames() { - ShowTrafficRuleExecutor executor = new ShowTrafficRuleExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(6)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("name")); - assertThat(iterator.next(), is("labels")); - assertThat(iterator.next(), is("algorithm_type")); - assertThat(iterator.next(), is("algorithm_props")); - assertThat(iterator.next(), is("load_balancer_type")); - assertThat(iterator.next(), is("load_balancer_props")); - } - - private ShardingSphereMetaData mockMetaData() { - TrafficRule trafficRule = mock(TrafficRule.class); - when(trafficRule.getConfiguration()).thenReturn(createTrafficRuleConfiguration()); - return new ShardingSphereMetaData(new LinkedHashMap<>(), mock(ResourceMetaData.class), - new RuleMetaData(Collections.singleton(trafficRule)), new ConfigurationProperties(new Properties())); - } - private TrafficRuleConfiguration createTrafficRuleConfiguration() { TrafficRuleConfiguration result = new TrafficRuleConfiguration(); result.getTrafficStrategies().add(new TrafficStrategyConfiguration("rule_name_1", Arrays.asList("olap", "order_by"), "algorithm_1", "load_balancer_1")); diff --git a/kernel/traffic/distsql/statement/src/main/java/org/apache/shardingsphere/traffic/distsql/statement/queryable/ShowTrafficRulesStatement.java b/kernel/traffic/distsql/statement/src/main/java/org/apache/shardingsphere/traffic/distsql/statement/queryable/ShowTrafficRulesStatement.java index 583cba7d29f1f..627ea92e3bd61 100644 --- a/kernel/traffic/distsql/statement/src/main/java/org/apache/shardingsphere/traffic/distsql/statement/queryable/ShowTrafficRulesStatement.java +++ b/kernel/traffic/distsql/statement/src/main/java/org/apache/shardingsphere/traffic/distsql/statement/queryable/ShowTrafficRulesStatement.java @@ -19,14 +19,14 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; -import org.apache.shardingsphere.distsql.statement.ral.QueryableRALStatement; +import org.apache.shardingsphere.distsql.statement.rql.RQLStatement; /** * Show traffic rules statement. */ @RequiredArgsConstructor @Getter -public final class ShowTrafficRulesStatement extends QueryableRALStatement { +public final class ShowTrafficRulesStatement extends RQLStatement { private final String ruleName; } diff --git a/kernel/transaction/distsql/handler/src/main/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutor.java b/kernel/transaction/distsql/handler/src/main/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutor.java index a1971a7806de3..b7fe49d690172 100644 --- a/kernel/transaction/distsql/handler/src/main/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutor.java +++ b/kernel/transaction/distsql/handler/src/main/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutor.java @@ -17,9 +17,9 @@ package org.apache.shardingsphere.transaction.distsql.handler.query; -import org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor; +import lombok.Setter; +import org.apache.shardingsphere.distsql.handler.type.rql.aware.GlobalRuleAwareRQLExecutor; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; import org.apache.shardingsphere.infra.props.PropertiesConverter; import org.apache.shardingsphere.transaction.distsql.statement.queryable.ShowTransactionRuleStatement; import org.apache.shardingsphere.transaction.rule.TransactionRule; @@ -31,18 +31,25 @@ /** * Show transaction rule executor. */ -public final class ShowTransactionRuleExecutor implements QueryableRALExecutor { +@Setter +public final class ShowTransactionRuleExecutor implements GlobalRuleAwareRQLExecutor { + + private TransactionRule rule; + + @Override + public Collection getColumnNames() { + return Arrays.asList("default_type", "provider_type", "props"); + } @Override - public Collection getRows(final ShowTransactionRuleStatement sqlStatement, final ShardingSphereMetaData metaData) { - TransactionRule rule = metaData.getGlobalRuleMetaData().getSingleRule(TransactionRule.class); + public Collection getRows(final ShowTransactionRuleStatement sqlStatement) { return Collections.singleton(new LocalDataQueryResultRow(rule.getDefaultType().name(), null != rule.getProviderType() ? rule.getProviderType() : "", rule.getProps().isEmpty() ? "" : PropertiesConverter.convert(rule.getProps()))); } @Override - public Collection getColumnNames() { - return Arrays.asList("default_type", "provider_type", "props"); + public Class getRuleClass() { + return TransactionRule.class; } @Override diff --git a/kernel/transaction/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor b/kernel/transaction/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor similarity index 100% rename from kernel/transaction/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor rename to kernel/transaction/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor diff --git a/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutorTest.java b/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutorTest.java index 338c0f294ef66..865f8acf97ad1 100644 --- a/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutorTest.java +++ b/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutorTest.java @@ -17,11 +17,7 @@ package org.apache.shardingsphere.transaction.distsql.handler.query; -import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; -import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData; -import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; import org.apache.shardingsphere.test.util.PropertiesBuilder; import org.apache.shardingsphere.test.util.PropertiesBuilder.Property; import org.apache.shardingsphere.transaction.api.TransactionType; @@ -33,7 +29,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.Properties; import static org.hamcrest.CoreMatchers.is; @@ -46,10 +41,10 @@ class ShowTransactionRuleExecutorTest { @Test void assertExecuteWithXA() { ShowTransactionRuleExecutor executor = new ShowTransactionRuleExecutor(); - RuleMetaData ruleMetaData = mockGlobalRuleMetaData(TransactionType.XA.name(), "Atomikos", - PropertiesBuilder.build(new Property("host", "127.0.0.1"), new Property("databaseName", "jbossts"))); - ShardingSphereMetaData metaData = new ShardingSphereMetaData(new LinkedHashMap<>(), mock(ResourceMetaData.class), ruleMetaData, new ConfigurationProperties(new Properties())); - Collection actual = executor.getRows(mock(ShowTransactionRuleStatement.class), metaData); + TransactionRule rule = new TransactionRule(createTransactionRuleConfiguration(TransactionType.XA.name(), "Atomikos", + PropertiesBuilder.build(new Property("host", "127.0.0.1"), new Property("databaseName", "jbossts"))), Collections.emptyMap()); + executor.setRule(rule); + Collection actual = executor.getRows(mock(ShowTransactionRuleStatement.class)); assertThat(actual.size(), is(1)); Iterator iterator = actual.iterator(); LocalDataQueryResultRow row = iterator.next(); @@ -63,9 +58,9 @@ void assertExecuteWithXA() { @Test void assertExecuteWithLocal() { ShowTransactionRuleExecutor executor = new ShowTransactionRuleExecutor(); - RuleMetaData ruleMetaData = mockGlobalRuleMetaData(TransactionType.LOCAL.name(), null, new Properties()); - ShardingSphereMetaData metaData = new ShardingSphereMetaData(new LinkedHashMap<>(), mock(ResourceMetaData.class), ruleMetaData, new ConfigurationProperties(new Properties())); - Collection actual = executor.getRows(mock(ShowTransactionRuleStatement.class), metaData); + TransactionRule rule = new TransactionRule(createTransactionRuleConfiguration(TransactionType.LOCAL.name(), null, new Properties()), Collections.emptyMap()); + executor.setRule(rule); + Collection actual = executor.getRows(mock(ShowTransactionRuleStatement.class)); assertThat(actual.size(), is(1)); Iterator iterator = actual.iterator(); LocalDataQueryResultRow row = iterator.next(); @@ -74,22 +69,6 @@ void assertExecuteWithLocal() { assertThat(row.getCell(3), is("")); } - @Test - void assertGetColumnNames() { - ShowTransactionRuleExecutor executor = new ShowTransactionRuleExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("default_type")); - assertThat(iterator.next(), is("provider_type")); - assertThat(iterator.next(), is("props")); - } - - private RuleMetaData mockGlobalRuleMetaData(final String defaultType, final String providerType, final Properties props) { - TransactionRule transactionRule = new TransactionRule(createTransactionRuleConfiguration(defaultType, providerType, props), Collections.emptyMap()); - return new RuleMetaData(Collections.singleton(transactionRule)); - } - private TransactionRuleConfiguration createTransactionRuleConfiguration(final String defaultType, final String providerType, final Properties props) { return new TransactionRuleConfiguration(defaultType, providerType, props); } diff --git a/kernel/transaction/distsql/statement/src/main/java/org/apache/shardingsphere/transaction/distsql/statement/queryable/ShowTransactionRuleStatement.java b/kernel/transaction/distsql/statement/src/main/java/org/apache/shardingsphere/transaction/distsql/statement/queryable/ShowTransactionRuleStatement.java index a845d26518d74..516939759c4c4 100644 --- a/kernel/transaction/distsql/statement/src/main/java/org/apache/shardingsphere/transaction/distsql/statement/queryable/ShowTransactionRuleStatement.java +++ b/kernel/transaction/distsql/statement/src/main/java/org/apache/shardingsphere/transaction/distsql/statement/queryable/ShowTransactionRuleStatement.java @@ -17,10 +17,10 @@ package org.apache.shardingsphere.transaction.distsql.statement.queryable; -import org.apache.shardingsphere.distsql.statement.ral.QueryableRALStatement; +import org.apache.shardingsphere.distsql.statement.rql.RQLStatement; /** * Show transaction rule statement. */ -public final class ShowTransactionRuleStatement extends QueryableRALStatement { +public final class ShowTransactionRuleStatement extends RQLStatement { } diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLBackendHandler.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLBackendHandler.java index 5f60337cd1262..4718bad77f331 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLBackendHandler.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLBackendHandler.java @@ -21,6 +21,7 @@ import org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor; import org.apache.shardingsphere.distsql.handler.type.rql.aware.DatabaseAwareRQLExecutor; import org.apache.shardingsphere.distsql.handler.type.rql.aware.DatabaseRuleAwareRQLExecutor; +import org.apache.shardingsphere.distsql.handler.type.rql.aware.GlobalRuleAwareRQLExecutor; import org.apache.shardingsphere.distsql.statement.rql.RQLStatement; import org.apache.shardingsphere.infra.merge.result.MergedResult; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataMergedResult; @@ -69,6 +70,9 @@ public ResponseHeader execute() throws SQLException { if (executor instanceof DatabaseAwareRQLExecutor) { setUpDatabaseAwareExecutor((DatabaseAwareRQLExecutor) executor); } + if (executor instanceof GlobalRuleAwareRQLExecutor) { + setUpGlobalRuleAwareExecutor((GlobalRuleAwareRQLExecutor) executor); + } mergedResult = null == mergedResult ? createMergedResult(executor.getRows(sqlStatement)) : mergedResult; return new QueryResponseHeader(queryHeaders); } @@ -87,6 +91,16 @@ private void setUpDatabaseAwareExecutor(final DatabaseAwareRQLExecutor executor) } } + @SuppressWarnings({"rawtypes", "unchecked"}) + private void setUpGlobalRuleAwareExecutor(final GlobalRuleAwareRQLExecutor executor) { + Optional rule = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(executor.getRuleClass()); + if (rule.isPresent()) { + executor.setRule(rule.get()); + } else { + mergedResult = createMergedResult(Collections.emptyList()); + } + } + private List createQueryHeader(final Collection columnNames) { return columnNames.stream().map(each -> new QueryHeader("", "", each, each, Types.CHAR, "CHAR", 255, 0, false, false, false, false)).collect(Collectors.toList()); } diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java index 787d4ebbe53de..6f87bef5540ad 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java @@ -226,7 +226,7 @@ void assertNewInstanceWithQueryableRALStatementInTransaction() throws SQLExcepti when(connectionSession.getTransactionStatus().isInTransaction()).thenReturn(true); String sql = "SHOW TRANSACTION RULE;"; ProxyBackendHandler actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, connectionSession, new HintValueContext()); - assertThat(actual, instanceOf(QueryableRALBackendHandler.class)); + assertThat(actual, instanceOf(RQLBackendHandler.class)); } @Test diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutorTest.java index 229f3f0d25af4..f304950861674 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutorTest.java @@ -32,7 +32,6 @@ import java.io.FileReader; import java.io.IOException; import java.util.Collection; -import java.util.Iterator; import java.util.Objects; import static org.hamcrest.CoreMatchers.is; @@ -74,15 +73,6 @@ void assertExecuteWithMix() { assertExecute("/conf/convert/config-mix.yaml", "/expected/convert-mix.yaml"); } - @Test - void assertGetColumnNames() { - ConvertYamlConfigurationExecutor executor = new ConvertYamlConfigurationExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(1)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("dist_sql")); - } - private void assertExecute(final String configFilePath, final String expectedFilePath) { ConvertYamlConfigurationExecutor executor = new ConvertYamlConfigurationExecutor(); Collection actual = executor.getRows( diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeModeExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeModeExecutorTest.java index 2449479037f0e..1899d687864b3 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeModeExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowComputeNodeModeExecutorTest.java @@ -51,17 +51,6 @@ void assertExecute() { assertThat(row.getCell(3), is("{\"key\":\"value1,value2\"}")); } - @Test - void assertGetColumnNames() { - ShowComputeNodeModeExecutor executor = new ShowComputeNodeModeExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("repository")); - assertThat(iterator.next(), is("props")); - } - private InstanceContext createInstanceContext() { InstanceContext result = mock(InstanceContext.class, RETURNS_DEEP_STUBS); when(result.getInstance().getMetaData().getId()).thenReturn("127.0.0.1@3309"); diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutorTest.java index 783d3b71ec55c..62c0779cd2bcd 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutorTest.java @@ -44,15 +44,4 @@ void assertGetRowData() { assertThat(row.getCell(2), is("DISTSQL.IMPLEMENTATIONS.FIXTURE")); assertThat(row.getCell(3), is("org.apache.shardingsphere.proxy.backend.handler.distsql.fixture.DistSQLKeyGenerateAlgorithmImplementationsFixture")); } - - @Test - void assertGetColumnNames() { - QueryableRALExecutor executor = new ShowKeyGenerateAlgorithmImplementationsExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("name")); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("class_path")); - } } diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowServiceProviderImplementationsExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowServiceProviderImplementationsExecutorTest.java index 9df2a3927707e..4cacc71ef8279 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowServiceProviderImplementationsExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowServiceProviderImplementationsExecutorTest.java @@ -47,15 +47,4 @@ void assertGetRowData() { assertThat(row.getCell(2), is("com.zaxxer.hikari.HikariDataSource")); assertThat(row.getCell(3), is("org.apache.shardingsphere.infra.datasource.pool.hikari.detector.HikariDataSourcePoolActiveDetector")); } - - @Test - void assertGetColumnNames() { - QueryableRALExecutor executor = new ShowServiceProviderImplementationsExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(3)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("name")); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("class_path")); - } } diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutorTest.java index 7fd05b55890e1..232b03870588f 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutorTest.java @@ -51,19 +51,6 @@ @StaticMockSettings(ProxyContext.class) class ShowTableMetaDataExecutorTest { - @Test - void assertGetColumnNames() { - ShowTableMetaDataExecutor executor = new ShowTableMetaDataExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(5)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("database_name")); - assertThat(iterator.next(), is("table_name")); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("name")); - assertThat(iterator.next(), is("value")); - } - @Test void assertExecute() { ShardingSphereDatabase database = mockDatabase(); diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/type/ShowLogicalTableExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/type/ShowLogicalTableExecutorTest.java index 63de66a8cccb6..500f7eeefd89b 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/type/ShowLogicalTableExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/type/ShowLogicalTableExecutorTest.java @@ -77,12 +77,4 @@ void assertRowDataWithLike() { Iterator iterator = actual.iterator(); assertThat(iterator.next().getCell(1), is("t_order_item")); } - - @Test - void assertGetColumnNames() { - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(1)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("table_name")); - } } diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/type/ShowRulesUsedStorageUnitExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/type/ShowRulesUsedStorageUnitExecutorTest.java index cba3bd0d57780..795ee16f3597e 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/type/ShowRulesUsedStorageUnitExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/type/ShowRulesUsedStorageUnitExecutorTest.java @@ -17,7 +17,6 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.rql.type; -import org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor; import org.apache.shardingsphere.distsql.statement.rql.show.ShowRulesUsedStorageUnitStatement; import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration; import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration; @@ -159,14 +158,4 @@ private ShardingSphereDatabase mockEmptyDatabase() { when(result.getResourceMetaData()).thenReturn(resourceMetaData); return result; } - - @Test - void assertGetColumnNames() { - RQLExecutor executor = new ShowRulesUsedStorageUnitExecutor(); - Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(2)); - Iterator iterator = columns.iterator(); - assertThat(iterator.next(), is("type")); - assertThat(iterator.next(), is("name")); - } } diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/QueryableRALStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/QueryableRALStatementAssert.java index fff02ac1ec1a6..fa959ef130ea8 100644 --- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/QueryableRALStatementAssert.java +++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/QueryableRALStatementAssert.java @@ -19,7 +19,6 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; -import org.apache.shardingsphere.authority.distsql.statement.ShowAuthorityRuleStatement; import org.apache.shardingsphere.distsql.statement.ral.QueryableRALStatement; import org.apache.shardingsphere.distsql.statement.ral.queryable.ConvertYamlConfigurationStatement; import org.apache.shardingsphere.distsql.statement.ral.queryable.ExportDatabaseConfigurationStatement; @@ -31,24 +30,18 @@ import org.apache.shardingsphere.distsql.statement.ral.queryable.ShowDistVariableStatement; import org.apache.shardingsphere.distsql.statement.ral.queryable.ShowDistVariablesStatement; import org.apache.shardingsphere.distsql.statement.ral.queryable.ShowTableMetaDataStatement; -import org.apache.shardingsphere.parser.distsql.statement.queryable.ShowSQLParserRuleStatement; import org.apache.shardingsphere.readwritesplitting.distsql.statement.ShowStatusFromReadwriteSplittingRulesStatement; -import org.apache.shardingsphere.sqltranslator.distsql.statement.queryable.ShowSQLTranslatorRuleStatement; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ConvertYamlConfigurationStatementAssert; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowDistVariableStatementAssert; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowDistVariablesStatementAssert; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowTableMetaDataStatementAssert; -import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowTrafficRulesStatementAssert; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ConvertYamlConfigurationStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowDistVariableStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowDistVariablesStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowTableMetaDataStatementTestCase; -import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowTrafficRulesStatementTestCase; -import org.apache.shardingsphere.traffic.distsql.statement.queryable.ShowTrafficRulesStatement; -import org.apache.shardingsphere.transaction.distsql.statement.queryable.ShowTransactionRuleStatement; /** * Queryable RAL statement assert. @@ -74,22 +67,12 @@ public static void assertIs(final SQLCaseAssertContext assertContext, final Quer ExistingAssert.assertIs(assertContext, actual, expected); } else if (actual instanceof ShowTableMetaDataStatement) { ShowTableMetaDataStatementAssert.assertIs(assertContext, (ShowTableMetaDataStatement) actual, (ShowTableMetaDataStatementTestCase) expected); - } else if (actual instanceof ShowAuthorityRuleStatement) { - ExistingAssert.assertIs(assertContext, actual, expected); - } else if (actual instanceof ShowTransactionRuleStatement) { - ExistingAssert.assertIs(assertContext, actual, expected); - } else if (actual instanceof ShowTrafficRulesStatement) { - ShowTrafficRulesStatementAssert.assertIs(assertContext, (ShowTrafficRulesStatement) actual, (ShowTrafficRulesStatementTestCase) expected); - } else if (actual instanceof ShowSQLParserRuleStatement) { - ExistingAssert.assertIs(assertContext, actual, expected); } else if (actual instanceof ExportDatabaseConfigurationStatement) { ExistingAssert.assertIs(assertContext, actual, expected); } else if (actual instanceof ExportMetaDataStatement) { ExistingAssert.assertIs(assertContext, actual, expected); } else if (actual instanceof ExportStorageNodesStatement) { ExistingAssert.assertIs(assertContext, actual, expected); - } else if (actual instanceof ShowSQLTranslatorRuleStatement) { - ExistingAssert.assertIs(assertContext, actual, expected); } else if (actual instanceof ShowComputeNodeInfoStatement) { ExistingAssert.assertIs(assertContext, actual, expected); } else if (actual instanceof ShowComputeNodeModeStatement) { diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/RQLStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/RQLStatementAssert.java index abb4f812a91b0..4ae2a6bc5d958 100644 --- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/RQLStatementAssert.java +++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/RQLStatementAssert.java @@ -19,15 +19,23 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; +import org.apache.shardingsphere.authority.distsql.statement.ShowAuthorityRuleStatement; import org.apache.shardingsphere.distsql.statement.rql.RQLStatement; import org.apache.shardingsphere.distsql.statement.rql.show.ShowRulesStatement; import org.apache.shardingsphere.distsql.statement.rql.show.ShowStorageUnitsStatement; import org.apache.shardingsphere.distsql.statement.rql.show.ShowTablesStatement; +import org.apache.shardingsphere.parser.distsql.statement.queryable.ShowSQLParserRuleStatement; +import org.apache.shardingsphere.sqltranslator.distsql.statement.queryable.ShowSQLTranslatorRuleStatement; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext; +import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert; +import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.rql.impl.ShowTrafficRulesStatementAssert; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.rql.impl.ShowRulesStatementAssert; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.rql.impl.ShowStorageUnitsStatementAssert; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.rql.impl.ShowTablesStatementAssert; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase; +import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.traffic.ShowTrafficRulesStatementTestCase; +import org.apache.shardingsphere.traffic.distsql.statement.queryable.ShowTrafficRulesStatement; +import org.apache.shardingsphere.transaction.distsql.statement.queryable.ShowTransactionRuleStatement; /** * RQL statement assert. @@ -45,12 +53,20 @@ public final class RQLStatementAssert { public static void assertIs(final SQLCaseAssertContext assertContext, final RQLStatement actual, final SQLParserTestCase expected) { if (actual instanceof ShowRulesStatement) { ShowRulesStatementAssert.assertIs(assertContext, (ShowRulesStatement) actual, expected); - } - if (actual instanceof ShowTablesStatement) { + } else if (actual instanceof ShowTablesStatement) { ShowTablesStatementAssert.assertIs(assertContext, (ShowTablesStatement) actual, expected); - } - if (actual instanceof ShowStorageUnitsStatement) { + } else if (actual instanceof ShowStorageUnitsStatement) { ShowStorageUnitsStatementAssert.assertIs(assertContext, (ShowStorageUnitsStatement) actual, expected); + } else if (actual instanceof ShowAuthorityRuleStatement) { + ExistingAssert.assertIs(assertContext, actual, expected); + } else if (actual instanceof ShowTransactionRuleStatement) { + ExistingAssert.assertIs(assertContext, actual, expected); + } else if (actual instanceof ShowTrafficRulesStatement) { + ShowTrafficRulesStatementAssert.assertIs(assertContext, (ShowTrafficRulesStatement) actual, (ShowTrafficRulesStatementTestCase) expected); + } else if (actual instanceof ShowSQLParserRuleStatement) { + ExistingAssert.assertIs(assertContext, actual, expected); + } else if (actual instanceof ShowSQLTranslatorRuleStatement) { + ExistingAssert.assertIs(assertContext, actual, expected); } } } diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTrafficRulesStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/impl/ShowTrafficRulesStatementAssert.java similarity index 95% rename from test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTrafficRulesStatementAssert.java rename to test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/impl/ShowTrafficRulesStatementAssert.java index 73b8cd33d876c..77723e87753b5 100644 --- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTrafficRulesStatementAssert.java +++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/impl/ShowTrafficRulesStatementAssert.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable; +package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.rql.impl; import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert; -import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowTrafficRulesStatementTestCase; +import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.traffic.ShowTrafficRulesStatementTestCase; import org.apache.shardingsphere.traffic.distsql.statement.queryable.ShowTrafficRulesStatement; import static org.hamcrest.CoreMatchers.is; diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java index 7c45a7a431e0a..21ff2f572026b 100644 --- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java +++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java @@ -324,20 +324,20 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.PrepareDistSQLStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.RefreshTableMetaDataStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.SetDistVariableStatementTestCase; -import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowAuthorityRuleStatementTestCase; +import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.authority.ShowAuthorityRuleStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowComputeNodeInfoStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowComputeNodeModeStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowComputeNodesStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowDistVariableStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowDistVariablesStatementTestCase; -import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowGlobalClockRuleStatementTestCase; +import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.globalclock.ShowGlobalClockRuleStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowMigrationListStatementTestCase; -import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowSQLParserRuleStatementTestCase; -import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowSQLTranslatorRuleStatementTestCase; +import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.parser.ShowSQLParserRuleStatementTestCase; +import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.translator.ShowSQLTranslatorRuleStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowStatusFromReadwriteSplittingRulesStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowTableMetaDataStatementTestCase; -import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowTrafficRulesStatementTestCase; -import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowTransactionRuleStatementTestCase; +import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.traffic.ShowTrafficRulesStatementTestCase; +import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.transaction.ShowTransactionRuleStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.UnlabelComputeNodeStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.cdc.DropStreamingStatementTestCase; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.cdc.ShowStreamingListStatementTestCase; diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowAuthorityRuleStatementTestCase.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/authority/ShowAuthorityRuleStatementTestCase.java similarity index 95% rename from test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowAuthorityRuleStatementTestCase.java rename to test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/authority/ShowAuthorityRuleStatementTestCase.java index 03877f412f095..8a52d0264546a 100644 --- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowAuthorityRuleStatementTestCase.java +++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/authority/ShowAuthorityRuleStatementTestCase.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral; +package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.authority; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase; diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowGlobalClockRuleStatementTestCase.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/globalclock/ShowGlobalClockRuleStatementTestCase.java similarity index 95% rename from test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowGlobalClockRuleStatementTestCase.java rename to test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/globalclock/ShowGlobalClockRuleStatementTestCase.java index 0fa8007d94295..77d4581bf367d 100644 --- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowGlobalClockRuleStatementTestCase.java +++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/globalclock/ShowGlobalClockRuleStatementTestCase.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral; +package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.globalclock; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase; diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowSQLParserRuleStatementTestCase.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/parser/ShowSQLParserRuleStatementTestCase.java similarity index 96% rename from test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowSQLParserRuleStatementTestCase.java rename to test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/parser/ShowSQLParserRuleStatementTestCase.java index 1f56cb5b7c184..4929da27151d4 100644 --- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowSQLParserRuleStatementTestCase.java +++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/parser/ShowSQLParserRuleStatementTestCase.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral; +package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.parser; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase; diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowTrafficRulesStatementTestCase.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/traffic/ShowTrafficRulesStatementTestCase.java similarity index 96% rename from test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowTrafficRulesStatementTestCase.java rename to test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/traffic/ShowTrafficRulesStatementTestCase.java index dda32fad313d2..833cb56f609df 100644 --- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowTrafficRulesStatementTestCase.java +++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/traffic/ShowTrafficRulesStatementTestCase.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral; +package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.traffic; import lombok.Getter; import lombok.Setter; diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowTransactionRuleStatementTestCase.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/transaction/ShowTransactionRuleStatementTestCase.java similarity index 95% rename from test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowTransactionRuleStatementTestCase.java rename to test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/transaction/ShowTransactionRuleStatementTestCase.java index 1070c0493439c..dfaaa1bfe1ca2 100644 --- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowTransactionRuleStatementTestCase.java +++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/transaction/ShowTransactionRuleStatementTestCase.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral; +package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.transaction; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase; diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowSQLTranslatorRuleStatementTestCase.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/translator/ShowSQLTranslatorRuleStatementTestCase.java similarity index 95% rename from test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowSQLTranslatorRuleStatementTestCase.java rename to test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/translator/ShowSQLTranslatorRuleStatementTestCase.java index ae009d523862c..e39007297e4c2 100644 --- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ral/ShowSQLTranslatorRuleStatementTestCase.java +++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/rql/rule/translator/ShowSQLTranslatorRuleStatementTestCase.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral; +package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.rule.translator; import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;