You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2026/09/26 14:31:22 UTC
(shardingsphere) branch master updated: Refactor Proxy DistSQL executors into neutral handler modules (#39972)
This is an automated email from the ASF dual-hosted git repository.
terrymanu 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 dc7be42a491 Refactor Proxy DistSQL executors into neutral handler modules (#39972)
dc7be42a491 is described below
commit dc7be42a491f8c0127992ba5dd1251789a1efd7c
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Sep 26 22:31:15 2026 +0800
Refactor Proxy DistSQL executors into neutral handler modules (#39972)
* Avoid duplicate unsupported SQL parser test invocations
* Deduplicate Oracle ALTER PROFILE and Doris BITOR parser cases
* Recover successful @Disabled test cases
* Clarify high-frequency invocation guidance
* Refactor Proxy DistSQL executors into neutral handler modules
* Refactor Proxy DistSQL executors into neutral handler modules
---
infra/distsql-handler/pom.xml | 17 +++
.../handler/engine/DistSQLConnectionContext.java | 9 ++
.../yaml/YamlExportedServerConfiguration.java | 37 +++---
.../yaml/YamlProxyDataSourceConfiguration.java | 2 +-
.../yaml/YamlProxyDatabaseConfiguration.java | 2 +-
.../YamlProxyDataSourceConfigurationSwapper.java | 4 +-
.../executor}/export/ExportedClusterInfo.java | 2 +-
.../handler/executor}/export/ExportedMetaData.java | 2 +-
.../executor}/export/ExportedSnapshotInfo.java | 2 +-
.../export/ExportedSnapshotInfoGenerator.java | 20 ++--
.../executor}/export/ExportedStorageNode.java | 2 +-
.../executor}/export/ExportedStorageNodes.java | 2 +-
.../executor}/lock/spi/ClusterLockStrategy.java | 2 +-
.../executor}/ral/common/DistSQLVariable.java | 2 +-
.../computenode/ShowComputeNodeInfoExecutor.java | 2 +-
.../computenode/ShowComputeNodeModeExecutor.java | 2 +-
.../computenode/ShowComputeNodesExecutor.java | 2 +-
.../ExportDatabaseConfigurationExecutor.java | 6 +-
.../queryable/export/ExportMetaDataExecutor.java | 6 +-
.../export/ExportStorageNodesExecutor.java | 8 +-
.../export/ShowTableMetaDataExecutor.java | 2 +-
.../variable/ShowDistVariableExecutor.java | 4 +-
.../variable/ShowDistVariablesExecutor.java | 4 +-
.../yaml/ConvertYamlConfigurationExecutor.java | 8 +-
.../computenode/SetComputeNodeStateExecutor.java | 2 +-
.../ImportDatabaseConfigurationExecutor.java | 6 +-
.../updatable/imports/ImportMetaDataExecutor.java | 8 +-
.../ral/updatable/lock/LockClusterExecutor.java | 4 +-
.../ral/updatable/lock/LockClusterOperation.java | 2 +-
.../ral/updatable/lock/UnlockClusterExecutor.java | 2 +-
.../refresh/RefreshDatabaseMetaDataExecutor.java | 2 +-
.../refresh/RefreshTableMetaDataExecutor.java | 2 +-
.../variable/SetDistVariableExecutor.java | 2 +-
.../rul/PreviewExecutionUnitGenerator.java | 45 ++++++++
.../handler/executor}/rul/PreviewExecutor.java | 73 ++----------
.../util/ClusterExportMetaDataGenerator.java | 20 ++--
.../util/DatabaseExportMetaDataGenerator.java | 2 +-
.../handler/executor}/util/ExportUtils.java | 2 +-
.../executor}/util/MetaDataImportExecutor.java | 20 ++--
.../YamlDatabaseConfigurationImportExecutor.java | 8 +-
...stsql.handler.engine.query.DistSQLQueryExecutor | 11 ++
...sql.handler.engine.update.DistSQLUpdateExecutor | 8 ++
.../reachability-metadata.json | 16 +--
.../GlobalClockExportedSnapshotInfoGenerator.java | 45 ++++++++
....executor.export.ExportedSnapshotInfoGenerator} | 2 +-
...obalClockExportedSnapshotInfoGeneratorTest.java | 87 ++++++++++++++
...SQLFederationPreviewExecutionUnitGenerator.java | 98 ++++++++++++++++
...ler.executor.rul.PreviewExecutionUnitGenerator} | 2 +-
...ederationPreviewExecutionUnitGeneratorTest.java | 125 +++++++++++++++++++++
.../handler/query}/ParseDistSQLExecutor.java | 2 +-
...stsql.handler.engine.query.DistSQLQueryExecutor | 1 +
proxy/backend/core/pom.xml | 5 +
.../backend/config/ProxyConfigurationLoader.java | 2 +-
.../backend/config/YamlProxyConfiguration.java | 2 +-
.../checker/YamlProxyConfigurationChecker.java | 4 +-
.../config/yaml/YamlProxyServerConfiguration.java | 1 +
.../swapper/YamlProxyConfigurationSwapper.java | 5 +-
.../distsql/DistSQLQueryProxyBackendHandler.java | 3 +
.../lock/impl/ClusterReadWriteLockStrategy.java | 2 +-
.../lock/impl/ClusterWriteLockStrategy.java | 2 +-
...stsql.handler.engine.query.DistSQLQueryExecutor | 29 -----
...sql.handler.engine.update.DistSQLUpdateExecutor | 25 -----
....handler.executor.lock.spi.ClusterLockStrategy} | 0
.../config/ProxyConfigurationLoaderTest.java | 4 +-
.../checker/YamlProxyConfigurationCheckerTest.java | 4 +-
.../yaml/YamlProxyDatabaseConfigurationTest.java | 2 +
...amlProxyDataSourceConfigurationSwapperTest.java | 3 +-
.../handler/distsql/DistSQLExecutorSPITest.java | 56 +++++++++
.../ShowComputeNodeInfoExecutorTest.java | 1 +
.../ShowComputeNodeModeExecutorTest.java | 1 +
.../computenode/ShowComputeNodesExecutorTest.java | 1 +
.../ExportDatabaseConfigurationExecutorTest.java | 1 +
.../export/ExportMetaDataExecutorTest.java | 9 +-
.../export/ExportStorageNodesExecutorTest.java | 1 +
.../export/ShowTableMetaDataExecutorTest.java | 1 +
.../variable/ShowDistVariableExecutorTest.java | 3 +-
.../variable/ShowDistVariablesExecutorTest.java | 1 +
.../yaml/ConvertYamlConfigurationExecutorTest.java | 5 +-
.../SetComputeNodeStateExecutorTest.java | 1 +
.../ImportDatabaseConfigurationExecutorTest.java | 1 +
.../imports/ImportMetaDataExecutorTest.java | 1 +
.../updatable/lock/LockClusterExecutorTest.java | 1 +
.../updatable/lock/LockClusterOperationTest.java | 1 +
.../updatable/lock/UnlockClusterExecutorTest.java | 1 +
.../RefreshDatabaseMetaDataExecutorTest.java | 1 +
.../refresh/RefreshTableMetaDataExecutorTest.java | 1 +
.../variable/SetDistVariableExecutorTest.java | 1 +
.../handler/distsql/rul/PreviewExecutorTest.java | 12 +-
.../impl/ClusterReadWriteLockStrategyTest.java | 2 +-
.../lock/impl/ClusterWriteLockStrategyTest.java | 2 +-
.../util/ClusterExportMetaDataGeneratorTest.java | 5 +-
.../util/DatabaseExportMetaDataGeneratorTest.java | 1 +
.../proxy/backend/util/ExportUtilsTest.java | 1 +
.../backend/util/MetaDataImportExecutorTest.java | 27 ++++-
...amlDatabaseConfigurationImportExecutorTest.java | 7 +-
.../initializer/BootstrapInitializerTest.java | 2 +-
96 files changed, 721 insertions(+), 266 deletions(-)
diff --git a/infra/distsql-handler/pom.xml b/infra/distsql-handler/pom.xml
index 4fe2a4f59c0..a57be258734 100644
--- a/infra/distsql-handler/pom.xml
+++ b/infra/distsql-handler/pom.xml
@@ -37,6 +37,23 @@
<artifactId>shardingsphere-mode-core</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-cluster-mode-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.quartz-scheduler</groupId>
+ <artifactId>quartz</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/DistSQLConnectionContext.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/DistSQLConnectionContext.java
index b7df0d0a35a..abc37415faf 100644
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/DistSQLConnectionContext.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/DistSQLConnectionContext.java
@@ -19,16 +19,21 @@ package org.apache.shardingsphere.distsql.handler.engine;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import lombok.Setter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.DatabaseConnectionManager;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.ExecutorStatementManager;
import org.apache.shardingsphere.infra.session.query.QueryContext;
+import java.util.function.Supplier;
+
/**
* DistSQL connection context.
*/
@RequiredArgsConstructor
@Getter
+@Setter
public final class DistSQLConnectionContext {
private final QueryContext queryContext;
@@ -42,4 +47,8 @@ public final class DistSQLConnectionContext {
@SuppressWarnings("rawtypes")
private final ExecutorStatementManager executorStatementManager;
+
+ private Supplier<ExecutorEngine> executorEngineSupplier;
+
+ private String processId;
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfiguration.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/config/yaml/YamlExportedServerConfiguration.java
similarity index 61%
copy from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfiguration.java
copy to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/config/yaml/YamlExportedServerConfiguration.java
index 976e06fb183..07c401b16cd 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfiguration.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/config/yaml/YamlExportedServerConfiguration.java
@@ -15,38 +15,45 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.config.yaml;
+package org.apache.shardingsphere.distsql.handler.executor.config.yaml;
-import com.google.common.base.Strings;
import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.infra.util.yaml.YamlConfiguration;
import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
import java.util.Collection;
-import java.util.HashMap;
import java.util.LinkedList;
-import java.util.Map;
+import java.util.Properties;
/**
- * YAML database configuration for ShardingSphere-Proxy.
+ * YAML server configuration contained in exported metadata.
*/
@Getter
-@Setter
-public final class YamlProxyDatabaseConfiguration implements YamlConfiguration {
+public final class YamlExportedServerConfiguration implements YamlConfiguration {
- private String databaseName;
+ private Collection<YamlRuleConfiguration> rules = new LinkedList<>();
- private Map<String, YamlProxyDataSourceConfiguration> dataSources = new HashMap<>();
+ private Properties props = new Properties();
- private Collection<YamlRuleConfiguration> rules = new LinkedList<>();
+ /**
+ * Set rules when present.
+ *
+ * @param rules rules to set
+ */
+ public void setRules(final Collection<YamlRuleConfiguration> rules) {
+ if (null != rules) {
+ this.rules = rules;
+ }
+ }
/**
- * Check whether the YAML database configuration is empty.
+ * Set properties when present.
*
- * @return whether the YAML database configuration is empty
+ * @param props properties to set
*/
- public boolean isEmpty() {
- return Strings.isNullOrEmpty(databaseName) && dataSources.isEmpty() && rules.isEmpty();
+ public void setProps(final Properties props) {
+ if (null != props) {
+ this.props = props;
+ }
}
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDataSourceConfiguration.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/config/yaml/YamlProxyDataSourceConfiguration.java
similarity index 95%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDataSourceConfiguration.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/config/yaml/YamlProxyDataSourceConfiguration.java
index dc5c84f367a..64b276df0f4 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDataSourceConfiguration.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/config/yaml/YamlProxyDataSourceConfiguration.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.config.yaml;
+package org.apache.shardingsphere.distsql.handler.executor.config.yaml;
import lombok.Getter;
import lombok.Setter;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfiguration.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/config/yaml/YamlProxyDatabaseConfiguration.java
similarity index 96%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfiguration.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/config/yaml/YamlProxyDatabaseConfiguration.java
index 976e06fb183..36264772cd9 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfiguration.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/config/yaml/YamlProxyDatabaseConfiguration.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.config.yaml;
+package org.apache.shardingsphere.distsql.handler.executor.config.yaml;
import com.google.common.base.Strings;
import lombok.Getter;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java
similarity index 92%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java
index 34a7fdd6f6b..af99679a990 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.config.yaml.swapper;
+package org.apache.shardingsphere.distsql.handler.executor.config.yaml.swapper;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDataSourceConfiguration;
import org.apache.shardingsphere.infra.datasource.pool.config.ConnectionConfiguration;
import org.apache.shardingsphere.infra.datasource.pool.config.DataSourceConfiguration;
import org.apache.shardingsphere.infra.datasource.pool.config.PoolConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
/**
* YAML proxy data source configuration swapper.
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedClusterInfo.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedClusterInfo.java
similarity index 94%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedClusterInfo.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedClusterInfo.java
index 77bab726c7c..a581b744729 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedClusterInfo.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedClusterInfo.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.distsql.export;
+package org.apache.shardingsphere.distsql.handler.executor.export;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedMetaData.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedMetaData.java
similarity index 94%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedMetaData.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedMetaData.java
index 992456c11f1..d71193ca694 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedMetaData.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedMetaData.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.distsql.export;
+package org.apache.shardingsphere.distsql.handler.executor.export;
import lombok.Getter;
import lombok.Setter;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedSnapshotInfo.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedSnapshotInfo.java
similarity index 94%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedSnapshotInfo.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedSnapshotInfo.java
index b8788b9423c..5b5db15d179 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedSnapshotInfo.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedSnapshotInfo.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.distsql.export;
+package org.apache.shardingsphere.distsql.handler.executor.export;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/spi/ClusterLockStrategy.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedSnapshotInfoGenerator.java
similarity index 56%
copy from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/spi/ClusterLockStrategy.java
copy to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedSnapshotInfoGenerator.java
index 5cd8ca05c0d..a5098c1e3f2 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/spi/ClusterLockStrategy.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedSnapshotInfoGenerator.java
@@ -15,19 +15,23 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.lock.spi;
+package org.apache.shardingsphere.distsql.handler.executor.export;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.spi.ShardingSphereSPI;
+
+import java.util.Optional;
/**
- * Cluster lock strategy.
+ * Generates snapshot information for exported cluster metadata.
*/
-@SingletonSPI
-public interface ClusterLockStrategy extends TypedSPI {
+public interface ExportedSnapshotInfoGenerator extends ShardingSphereSPI {
/**
- * Lock cluster.
+ * Generate snapshot information when the owning feature is enabled.
+ *
+ * @param metaData cluster metadata
+ * @return snapshot information, or empty when the owning feature is disabled
*/
- void lock();
+ Optional<ExportedSnapshotInfo> generate(ShardingSphereMetaData metaData);
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedStorageNode.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedStorageNode.java
similarity index 95%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedStorageNode.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedStorageNode.java
index 127baf7ecea..50783e1d589 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedStorageNode.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedStorageNode.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.distsql.export;
+package org.apache.shardingsphere.distsql.handler.executor.export;
import lombok.AllArgsConstructor;
import lombok.Getter;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedStorageNodes.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedStorageNodes.java
similarity index 94%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedStorageNodes.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedStorageNodes.java
index 1880cde30e1..266133367bf 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/export/ExportedStorageNodes.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/export/ExportedStorageNodes.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.distsql.export;
+package org.apache.shardingsphere.distsql.handler.executor.export;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/spi/ClusterLockStrategy.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/lock/spi/ClusterLockStrategy.java
similarity index 94%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/spi/ClusterLockStrategy.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/lock/spi/ClusterLockStrategy.java
index 5cd8ca05c0d..30f87fc49e1 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/spi/ClusterLockStrategy.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/lock/spi/ClusterLockStrategy.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.lock.spi;
+package org.apache.shardingsphere.distsql.handler.executor.lock.spi;
import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/DistSQLVariable.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/common/DistSQLVariable.java
similarity index 92%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/DistSQLVariable.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/common/DistSQLVariable.java
index b9a65cd0d0c..d36a1bf930f 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/DistSQLVariable.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/common/DistSQLVariable.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common;
+package org.apache.shardingsphere.distsql.handler.executor.ral.common;
/**
* DistSQL variable.
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeInfoExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/computenode/ShowComputeNodeInfoExecutor.java
similarity index 96%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeInfoExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/computenode/ShowComputeNodeInfoExecutor.java
index 6d8d5338656..1e58be93f8d 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeInfoExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/computenode/ShowComputeNodeInfoExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.computenode;
+package org.apache.shardingsphere.distsql.handler.executor.ral.queryable.computenode;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.show.ShowComputeNodeInfoStatement;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeModeExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/computenode/ShowComputeNodeModeExecutor.java
similarity index 96%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeModeExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/computenode/ShowComputeNodeModeExecutor.java
index 027af2ebc27..acb9f6f5a35 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeModeExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/computenode/ShowComputeNodeModeExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.computenode;
+package org.apache.shardingsphere.distsql.handler.executor.ral.queryable.computenode;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.show.ShowComputeNodeModeStatement;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodesExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/computenode/ShowComputeNodesExecutor.java
similarity index 97%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodesExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/computenode/ShowComputeNodesExecutor.java
index ffadeb5621d..91a1083765f 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodesExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/computenode/ShowComputeNodesExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.computenode;
+package org.apache.shardingsphere.distsql.handler.executor.ral.queryable.computenode;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.show.ShowComputeNodesStatement;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportDatabaseConfigurationExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/export/ExportDatabaseConfigurationExecutor.java
similarity index 91%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportDatabaseConfigurationExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/export/ExportDatabaseConfigurationExecutor.java
index c23c230841e..24d690dbcd4 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportDatabaseConfigurationExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/export/ExportDatabaseConfigurationExecutor.java
@@ -15,17 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.export;
+package org.apache.shardingsphere.distsql.handler.executor.ral.queryable.export;
import lombok.Setter;
import org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorDatabaseAware;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.util.DatabaseExportMetaDataGenerator;
+import org.apache.shardingsphere.distsql.handler.executor.util.ExportUtils;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.export.ExportDatabaseConfigurationStatement;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.util.DatabaseExportMetaDataGenerator;
-import org.apache.shardingsphere.proxy.backend.util.ExportUtils;
import java.util.Collection;
import java.util.Collections;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportMetaDataExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/export/ExportMetaDataExecutor.java
similarity index 91%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportMetaDataExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/export/ExportMetaDataExecutor.java
index 53ee8a42bac..27b08203236 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportMetaDataExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/export/ExportMetaDataExecutor.java
@@ -15,15 +15,15 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.export;
+package org.apache.shardingsphere.distsql.handler.executor.ral.queryable.export;
import org.apache.commons.codec.binary.Base64;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.util.ClusterExportMetaDataGenerator;
+import org.apache.shardingsphere.distsql.handler.executor.util.ExportUtils;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.export.ExportMetaDataStatement;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.util.ClusterExportMetaDataGenerator;
-import org.apache.shardingsphere.proxy.backend.util.ExportUtils;
import java.time.LocalDateTime;
import java.util.Arrays;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportStorageNodesExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/export/ExportStorageNodesExecutor.java
similarity index 95%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportStorageNodesExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/export/ExportStorageNodesExecutor.java
index 8a0f3f48aed..ed7a2d2c316 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportStorageNodesExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/export/ExportStorageNodesExecutor.java
@@ -15,10 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.export;
+package org.apache.shardingsphere.distsql.handler.executor.ral.queryable.export;
import org.apache.shardingsphere.database.connector.core.jdbcurl.parser.ConnectionProperties;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedStorageNode;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedStorageNodes;
+import org.apache.shardingsphere.distsql.handler.executor.util.ExportUtils;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.export.ExportStorageNodesStatement;
import org.apache.shardingsphere.infra.datasource.pool.props.creator.DataSourcePoolPropertiesCreator;
import org.apache.shardingsphere.infra.exception.ShardingSpherePreconditions;
@@ -28,9 +31,6 @@ import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
import org.apache.shardingsphere.infra.util.json.JsonEngine;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.distsql.export.ExportedStorageNode;
-import org.apache.shardingsphere.proxy.backend.distsql.export.ExportedStorageNodes;
-import org.apache.shardingsphere.proxy.backend.util.ExportUtils;
import java.time.LocalDateTime;
import java.util.Arrays;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ShowTableMetaDataExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/export/ShowTableMetaDataExecutor.java
similarity index 97%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ShowTableMetaDataExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/export/ShowTableMetaDataExecutor.java
index 54b8b2ef4f8..7d095e5540c 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ShowTableMetaDataExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/export/ShowTableMetaDataExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.export;
+package org.apache.shardingsphere.distsql.handler.executor.ral.queryable.export;
import lombok.Setter;
import org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorDatabaseAware;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariableExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/variable/ShowDistVariableExecutor.java
similarity index 96%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariableExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/variable/ShowDistVariableExecutor.java
index 8abcff831ac..6a6e8e3f175 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariableExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/variable/ShowDistVariableExecutor.java
@@ -15,12 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.variable;
+package org.apache.shardingsphere.distsql.handler.executor.ral.queryable.variable;
import lombok.Setter;
import org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorConnectionContextAware;
import org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.common.DistSQLVariable;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.show.ShowDistVariableStatement;
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.config.props.temporary.TemporaryConfigurationPropertyKey;
@@ -30,7 +31,6 @@ import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryRes
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.DistSQLVariable;
import java.util.Arrays;
import java.util.Collection;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariablesExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/variable/ShowDistVariablesExecutor.java
similarity index 96%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariablesExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/variable/ShowDistVariablesExecutor.java
index 4eca8d84507..7a071bb333a 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariablesExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/variable/ShowDistVariablesExecutor.java
@@ -15,12 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.variable;
+package org.apache.shardingsphere.distsql.handler.executor.ral.queryable.variable;
import lombok.Setter;
import org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorConnectionContextAware;
import org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.common.DistSQLVariable;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.show.ShowDistVariablesStatement;
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.config.props.temporary.TemporaryConfigurationPropertyKey;
@@ -29,7 +30,6 @@ import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
import org.apache.shardingsphere.infra.util.regex.RegexUtils;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.DistSQLVariable;
import java.util.Arrays;
import java.util.Collection;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/yaml/ConvertYamlConfigurationExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/yaml/ConvertYamlConfigurationExecutor.java
similarity index 95%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/yaml/ConvertYamlConfigurationExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/yaml/ConvertYamlConfigurationExecutor.java
index ec86f3393e0..3de337b8070 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/yaml/ConvertYamlConfigurationExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/queryable/yaml/ConvertYamlConfigurationExecutor.java
@@ -15,13 +15,16 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.yaml;
+package org.apache.shardingsphere.distsql.handler.executor.ral.queryable.yaml;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
import org.apache.shardingsphere.distsql.handler.engine.query.ral.convert.DistSQLScriptConstants;
import org.apache.shardingsphere.distsql.handler.engine.query.ral.convert.RuleConfigurationToDistSQLConverter;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDataSourceConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.swapper.YamlProxyDataSourceConfigurationSwapper;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.convert.ConvertYamlConfigurationStatement;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.datasource.pool.config.DataSourceConfiguration;
@@ -38,9 +41,6 @@ import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.swapper.YamlProxyDataSourceConfigurationSwapper;
import java.io.File;
import java.io.IOException;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/computenode/SetComputeNodeStateExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/computenode/SetComputeNodeStateExecutor.java
similarity index 97%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/computenode/SetComputeNodeStateExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/computenode/SetComputeNodeStateExecutor.java
index 4ddf2735914..879032b33f7 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/computenode/SetComputeNodeStateExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/computenode/SetComputeNodeStateExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.computenode;
+package org.apache.shardingsphere.distsql.handler.executor.ral.updatable.computenode;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
import org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorClusterModeRequired;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportDatabaseConfigurationExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/imports/ImportDatabaseConfigurationExecutor.java
similarity index 89%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportDatabaseConfigurationExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/imports/ImportDatabaseConfigurationExecutor.java
index 0c63928a01c..160acf9258f 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportDatabaseConfigurationExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/imports/ImportDatabaseConfigurationExecutor.java
@@ -15,15 +15,15 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.imports;
+package org.apache.shardingsphere.distsql.handler.executor.ral.updatable.imports;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.util.MetaDataImportExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.updatable.ImportDatabaseConfigurationStatement;
import org.apache.shardingsphere.infra.exception.generic.FileIOException;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
-import org.apache.shardingsphere.proxy.backend.util.MetaDataImportExecutor;
import java.io.File;
import java.io.IOException;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportMetaDataExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/imports/ImportMetaDataExecutor.java
similarity index 89%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportMetaDataExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/imports/ImportMetaDataExecutor.java
index 901a4f37219..6102f7b7cd5 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportMetaDataExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/imports/ImportMetaDataExecutor.java
@@ -15,18 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.imports;
+package org.apache.shardingsphere.distsql.handler.executor.ral.updatable.imports;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedClusterInfo;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedMetaData;
+import org.apache.shardingsphere.distsql.handler.executor.util.MetaDataImportExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.updatable.ImportMetaDataStatement;
import org.apache.shardingsphere.infra.exception.generic.FileIOException;
import org.apache.shardingsphere.infra.util.json.JsonEngine;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.distsql.export.ExportedClusterInfo;
-import org.apache.shardingsphere.proxy.backend.distsql.export.ExportedMetaData;
-import org.apache.shardingsphere.proxy.backend.util.MetaDataImportExecutor;
import java.io.File;
import java.io.IOException;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/lock/LockClusterExecutor.java
similarity index 94%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/lock/LockClusterExecutor.java
index c48d4fa11b0..944f3f287a4 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/lock/LockClusterExecutor.java
@@ -15,9 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.lock;
+package org.apache.shardingsphere.distsql.handler.executor.ral.updatable.lock;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.lock.spi.ClusterLockStrategy;
import org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorClusterModeRequired;
import org.apache.shardingsphere.distsql.statement.type.ral.updatable.LockClusterStatement;
import org.apache.shardingsphere.infra.algorithm.core.exception.MissingRequiredAlgorithmException;
@@ -27,7 +28,6 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.lock.exception.LockedClusterException;
import org.apache.shardingsphere.mode.state.ShardingSphereState;
-import org.apache.shardingsphere.proxy.backend.lock.spi.ClusterLockStrategy;
import java.sql.SQLException;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterOperation.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/lock/LockClusterOperation.java
similarity index 92%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterOperation.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/lock/LockClusterOperation.java
index 6109daaa4f9..6580e72db8b 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterOperation.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/lock/LockClusterOperation.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.lock;
+package org.apache.shardingsphere.distsql.handler.executor.ral.updatable.lock;
import org.apache.shardingsphere.mode.exclusive.ExclusiveOperation;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/UnlockClusterExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/lock/UnlockClusterExecutor.java
similarity index 96%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/UnlockClusterExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/lock/UnlockClusterExecutor.java
index b3ffb6eefc5..690ff774b13 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/UnlockClusterExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/lock/UnlockClusterExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.lock;
+package org.apache.shardingsphere.distsql.handler.executor.ral.updatable.lock;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
import org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorClusterModeRequired;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshDatabaseMetaDataExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/refresh/RefreshDatabaseMetaDataExecutor.java
similarity index 96%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshDatabaseMetaDataExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/refresh/RefreshDatabaseMetaDataExecutor.java
index 85b48767f02..57632e80af1 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshDatabaseMetaDataExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/refresh/RefreshDatabaseMetaDataExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.refresh;
+package org.apache.shardingsphere.distsql.handler.executor.ral.updatable.refresh;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.updatable.RefreshDatabaseMetaDataStatement;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshTableMetaDataExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/refresh/RefreshTableMetaDataExecutor.java
similarity index 98%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshTableMetaDataExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/refresh/RefreshTableMetaDataExecutor.java
index a86422dcbf4..a9e583c071c 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshTableMetaDataExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/refresh/RefreshTableMetaDataExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.refresh;
+package org.apache.shardingsphere.distsql.handler.executor.ral.updatable.refresh;
import lombok.Setter;
import org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorDatabaseAware;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/variable/SetDistVariableExecutor.java
similarity index 98%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/variable/SetDistVariableExecutor.java
index c275ec479d9..25486849a3f 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/updatable/variable/SetDistVariableExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.variable;
+package org.apache.shardingsphere.distsql.handler.executor.ral.updatable.variable;
import com.google.common.base.Strings;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rul/PreviewExecutionUnitGenerator.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rul/PreviewExecutionUnitGenerator.java
new file mode 100644
index 00000000000..49275164cf2
--- /dev/null
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rul/PreviewExecutionUnitGenerator.java
@@ -0,0 +1,45 @@
+/*
+ * 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.executor.rul;
+
+import org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.session.query.QueryContext;
+import org.apache.shardingsphere.infra.spi.ShardingSphereSPI;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+
+import java.util.Collection;
+import java.util.Optional;
+
+/**
+ * Generates PREVIEW execution units for a feature-specific execution path.
+ */
+public interface PreviewExecutionUnitGenerator extends ShardingSphereSPI {
+
+ /**
+ * Generate execution units when this implementation handles the query.
+ *
+ * @param database current database
+ * @param queryContext query context
+ * @param contextManager context manager
+ * @param connectionContext DistSQL connection context
+ * @return execution units, or empty when the query uses the regular kernel path
+ */
+ Optional<Collection<ExecutionUnit>> generate(ShardingSphereDatabase database, QueryContext queryContext, ContextManager contextManager, DistSQLConnectionContext connectionContext);
+}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/PreviewExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rul/PreviewExecutor.java
similarity index 56%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/PreviewExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rul/PreviewExecutor.java
index 97a79d6ca70..d5b7080ab6d 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/PreviewExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rul/PreviewExecutor.java
@@ -15,11 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rul;
+package org.apache.shardingsphere.distsql.handler.executor.rul;
import com.google.common.base.Preconditions;
import lombok.Setter;
-import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorConnectionContextAware;
import org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorDatabaseAware;
import org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
@@ -29,39 +28,22 @@ import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementCont
import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CursorHeldSQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CursorStatementContext;
import org.apache.shardingsphere.infra.binder.engine.SQLBindEngine;
-import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.connection.kernel.KernelProcessor;
import org.apache.shardingsphere.infra.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.exception.kernel.metadata.rule.EmptyRuleException;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.SQLExecutorExceptionHandler;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutionUnit;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.stream.JDBCStreamQueryResult;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.JDBCDriverType;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.StatementOption;
import org.apache.shardingsphere.infra.hint.HintValueContext;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.session.query.QueryContext;
+import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
-import org.apache.shardingsphere.proxy.backend.connector.ProxyDatabaseConnectionManager;
-import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.cursor.CursorNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.CursorSQLStatementAttribute;
-import org.apache.shardingsphere.sqlfederation.context.SQLFederationContext;
-import org.apache.shardingsphere.sqlfederation.engine.SQLFederationEngine;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -99,24 +81,10 @@ public final class PreviewExecutor implements DistSQLQueryExecutor<PreviewStatem
setUpCursorDefinition((CursorHeldSQLStatementContext) toBePreviewedStatementContext);
}
ShardingSpherePreconditions.checkState(database.isComplete(), () -> new EmptyRuleException(database.getName()));
- String schemaName = getSchemaName(queryContext.getSqlStatementContext(), database);
- Collection<ExecutionUnit> executionUnits = getExecutionUnits(contextManager, schemaName, metaData, queryContext);
+ Collection<ExecutionUnit> executionUnits = getExecutionUnits(contextManager, metaData, queryContext);
return executionUnits.stream().map(each -> new LocalDataQueryResultRow(each.getDataSourceName(), each.getSqlUnit().getSql())).collect(Collectors.toList());
}
- private String getSchemaName(final SQLStatementContext sqlStatementContext, final ShardingSphereDatabase database) {
- return sqlStatementContext.getTablesContext().getSchemaName().orElseGet(database::getDefaultSchemaName);
- }
-
- private Collection<ExecutionUnit> getExecutionUnits(final ContextManager contextManager, final String schemaName, final ShardingSphereMetaData metaData, final QueryContext queryContext) {
- JDBCExecutor jdbcExecutor = new JDBCExecutor(BackendExecutorContext.getInstance().getExecutorEngine(), connectionContext.getQueryContext().getConnectionContext());
- SQLFederationEngine federationEngine = new SQLFederationEngine(database.getName(), schemaName, metaData, contextManager.getMetaDataContexts().getStatistics(), jdbcExecutor);
- if (federationEngine.decide(queryContext, metaData.getGlobalRuleMetaData())) {
- return getFederationExecutionUnits(queryContext, metaData, federationEngine);
- }
- return new KernelProcessor().generateExecutionContext(queryContext, metaData.getGlobalRuleMetaData(), metaData.getProps()).getExecutionUnits();
- }
-
private void setUpCursorDefinition(final CursorHeldSQLStatementContext toBePreviewedStatementContext) {
Optional<CursorNameSegment> cursorNameSegment = toBePreviewedStatementContext.getSqlStatement().getAttributes().getAttribute(CursorSQLStatementAttribute.class).getCursorName();
if (!cursorNameSegment.isPresent()) {
@@ -128,35 +96,14 @@ public final class PreviewExecutor implements DistSQLQueryExecutor<PreviewStatem
toBePreviewedStatementContext.setCursorStatementContext(cursorStatementContext);
}
- private Collection<ExecutionUnit> getFederationExecutionUnits(final QueryContext queryContext, final ShardingSphereMetaData metaData, final SQLFederationEngine federationEngine) {
- SQLStatement sqlStatement = queryContext.getSqlStatementContext().getSqlStatement();
- DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = createDriverExecutionPrepareEngine(metaData);
- SQLFederationContext context = new SQLFederationContext(true, queryContext, metaData,
- ((ProxyDatabaseConnectionManager) connectionContext.getDatabaseConnectionManager()).getConnectionSession().getProcessId());
- federationEngine.executeQuery(prepareEngine, createPreviewCallback(sqlStatement), context);
- return context.getPreviewExecutionUnits();
- }
-
- private JDBCExecutorCallback<ExecuteResult> createPreviewCallback(final SQLStatement sqlStatement) {
- return new JDBCExecutorCallback<ExecuteResult>(database.getProtocolType(), database.getResourceMetaData(), sqlStatement, SQLExecutorExceptionHandler.isExceptionThrown()) {
-
- @Override
- protected ExecuteResult executeSQL(final String sql, final Statement statement, final ConnectionMode connectionMode, final DatabaseType storageType) throws SQLException {
- return new JDBCStreamQueryResult(statement.executeQuery(sql));
- }
-
- @Override
- protected Optional<ExecuteResult> getSaneResult(final SQLStatement sqlStatement, final SQLException ex) {
- return Optional.empty();
+ private Collection<ExecutionUnit> getExecutionUnits(final ContextManager contextManager, final ShardingSphereMetaData metaData, final QueryContext queryContext) {
+ for (PreviewExecutionUnitGenerator each : ShardingSphereServiceLoader.getServiceInstances(PreviewExecutionUnitGenerator.class)) {
+ Optional<Collection<ExecutionUnit>> result = each.generate(database, queryContext, contextManager, connectionContext);
+ if (result.isPresent()) {
+ return result.get();
}
- };
- }
-
- @SuppressWarnings({"unchecked", "rawtypes"})
- private DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> createDriverExecutionPrepareEngine(final ShardingSphereMetaData metaData) {
- int maxConnectionsSizePerQuery = metaData.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
- return new DriverExecutionPrepareEngine<>(JDBCDriverType.STATEMENT, maxConnectionsSizePerQuery, connectionContext.getDatabaseConnectionManager(),
- connectionContext.getExecutorStatementManager(), new StatementOption(false), database.getRuleMetaData().getRules(), metaData);
+ }
+ return new KernelProcessor().generateExecutionContext(queryContext, metaData.getGlobalRuleMetaData(), metaData.getProps()).getExecutionUnits();
}
@Override
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/ClusterExportMetaDataGenerator.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/ClusterExportMetaDataGenerator.java
similarity index 80%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/ClusterExportMetaDataGenerator.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/ClusterExportMetaDataGenerator.java
index 226433b3f04..6b94426826f 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/ClusterExportMetaDataGenerator.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/ClusterExportMetaDataGenerator.java
@@ -15,24 +15,22 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.util;
+package org.apache.shardingsphere.distsql.handler.executor.util;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.globalclock.provider.GlobalClockProvider;
-import org.apache.shardingsphere.globalclock.rule.GlobalClockRule;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedClusterInfo;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedMetaData;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedSnapshotInfoGenerator;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
import org.apache.shardingsphere.infra.util.json.JsonEngine;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.distsql.export.ExportedClusterInfo;
-import org.apache.shardingsphere.proxy.backend.distsql.export.ExportedMetaData;
-import org.apache.shardingsphere.proxy.backend.distsql.export.ExportedSnapshotInfo;
-import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -94,12 +92,8 @@ public final class ClusterExportMetaDataGenerator {
}
private void generateSnapshotInfo(final ShardingSphereMetaData metaData, final ExportedClusterInfo exportedClusterInfo) {
- GlobalClockRule globalClockRule = metaData.getGlobalRuleMetaData().getSingleRule(GlobalClockRule.class);
- if (globalClockRule.getConfiguration().isEnabled()) {
- ExportedSnapshotInfo snapshotInfo = new ExportedSnapshotInfo();
- snapshotInfo.setCsn(String.valueOf(globalClockRule.getGlobalClockProvider().map(GlobalClockProvider::getCurrentTimestamp).orElse(0L)));
- snapshotInfo.setCreateTime(LocalDateTime.now());
- exportedClusterInfo.setSnapshotInfo(snapshotInfo);
+ for (ExportedSnapshotInfoGenerator each : ShardingSphereServiceLoader.getServiceInstances(ExportedSnapshotInfoGenerator.class)) {
+ each.generate(metaData).ifPresent(exportedClusterInfo::setSnapshotInfo);
}
}
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/DatabaseExportMetaDataGenerator.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/DatabaseExportMetaDataGenerator.java
similarity index 98%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/DatabaseExportMetaDataGenerator.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/DatabaseExportMetaDataGenerator.java
index 1fd67a0d96a..26d55c3e3ee 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/DatabaseExportMetaDataGenerator.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/DatabaseExportMetaDataGenerator.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.util;
+package org.apache.shardingsphere.distsql.handler.executor.util;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/ExportUtils.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/ExportUtils.java
similarity index 96%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/ExportUtils.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/ExportUtils.java
index cc482d0566a..c6e767bc976 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/ExportUtils.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/ExportUtils.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.util;
+package org.apache.shardingsphere.distsql.handler.executor.util;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/MetaDataImportExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/MetaDataImportExecutor.java
similarity index 80%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/MetaDataImportExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/MetaDataImportExecutor.java
index 27302b8beab..4df119961d1 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/MetaDataImportExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/MetaDataImportExecutor.java
@@ -15,15 +15,15 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.util;
+package org.apache.shardingsphere.distsql.handler.executor.util;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlExportedServerConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedMetaData;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyServerConfiguration;
-import org.apache.shardingsphere.proxy.backend.distsql.export.ExportedMetaData;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -54,12 +54,12 @@ public final class MetaDataImportExecutor {
*/
public void importClusterConfigurations(final ExportedMetaData exportedMetaData) {
Map<String, YamlProxyDatabaseConfiguration> yamlDatabaseConfigs = getYamlProxyDatabaseConfigurations(exportedMetaData);
- YamlProxyServerConfiguration yamlServerConfig = getYamlServerConfiguration(exportedMetaData);
+ YamlExportedServerConfiguration yamlServerConfig = getYamlServerConfiguration(exportedMetaData);
importServerConfiguration(yamlServerConfig);
importDatabaseConfigurations(yamlDatabaseConfigs.values());
}
- private void importServerConfiguration(final YamlProxyServerConfiguration yamlServerConfig) {
+ private void importServerConfiguration(final YamlExportedServerConfiguration yamlServerConfig) {
if (null == yamlServerConfig) {
return;
}
@@ -67,14 +67,14 @@ public final class MetaDataImportExecutor {
importProps(yamlServerConfig);
}
- private void importGlobalRules(final YamlProxyServerConfiguration yamlServerConfig) {
+ private void importGlobalRules(final YamlExportedServerConfiguration yamlServerConfig) {
Collection<RuleConfiguration> rules = ruleConfigSwapperEngine.swapToRuleConfigurations(yamlServerConfig.getRules());
for (RuleConfiguration each : rules) {
contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService().alterGlobalRuleConfiguration(each);
}
}
- private void importProps(final YamlProxyServerConfiguration yamlServerConfig) {
+ private void importProps(final YamlExportedServerConfiguration yamlServerConfig) {
contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService().alterProperties(yamlServerConfig.getProps());
}
@@ -83,8 +83,8 @@ public final class MetaDataImportExecutor {
Collectors.toMap(Entry::getKey, entry -> YamlEngine.unmarshal(entry.getValue(), YamlProxyDatabaseConfiguration.class), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
}
- private YamlProxyServerConfiguration getYamlServerConfiguration(final ExportedMetaData exportedMetaData) {
- return YamlEngine.unmarshal(exportedMetaData.getRules() + System.lineSeparator() + exportedMetaData.getProps(), YamlProxyServerConfiguration.class);
+ private YamlExportedServerConfiguration getYamlServerConfiguration(final ExportedMetaData exportedMetaData) {
+ return YamlEngine.unmarshal(exportedMetaData.getRules() + System.lineSeparator() + exportedMetaData.getProps(), YamlExportedServerConfiguration.class);
}
/**
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/YamlDatabaseConfigurationImportExecutor.java
similarity index 96%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/YamlDatabaseConfigurationImportExecutor.java
index f6dc2866ba5..051bb574540 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/util/YamlDatabaseConfigurationImportExecutor.java
@@ -15,11 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.util;
+package org.apache.shardingsphere.distsql.handler.executor.util;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.database.exception.core.exception.syntax.database.DatabaseCreateExistsException;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDataSourceConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.swapper.YamlProxyDataSourceConfigurationSwapper;
import org.apache.shardingsphere.distsql.handler.validate.DistSQLDataSourcePoolPropertiesValidator;
import org.apache.shardingsphere.infra.config.props.temporary.TemporaryConfigurationPropertyKey;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
@@ -46,9 +49,6 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfigurati
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.swapper.YamlProxyDataSourceConfigurationSwapper;
import javax.sql.DataSource;
import java.util.Collection;
diff --git a/infra/distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor b/infra/distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
index a7d745cb3f0..b3753f4d0d2 100644
--- a/infra/distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
+++ b/infra/distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
@@ -20,3 +20,14 @@ org.apache.shardingsphere.distsql.handler.executor.rql.resource.ShowRulesUsedSto
org.apache.shardingsphere.distsql.handler.executor.rql.resource.ShowLogicalTablesExecutor
org.apache.shardingsphere.distsql.handler.executor.rql.rule.RuleCountExecutor
org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.queryable.computenode.ShowComputeNodesExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.queryable.computenode.ShowComputeNodeInfoExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.queryable.computenode.ShowComputeNodeModeExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.queryable.export.ExportDatabaseConfigurationExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.queryable.export.ExportMetaDataExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.queryable.export.ExportStorageNodesExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.queryable.yaml.ConvertYamlConfigurationExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.queryable.variable.ShowDistVariableExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.queryable.variable.ShowDistVariablesExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.queryable.export.ShowTableMetaDataExecutor
+org.apache.shardingsphere.distsql.handler.executor.rul.PreviewExecutor
diff --git a/infra/distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor b/infra/distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor
index 9e75a40bacb..94617fe7c63 100644
--- a/infra/distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor
+++ b/infra/distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor
@@ -18,3 +18,11 @@
org.apache.shardingsphere.distsql.handler.executor.rdl.resource.RegisterStorageUnitExecutor
org.apache.shardingsphere.distsql.handler.executor.rdl.resource.AlterStorageUnitExecutor
org.apache.shardingsphere.distsql.handler.executor.rdl.resource.UnregisterStorageUnitExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.updatable.computenode.SetComputeNodeStateExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.updatable.imports.ImportDatabaseConfigurationExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.updatable.imports.ImportMetaDataExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.updatable.variable.SetDistVariableExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.updatable.refresh.RefreshDatabaseMetaDataExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.updatable.lock.LockClusterExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.updatable.lock.UnlockClusterExecutor
+org.apache.shardingsphere.distsql.handler.executor.ral.updatable.refresh.RefreshTableMetaDataExecutor
diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reachability-metadata.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reachability-metadata.json
index 8945c7b819f..08005cd4d9f 100644
--- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reachability-metadata.json
+++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reachability-metadata.json
@@ -4119,7 +4119,7 @@
"condition": {
"typeReached": "org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecuteEngine"
},
- "type": "org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.computenode.SetComputeNodeStateExecutor",
+ "type": "org.apache.shardingsphere.distsql.handler.executor.ral.updatable.computenode.SetComputeNodeStateExecutor",
"methods": [
{
"name": "<init>",
@@ -4131,7 +4131,7 @@
"condition": {
"typeReached": "org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecuteEngine"
},
- "type": "org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.imports.ImportDatabaseConfigurationExecutor",
+ "type": "org.apache.shardingsphere.distsql.handler.executor.ral.updatable.imports.ImportDatabaseConfigurationExecutor",
"methods": [
{
"name": "<init>",
@@ -4143,7 +4143,7 @@
"condition": {
"typeReached": "org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecuteEngine"
},
- "type": "org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.imports.ImportMetaDataExecutor",
+ "type": "org.apache.shardingsphere.distsql.handler.executor.ral.updatable.imports.ImportMetaDataExecutor",
"methods": [
{
"name": "<init>",
@@ -4155,7 +4155,7 @@
"condition": {
"typeReached": "org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecuteEngine"
},
- "type": "org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.lock.LockClusterExecutor",
+ "type": "org.apache.shardingsphere.distsql.handler.executor.ral.updatable.lock.LockClusterExecutor",
"methods": [
{
"name": "<init>",
@@ -4167,7 +4167,7 @@
"condition": {
"typeReached": "org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecuteEngine"
},
- "type": "org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.lock.UnlockClusterExecutor",
+ "type": "org.apache.shardingsphere.distsql.handler.executor.ral.updatable.lock.UnlockClusterExecutor",
"methods": [
{
"name": "<init>",
@@ -4179,7 +4179,7 @@
"condition": {
"typeReached": "org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecuteEngine"
},
- "type": "org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.refresh.RefreshDatabaseMetaDataExecutor",
+ "type": "org.apache.shardingsphere.distsql.handler.executor.ral.updatable.refresh.RefreshDatabaseMetaDataExecutor",
"methods": [
{
"name": "<init>",
@@ -4191,7 +4191,7 @@
"condition": {
"typeReached": "org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecuteEngine"
},
- "type": "org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.refresh.RefreshTableMetaDataExecutor",
+ "type": "org.apache.shardingsphere.distsql.handler.executor.ral.updatable.refresh.RefreshTableMetaDataExecutor",
"methods": [
{
"name": "<init>",
@@ -4203,7 +4203,7 @@
"condition": {
"typeReached": "org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecuteEngine"
},
- "type": "org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.variable.SetDistVariableExecutor",
+ "type": "org.apache.shardingsphere.distsql.handler.executor.ral.updatable.variable.SetDistVariableExecutor",
"methods": [
{
"name": "<init>",
diff --git a/kernel/global-clock/distsql/handler/src/main/java/org/apache/shardingsphere/globalclock/distsql/handler/GlobalClockExportedSnapshotInfoGenerator.java b/kernel/global-clock/distsql/handler/src/main/java/org/apache/shardingsphere/globalclock/distsql/handler/GlobalClockExportedSnapshotInfoGenerator.java
new file mode 100644
index 00000000000..92235fc7d13
--- /dev/null
+++ b/kernel/global-clock/distsql/handler/src/main/java/org/apache/shardingsphere/globalclock/distsql/handler/GlobalClockExportedSnapshotInfoGenerator.java
@@ -0,0 +1,45 @@
+/*
+ * 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.globalclock.distsql.handler;
+
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedSnapshotInfo;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedSnapshotInfoGenerator;
+import org.apache.shardingsphere.globalclock.provider.GlobalClockProvider;
+import org.apache.shardingsphere.globalclock.rule.GlobalClockRule;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+
+import java.time.LocalDateTime;
+import java.util.Optional;
+
+/**
+ * Generates GlobalClock snapshot information for exported cluster metadata.
+ */
+public final class GlobalClockExportedSnapshotInfoGenerator implements ExportedSnapshotInfoGenerator {
+
+ @Override
+ public Optional<ExportedSnapshotInfo> generate(final ShardingSphereMetaData metaData) {
+ GlobalClockRule globalClockRule = metaData.getGlobalRuleMetaData().getSingleRule(GlobalClockRule.class);
+ if (!globalClockRule.getConfiguration().isEnabled()) {
+ return Optional.empty();
+ }
+ ExportedSnapshotInfo result = new ExportedSnapshotInfo();
+ result.setCsn(String.valueOf(globalClockRule.getGlobalClockProvider().map(GlobalClockProvider::getCurrentTimestamp).orElse(0L)));
+ result.setCreateTime(LocalDateTime.now());
+ return Optional.of(result);
+ }
+}
diff --git a/kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor b/kernel/global-clock/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.export.ExportedSnapshotInfoGenerator
similarity index 89%
copy from kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
copy to kernel/global-clock/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.export.ExportedSnapshotInfoGenerator
index d1a0b508dbc..d28f3fc6ede 100644
--- a/kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
+++ b/kernel/global-clock/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.export.ExportedSnapshotInfoGenerator
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.parser.distsql.handler.query.ShowSQLParserRuleExecutor
+org.apache.shardingsphere.globalclock.distsql.handler.GlobalClockExportedSnapshotInfoGenerator
diff --git a/kernel/global-clock/distsql/handler/src/test/java/org/apache/shardingsphere/globalclock/distsql/handler/GlobalClockExportedSnapshotInfoGeneratorTest.java b/kernel/global-clock/distsql/handler/src/test/java/org/apache/shardingsphere/globalclock/distsql/handler/GlobalClockExportedSnapshotInfoGeneratorTest.java
new file mode 100644
index 00000000000..84cc7182d6b
--- /dev/null
+++ b/kernel/global-clock/distsql/handler/src/test/java/org/apache/shardingsphere/globalclock/distsql/handler/GlobalClockExportedSnapshotInfoGeneratorTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.globalclock.distsql.handler;
+
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedSnapshotInfo;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedSnapshotInfoGenerator;
+import org.apache.shardingsphere.globalclock.config.GlobalClockRuleConfiguration;
+import org.apache.shardingsphere.globalclock.provider.GlobalClockProvider;
+import org.apache.shardingsphere.globalclock.rule.GlobalClockRule;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
+import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
+import org.junit.jupiter.api.Test;
+
+import java.util.Optional;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class GlobalClockExportedSnapshotInfoGeneratorTest {
+
+ private final ExportedSnapshotInfoGenerator generator = ShardingSphereServiceLoader.getServiceInstances(ExportedSnapshotInfoGenerator.class).iterator().next();
+
+ @Test
+ void assertGenerateWhenDisabled() {
+ GlobalClockRule rule = mock(GlobalClockRule.class);
+ GlobalClockRuleConfiguration ruleConfig = mock(GlobalClockRuleConfiguration.class);
+ when(rule.getConfiguration()).thenReturn(ruleConfig);
+ Optional<ExportedSnapshotInfo> actual = generator.generate(mockMetaData(rule));
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ void assertGenerateWithCurrentTimestamp() {
+ GlobalClockRule rule = mock(GlobalClockRule.class);
+ GlobalClockRuleConfiguration ruleConfig = mock(GlobalClockRuleConfiguration.class);
+ when(ruleConfig.isEnabled()).thenReturn(true);
+ when(rule.getConfiguration()).thenReturn(ruleConfig);
+ GlobalClockProvider provider = mock(GlobalClockProvider.class);
+ when(provider.getCurrentTimestamp()).thenReturn(123L);
+ when(rule.getGlobalClockProvider()).thenReturn(Optional.of(provider));
+ Optional<ExportedSnapshotInfo> actual = generator.generate(mockMetaData(rule));
+ assertTrue(actual.isPresent());
+ assertThat(actual.get().getCsn(), is("123"));
+ assertNotNull(actual.get().getCreateTime());
+ }
+
+ @Test
+ void assertGenerateWithoutProvider() {
+ GlobalClockRule rule = mock(GlobalClockRule.class);
+ GlobalClockRuleConfiguration ruleConfig = mock(GlobalClockRuleConfiguration.class);
+ when(ruleConfig.isEnabled()).thenReturn(true);
+ when(rule.getConfiguration()).thenReturn(ruleConfig);
+ when(rule.getGlobalClockProvider()).thenReturn(Optional.empty());
+ Optional<ExportedSnapshotInfo> actual = generator.generate(mockMetaData(rule));
+ assertTrue(actual.isPresent());
+ assertThat(actual.get().getCsn(), is("0"));
+ }
+
+ private ShardingSphereMetaData mockMetaData(final GlobalClockRule rule) {
+ ShardingSphereMetaData result = mock(ShardingSphereMetaData.class);
+ RuleMetaData ruleMetaData = mock(RuleMetaData.class);
+ when(result.getGlobalRuleMetaData()).thenReturn(ruleMetaData);
+ when(ruleMetaData.getSingleRule(GlobalClockRule.class)).thenReturn(rule);
+ return result;
+ }
+}
diff --git a/kernel/sql-federation/distsql/handler/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/handler/SQLFederationPreviewExecutionUnitGenerator.java b/kernel/sql-federation/distsql/handler/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/handler/SQLFederationPreviewExecutionUnitGenerator.java
new file mode 100644
index 00000000000..cc42cd59799
--- /dev/null
+++ b/kernel/sql-federation/distsql/handler/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/handler/SQLFederationPreviewExecutionUnitGenerator.java
@@ -0,0 +1,98 @@
+/*
+ * 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.sqlfederation.distsql.handler;
+
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import org.apache.shardingsphere.distsql.handler.executor.rul.PreviewExecutionUnitGenerator;
+import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
+import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
+import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
+import org.apache.shardingsphere.infra.executor.sql.execute.engine.SQLExecutorExceptionHandler;
+import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutionUnit;
+import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor;
+import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback;
+import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
+import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.stream.JDBCStreamQueryResult;
+import org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine;
+import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.JDBCDriverType;
+import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.StatementOption;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.session.query.QueryContext;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
+import org.apache.shardingsphere.sqlfederation.context.SQLFederationContext;
+import org.apache.shardingsphere.sqlfederation.engine.SQLFederationEngine;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Collection;
+import java.util.Optional;
+
+/**
+ * Generates PREVIEW execution units for SQL federation.
+ */
+public final class SQLFederationPreviewExecutionUnitGenerator implements PreviewExecutionUnitGenerator {
+
+ @Override
+ public Optional<Collection<ExecutionUnit>> generate(final ShardingSphereDatabase database, final QueryContext queryContext, final ContextManager contextManager,
+ final DistSQLConnectionContext connectionContext) {
+ ShardingSphereMetaData metaData = contextManager.getMetaDataContexts().getMetaData();
+ String schemaName = queryContext.getSqlStatementContext().getTablesContext().getSchemaName().orElseGet(database::getDefaultSchemaName);
+ JDBCExecutor jdbcExecutor = new JDBCExecutor(connectionContext.getExecutorEngineSupplier().get(), connectionContext.getQueryContext().getConnectionContext());
+ SQLFederationEngine federationEngine = new SQLFederationEngine(database.getName(), schemaName, metaData, contextManager.getMetaDataContexts().getStatistics(), jdbcExecutor);
+ if (!federationEngine.decide(queryContext, metaData.getGlobalRuleMetaData())) {
+ return Optional.empty();
+ }
+ return Optional.of(getFederationExecutionUnits(database, queryContext, metaData, federationEngine, connectionContext));
+ }
+
+ private Collection<ExecutionUnit> getFederationExecutionUnits(final ShardingSphereDatabase database, final QueryContext queryContext, final ShardingSphereMetaData metaData,
+ final SQLFederationEngine federationEngine, final DistSQLConnectionContext connectionContext) {
+ SQLStatement sqlStatement = queryContext.getSqlStatementContext().getSqlStatement();
+ DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = createDriverExecutionPrepareEngine(database, metaData, connectionContext);
+ SQLFederationContext context = new SQLFederationContext(true, queryContext, metaData, connectionContext.getProcessId());
+ federationEngine.executeQuery(prepareEngine, createPreviewCallback(database, sqlStatement), context);
+ return context.getPreviewExecutionUnits();
+ }
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ private DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> createDriverExecutionPrepareEngine(final ShardingSphereDatabase database, final ShardingSphereMetaData metaData,
+ final DistSQLConnectionContext connectionContext) {
+ int maxConnectionsSizePerQuery = metaData.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
+ return new DriverExecutionPrepareEngine<>(JDBCDriverType.STATEMENT, maxConnectionsSizePerQuery, connectionContext.getDatabaseConnectionManager(),
+ connectionContext.getExecutorStatementManager(), new StatementOption(false), database.getRuleMetaData().getRules(), metaData);
+ }
+
+ private JDBCExecutorCallback<ExecuteResult> createPreviewCallback(final ShardingSphereDatabase database, final SQLStatement sqlStatement) {
+ return new JDBCExecutorCallback<ExecuteResult>(database.getProtocolType(), database.getResourceMetaData(), sqlStatement, SQLExecutorExceptionHandler.isExceptionThrown()) {
+
+ @Override
+ protected ExecuteResult executeSQL(final String sql, final Statement statement, final ConnectionMode connectionMode, final DatabaseType storageType) throws SQLException {
+ return new JDBCStreamQueryResult(statement.executeQuery(sql));
+ }
+
+ @Override
+ protected Optional<ExecuteResult> getSaneResult(final SQLStatement sqlStatement, final SQLException ex) {
+ return Optional.empty();
+ }
+ };
+ }
+}
diff --git a/kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor b/kernel/sql-federation/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.rul.PreviewExecutionUnitGenerator
similarity index 88%
copy from kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
copy to kernel/sql-federation/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.rul.PreviewExecutionUnitGenerator
index d1a0b508dbc..39f576346fd 100644
--- a/kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
+++ b/kernel/sql-federation/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.rul.PreviewExecutionUnitGenerator
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.parser.distsql.handler.query.ShowSQLParserRuleExecutor
+org.apache.shardingsphere.sqlfederation.distsql.handler.SQLFederationPreviewExecutionUnitGenerator
diff --git a/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/SQLFederationPreviewExecutionUnitGeneratorTest.java b/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/SQLFederationPreviewExecutionUnitGeneratorTest.java
new file mode 100644
index 00000000000..3c84c3f5573
--- /dev/null
+++ b/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/SQLFederationPreviewExecutionUnitGeneratorTest.java
@@ -0,0 +1,125 @@
+/*
+ * 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.sqlfederation.distsql.handler;
+
+import org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import org.apache.shardingsphere.distsql.handler.executor.rul.PreviewExecutionUnitGenerator;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
+import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
+import org.apache.shardingsphere.infra.executor.sql.context.SQLUnit;
+import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor;
+import org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
+import org.apache.shardingsphere.infra.session.query.QueryContext;
+import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.sqlfederation.context.SQLFederationContext;
+import org.apache.shardingsphere.sqlfederation.engine.SQLFederationEngine;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedConstruction;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.mockConstruction;
+import static org.mockito.Mockito.when;
+
+class SQLFederationPreviewExecutionUnitGeneratorTest {
+
+ private final PreviewExecutionUnitGenerator generator = ShardingSphereServiceLoader.getServiceInstances(PreviewExecutionUnitGenerator.class).iterator().next();
+
+ @Test
+ void assertGenerateWhenFederationNotSelected() {
+ ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
+ when(database.getName()).thenReturn("foo_db");
+ when(database.getDefaultSchemaName()).thenReturn("foo_schema");
+ QueryContext queryContext = mock(QueryContext.class, RETURNS_DEEP_STUBS);
+ when(queryContext.getSqlStatementContext().getTablesContext().getSchemaName()).thenReturn(Optional.empty());
+ ContextManager contextManager = mockContextManager();
+ DistSQLConnectionContext connectionContext = mockConnectionContext();
+ try (
+ MockedConstruction<JDBCExecutor> ignoredJDBCExecutor = mockConstruction(JDBCExecutor.class);
+ MockedConstruction<SQLFederationEngine> ignoredFederationEngine =
+ mockConstruction(SQLFederationEngine.class, (mock, context) -> when(mock.decide(any(), any())).thenReturn(false))) {
+ Optional<Collection<ExecutionUnit>> actual = generator.generate(database, queryContext, contextManager, connectionContext);
+ assertFalse(actual.isPresent());
+ }
+ }
+
+ @Test
+ void assertGenerateWhenFederationSelected() {
+ ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+ when(database.getName()).thenReturn("foo_db");
+ when(database.getDefaultSchemaName()).thenReturn("foo_schema");
+ when(database.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+ QueryContext queryContext = mock(QueryContext.class, RETURNS_DEEP_STUBS);
+ when(queryContext.getSqlStatementContext().getTablesContext().getSchemaName()).thenReturn(Optional.empty());
+ ContextManager contextManager = mockContextManager();
+ DistSQLConnectionContext connectionContext = mockConnectionContext();
+ when(connectionContext.getProcessId()).thenReturn("foo_process");
+ ExecutionUnit expected = new ExecutionUnit("foo_ds", new SQLUnit("SELECT 1", Collections.emptyList()));
+ AtomicReference<String> actualSchemaName = new AtomicReference<>();
+ try (
+ MockedConstruction<JDBCExecutor> ignoredJDBCExecutor = mockConstruction(JDBCExecutor.class);
+ MockedConstruction<DriverExecutionPrepareEngine> ignoredPrepareEngine = mockConstruction(DriverExecutionPrepareEngine.class);
+ MockedConstruction<SQLFederationEngine> ignoredFederationEngine = mockConstruction(SQLFederationEngine.class, (mock, context) -> {
+ actualSchemaName.set((String) context.arguments().get(1));
+ when(mock.decide(any(), any())).thenReturn(true);
+ doAnswer(invocation -> {
+ SQLFederationContext federationContext = invocation.getArgument(2);
+ assertThat(federationContext.getProcessId(), is("foo_process"));
+ federationContext.getPreviewExecutionUnits().add(expected);
+ return null;
+ }).when(mock).executeQuery(any(), any(), any());
+ })) {
+ Optional<Collection<ExecutionUnit>> actual = generator.generate(database, queryContext, contextManager, connectionContext);
+ assertTrue(actual.isPresent());
+ assertThat(actual.get(), is(Collections.singletonList(expected)));
+ assertThat(actualSchemaName.get(), is("foo_schema"));
+ }
+ }
+
+ private ContextManager mockContextManager() {
+ ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+ ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
+ when(metaData.getGlobalRuleMetaData()).thenReturn(mock(RuleMetaData.class));
+ when(metaData.getProps()).thenReturn(new ConfigurationProperties(new Properties()));
+ when(result.getMetaDataContexts().getMetaData()).thenReturn(metaData);
+ return result;
+ }
+
+ private DistSQLConnectionContext mockConnectionContext() {
+ DistSQLConnectionContext result = mock(DistSQLConnectionContext.class, RETURNS_DEEP_STUBS);
+ when(result.getExecutorEngineSupplier()).thenReturn(() -> mock(ExecutorEngine.class));
+ return result;
+ }
+}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/ParseDistSQLExecutor.java b/kernel/sql-parser/distsql/handler/src/main/java/org/apache/shardingsphere/parser/distsql/handler/query/ParseDistSQLExecutor.java
similarity index 97%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/ParseDistSQLExecutor.java
rename to kernel/sql-parser/distsql/handler/src/main/java/org/apache/shardingsphere/parser/distsql/handler/query/ParseDistSQLExecutor.java
index dc84786d5cd..1fd56efb0e4 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/ParseDistSQLExecutor.java
+++ b/kernel/sql-parser/distsql/handler/src/main/java/org/apache/shardingsphere/parser/distsql/handler/query/ParseDistSQLExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rul;
+package org.apache.shardingsphere.parser.distsql.handler.query;
import lombok.Setter;
import org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorConnectionContextAware;
diff --git a/kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor b/kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
index d1a0b508dbc..520a811a0ec 100644
--- a/kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
+++ b/kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
@@ -16,3 +16,4 @@
#
org.apache.shardingsphere.parser.distsql.handler.query.ShowSQLParserRuleExecutor
+org.apache.shardingsphere.parser.distsql.handler.query.ParseDistSQLExecutor
diff --git a/proxy/backend/core/pom.xml b/proxy/backend/core/pom.xml
index 8899d1263f3..d6506586bc2 100644
--- a/proxy/backend/core/pom.xml
+++ b/proxy/backend/core/pom.xml
@@ -27,6 +27,11 @@
<name>${project.artifactId}</name>
<dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-distsql-handler</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-database-protocol-core</artifactId>
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java
index aebfd57c4f6..1cdf93e841e 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java
@@ -21,6 +21,7 @@ import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.metadata.database.DatabaseNameValidator;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
@@ -29,7 +30,6 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlGlobalRuleConfi
import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.proxy.backend.config.checker.YamlProxyConfigurationChecker;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyServerConfiguration;
import java.io.File;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/YamlProxyConfiguration.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/YamlProxyConfiguration.java
index 8ab671b2b76..2747d523590 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/YamlProxyConfiguration.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/YamlProxyConfiguration.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyServerConfiguration;
import java.util.Map;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/checker/YamlProxyConfigurationChecker.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/checker/YamlProxyConfigurationChecker.java
index 1f413e6c3b5..66b135926cb 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/checker/YamlProxyConfigurationChecker.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/checker/YamlProxyConfigurationChecker.java
@@ -19,10 +19,10 @@ package org.apache.shardingsphere.proxy.backend.config.checker;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDataSourceConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.infra.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.exception.kernel.metadata.resource.storageunit.DuplicateStorageUnitException;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
import java.util.Collection;
import java.util.Map;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyServerConfiguration.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyServerConfiguration.java
index 954081a1265..6d8fd33b801 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyServerConfiguration.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyServerConfiguration.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.proxy.backend.config.yaml;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDataSourceConfiguration;
import org.apache.shardingsphere.globalclock.yaml.config.YamlGlobalClockRuleConfiguration;
import org.apache.shardingsphere.infra.util.yaml.YamlConfiguration;
import org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlModeConfiguration;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyConfigurationSwapper.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyConfigurationSwapper.java
index eb3a592b857..ecef6345d92 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyConfigurationSwapper.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyConfigurationSwapper.java
@@ -17,6 +17,9 @@
package org.apache.shardingsphere.proxy.backend.config.yaml.swapper;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDataSourceConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.swapper.YamlProxyDataSourceConfigurationSwapper;
import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration;
import org.apache.shardingsphere.infra.config.database.impl.DataSourceGeneratedDatabaseConfiguration;
import org.apache.shardingsphere.infra.config.props.temporary.TemporaryConfigurationPropertyKey;
@@ -29,8 +32,6 @@ import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigur
import org.apache.shardingsphere.proxy.backend.config.ProxyConfiguration;
import org.apache.shardingsphere.proxy.backend.config.ProxyGlobalConfiguration;
import org.apache.shardingsphere.proxy.backend.config.YamlProxyConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyServerConfiguration;
import javax.sql.DataSource;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLQueryProxyBackendHandler.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLQueryProxyBackendHandler.java
index 463f88371de..3826137ced6 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLQueryProxyBackendHandler.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLQueryProxyBackendHandler.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataMergedResult;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
@@ -53,6 +54,8 @@ public final class DistSQLQueryProxyBackendHandler implements DistSQLProxyBacken
DistSQLConnectionContext distsqlConnectionContext = new DistSQLConnectionContext(queryContext,
connectionSession.getDatabaseConnectionManager().getConnectionSize(), connectionSession.getProtocolType(),
connectionSession.getDatabaseConnectionManager(), connectionSession.getStatementManager());
+ distsqlConnectionContext.setExecutorEngineSupplier(BackendExecutorContext.getInstance()::getExecutorEngine);
+ distsqlConnectionContext.setProcessId(connectionSession.getProcessId());
engine = new DistSQLQueryExecuteEngine(sqlStatement, connectionSession.getUsedDatabaseName(), contextManager, distsqlConnectionContext);
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterReadWriteLockStrategy.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterReadWriteLockStrategy.java
index 0486e196f23..6db5210aff8 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterReadWriteLockStrategy.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterReadWriteLockStrategy.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.proxy.backend.lock.impl;
+import org.apache.shardingsphere.distsql.handler.executor.lock.spi.ClusterLockStrategy;
import org.apache.shardingsphere.mode.state.ShardingSphereState;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.lock.spi.ClusterLockStrategy;
/**
* Cluster read-write lock strategy.
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterWriteLockStrategy.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterWriteLockStrategy.java
index 78ccc501515..5feb9a239ba 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterWriteLockStrategy.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterWriteLockStrategy.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.proxy.backend.lock.impl;
+import org.apache.shardingsphere.distsql.handler.executor.lock.spi.ClusterLockStrategy;
import org.apache.shardingsphere.mode.state.ShardingSphereState;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.lock.spi.ClusterLockStrategy;
/**
* Cluster write lock strategy.
diff --git a/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor b/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
deleted file mode 100644
index adb3a065fd1..00000000000
--- a/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
+++ /dev/null
@@ -1,29 +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.
-#
-
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.computenode.ShowComputeNodesExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.computenode.ShowComputeNodeInfoExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.computenode.ShowComputeNodeModeExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.export.ExportDatabaseConfigurationExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.export.ExportMetaDataExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.export.ExportStorageNodesExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.yaml.ConvertYamlConfigurationExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.variable.ShowDistVariableExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.variable.ShowDistVariablesExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.export.ShowTableMetaDataExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.rul.ParseDistSQLExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.rul.PreviewExecutor
diff --git a/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor b/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor
deleted file mode 100644
index 6bded2ed8f2..00000000000
--- a/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor
+++ /dev/null
@@ -1,25 +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.
-#
-
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.computenode.SetComputeNodeStateExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.imports.ImportDatabaseConfigurationExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.imports.ImportMetaDataExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.variable.SetDistVariableExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.refresh.RefreshDatabaseMetaDataExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.lock.LockClusterExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.lock.UnlockClusterExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.refresh.RefreshTableMetaDataExecutor
diff --git a/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.lock.spi.ClusterLockStrategy b/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.lock.spi.ClusterLockStrategy
similarity index 100%
rename from proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.lock.spi.ClusterLockStrategy
rename to proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.lock.spi.ClusterLockStrategy
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java
index 9b160c8369a..7bc6dc333a1 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java
@@ -18,6 +18,8 @@
package org.apache.shardingsphere.proxy.backend.config;
import org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDataSourceConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguration;
import org.apache.shardingsphere.globalclock.yaml.config.YamlGlobalClockRuleConfiguration;
import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
@@ -25,8 +27,6 @@ import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.parser.yaml.config.YamlSQLParserRuleConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyServerConfiguration;
import org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceGroupRuleConfiguration;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/checker/YamlProxyConfigurationCheckerTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/checker/YamlProxyConfigurationCheckerTest.java
index b7cd769f932..0c36b6e1d26 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/checker/YamlProxyConfigurationCheckerTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/checker/YamlProxyConfigurationCheckerTest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.proxy.backend.config.checker;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDataSourceConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.infra.exception.kernel.metadata.resource.storageunit.DuplicateStorageUnitException;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
import org.junit.jupiter.api.Test;
import java.util.Collections;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfigurationTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfigurationTest.java
index 5bff3a1f388..a1ac31471e8 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfigurationTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfigurationTest.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.proxy.backend.config.yaml;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDataSourceConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
import org.junit.jupiter.api.Test;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapperTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapperTest.java
index ebf2d359486..a17e5f5dbbe 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapperTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapperTest.java
@@ -17,12 +17,13 @@
package org.apache.shardingsphere.proxy.backend.config.yaml.swapper;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDataSourceConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.swapper.YamlProxyDataSourceConfigurationSwapper;
import org.apache.shardingsphere.infra.datasource.pool.config.ConnectionConfiguration;
import org.apache.shardingsphere.infra.datasource.pool.config.DataSourceConfiguration;
import org.apache.shardingsphere.infra.datasource.pool.config.PoolConfiguration;
import org.apache.shardingsphere.proxy.backend.config.ProxyConfigurationLoader;
import org.apache.shardingsphere.proxy.backend.config.YamlProxyConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
import org.junit.jupiter.api.Test;
import java.io.IOException;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLExecutorSPITest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLExecutorSPITest.java
new file mode 100644
index 00000000000..3c876a2bfce
--- /dev/null
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLExecutorSPITest.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.proxy.backend.handler.distsql;
+
+import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collection;
+import java.util.ServiceLoader;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+class DistSQLExecutorSPITest {
+
+ @Test
+ void assertMigratedQueryExecutorsLoadOncePerStatement() {
+ Collection<DistSQLQueryExecutor> executors = StreamSupport.stream(ServiceLoader.load(DistSQLQueryExecutor.class).spliterator(), false)
+ .filter(each -> isMigratedExecutor(each.getClass().getName())).collect(Collectors.toList());
+ assertThat(executors.size(), is(12));
+ assertThat(executors.stream().map(DistSQLQueryExecutor::getType).distinct().count(), is(12L));
+ }
+
+ @Test
+ void assertMigratedUpdateExecutorsLoadOncePerStatement() {
+ Collection<DistSQLUpdateExecutor> executors = StreamSupport.stream(ServiceLoader.load(DistSQLUpdateExecutor.class).spliterator(), false)
+ .filter(each -> isMigratedExecutor(each.getClass().getName())).collect(Collectors.toList());
+ assertThat(executors.size(), is(8));
+ assertThat(executors.stream().map(DistSQLUpdateExecutor::getType).distinct().count(), is(8L));
+ }
+
+ private boolean isMigratedExecutor(final String className) {
+ return className.startsWith("org.apache.shardingsphere.distsql.handler.executor.ral.queryable.")
+ || className.startsWith("org.apache.shardingsphere.distsql.handler.executor.ral.updatable.")
+ || className.startsWith("org.apache.shardingsphere.distsql.handler.executor.rul.")
+ || "org.apache.shardingsphere.parser.distsql.handler.query.ParseDistSQLExecutor".equals(className);
+ }
+}
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeInfoExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeInfoExecutorTest.java
index fb54f8bb41c..ea773f2581c 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeInfoExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeInfoExecutorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.computenode;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.queryable.computenode.ShowComputeNodeInfoExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.show.ShowComputeNodeInfoStatement;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeModeExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeModeExecutorTest.java
index 95e07407063..4deb2f5e74d 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeModeExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodeModeExecutorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.computenode;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.queryable.computenode.ShowComputeNodeModeExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.show.ShowComputeNodeModeStatement;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodesExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodesExecutorTest.java
index 9d02bed4294..cc257b6e3b0 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodesExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/computenode/ShowComputeNodesExecutorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.computenode;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.queryable.computenode.ShowComputeNodesExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.show.ShowComputeNodesStatement;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.config.mode.PersistRepositoryConfiguration;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportDatabaseConfigurationExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportDatabaseConfigurationExecutorTest.java
index 3efcc75ae92..02f99fa2e5c 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportDatabaseConfigurationExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportDatabaseConfigurationExecutorTest.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ex
import lombok.SneakyThrows;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.queryable.export.ExportDatabaseConfigurationExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.export.ExportDatabaseConfigurationStatement;
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.keygen.impl.ColumnKeyGenerateStrategiesRuleConfiguration;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportMetaDataExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportMetaDataExecutorTest.java
index 41031983f48..3b82acb5554 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportMetaDataExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportMetaDataExecutorTest.java
@@ -22,6 +22,11 @@ import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.authority.rule.builder.DefaultAuthorityRuleConfigurationBuilder;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDataSourceConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedClusterInfo;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedMetaData;
+import org.apache.shardingsphere.distsql.handler.executor.ral.queryable.export.ExportMetaDataExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.export.ExportMetaDataStatement;
import org.apache.shardingsphere.globalclock.rule.GlobalClockRule;
import org.apache.shardingsphere.globalclock.rule.builder.DefaultGlobalClockRuleConfigurationBuilder;
@@ -53,11 +58,7 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfigurati
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.standalone.workerid.StandaloneWorkerIdGenerator;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyServerConfiguration;
-import org.apache.shardingsphere.proxy.backend.distsql.export.ExportedClusterInfo;
-import org.apache.shardingsphere.proxy.backend.distsql.export.ExportedMetaData;
import org.apache.shardingsphere.test.infra.fixture.jdbc.MockedDataSource;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportStorageNodesExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportStorageNodesExecutorTest.java
index a829fe63d46..b5311f86a86 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportStorageNodesExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportStorageNodesExecutorTest.java
@@ -22,6 +22,7 @@ import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.authority.rule.builder.DefaultAuthorityRuleConfigurationBuilder;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.queryable.export.ExportStorageNodesExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.export.ExportStorageNodesStatement;
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.keygen.impl.ColumnKeyGenerateStrategiesRuleConfiguration;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ShowTableMetaDataExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ShowTableMetaDataExecutorTest.java
index bf2fe4bb642..ce654863ed0 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ShowTableMetaDataExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ShowTableMetaDataExecutorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.export;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.distsql.handler.executor.ral.queryable.export.ShowTableMetaDataExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.show.ShowTableMetaDataStatement;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariableExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariableExecutorTest.java
index 53f0df6973f..75290ea41b1 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariableExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariableExecutorTest.java
@@ -20,6 +20,8 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.va
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.common.DistSQLVariable;
+import org.apache.shardingsphere.distsql.handler.executor.ral.queryable.variable.ShowDistVariableExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.show.ShowDistVariableStatement;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.props.temporary.TemporaryConfigurationProperties;
@@ -32,7 +34,6 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.infra.util.props.PropertiesBuilder;
import org.apache.shardingsphere.infra.util.props.PropertiesBuilder.Property;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.DistSQLVariable;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariablesExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariablesExecutorTest.java
index 475214eccfe..b34eeb8b0a4 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariablesExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/variable/ShowDistVariablesExecutorTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.va
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.queryable.variable.ShowDistVariablesExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.show.ShowDistVariablesStatement;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.props.temporary.TemporaryConfigurationProperties;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/yaml/ConvertYamlConfigurationExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/yaml/ConvertYamlConfigurationExecutorTest.java
index c9a44acc0b8..5a20ebcd7a4 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/yaml/ConvertYamlConfigurationExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/yaml/ConvertYamlConfigurationExecutorTest.java
@@ -21,6 +21,9 @@ import com.google.common.base.Splitter;
import lombok.SneakyThrows;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDataSourceConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.ral.queryable.yaml.ConvertYamlConfigurationExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.queryable.convert.ConvertYamlConfigurationStatement;
import org.apache.shardingsphere.infra.exception.generic.FileIOException;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
@@ -28,8 +31,6 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/computenode/SetComputeNodeStateExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/computenode/SetComputeNodeStateExecutorTest.java
index 28feb0f9f26..9748cf8565f 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/computenode/SetComputeNodeStateExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/computenode/SetComputeNodeStateExecutorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.computenode;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.updatable.computenode.SetComputeNodeStateExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.updatable.SetComputeNodeStateStatement;
import org.apache.shardingsphere.infra.exception.generic.UnsupportedSQLOperationException;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportDatabaseConfigurationExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportDatabaseConfigurationExecutorTest.java
index 3bb4cf9902b..4cc52f3bb0e 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportDatabaseConfigurationExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportDatabaseConfigurationExecutorTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.im
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.database.exception.core.exception.syntax.database.DatabaseCreateExistsException;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.updatable.imports.ImportDatabaseConfigurationExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.updatable.ImportDatabaseConfigurationStatement;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportMetaDataExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportMetaDataExecutorTest.java
index 4d9eef6f336..59e06138f1b 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportMetaDataExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportMetaDataExecutorTest.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.authority.rule.builder.DefaultAuthorityRuleConf
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.database.exception.core.exception.syntax.database.DatabaseCreateExistsException;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.updatable.imports.ImportMetaDataExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.updatable.ImportMetaDataStatement;
import org.apache.shardingsphere.globalclock.rule.GlobalClockRule;
import org.apache.shardingsphere.globalclock.rule.builder.DefaultGlobalClockRuleConfigurationBuilder;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterExecutorTest.java
index 67421c13552..ce6517adb65 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterExecutorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.lock;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.updatable.lock.LockClusterExecutor;
import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
import org.apache.shardingsphere.distsql.statement.type.ral.updatable.LockClusterStatement;
import org.apache.shardingsphere.infra.algorithm.core.exception.MissingRequiredAlgorithmException;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterOperationTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterOperationTest.java
index 5c075df6d32..dbde3f3d363 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterOperationTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterOperationTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.lock;
+import org.apache.shardingsphere.distsql.handler.executor.ral.updatable.lock.LockClusterOperation;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/UnlockClusterExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/UnlockClusterExecutorTest.java
index 9944caf6d29..5538d1f9406 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/UnlockClusterExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/UnlockClusterExecutorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.lock;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.updatable.lock.UnlockClusterExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.updatable.UnlockClusterStatement;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.exclusive.ExclusiveOperatorEngine;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshDatabaseMetaDataExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshDatabaseMetaDataExecutorTest.java
index 3d49c29c4d1..73664ebf578 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshDatabaseMetaDataExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshDatabaseMetaDataExecutorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.refresh;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.updatable.refresh.RefreshDatabaseMetaDataExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.updatable.RefreshDatabaseMetaDataStatement;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.schema.util.SystemSchemaUtils;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshTableMetaDataExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshTableMetaDataExecutorTest.java
index aa454e6c879..046bbf4903d 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshTableMetaDataExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/refresh/RefreshTableMetaDataExecutorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.refresh;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.updatable.refresh.RefreshTableMetaDataExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.updatable.RefreshTableMetaDataStatement;
import org.apache.shardingsphere.infra.exception.kernel.metadata.SchemaNotFoundException;
import org.apache.shardingsphere.infra.exception.kernel.metadata.TableNotFoundException;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutorTest.java
index a909ddf6313..c813110fef8 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.variable;
import org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.ral.updatable.variable.SetDistVariableExecutor;
import org.apache.shardingsphere.distsql.statement.type.ral.updatable.SetDistVariableStatement;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/PreviewExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/PreviewExecutorTest.java
index 101970f5fbc..f1bf001f41f 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/PreviewExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/PreviewExecutorTest.java
@@ -21,6 +21,7 @@ import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.database.exception.core.exception.syntax.sql.DialectSQLParsingException;
import org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
import org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.rul.PreviewExecutor;
import org.apache.shardingsphere.distsql.statement.type.rul.sql.PreviewStatement;
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
@@ -57,7 +58,6 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
-import org.apache.shardingsphere.proxy.backend.connector.ProxyDatabaseConnectionManager;
import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.cursor.CursorNameSegment;
@@ -208,11 +208,9 @@ class PreviewExecutorTest {
when(tablesContext.getSchemaName()).thenReturn(Optional.of("foo_schema"));
when(cursorStatementContext.getTablesContext()).thenReturn(tablesContext);
connectionContext.getCursorContext().getCursorStatementContexts().put("foo_cursor", cursorStatementContext);
- ProxyDatabaseConnectionManager databaseConnectionManager = mock(ProxyDatabaseConnectionManager.class, RETURNS_DEEP_STUBS);
- when(databaseConnectionManager.getConnectionSession().getProcessId()).thenReturn("process_id");
HintValueContext hintValueContext = new HintValueContext();
executor.setDatabase(mockCompleteDatabase());
- executor.setConnectionContext(mockConnectionContext(hintValueContext, connectionContext, databaseConnectionManager));
+ executor.setConnectionContext(mockConnectionContext(hintValueContext, connectionContext, mock(DatabaseConnectionManager.class)));
SQLStatement sqlStatement = mockSQLStatement(new CursorSQLStatementAttribute(new CursorNameSegment(0, 0, new IdentifierValue("FOO_CURSOR"))));
CursorHeldSQLStatementContext cursorHeldSQLStatementContext = new CursorHeldSQLStatementContext(sqlStatement);
AtomicReference<String> actualSchemaName = new AtomicReference<>();
@@ -258,7 +256,10 @@ class PreviewExecutorTest {
QueryContext queryContext = mock(QueryContext.class);
when(queryContext.getHintValueContext()).thenReturn(hintValueContext);
when(queryContext.getConnectionContext()).thenReturn(connectionContext);
- return new DistSQLConnectionContext(queryContext, 1, databaseType, databaseConnectionManager, mock(ExecutorStatementManager.class));
+ DistSQLConnectionContext result = new DistSQLConnectionContext(queryContext, 1, databaseType, databaseConnectionManager, mock(ExecutorStatementManager.class));
+ result.setExecutorEngineSupplier(BackendExecutorContext.getInstance()::getExecutorEngine);
+ result.setProcessId("process_id");
+ return result;
}
private SQLStatement mockSQLStatement(final CursorSQLStatementAttribute cursorSQLStatementAttribute) {
@@ -290,6 +291,7 @@ class PreviewExecutorTest {
private Object executePreviewCallback(final InvocationOnMock invocation) throws SQLException {
SQLFederationContext sqlFederationContext = invocation.getArgument(2);
+ assertThat(sqlFederationContext.getProcessId(), is("process_id"));
JDBCExecutorCallback<? extends ExecuteResult> callback = invocation.getArgument(1);
callback.execute(Collections.singletonList(createJDBCExecutionUnit("foo_ds", "SELECT 2", false)), true, "process_id");
try {
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterReadWriteLockStrategyTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterReadWriteLockStrategyTest.java
index b70da60a520..b4c4b1b650c 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterReadWriteLockStrategyTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterReadWriteLockStrategyTest.java
@@ -17,11 +17,11 @@
package org.apache.shardingsphere.proxy.backend.lock.impl;
+import org.apache.shardingsphere.distsql.handler.executor.lock.spi.ClusterLockStrategy;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.state.ShardingSphereState;
import org.apache.shardingsphere.mode.state.StatePersistService;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.lock.spi.ClusterLockStrategy;
import org.apache.shardingsphere.test.infra.framework.extension.mock.AutoMockExtension;
import org.apache.shardingsphere.test.infra.framework.extension.mock.StaticMockSettings;
import org.junit.jupiter.api.Test;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterWriteLockStrategyTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterWriteLockStrategyTest.java
index aa35699cec7..b17f4dbd923 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterWriteLockStrategyTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/lock/impl/ClusterWriteLockStrategyTest.java
@@ -17,11 +17,11 @@
package org.apache.shardingsphere.proxy.backend.lock.impl;
+import org.apache.shardingsphere.distsql.handler.executor.lock.spi.ClusterLockStrategy;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.state.ShardingSphereState;
import org.apache.shardingsphere.mode.state.StatePersistService;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.lock.spi.ClusterLockStrategy;
import org.apache.shardingsphere.test.infra.framework.extension.mock.AutoMockExtension;
import org.apache.shardingsphere.test.infra.framework.extension.mock.StaticMockSettings;
import org.junit.jupiter.api.Test;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/ClusterExportMetaDataGeneratorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/ClusterExportMetaDataGeneratorTest.java
index a0fddc1ea05..f69779674f6 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/ClusterExportMetaDataGeneratorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/ClusterExportMetaDataGeneratorTest.java
@@ -17,6 +17,9 @@
package org.apache.shardingsphere.proxy.backend.util;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedClusterInfo;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedMetaData;
+import org.apache.shardingsphere.distsql.handler.executor.util.ClusterExportMetaDataGenerator;
import org.apache.shardingsphere.globalclock.config.GlobalClockRuleConfiguration;
import org.apache.shardingsphere.globalclock.provider.GlobalClockProvider;
import org.apache.shardingsphere.globalclock.rule.GlobalClockRule;
@@ -30,8 +33,6 @@ import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUn
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.infra.util.json.JsonEngine;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.distsql.export.ExportedClusterInfo;
-import org.apache.shardingsphere.proxy.backend.distsql.export.ExportedMetaData;
import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
import org.junit.jupiter.api.Test;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/DatabaseExportMetaDataGeneratorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/DatabaseExportMetaDataGeneratorTest.java
index 3cf28298cf7..06bc16899f1 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/DatabaseExportMetaDataGeneratorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/DatabaseExportMetaDataGeneratorTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.proxy.backend.util;
+import org.apache.shardingsphere.distsql.handler.executor.util.DatabaseExportMetaDataGenerator;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties;
import org.apache.shardingsphere.infra.datasource.pool.props.domain.synonym.ConnectionPropertySynonyms;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/ExportUtilsTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/ExportUtilsTest.java
index 232ba7a0bbb..02800bc879f 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/ExportUtilsTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/ExportUtilsTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.proxy.backend.util;
+import org.apache.shardingsphere.distsql.handler.executor.util.ExportUtils;
import org.apache.shardingsphere.infra.exception.generic.FileIOException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/MetaDataImportExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/MetaDataImportExecutorTest.java
index ecbec3a77e0..15b213ff251 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/MetaDataImportExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/MetaDataImportExecutorTest.java
@@ -18,14 +18,18 @@
package org.apache.shardingsphere.proxy.backend.util;
import lombok.SneakyThrows;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlExportedServerConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.export.ExportedMetaData;
+import org.apache.shardingsphere.distsql.handler.executor.util.MetaDataImportExecutor;
+import org.apache.shardingsphere.distsql.handler.executor.util.YamlDatabaseConfigurationImportExecutor;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.persist.service.MetaDataManagerPersistService;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
+import org.apache.shardingsphere.parser.yaml.config.YamlSQLParserRuleConfiguration;
import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyServerConfiguration;
-import org.apache.shardingsphere.proxy.backend.distsql.export.ExportedMetaData;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
@@ -65,7 +69,7 @@ class MetaDataImportExecutorTest {
YamlProxyDatabaseConfiguration databaseConfig = new YamlProxyDatabaseConfiguration();
databaseConfig.setDatabaseName("logic_db");
try (MockedStatic<YamlEngine> mockedStatic = mockStatic(YamlEngine.class)) {
- mockedStatic.when(() -> YamlEngine.unmarshal(anyString(), eq(YamlProxyServerConfiguration.class))).thenReturn(null);
+ mockedStatic.when(() -> YamlEngine.unmarshal(anyString(), eq(YamlExportedServerConfiguration.class))).thenReturn(null);
mockedStatic.when(() -> YamlEngine.unmarshal(anyString(), eq(YamlProxyDatabaseConfiguration.class))).thenReturn(databaseConfig);
executor.importClusterConfigurations(exportedMetaData);
}
@@ -84,12 +88,12 @@ class MetaDataImportExecutorTest {
when(swapperEngine.swapToRuleConfigurations(anyCollection())).thenReturn(Collections.singleton(ruleConfig));
setField(executor, "ruleConfigSwapperEngine", swapperEngine);
Properties props = new Properties();
- YamlProxyServerConfiguration serverConfig = new YamlProxyServerConfiguration();
+ YamlExportedServerConfiguration serverConfig = new YamlExportedServerConfiguration();
serverConfig.setProps(props);
YamlProxyDatabaseConfiguration databaseConfig = new YamlProxyDatabaseConfiguration();
databaseConfig.setDatabaseName("logic_db");
try (MockedStatic<YamlEngine> mockedStatic = mockStatic(YamlEngine.class)) {
- mockedStatic.when(() -> YamlEngine.unmarshal(anyString(), eq(YamlProxyServerConfiguration.class))).thenReturn(serverConfig);
+ mockedStatic.when(() -> YamlEngine.unmarshal(anyString(), eq(YamlExportedServerConfiguration.class))).thenReturn(serverConfig);
mockedStatic.when(() -> YamlEngine.unmarshal(anyString(), eq(YamlProxyDatabaseConfiguration.class))).thenReturn(databaseConfig);
executor.importClusterConfigurations(exportedMetaData);
}
@@ -100,6 +104,19 @@ class MetaDataImportExecutorTest {
assertThat(captor.getValue().getDatabaseName(), is("logic_db"));
}
+ @Test
+ void assertExportedServerConfigurationYamlCompatibility() {
+ Properties props = new Properties();
+ props.setProperty("sql-show", "true");
+ String yaml = "rules:" + System.lineSeparator() + YamlEngine.marshal(Collections.singletonList(new YamlSQLParserRuleConfiguration()))
+ + System.lineSeparator() + YamlEngine.marshal(Collections.singletonMap("props", props));
+ YamlExportedServerConfiguration actual = YamlEngine.unmarshal(yaml, YamlExportedServerConfiguration.class);
+ YamlProxyServerConfiguration previous = YamlEngine.unmarshal(yaml, YamlProxyServerConfiguration.class);
+ assertThat(actual.getProps(), is(previous.getProps()));
+ assertThat(actual.getRules().size(), is(1));
+ assertThat(actual.getRules().iterator().next().getClass(), is(previous.getRules().iterator().next().getClass()));
+ }
+
private ExportedMetaData createExportedMetaData() {
ExportedMetaData result = new ExportedMetaData();
result.setDatabases(Collections.singletonMap("logic_db", "databaseName: logic_db"));
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutorTest.java
index 1a877bf37a1..cfb5b00a3a2 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutorTest.java
@@ -18,6 +18,10 @@
package org.apache.shardingsphere.proxy.backend.util;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDataSourceConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.swapper.YamlProxyDataSourceConfigurationSwapper;
+import org.apache.shardingsphere.distsql.handler.executor.util.YamlDatabaseConfigurationImportExecutor;
import org.apache.shardingsphere.distsql.handler.validate.DistSQLDataSourcePoolPropertiesValidator;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.props.temporary.TemporaryConfigurationProperties;
@@ -45,9 +49,6 @@ import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.config.database.DatabaseRulePersistService;
import org.apache.shardingsphere.mode.persist.service.MetaDataManagerPersistService;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDataSourceConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.swapper.YamlProxyDataSourceConfigurationSwapper;
import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
import org.apache.shardingsphere.single.rule.SingleRule;
import org.apache.shardingsphere.test.infra.framework.extension.mock.AutoMockExtension;
diff --git a/proxy/bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializerTest.java b/proxy/bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializerTest.java
index fed04ab153a..920cf75d01c 100644
--- a/proxy/bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializerTest.java
+++ b/proxy/bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializerTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.initializer;
import lombok.SneakyThrows;
+import org.apache.shardingsphere.distsql.handler.executor.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaDataBuilder;
@@ -27,7 +28,6 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlModeConfigurati
import org.apache.shardingsphere.mode.manager.builder.ContextManagerBuilder;
import org.apache.shardingsphere.mode.manager.builder.ContextManagerBuilderParameter;
import org.apache.shardingsphere.proxy.backend.config.YamlProxyConfiguration;
-import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyDatabaseConfiguration;
import org.apache.shardingsphere.proxy.backend.config.yaml.YamlProxyServerConfiguration;
import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;