From eb2bed80670b178eab993c7385bc7a6accacc083 Mon Sep 17 00:00:00 2001 From: Zonglei Dong Date: Wed, 13 Dec 2023 18:51:55 +0800 Subject: [PATCH] refactor "SHOW KEY GENERATE ALGORITHM IMPLEMENTATIONS" module (#29395) --- ...sql.handler.ral.query.QueryableRALExecutor | 1 - .../main/antlr4/imports/sharding/Keyword.g4 | 4 -- .../antlr4/imports/sharding/RALStatement.g4 | 4 -- .../autogen/ShardingDistSQLStatement.g4 | 1 - .../core/ShardingDistSQLStatementVisitor.java | 7 ---- .../engine/src/main/antlr4/imports/Keyword.g4 | 12 ++++++ .../src/main/antlr4/imports/RALStatement.g4 | 4 ++ .../parser/autogen/KernelDistSQLStatement.g4 | 1 + .../kernel/KernelDistSQLStatementVisitor.java | 7 ++++ ...rateAlgorithmImplementationsStatement.java | 6 +-- ...erateAlgorithmImplementationsExecutor.java | 14 +++---- ...sql.handler.ral.query.QueryableRALExecutor | 1 + ...nerateAlgorithmImplementationsFixture.java | 39 +++++++++++++++++++ ...eAlgorithmImplementationsExecutorTest.java | 21 +++++----- ...keygen.core.algorithm.KeyGenerateAlgorithm | 18 +++++++++ 15 files changed, 101 insertions(+), 39 deletions(-) rename features/sharding/distsql/statement/src/main/java/org/apache/shardingsphere/sharding/distsql/statement/ShowShardingKeyGenerateAlgorithmImplementationsStatement.java => parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/ShowKeyGenerateAlgorithmImplementationsStatement.java (79%) rename features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingKeyGenerateAlgorithmImplementationsExecutor.java => proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutor.java (74%) create mode 100644 proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/fixture/DistSQLKeyGenerateAlgorithmImplementationsFixture.java rename features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingKeyGenerateAlgorithmImplementationsExecutorTest.java => proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutorTest.java (64%) create mode 100644 proxy/backend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm diff --git a/features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor b/features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor index 63593d3b8b1ae..79ba98c3e8fd5 100644 --- a/features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor +++ b/features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor @@ -16,4 +16,3 @@ # org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingAlgorithmImplementationsExecutor -org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingKeyGenerateAlgorithmImplementationsExecutor diff --git a/features/sharding/distsql/parser/src/main/antlr4/imports/sharding/Keyword.g4 b/features/sharding/distsql/parser/src/main/antlr4/imports/sharding/Keyword.g4 index 3eb8c752e0936..1649f15fd0774 100644 --- a/features/sharding/distsql/parser/src/main/antlr4/imports/sharding/Keyword.g4 +++ b/features/sharding/distsql/parser/src/main/antlr4/imports/sharding/Keyword.g4 @@ -282,7 +282,3 @@ NONE IMPLEMENTATIONS : I M P L E M E N T A T I O N S ; - -GENERATE - : G E N E R A T E - ; diff --git a/features/sharding/distsql/parser/src/main/antlr4/imports/sharding/RALStatement.g4 b/features/sharding/distsql/parser/src/main/antlr4/imports/sharding/RALStatement.g4 index 9f0a3cbd31772..b21e64d015bb9 100644 --- a/features/sharding/distsql/parser/src/main/antlr4/imports/sharding/RALStatement.g4 +++ b/features/sharding/distsql/parser/src/main/antlr4/imports/sharding/RALStatement.g4 @@ -22,7 +22,3 @@ import BaseRule; showShardingAlgorithmImplementations : SHOW SHARDING ALGORITHM IMPLEMENTATIONS ; - -showShardingKeyGenerateAlgorithmImplementations - : SHOW SHARDING KEY GENERATE ALGORITHM IMPLEMENTATIONS - ; diff --git a/features/sharding/distsql/parser/src/main/antlr4/sharding/org/apache/shardingsphere/distsql/parser/autogen/ShardingDistSQLStatement.g4 b/features/sharding/distsql/parser/src/main/antlr4/sharding/org/apache/shardingsphere/distsql/parser/autogen/ShardingDistSQLStatement.g4 index a7574f8b39562..e19fa5cd9e2d3 100644 --- a/features/sharding/distsql/parser/src/main/antlr4/sharding/org/apache/shardingsphere/distsql/parser/autogen/ShardingDistSQLStatement.g4 +++ b/features/sharding/distsql/parser/src/main/antlr4/sharding/org/apache/shardingsphere/distsql/parser/autogen/ShardingDistSQLStatement.g4 @@ -47,6 +47,5 @@ execute | showUnusedShardingAuditors | countShardingRule | showShardingAlgorithmImplementations - | showShardingKeyGenerateAlgorithmImplementations ) SEMI_? EOF ; diff --git a/features/sharding/distsql/parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java b/features/sharding/distsql/parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java index adf578acb81bc..8e655c3ecdb35 100644 --- a/features/sharding/distsql/parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java +++ b/features/sharding/distsql/parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java @@ -50,7 +50,6 @@ import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShowShardingAlgorithmsContext; import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShowShardingAuditorsContext; import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShowShardingKeyGeneratorsContext; -import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShowShardingKeyGenerateAlgorithmImplementationsContext; import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShowShardingTableNodesContext; import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShowShardingTableReferenceRulesContext; import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShowShardingTableRulesContext; @@ -90,7 +89,6 @@ import org.apache.shardingsphere.sharding.distsql.statement.ShowShardingAlgorithmImplementationsStatement; import org.apache.shardingsphere.sharding.distsql.statement.ShowShardingAlgorithmsStatement; import org.apache.shardingsphere.sharding.distsql.statement.ShowShardingAuditorsStatement; -import org.apache.shardingsphere.sharding.distsql.statement.ShowShardingKeyGenerateAlgorithmImplementationsStatement; import org.apache.shardingsphere.sharding.distsql.statement.ShowShardingKeyGeneratorsStatement; import org.apache.shardingsphere.sharding.distsql.statement.ShowShardingTableNodesStatement; import org.apache.shardingsphere.sharding.distsql.statement.ShowShardingTableReferenceRulesStatement; @@ -409,9 +407,4 @@ public ASTNode visitCountShardingRule(final CountShardingRuleContext ctx) { public ASTNode visitShowShardingAlgorithmImplementations(final ShowShardingAlgorithmImplementationsContext ctx) { return new ShowShardingAlgorithmImplementationsStatement(); } - - @Override - public ASTNode visitShowShardingKeyGenerateAlgorithmImplementations(final ShowShardingKeyGenerateAlgorithmImplementationsContext ctx) { - return new ShowShardingKeyGenerateAlgorithmImplementationsStatement(); - } } diff --git a/parser/distsql/engine/src/main/antlr4/imports/Keyword.g4 b/parser/distsql/engine/src/main/antlr4/imports/Keyword.g4 index a12f065658fd4..29b1428edcbc3 100644 --- a/parser/distsql/engine/src/main/antlr4/imports/Keyword.g4 +++ b/parser/distsql/engine/src/main/antlr4/imports/Keyword.g4 @@ -354,3 +354,15 @@ IMPLEMENTATIONS OF : O F ; + +KEY + : K E Y + ; + +GENERATE + : G E N E R A T E + ; + +ALGORITHM + : A L G O R I T H M + ; diff --git a/parser/distsql/engine/src/main/antlr4/imports/RALStatement.g4 b/parser/distsql/engine/src/main/antlr4/imports/RALStatement.g4 index ba93cc20e24df..a6beedb0fd4f7 100644 --- a/parser/distsql/engine/src/main/antlr4/imports/RALStatement.g4 +++ b/parser/distsql/engine/src/main/antlr4/imports/RALStatement.g4 @@ -119,6 +119,10 @@ showServiceProviderImplementations : SHOW IMPLEMENTATIONS OF serviceProviderInterface ; +showKeyGenerateAlgorithmImplementations + : SHOW KEY GENERATE ALGORITHM IMPLEMENTATIONS + ; + transmissionRule : LP_ readDefinition? (COMMA_? writeDefinition)? (COMMA_? streamChannel)? RP_ ; diff --git a/parser/distsql/engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/KernelDistSQLStatement.g4 b/parser/distsql/engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/KernelDistSQLStatement.g4 index 30000d0f6d648..5b1bf9a89cfdb 100644 --- a/parser/distsql/engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/KernelDistSQLStatement.g4 +++ b/parser/distsql/engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/KernelDistSQLStatement.g4 @@ -51,5 +51,6 @@ execute | lockCluster | unlockCluster | showServiceProviderImplementations + | showKeyGenerateAlgorithmImplementations ) SEMI_? EOF ; diff --git a/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java b/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java index 146ba47be6001..f132ba3ab87ba 100644 --- a/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java +++ b/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java @@ -56,6 +56,7 @@ import org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowDistVariableContext; import org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowDistVariablesContext; import org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowLogicalTablesContext; +import org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowKeyGenerateAlgorithmImplementationsContext; import org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowMigrationRuleContext; import org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowRulesUsedStorageUnitContext; import org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowServiceProviderImplementationsContext; @@ -84,6 +85,7 @@ import org.apache.shardingsphere.distsql.statement.ral.queryable.ShowComputeNodesStatement; 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.ShowKeyGenerateAlgorithmImplementationsStatement; import org.apache.shardingsphere.distsql.statement.ral.queryable.ShowMigrationRuleStatement; import org.apache.shardingsphere.distsql.statement.ral.queryable.ShowServiceProviderImplementationsStatement; import org.apache.shardingsphere.distsql.statement.ral.queryable.ShowTableMetaDataStatement; @@ -408,4 +410,9 @@ private String getQuotedContent(final ParseTree context) { public ASTNode visitShowServiceProviderImplementations(final ShowServiceProviderImplementationsContext ctx) { return new ShowServiceProviderImplementationsStatement(getIdentifierValue(ctx.serviceProviderInterface())); } + + @Override + public ASTNode visitShowKeyGenerateAlgorithmImplementations(final ShowKeyGenerateAlgorithmImplementationsContext ctx) { + return new ShowKeyGenerateAlgorithmImplementationsStatement(); + } } diff --git a/features/sharding/distsql/statement/src/main/java/org/apache/shardingsphere/sharding/distsql/statement/ShowShardingKeyGenerateAlgorithmImplementationsStatement.java b/parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/ShowKeyGenerateAlgorithmImplementationsStatement.java similarity index 79% rename from features/sharding/distsql/statement/src/main/java/org/apache/shardingsphere/sharding/distsql/statement/ShowShardingKeyGenerateAlgorithmImplementationsStatement.java rename to parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/ShowKeyGenerateAlgorithmImplementationsStatement.java index 8176594028db5..10b9d648f5a6b 100644 --- a/features/sharding/distsql/statement/src/main/java/org/apache/shardingsphere/sharding/distsql/statement/ShowShardingKeyGenerateAlgorithmImplementationsStatement.java +++ b/parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/ShowKeyGenerateAlgorithmImplementationsStatement.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.shardingsphere.sharding.distsql.statement; +package org.apache.shardingsphere.distsql.statement.ral.queryable; import org.apache.shardingsphere.distsql.statement.ral.QueryableRALStatement; /** - * Show sharding key generate algorithm implementations statement. + * Show key generate algorithm implementations statement. */ -public final class ShowShardingKeyGenerateAlgorithmImplementationsStatement extends QueryableRALStatement { +public final class ShowKeyGenerateAlgorithmImplementationsStatement extends QueryableRALStatement { } diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingKeyGenerateAlgorithmImplementationsExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutor.java similarity index 74% rename from features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingKeyGenerateAlgorithmImplementationsExecutor.java rename to proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutor.java index eb8dc842b45ab..d5bc6cc888f6e 100644 --- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingKeyGenerateAlgorithmImplementationsExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutor.java @@ -15,22 +15,22 @@ * limitations under the License. */ -package org.apache.shardingsphere.sharding.distsql.handler.query; +package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable; import org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor; +import org.apache.shardingsphere.distsql.statement.ral.queryable.ShowKeyGenerateAlgorithmImplementationsStatement; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader; import org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm; -import org.apache.shardingsphere.sharding.distsql.statement.ShowShardingKeyGenerateAlgorithmImplementationsStatement; import java.util.Arrays; import java.util.Collection; import java.util.LinkedList; /** - * Show sharding key generate algorithm implementations executor. + * Show key generate algorithm implementations executor. */ -public final class ShowShardingKeyGenerateAlgorithmImplementationsExecutor implements QueryableRALExecutor { +public final class ShowKeyGenerateAlgorithmImplementationsExecutor implements QueryableRALExecutor { @Override public Collection getColumnNames() { @@ -38,7 +38,7 @@ public Collection getColumnNames() { } @Override - public Collection getRows(final ShowShardingKeyGenerateAlgorithmImplementationsStatement sqlStatement) { + public Collection getRows(final ShowKeyGenerateAlgorithmImplementationsStatement sqlStatement) { Collection result = new LinkedList<>(); Collection keyGenerateAlgorithms = ShardingSphereServiceLoader.getServiceInstances(KeyGenerateAlgorithm.class); for (KeyGenerateAlgorithm each : keyGenerateAlgorithms) { @@ -48,7 +48,7 @@ public Collection getRows(final ShowShardingKeyGenerate } @Override - public Class getType() { - return ShowShardingKeyGenerateAlgorithmImplementationsStatement.class; + public Class getType() { + return ShowKeyGenerateAlgorithmImplementationsStatement.class; } } diff --git a/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor b/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor index 97d4f5329cc4a..0a2c431c9b0d3 100644 --- a/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor +++ b/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor @@ -28,3 +28,4 @@ org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowStatus org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowTableMetaDataExecutor org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowMigrationRuleExecutor org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowServiceProviderImplementationsExecutor +org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowKeyGenerateAlgorithmImplementationsExecutor diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/fixture/DistSQLKeyGenerateAlgorithmImplementationsFixture.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/fixture/DistSQLKeyGenerateAlgorithmImplementationsFixture.java new file mode 100644 index 0000000000000..40f1529efc294 --- /dev/null +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/fixture/DistSQLKeyGenerateAlgorithmImplementationsFixture.java @@ -0,0 +1,39 @@ +/* + * 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.proxy.backend.handler.distsql.fixture; + +import org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm; +import org.apache.shardingsphere.keygen.core.context.KeyGenerateContext; + +import java.util.Collection; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public final class DistSQLKeyGenerateAlgorithmImplementationsFixture implements KeyGenerateAlgorithm { + + @Override + public Collection> generateKeys(final KeyGenerateContext keyGenerateContext, final int keyGenerateCount) { + return IntStream.range(0, keyGenerateCount).mapToObj(each -> 0L).collect(Collectors.toList()); + + } + + @Override + public String getType() { + return "DISTSQL.IMPLEMENTATIONS.FIXTURE"; + } +} diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingKeyGenerateAlgorithmImplementationsExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutorTest.java similarity index 64% rename from features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingKeyGenerateAlgorithmImplementationsExecutorTest.java rename to proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutorTest.java index b5eaa7b5dc660..f8a6e87ea366e 100644 --- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingKeyGenerateAlgorithmImplementationsExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutorTest.java @@ -15,14 +15,11 @@ * limitations under the License. */ -package org.apache.shardingsphere.sharding.distsql.query; +package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable; import org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor; +import org.apache.shardingsphere.distsql.statement.ral.queryable.ShowKeyGenerateAlgorithmImplementationsStatement; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingAlgorithmImplementationsExecutor; -import org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingKeyGenerateAlgorithmImplementationsExecutor; -import org.apache.shardingsphere.sharding.distsql.statement.ShowShardingAlgorithmImplementationsStatement; -import org.apache.shardingsphere.sharding.distsql.statement.ShowShardingKeyGenerateAlgorithmImplementationsStatement; import org.junit.jupiter.api.Test; import java.util.Collection; @@ -33,23 +30,23 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.Mockito.mock; -class ShowShardingKeyGenerateAlgorithmImplementationsExecutorTest { +class ShowKeyGenerateAlgorithmImplementationsExecutorTest { @Test void assertGetRowData() { - QueryableRALExecutor executor = new ShowShardingKeyGenerateAlgorithmImplementationsExecutor(); - Collection actual = executor.getRows(mock(ShowShardingKeyGenerateAlgorithmImplementationsStatement.class)); + QueryableRALExecutor executor = new ShowKeyGenerateAlgorithmImplementationsExecutor(); + Collection actual = executor.getRows(mock(ShowKeyGenerateAlgorithmImplementationsStatement.class)); assertFalse(actual.isEmpty()); Iterator iterator = actual.iterator(); LocalDataQueryResultRow row = iterator.next(); - assertThat(row.getCell(1), is("DistSQLKeyGenerateAlgorithmFixture")); - assertThat(row.getCell(2), is("DISTSQL.FIXTURE")); - assertThat(row.getCell(3), is("org.apache.shardingsphere.sharding.distsql.fixture.keygen.DistSQLKeyGenerateAlgorithmFixture")); + assertThat(row.getCell(1), is("DistSQLKeyGenerateAlgorithmImplementationsFixture")); + 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 ShowShardingAlgorithmImplementationsExecutor(); + QueryableRALExecutor executor = new ShowKeyGenerateAlgorithmImplementationsExecutor(); Collection columns = executor.getColumnNames(); assertThat(columns.size(), is(3)); Iterator iterator = columns.iterator(); diff --git a/proxy/backend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm b/proxy/backend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm new file mode 100644 index 0000000000000..74db2039b5d7a --- /dev/null +++ b/proxy/backend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm @@ -0,0 +1,18 @@ +# +# 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. +# + +org.apache.shardingsphere.proxy.backend.handler.distsql.fixture.DistSQLKeyGenerateAlgorithmImplementationsFixture