diff --git a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmImplementationsExecutor.java b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmImplementationsExecutor.java deleted file mode 100644 index 6e5cc1f74f25f..0000000000000 --- a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmImplementationsExecutor.java +++ /dev/null @@ -1,52 +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.mask.distsql.handler.query; - -import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor; -import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader; -import org.apache.shardingsphere.mask.distsql.statement.ShowMaskAlgorithmImplementationsStatement; -import org.apache.shardingsphere.mask.spi.MaskAlgorithm; -import org.apache.shardingsphere.mode.manager.ContextManager; - -import java.util.Arrays; -import java.util.Collection; -import java.util.stream.Collectors; - -/** - * Show mask algorithm implementations executor. - */ -public final class ShowMaskAlgorithmImplementationsExecutor implements DistSQLQueryExecutor { - - @Override - public Collection getColumnNames() { - return Arrays.asList("name", "type", "class_path"); - } - - @SuppressWarnings("rawtypes") - @Override - public Collection getRows(final ShowMaskAlgorithmImplementationsStatement sqlStatement, final ContextManager contextManager) { - Collection maskAlgorithms = ShardingSphereServiceLoader.getServiceInstances(MaskAlgorithm.class); - return maskAlgorithms.stream().map(each -> new LocalDataQueryResultRow(each.getClass().getSimpleName(), each.getType(), each.getClass().getName())).collect(Collectors.toList()); - } - - @Override - public Class getType() { - return ShowMaskAlgorithmImplementationsStatement.class; - } -} diff --git a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmPluginsResultRowBuilder.java b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmPluginsResultRowBuilder.java new file mode 100644 index 0000000000000..cf70add495b14 --- /dev/null +++ b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmPluginsResultRowBuilder.java @@ -0,0 +1,49 @@ +/* + * 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.mask.distsql.handler.query; + +import org.apache.shardingsphere.distsql.handler.engine.query.ral.plugin.PluginMetaDataQueryResultRows; +import org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder; +import org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement; +import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; +import org.apache.shardingsphere.mask.spi.MaskAlgorithm; + +import java.util.Collection; + +/** + * Show mask algorithm plugins result row builder. + */ +public final class ShowMaskAlgorithmPluginsResultRowBuilder implements ShowPluginsResultRowBuilder { + + private final PluginMetaDataQueryResultRows pluginMetaDataQueryResultRows = new PluginMetaDataQueryResultRows(MaskAlgorithm.class); + + @Override + public Collection generateRows(final ShowPluginsStatement sqlStatement) { + return pluginMetaDataQueryResultRows.getRows(); + } + + @Override + public Collection getColumnNames() { + return pluginMetaDataQueryResultRows.getColumnNames(); + } + + @Override + public String getType() { + return "MASK_ALGORITHM"; + } +} diff --git a/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor b/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor index e0d50e5893d89..91d46e793cb35 100644 --- a/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor +++ b/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor @@ -16,4 +16,3 @@ # org.apache.shardingsphere.mask.distsql.handler.query.ShowMaskRuleExecutor -org.apache.shardingsphere.mask.distsql.handler.query.ShowMaskAlgorithmImplementationsExecutor diff --git a/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder b/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder new file mode 100644 index 0000000000000..8335918e02afb --- /dev/null +++ b/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder @@ -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.mask.distsql.handler.query.ShowMaskAlgorithmPluginsResultRowBuilder diff --git a/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLStatementVisitor.java b/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLStatementVisitor.java index 367aa83d49d21..f3523cf4424bd 100644 --- a/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLStatementVisitor.java +++ b/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLStatementVisitor.java @@ -32,13 +32,13 @@ import org.apache.shardingsphere.distsql.parser.autogen.MaskDistSQLStatementParser.ShowMaskAlgorithmImplementationsContext; import org.apache.shardingsphere.distsql.parser.autogen.MaskDistSQLStatementParser.ShowMaskRulesContext; import org.apache.shardingsphere.distsql.segment.AlgorithmSegment; +import org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement; import org.apache.shardingsphere.distsql.statement.rql.rule.database.CountRuleStatement; import org.apache.shardingsphere.mask.distsql.segment.MaskColumnSegment; import org.apache.shardingsphere.mask.distsql.segment.MaskRuleSegment; import org.apache.shardingsphere.mask.distsql.statement.AlterMaskRuleStatement; import org.apache.shardingsphere.mask.distsql.statement.CreateMaskRuleStatement; import org.apache.shardingsphere.mask.distsql.statement.DropMaskRuleStatement; -import org.apache.shardingsphere.mask.distsql.statement.ShowMaskAlgorithmImplementationsStatement; import org.apache.shardingsphere.mask.distsql.statement.ShowMaskRulesStatement; import org.apache.shardingsphere.sql.parser.api.ASTNode; import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor; @@ -116,6 +116,6 @@ public ASTNode visitDatabaseName(final DatabaseNameContext ctx) { @Override public ASTNode visitShowMaskAlgorithmImplementations(final ShowMaskAlgorithmImplementationsContext ctx) { - return new ShowMaskAlgorithmImplementationsStatement(); + return new ShowPluginsStatement("MASK_ALGORITHM"); } } diff --git a/features/mask/distsql/statement/src/main/java/org/apache/shardingsphere/mask/distsql/statement/ShowMaskAlgorithmImplementationsStatement.java b/features/mask/distsql/statement/src/main/java/org/apache/shardingsphere/mask/distsql/statement/ShowMaskAlgorithmImplementationsStatement.java deleted file mode 100644 index 6eb08bf37ba97..0000000000000 --- a/features/mask/distsql/statement/src/main/java/org/apache/shardingsphere/mask/distsql/statement/ShowMaskAlgorithmImplementationsStatement.java +++ /dev/null @@ -1,26 +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.mask.distsql.statement; - -import org.apache.shardingsphere.distsql.statement.ral.queryable.QueryableRALStatement; - -/** - * Show mask algorithm implementations statement. - */ -public final class ShowMaskAlgorithmImplementationsStatement extends QueryableRALStatement { -} diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShowShadowAlgorithmImplementationsExecutor.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShowShadowAlgorithmImplementationsExecutor.java deleted file mode 100644 index f3808ad8858e3..0000000000000 --- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShowShadowAlgorithmImplementationsExecutor.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.shadow.distsql.handler.query; - -import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor; -import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; -import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader; -import org.apache.shardingsphere.mode.manager.ContextManager; -import org.apache.shardingsphere.shadow.distsql.statement.ShowShadowAlgorithmImplementationsStatement; -import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm; - -import java.util.Arrays; -import java.util.Collection; -import java.util.stream.Collectors; - -/** - * Show shadow algorithm implementations executor. - */ -public final class ShowShadowAlgorithmImplementationsExecutor implements DistSQLQueryExecutor { - - @Override - public Collection getColumnNames() { - return Arrays.asList("name", "type", "class_path"); - } - - @Override - public Collection getRows(final ShowShadowAlgorithmImplementationsStatement sqlStatement, final ContextManager contextManager) { - Collection shadowAlgorithms = ShardingSphereServiceLoader.getServiceInstances(ShadowAlgorithm.class); - return shadowAlgorithms.stream().map(each -> new LocalDataQueryResultRow(each.getClass().getSimpleName(), each.getType(), each.getClass().getName())).collect(Collectors.toList()); - } - - @Override - public Class getType() { - return ShowShadowAlgorithmImplementationsStatement.class; - } -} diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShowShadowAlgorithmPluginsResultRowBuilder.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShowShadowAlgorithmPluginsResultRowBuilder.java new file mode 100644 index 0000000000000..b87e7d1683e84 --- /dev/null +++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShowShadowAlgorithmPluginsResultRowBuilder.java @@ -0,0 +1,49 @@ +/* + * 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.shadow.distsql.handler.query; + +import org.apache.shardingsphere.distsql.handler.engine.query.ral.plugin.PluginMetaDataQueryResultRows; +import org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder; +import org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement; +import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; +import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm; + +import java.util.Collection; + +/** + * Show shadow algorithm plugins result row builder. + */ +public final class ShowShadowAlgorithmPluginsResultRowBuilder implements ShowPluginsResultRowBuilder { + + private final PluginMetaDataQueryResultRows pluginMetaDataQueryResultRows = new PluginMetaDataQueryResultRows(ShadowAlgorithm.class); + + @Override + public Collection generateRows(final ShowPluginsStatement sqlStatement) { + return pluginMetaDataQueryResultRows.getRows(); + } + + @Override + public Collection getColumnNames() { + return pluginMetaDataQueryResultRows.getColumnNames(); + } + + @Override + public String getType() { + return "SHADOW_ALGORITHM"; + } +} diff --git a/features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor b/features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor index f58cddf629e62..931d5eb50f63e 100644 --- a/features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor +++ b/features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor @@ -19,4 +19,3 @@ org.apache.shardingsphere.shadow.distsql.handler.query.ShowShadowRuleExecutor org.apache.shardingsphere.shadow.distsql.handler.query.ShowShadowTableRulesExecutor org.apache.shardingsphere.shadow.distsql.handler.query.ShowShadowAlgorithmsExecutor org.apache.shardingsphere.shadow.distsql.handler.query.ShowDefaultShadowAlgorithmExecutor -org.apache.shardingsphere.shadow.distsql.handler.query.ShowShadowAlgorithmImplementationsExecutor diff --git a/features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder b/features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder new file mode 100644 index 0000000000000..69f00f141143c --- /dev/null +++ b/features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder @@ -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.shadow.distsql.handler.query.ShowShadowAlgorithmPluginsResultRowBuilder diff --git a/features/shadow/distsql/parser/src/main/java/org/apache/shardingsphere/shadow/distsql/parser/core/ShadowDistSQLStatementVisitor.java b/features/shadow/distsql/parser/src/main/java/org/apache/shardingsphere/shadow/distsql/parser/core/ShadowDistSQLStatementVisitor.java index 912c104c525a9..f4446f1a5c365 100644 --- a/features/shadow/distsql/parser/src/main/java/org/apache/shardingsphere/shadow/distsql/parser/core/ShadowDistSQLStatementVisitor.java +++ b/features/shadow/distsql/parser/src/main/java/org/apache/shardingsphere/shadow/distsql/parser/core/ShadowDistSQLStatementVisitor.java @@ -38,6 +38,7 @@ import org.apache.shardingsphere.distsql.parser.autogen.ShadowDistSQLStatementParser.ShowShadowRulesContext; import org.apache.shardingsphere.distsql.parser.autogen.ShadowDistSQLStatementParser.ShowShadowTableRulesContext; import org.apache.shardingsphere.distsql.segment.AlgorithmSegment; +import org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement; import org.apache.shardingsphere.distsql.statement.rql.rule.database.CountRuleStatement; import org.apache.shardingsphere.shadow.distsql.segment.ShadowAlgorithmSegment; import org.apache.shardingsphere.shadow.distsql.segment.ShadowRuleSegment; @@ -49,7 +50,6 @@ import org.apache.shardingsphere.shadow.distsql.statement.DropShadowAlgorithmStatement; import org.apache.shardingsphere.shadow.distsql.statement.DropShadowRuleStatement; import org.apache.shardingsphere.shadow.distsql.statement.ShowDefaultShadowAlgorithmStatement; -import org.apache.shardingsphere.shadow.distsql.statement.ShowShadowAlgorithmImplementationsStatement; import org.apache.shardingsphere.shadow.distsql.statement.ShowShadowAlgorithmsStatement; import org.apache.shardingsphere.shadow.distsql.statement.ShowShadowRulesStatement; import org.apache.shardingsphere.shadow.distsql.statement.ShowShadowTableRulesStatement; @@ -206,6 +206,6 @@ private String buildAlgorithmName(final String ruleName, final String tableName, @Override public ASTNode visitShowShadowAlgorithmImplementations(final ShowShadowAlgorithmImplementationsContext ctx) { - return new ShowShadowAlgorithmImplementationsStatement(); + return new ShowPluginsStatement("SHADOW_ALGORITHM"); } } diff --git a/features/shadow/distsql/statement/src/main/java/org/apache/shardingsphere/shadow/distsql/statement/ShowShadowAlgorithmImplementationsStatement.java b/features/shadow/distsql/statement/src/main/java/org/apache/shardingsphere/shadow/distsql/statement/ShowShadowAlgorithmImplementationsStatement.java deleted file mode 100644 index 776dff64fe978..0000000000000 --- a/features/shadow/distsql/statement/src/main/java/org/apache/shardingsphere/shadow/distsql/statement/ShowShadowAlgorithmImplementationsStatement.java +++ /dev/null @@ -1,26 +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.shadow.distsql.statement; - -import org.apache.shardingsphere.distsql.statement.ral.queryable.QueryableRALStatement; - -/** - * Show shadow algorithm implementations statement. - */ -public final class ShowShadowAlgorithmImplementationsStatement extends QueryableRALStatement { -}