This is an automated email from the ASF dual-hosted git repository.

jianglongtao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 0599a8f47db Remove SingletonSPI annotation from DistSQL executors 
(#38097)
0599a8f47db is described below

commit 0599a8f47db3821b484b66ff913d268c1728ca2a
Author: Raigor <[email protected]>
AuthorDate: Thu Feb 19 15:36:40 2026 +0800

    Remove SingletonSPI annotation from DistSQL executors (#38097)
    
    * Remove SingletonSPI annotation from DistSQL executors
    
    * Update RELEASE-NOTES.md
---
 RELEASE-NOTES.md                                   |   1 +
 .../handler/engine/query/DistSQLQueryExecutor.java |   2 -
 .../update/AdvancedDistSQLUpdateExecutor.java      |   2 -
 .../engine/update/DistSQLUpdateExecutor.java       |   2 -
 .../database/DatabaseRuleDefinitionExecutor.java   |   2 -
 .../spi/global/GlobalRuleDefinitionExecutor.java   |   2 -
 .../DistSQLExecutorConcurrentIsolationTest.java    | 114 +++++++++++++++++++++
 .../FixtureDatabaseRuleDefinitionExecutor.java     |  56 ++++++++++
 .../FixtureDatabaseRuleDefinitionStatement.java}   |  22 ++--
 .../fixture/FixtureDistSQLQueryExecutor.java       |  69 +++++++++++++
 .../fixture/FixtureDistSQLQueryStatement.java}     |  19 ++--
 .../fixture/FixtureDistSQLUpdateExecutor.java      |  55 ++++++++++
 .../fixture/FixtureDistSQLUpdateStatement.java}    |  19 ++--
 .../engine/concurrent/fixture/FixtureRule.java}    |  32 ++++--
 ...stsql.handler.engine.query.DistSQLQueryExecutor |  18 ++++
 ...sql.handler.engine.update.DistSQLUpdateExecutor |  18 ++++
 ...ule.spi.database.DatabaseRuleDefinitionExecutor |  18 ++++
 17 files changed, 411 insertions(+), 40 deletions(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 333365ec53e..4c6e24a9bd9 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -152,6 +152,7 @@
 1. Pipeline: Fix PostgreSQL migration create table SQL generation failure 
caused by locale-formatted sequence values - 
[#28360](https://github.com/apache/shardingsphere/issues/28360)
 1. Pipeline: MySQLBinlogClient compatible with async exception - 
[#37631](https://github.com/apache/shardingsphere/issues/37631)
 1. Pipeline: Fix SHOW MIGRATION RULE always display default values when ALTER 
MIGRATION RULE without STREAM_CHANNEL - 
[#37737](https://github.com/apache/shardingsphere/issues/37737)
+1. DistSQL: Eliminate the concurrency safety risks of DistSQL executors. - 
[#38097](https://github.com/apache/shardingsphere/pull/38097)
 
 ### Change Logs
 
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/query/DistSQLQueryExecutor.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/query/DistSQLQueryExecutor.java
index ebf5df0875d..91ddab159af 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/query/DistSQLQueryExecutor.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/query/DistSQLQueryExecutor.java
@@ -19,7 +19,6 @@ package 
org.apache.shardingsphere.distsql.handler.engine.query;
 
 import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 
@@ -31,7 +30,6 @@ import java.util.Collection;
  *
  * @param <T> type of DistSQL statement
  */
-@SingletonSPI
 public interface DistSQLQueryExecutor<T extends DistSQLStatement> extends 
TypedSPI {
     
     /**
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
index 675731e70ff..3b35493ffd5 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
@@ -18,13 +18,11 @@
 package org.apache.shardingsphere.distsql.handler.engine.update;
 
 import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
 
 /**
  * Advanced DistSQL update executor.
  * 
  * @param <T> type of DistSQL statement
  */
-@SingletonSPI
 public interface AdvancedDistSQLUpdateExecutor<T extends DistSQLStatement> 
extends DistSQLUpdateExecutor<T> {
 }
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/DistSQLUpdateExecutor.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/DistSQLUpdateExecutor.java
index fb30b4502fa..0cbb025eb37 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/DistSQLUpdateExecutor.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/DistSQLUpdateExecutor.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.distsql.handler.engine.update;
 
 import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 
@@ -29,7 +28,6 @@ import java.sql.SQLException;
  * 
  * @param <T> type of DistSQL statement
  */
-@SingletonSPI
 public interface DistSQLUpdateExecutor<T extends DistSQLStatement> extends 
TypedSPI {
     
     /**
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/spi/database/DatabaseRuleDefinitionExecutor.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/spi/database/DatabaseRuleDefinitionExecutor.java
index 4daf26279ef..5673f7974ed 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/spi/database/DatabaseRuleDefinitionExecutor.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/spi/database/DatabaseRuleDefinitionExecutor.java
@@ -20,7 +20,6 @@ package 
org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.dat
 import 
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorDatabaseAware;
 import 
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorRuleAware;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
 
@@ -30,7 +29,6 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatemen
  * @param <T> type of SQL statement
  * @param <R> type of rule
  */
-@SingletonSPI
 public interface DatabaseRuleDefinitionExecutor<T extends SQLStatement, R 
extends ShardingSphereRule> extends TypedSPI, DistSQLExecutorDatabaseAware, 
DistSQLExecutorRuleAware<R> {
     
     /**
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/spi/global/GlobalRuleDefinitionExecutor.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/spi/global/GlobalRuleDefinitionExecutor.java
index e586d5527c8..e113317050c 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/spi/global/GlobalRuleDefinitionExecutor.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/spi/global/GlobalRuleDefinitionExecutor.java
@@ -21,7 +21,6 @@ import 
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorRuleAware;
 import 
org.apache.shardingsphere.distsql.statement.type.rdl.rule.global.GlobalRuleDefinitionStatement;
 import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
 
 /**
@@ -30,7 +29,6 @@ import 
org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
  * @param <T> type of rule definition statement
  * @param <R> type of rule
  */
-@SingletonSPI
 public interface GlobalRuleDefinitionExecutor<T extends 
GlobalRuleDefinitionStatement, R extends ShardingSphereRule> extends 
DistSQLExecutorRuleAware<R>, TypedSPI {
     
     /**
diff --git 
a/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/DistSQLExecutorConcurrentIsolationTest.java
 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/DistSQLExecutorConcurrentIsolationTest.java
new file mode 100644
index 00000000000..65e5088a291
--- /dev/null
+++ 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/DistSQLExecutorConcurrentIsolationTest.java
@@ -0,0 +1,114 @@
+/*
+ * 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.distsql.handler.engine.concurrent;
+
+import 
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorRuleAware;
+import 
org.apache.shardingsphere.distsql.handler.engine.concurrent.fixture.FixtureDatabaseRuleDefinitionStatement;
+import 
org.apache.shardingsphere.distsql.handler.engine.concurrent.fixture.FixtureDistSQLQueryStatement;
+import 
org.apache.shardingsphere.distsql.handler.engine.concurrent.fixture.FixtureDistSQLUpdateStatement;
+import 
org.apache.shardingsphere.distsql.handler.engine.concurrent.fixture.FixtureRule;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import 
org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import 
org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.junit.jupiter.api.Test;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.sameInstance;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class DistSQLExecutorConcurrentIsolationTest {
+    
+    private static final int THREAD_COUNT = 2;
+    
+    private static final int TIMEOUT_SECONDS = 10;
+    
+    @Test
+    void assertDatabaseRuleDefinitionExecutorConcurrentIsolation() throws 
Exception {
+        CyclicBarrier barrier = new CyclicBarrier(THREAD_COUNT);
+        assertConcurrentIsolation(createDatabaseRuleDefinitionTask(barrier, 
new FixtureRule("first")), createDatabaseRuleDefinitionTask(barrier, new 
FixtureRule("second")));
+    }
+    
+    @Test
+    void assertDistSQLQueryExecutorConcurrentIsolation() throws Exception {
+        CyclicBarrier barrier = new CyclicBarrier(THREAD_COUNT);
+        assertConcurrentIsolation(createDistSQLQueryTask(barrier, new 
FixtureRule("first")), createDistSQLQueryTask(barrier, new 
FixtureRule("second")));
+    }
+    
+    @Test
+    void assertDistSQLUpdateExecutorConcurrentIsolation() throws Exception {
+        CyclicBarrier barrier = new CyclicBarrier(THREAD_COUNT);
+        assertConcurrentIsolation(createDistSQLUpdateTask(barrier, new 
FixtureRule("first")), createDistSQLUpdateTask(barrier, new 
FixtureRule("second")));
+    }
+    
+    @SuppressWarnings("unchecked")
+    private Callable<Object> createDatabaseRuleDefinitionTask(final 
CyclicBarrier barrier, final FixtureRule expectedRule) {
+        return () -> {
+            
DatabaseRuleDefinitionExecutor<FixtureDatabaseRuleDefinitionStatement, 
ShardingSphereRule> executor =
+                    
TypedSPILoader.getService(DatabaseRuleDefinitionExecutor.class, 
FixtureDatabaseRuleDefinitionStatement.class);
+            executor.setDatabase(null);
+            executor.setRule(expectedRule);
+            barrier.await(TIMEOUT_SECONDS, TimeUnit.SECONDS);
+            executor.checkBeforeUpdate(new 
FixtureDatabaseRuleDefinitionStatement(expectedRule));
+            return executor;
+        };
+    }
+    
+    @SuppressWarnings("unchecked")
+    private Callable<Object> createDistSQLQueryTask(final CyclicBarrier 
barrier, final FixtureRule expectedRule) {
+        return () -> {
+            DistSQLQueryExecutor<FixtureDistSQLQueryStatement> executor = 
TypedSPILoader.getService(DistSQLQueryExecutor.class, 
FixtureDistSQLQueryStatement.class);
+            ((DistSQLExecutorRuleAware<ShardingSphereRule>) 
executor).setRule(expectedRule);
+            barrier.await(TIMEOUT_SECONDS, TimeUnit.SECONDS);
+            executor.getColumnNames(new 
FixtureDistSQLQueryStatement(expectedRule));
+            return executor;
+        };
+    }
+    
+    @SuppressWarnings("unchecked")
+    private Callable<Object> createDistSQLUpdateTask(final CyclicBarrier 
barrier, final FixtureRule expectedRule) {
+        return () -> {
+            DistSQLUpdateExecutor<FixtureDistSQLUpdateStatement> executor = 
TypedSPILoader.getService(DistSQLUpdateExecutor.class, 
FixtureDistSQLUpdateStatement.class);
+            ((DistSQLExecutorRuleAware<ShardingSphereRule>) 
executor).setRule(expectedRule);
+            barrier.await(TIMEOUT_SECONDS, TimeUnit.SECONDS);
+            executor.executeUpdate(new 
FixtureDistSQLUpdateStatement(expectedRule), null);
+            return executor;
+        };
+    }
+    
+    private void assertConcurrentIsolation(final Callable<Object> firstTask, 
final Callable<Object> secondTask) throws Exception {
+        ExecutorService executorService = 
Executors.newFixedThreadPool(THREAD_COUNT);
+        try {
+            Future<Object> firstFuture = executorService.submit(firstTask);
+            Future<Object> secondFuture = executorService.submit(secondTask);
+            Object firstExecutor = firstFuture.get(TIMEOUT_SECONDS, 
TimeUnit.SECONDS);
+            Object secondExecutor = secondFuture.get(TIMEOUT_SECONDS, 
TimeUnit.SECONDS);
+            assertThat(firstExecutor, not(sameInstance(secondExecutor)));
+        } finally {
+            executorService.shutdownNow();
+        }
+    }
+}
diff --git 
a/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDatabaseRuleDefinitionExecutor.java
 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDatabaseRuleDefinitionExecutor.java
new file mode 100644
index 00000000000..573a767f823
--- /dev/null
+++ 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDatabaseRuleDefinitionExecutor.java
@@ -0,0 +1,56 @@
+/*
+ * 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.distsql.handler.engine.concurrent.fixture;
+
+import 
org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor;
+import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+
+/**
+ * Fixture database rule definition executor.
+ */
+public final class FixtureDatabaseRuleDefinitionExecutor implements 
DatabaseRuleDefinitionExecutor<FixtureDatabaseRuleDefinitionStatement, 
ShardingSphereRule> {
+    
+    private ShardingSphereRule rule;
+    
+    @Override
+    public void setDatabase(final ShardingSphereDatabase database) {
+    }
+    
+    @Override
+    public void setRule(final ShardingSphereRule rule) {
+        this.rule = rule;
+    }
+    
+    @Override
+    public Class<ShardingSphereRule> getRuleClass() {
+        return ShardingSphereRule.class;
+    }
+    
+    @Override
+    public void checkBeforeUpdate(final FixtureDatabaseRuleDefinitionStatement 
sqlStatement) {
+        if (rule != sqlStatement.getExpectedRule()) {
+            throw new IllegalStateException(String.format("Current rule `%s` 
does not match expected rule `%s`", rule, sqlStatement.getExpectedRule()));
+        }
+    }
+    
+    @Override
+    public Class<FixtureDatabaseRuleDefinitionStatement> getType() {
+        return FixtureDatabaseRuleDefinitionStatement.class;
+    }
+}
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDatabaseRuleDefinitionStatement.java
similarity index 57%
copy from 
infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
copy to 
infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDatabaseRuleDefinitionStatement.java
index 675731e70ff..f251a1896d5 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
+++ 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDatabaseRuleDefinitionStatement.java
@@ -15,16 +15,22 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.handler.engine.update;
+package org.apache.shardingsphere.distsql.handler.engine.concurrent.fixture;
 
-import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
+import lombok.Getter;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
 
 /**
- * Advanced DistSQL update executor.
- * 
- * @param <T> type of DistSQL statement
+ * Fixture database rule definition statement.
  */
-@SingletonSPI
-public interface AdvancedDistSQLUpdateExecutor<T extends DistSQLStatement> 
extends DistSQLUpdateExecutor<T> {
+@Getter
+public final class FixtureDatabaseRuleDefinitionStatement extends SQLStatement 
{
+    
+    private final ShardingSphereRule expectedRule;
+    
+    public FixtureDatabaseRuleDefinitionStatement(final ShardingSphereRule 
expectedRule) {
+        super(null);
+        this.expectedRule = expectedRule;
+    }
 }
diff --git 
a/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDistSQLQueryExecutor.java
 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDistSQLQueryExecutor.java
new file mode 100644
index 00000000000..8dc7b63ac45
--- /dev/null
+++ 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDistSQLQueryExecutor.java
@@ -0,0 +1,69 @@
+/*
+ * 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.distsql.handler.engine.concurrent.fixture;
+
+import 
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorRuleAware;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Fixture DistSQL query executor.
+ */
+public final class FixtureDistSQLQueryExecutor implements 
DistSQLQueryExecutor<FixtureDistSQLQueryStatement>, 
DistSQLExecutorRuleAware<ShardingSphereRule> {
+    
+    private ShardingSphereRule rule;
+    
+    @Override
+    public void setRule(final ShardingSphereRule rule) {
+        this.rule = rule;
+    }
+    
+    @Override
+    public Class<ShardingSphereRule> getRuleClass() {
+        return ShardingSphereRule.class;
+    }
+    
+    @Override
+    public Collection<String> getColumnNames(final 
FixtureDistSQLQueryStatement sqlStatement) {
+        checkRule(sqlStatement);
+        return Collections.singleton("rule");
+    }
+    
+    private void checkRule(final FixtureDistSQLQueryStatement sqlStatement) {
+        if (rule != sqlStatement.getExpectedRule()) {
+            throw new IllegalStateException(String.format("Current rule `%s` 
does not match expected rule `%s`", rule, sqlStatement.getExpectedRule()));
+        }
+    }
+    
+    @Override
+    public Collection<LocalDataQueryResultRow> getRows(final 
FixtureDistSQLQueryStatement sqlStatement, final ContextManager contextManager) 
throws SQLException {
+        checkRule(sqlStatement);
+        return Collections.emptyList();
+    }
+    
+    @Override
+    public Class<FixtureDistSQLQueryStatement> getType() {
+        return FixtureDistSQLQueryStatement.class;
+    }
+}
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDistSQLQueryStatement.java
similarity index 65%
copy from 
infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
copy to 
infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDistSQLQueryStatement.java
index 675731e70ff..c9b1dea5f97 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
+++ 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDistSQLQueryStatement.java
@@ -15,16 +15,21 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.handler.engine.update;
+package org.apache.shardingsphere.distsql.handler.engine.concurrent.fixture;
 
+import lombok.Getter;
 import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 
 /**
- * Advanced DistSQL update executor.
- * 
- * @param <T> type of DistSQL statement
+ * Fixture DistSQL query statement.
  */
-@SingletonSPI
-public interface AdvancedDistSQLUpdateExecutor<T extends DistSQLStatement> 
extends DistSQLUpdateExecutor<T> {
+@Getter
+public final class FixtureDistSQLQueryStatement extends DistSQLStatement {
+    
+    private final ShardingSphereRule expectedRule;
+    
+    public FixtureDistSQLQueryStatement(final ShardingSphereRule expectedRule) 
{
+        this.expectedRule = expectedRule;
+    }
 }
diff --git 
a/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDistSQLUpdateExecutor.java
 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDistSQLUpdateExecutor.java
new file mode 100644
index 00000000000..84e4bfcd61b
--- /dev/null
+++ 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDistSQLUpdateExecutor.java
@@ -0,0 +1,55 @@
+/*
+ * 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.distsql.handler.engine.concurrent.fixture;
+
+import 
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorRuleAware;
+import 
org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+
+import java.sql.SQLException;
+
+/**
+ * Fixture DistSQL update executor.
+ */
+public final class FixtureDistSQLUpdateExecutor implements 
DistSQLUpdateExecutor<FixtureDistSQLUpdateStatement>, 
DistSQLExecutorRuleAware<ShardingSphereRule> {
+    
+    private ShardingSphereRule rule;
+    
+    @Override
+    public void setRule(final ShardingSphereRule rule) {
+        this.rule = rule;
+    }
+    
+    @Override
+    public Class<ShardingSphereRule> getRuleClass() {
+        return ShardingSphereRule.class;
+    }
+    
+    @Override
+    public void executeUpdate(final FixtureDistSQLUpdateStatement 
sqlStatement, final ContextManager contextManager) throws SQLException {
+        if (rule != sqlStatement.getExpectedRule()) {
+            throw new IllegalStateException(String.format("Current rule `%s` 
does not match expected rule `%s`", rule, sqlStatement.getExpectedRule()));
+        }
+    }
+    
+    @Override
+    public Class<FixtureDistSQLUpdateStatement> getType() {
+        return FixtureDistSQLUpdateStatement.class;
+    }
+}
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDistSQLUpdateStatement.java
similarity index 65%
copy from 
infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
copy to 
infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDistSQLUpdateStatement.java
index 675731e70ff..61895bfe39b 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
+++ 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureDistSQLUpdateStatement.java
@@ -15,16 +15,21 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.handler.engine.update;
+package org.apache.shardingsphere.distsql.handler.engine.concurrent.fixture;
 
+import lombok.Getter;
 import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 
 /**
- * Advanced DistSQL update executor.
- * 
- * @param <T> type of DistSQL statement
+ * Fixture DistSQL update statement.
  */
-@SingletonSPI
-public interface AdvancedDistSQLUpdateExecutor<T extends DistSQLStatement> 
extends DistSQLUpdateExecutor<T> {
+@Getter
+public final class FixtureDistSQLUpdateStatement extends DistSQLStatement {
+    
+    private final ShardingSphereRule expectedRule;
+    
+    public FixtureDistSQLUpdateStatement(final ShardingSphereRule 
expectedRule) {
+        this.expectedRule = expectedRule;
+    }
 }
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureRule.java
similarity index 56%
copy from 
infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
copy to 
infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureRule.java
index 675731e70ff..5a7a8dc5818 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/AdvancedDistSQLUpdateExecutor.java
+++ 
b/infra/distsql-handler/src/test/java/org/apache/shardingsphere/distsql/handler/engine/concurrent/fixture/FixtureRule.java
@@ -15,16 +15,32 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.handler.engine.update;
+package org.apache.shardingsphere.distsql.handler.engine.concurrent.fixture;
 
-import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 
 /**
- * Advanced DistSQL update executor.
- * 
- * @param <T> type of DistSQL statement
+ * Fixture rule.
  */
-@SingletonSPI
-public interface AdvancedDistSQLUpdateExecutor<T extends DistSQLStatement> 
extends DistSQLUpdateExecutor<T> {
+@RequiredArgsConstructor
+public final class FixtureRule implements ShardingSphereRule {
+    
+    private final String type;
+    
+    @Override
+    public RuleConfiguration getConfiguration() {
+        return null;
+    }
+    
+    @Override
+    public int getOrder() {
+        return 0;
+    }
+    
+    @Override
+    public String toString() {
+        return type;
+    }
 }
diff --git 
a/infra/distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
 
b/infra/distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
new file mode 100644
index 00000000000..00e99159f18
--- /dev/null
+++ 
b/infra/distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
@@ -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.distsql.handler.engine.concurrent.fixture.FixtureDistSQLQueryExecutor
diff --git 
a/infra/distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor
 
b/infra/distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor
new file mode 100644
index 00000000000..eb012944bf2
--- /dev/null
+++ 
b/infra/distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor
@@ -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.distsql.handler.engine.concurrent.fixture.FixtureDistSQLUpdateExecutor
diff --git 
a/infra/distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
 
b/infra/distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
new file mode 100644
index 00000000000..bc91e04442b
--- /dev/null
+++ 
b/infra/distsql-handler/src/test/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
@@ -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.distsql.handler.engine.concurrent.fixture.FixtureDatabaseRuleDefinitionExecutor


Reply via email to