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 2024/01/26 03:44:46 UTC
(shardingsphere) branch master updated: Move DistSQL handler common logic from proxy to handler module (#29861)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 a469b0801c0 Move DistSQL handler common logic from proxy to handler module (#29861)
a469b0801c0 is described below
commit a469b0801c0cef19f0a23a009393c444fc6658ca
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Jan 26 11:44:39 2024 +0800
Move DistSQL handler common logic from proxy to handler module (#29861)
* Move MetaDataAwareRQLExecutor to distsql-handler module
* Add RQLExecuteEngine
* Add RQLExecuteEngine
* Add RuleDefinitionExecuteEngine
* Add QueryableRALExecuteEngine and UpdatableRALExecuteEngine
---
.../update/CreateBroadcastTableRuleExecutor.java | 2 +-
.../update/DropBroadcastTableRuleExecutor.java | 2 +-
...le.spi.database.DatabaseRuleDefinitionExecutor} | 0
.../handler/update/AlterEncryptRuleExecutor.java | 2 +-
.../handler/update/CreateEncryptRuleExecutor.java | 2 +-
.../handler/update/DropEncryptRuleExecutor.java | 2 +-
...le.spi.database.DatabaseRuleDefinitionExecutor} | 0
.../handler/update/AlterMaskRuleExecutor.java | 2 +-
.../handler/update/CreateMaskRuleExecutor.java | 2 +-
.../handler/update/DropMaskRuleExecutor.java | 2 +-
...le.spi.database.DatabaseRuleDefinitionExecutor} | 0
.../AlterReadwriteSplittingRuleExecutor.java | 2 +-
.../CreateReadwriteSplittingRuleExecutor.java | 2 +-
.../update/DropReadwriteSplittingRuleExecutor.java | 2 +-
...le.spi.database.DatabaseRuleDefinitionExecutor} | 0
.../DropReadwriteSplittingRuleStatement.java | 3 +-
.../AlterDefaultShadowAlgorithmExecutor.java | 2 +-
.../handler/update/AlterShadowRuleExecutor.java | 2 +-
.../CreateDefaultShadowAlgorithmExecutor.java | 2 +-
.../handler/update/CreateShadowRuleExecutor.java | 2 +-
.../update/DropDefaultShadowAlgorithmExecutor.java | 2 +-
.../update/DropShadowAlgorithmExecutor.java | 2 +-
.../handler/update/DropShadowRuleExecutor.java | 2 +-
...le.spi.database.DatabaseRuleDefinitionExecutor} | 0
.../AlterDefaultShardingStrategyExecutor.java | 2 +-
.../AlterShardingTableReferenceRuleExecutor.java | 2 +-
.../update/AlterShardingTableRuleExecutor.java | 2 +-
.../CreateDefaultShardingStrategyExecutor.java | 2 +-
.../CreateShardingTableReferenceRuleExecutor.java | 2 +-
.../update/CreateShardingTableRuleExecutor.java | 2 +-
.../DropDefaultShardingStrategyExecutor.java | 2 +-
.../update/DropShardingAlgorithmExecutor.java | 2 +-
.../update/DropShardingAuditorExecutor.java | 2 +-
.../update/DropShardingKeyGeneratorExecutor.java | 2 +-
.../update/DropShardingTableReferenceExecutor.java | 2 +-
.../update/DropShardingTableRuleExecutor.java | 2 +-
...le.spi.database.DatabaseRuleDefinitionExecutor} | 0
infra/distsql-handler/pom.xml | 5 +
.../type/ral/query/QueryableRALExecuteEngine.java | 80 ++++++++++++++++
.../type/ral/update/UpdatableRALExecuteEngine.java | 53 +++++++++++
.../rule/engine/RuleDefinitionExecuteEngine.java | 67 +++++++++++++
.../DatabaseRuleDefinitionExecuteEngine.java | 24 +++--
.../rule/engine/database/DatabaseRuleOperator.java | 10 +-
.../database/DatabaseRuleOperatorFactory.java | 59 ++++++++++++
.../database/type/AlterDatabaseRuleOperator.java | 18 ++--
.../database/type/CreateDatabaseRuleOperator.java | 18 ++--
.../database/type/DropDatabaseRuleOperator.java | 25 ++---
.../global/GlobalRuleDefinitionExecuteEngine.java | 12 +--
.../LegacyGlobalRuleDefinitionExecuteEngine.java | 12 +--
.../database/DatabaseRuleAlterExecutor.java | 2 +-
.../database/DatabaseRuleCreateExecutor.java | 2 +-
.../database/DatabaseRuleDefinitionExecutor.java | 2 +-
.../database/DatabaseRuleDropExecutor.java | 2 +-
.../global/GlobalRuleDefinitionExecutor.java | 2 +-
.../distsql/handler/type/rql/RQLExecuteEngine.java | 105 +++++++++++++++++++++
.../type}/rql/aware/MetaDataAwareRQLExecutor.java | 2 +-
.../distsql/handler/util/DatabaseNameUtils.java | 45 +++++++++
.../update/AlterGlobalClockRuleExecutor.java | 2 +-
...l.rule.spi.global.GlobalRuleDefinitionExecutor} | 0
.../handler/update/LoadSingleTableExecutor.java | 2 +-
.../SetDefaultSingleTableStorageUnitExecutor.java | 2 +-
.../handler/update/UnloadSingleTableExecutor.java | 2 +-
...le.spi.database.DatabaseRuleDefinitionExecutor} | 0
.../update/AlterSQLFederationRuleExecutor.java | 2 +-
...l.rule.spi.global.GlobalRuleDefinitionExecutor} | 0
.../handler/update/AlterSQLParserRuleExecutor.java | 2 +-
...l.rule.spi.global.GlobalRuleDefinitionExecutor} | 0
.../update/AlterSQLTranslatorRuleExecutor.java | 2 +-
...l.rule.spi.global.GlobalRuleDefinitionExecutor} | 0
.../handler/update/AlterTrafficRuleExecutor.java | 2 +-
...l.rule.spi.global.GlobalRuleDefinitionExecutor} | 0
.../update/AlterTransactionRuleExecutor.java | 2 +-
...l.rule.spi.global.GlobalRuleDefinitionExecutor} | 0
...taticDataSourceContainedRuleAwareStatement.java | 22 ++---
.../distsql/ral/QueryableRALBackendHandler.java | 56 +++++------
.../distsql/ral/RALBackendHandlerFactory.java | 4 +-
.../distsql/ral/UpdatableRALBackendHandler.java | 29 +++---
.../distsql/rdl/RDLBackendHandlerFactory.java | 2 +-
.../LegacyRuleDefinitionBackendHandler.java | 10 +-
.../rdl/rule/RuleDefinitionBackendHandler.java | 38 +++-----
.../DatabaseRuleRDLExecuteEngineFactory.java | 56 -----------
.../handler/distsql/rql/RQLBackendHandler.java | 68 +++----------
...wStatusFromReadwriteSplittingRulesExecutor.java | 2 +-
.../fixture/FixtureDatabaseRuleCreateExecutor.java | 2 +-
.../ral/QueryableRALBackendHandlerTest.java | 8 +-
.../updatable/RefreshTableMetaDataUpdaterTest.java | 6 +-
...DistVariableUpdatableRALBackendHandlerTest.java | 2 +-
.../LegacyRuleDefinitionBackendHandlerTest.java | 1 -
...le.spi.database.DatabaseRuleDefinitionExecutor} | 0
89 files changed, 610 insertions(+), 322 deletions(-)
diff --git a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleExecutor.java b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleExecutor.java
index 066ba06af08..8de64f34930 100644
--- a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleExecutor.java
+++ b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleExecutor.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration
import org.apache.shardingsphere.broadcast.distsql.statement.CreateBroadcastTableRuleStatement;
import org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.distsql.handler.exception.storageunit.EmptyStorageUnitException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
diff --git a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutor.java b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutor.java
index 700aa1e078a..b003a80f511 100644
--- a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutor.java
+++ b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.broadcast.distsql.handler.update;
import org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration;
import org.apache.shardingsphere.broadcast.distsql.statement.DropBroadcastTableRuleStatement;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
diff --git a/features/broadcast/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor b/features/broadcast/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
similarity index 100%
rename from features/broadcast/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor
rename to features/broadcast/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
diff --git a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutor.java b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutor.java
index 0b342c64ab0..bb2e31214f3 100644
--- a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutor.java
+++ b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.encrypt.distsql.handler.update;
import com.google.common.base.Preconditions;
import org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleAlterExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnItemRuleConfiguration;
diff --git a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutor.java b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutor.java
index 1fb303bc589..e26c695907b 100644
--- a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutor.java
+++ b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutor.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgo
import org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
import org.apache.shardingsphere.distsql.handler.exception.storageunit.EmptyStorageUnitException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
diff --git a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutor.java b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutor.java
index d623913aa6f..5676cdbb854 100644
--- a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutor.java
+++ b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.encrypt.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnItemRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
diff --git a/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor b/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
similarity index 100%
rename from features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor
rename to features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
diff --git a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/AlterMaskRuleExecutor.java b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/AlterMaskRuleExecutor.java
index cbe7d8a80d7..5fb71bde462 100644
--- a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/AlterMaskRuleExecutor.java
+++ b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/AlterMaskRuleExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.mask.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleAlterExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
diff --git a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleExecutor.java b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleExecutor.java
index 96379c91b78..638e7931782 100644
--- a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleExecutor.java
+++ b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.mask.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
diff --git a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutor.java b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutor.java
index a2f789081bb..d0e56b0a837 100644
--- a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutor.java
+++ b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.mask.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
diff --git a/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor b/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
similarity index 100%
rename from features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor
rename to features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
diff --git a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleExecutor.java b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleExecutor.java
index 58aa477f952..fd567ff475c 100644
--- a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleExecutor.java
+++ b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
import com.google.common.base.Preconditions;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleAlterExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
diff --git a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleExecutor.java b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleExecutor.java
index 6c2c7c85e22..dc47d4b321d 100644
--- a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleExecutor.java
+++ b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleExecutor.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
diff --git a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutor.java b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutor.java
index 6ede7766444..142a6633d80 100644
--- a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutor.java
+++ b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutor.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.distsql.handler.exception.rule.RuleInUsedException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
diff --git a/features/readwrite-splitting/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor b/features/readwrite-splitting/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
similarity index 100%
rename from features/readwrite-splitting/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor
rename to features/readwrite-splitting/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
diff --git a/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/statement/DropReadwriteSplittingRuleStatement.java b/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/statement/DropReadwriteSplittingRuleStatement.java
index 8d1e29d65e1..30fb34b3c2c 100644
--- a/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/statement/DropReadwriteSplittingRuleStatement.java
+++ b/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/statement/DropReadwriteSplittingRuleStatement.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.readwritesplitting.distsql.statement;
import lombok.Getter;
+import org.apache.shardingsphere.distsql.statement.rdl.rule.aware.StaticDataSourceContainedRuleAwareStatement;
import org.apache.shardingsphere.distsql.statement.rdl.rule.type.DropRuleStatement;
import java.util.Collection;
@@ -26,7 +27,7 @@ import java.util.Collection;
* Drop readwrite-splitting rule statement.
*/
@Getter
-public final class DropReadwriteSplittingRuleStatement extends DropRuleStatement {
+public final class DropReadwriteSplittingRuleStatement extends DropRuleStatement implements StaticDataSourceContainedRuleAwareStatement {
private final Collection<String> names;
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterDefaultShadowAlgorithmExecutor.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterDefaultShadowAlgorithmExecutor.java
index eed3be09bc9..0428e796a58 100644
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterDefaultShadowAlgorithmExecutor.java
+++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterDefaultShadowAlgorithmExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.shadow.distsql.handler.update;
import com.google.common.base.Strings;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleAlterExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleExecutor.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleExecutor.java
index 8819766fe72..04d38c8ce69 100644
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleExecutor.java
+++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.shadow.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
import org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleAlterExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateDefaultShadowAlgorithmExecutor.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateDefaultShadowAlgorithmExecutor.java
index 7fc4ad02f6a..df99f7589ba 100644
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateDefaultShadowAlgorithmExecutor.java
+++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateDefaultShadowAlgorithmExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.shadow.distsql.handler.update;
import com.google.common.base.Strings;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.DuplicateAlgorithmException;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateShadowRuleExecutor.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateShadowRuleExecutor.java
index b3a87a0cfcf..8ba154428e3 100644
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateShadowRuleExecutor.java
+++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateShadowRuleExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmExecutor.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmExecutor.java
index 780656650fd..960d5a407dd 100644
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmExecutor.java
+++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmExecutor.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmExecutor.java
index bb8400c5266..9bd66723a97 100644
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmExecutor.java
+++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.shadow.distsql.handler.update;
import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.DistSQLException;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
diff --git a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleExecutor.java b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleExecutor.java
index 75ea1caf516..f34ce7fb667 100644
--- a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleExecutor.java
+++ b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
diff --git a/features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor b/features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
similarity index 100%
rename from features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor
rename to features/shadow/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyExecutor.java
index 09f34de763f..a511393ca1f 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterDefaultShardingStrategyExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleAlterExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableReferenceRuleExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableReferenceRuleExecutor.java
index 2122c7ce14f..46a909e14ce 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableReferenceRuleExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableReferenceRuleExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleAlterExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableRuleExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableRuleExecutor.java
index 75afafb9bb9..7fc05db984d 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableRuleExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableRuleExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleAlterExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyExecutor.java
index 917f7d29de3..5ef3e6bb90d 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateDefaultShardingStrategyExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
import org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableReferenceRuleExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableReferenceRuleExecutor.java
index cd1933ea9d0..5f46d7fdfb9 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableReferenceRuleExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableReferenceRuleExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
import org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableRuleExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableRuleExecutor.java
index 99e07ddce6c..ecde8d0ac3a 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableRuleExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableRuleExecutor.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultShardingStrategyExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultShardingStrategyExecutor.java
index c6ace7f52db..f50b3bc3724 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultShardingStrategyExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultShardingStrategyExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmExecutor.java
index fe7c5045b1b..ca37b0f2159 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmExecutor.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorExecutor.java
index c316a02e04d..f151162dc2d 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorExecutor.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorExecutor.java
index fb61082bc5c..fd4f2f93076 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import com.google.common.base.Strings;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
import org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableReferenceExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableReferenceExecutor.java
index 64284a37f4d..6ac1de55b6e 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableReferenceExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableReferenceExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleExecutor.java
index 0ab0dd97a74..d02e6670e78 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import com.google.common.base.Splitter;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.distsql.handler.exception.rule.RuleInUsedException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
diff --git a/features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor b/features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
similarity index 100%
rename from features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor
rename to features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
diff --git a/infra/distsql-handler/pom.xml b/infra/distsql-handler/pom.xml
index fa8ff57b472..f9e18d90f14 100644
--- a/infra/distsql-handler/pom.xml
+++ b/infra/distsql-handler/pom.xml
@@ -37,5 +37,10 @@
<artifactId>shardingsphere-infra-merge</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-mode-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/QueryableRALExecuteEngine.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/QueryableRALExecuteEngine.java
new file mode 100644
index 00000000000..4bcfe8642f9
--- /dev/null
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/query/QueryableRALExecuteEngine.java
@@ -0,0 +1,80 @@
+/*
+ * 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.type.ral.query;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.ConnectionSizeAwareQueryableRALExecutor;
+import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.DatabaseAwareQueryableRALExecutor;
+import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.InstanceContextAwareQueryableRALExecutor;
+import org.apache.shardingsphere.distsql.handler.util.DatabaseNameUtils;
+import org.apache.shardingsphere.distsql.statement.ral.queryable.QueryableRALStatement;
+import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+
+import java.util.Collection;
+
+/**
+ * Queryable RAL execute engine.
+ */
+@RequiredArgsConstructor
+public abstract class QueryableRALExecuteEngine {
+
+ private final QueryableRALStatement sqlStatement;
+
+ private final String currentDatabaseName;
+
+ private final ContextManager contextManager;
+
+ @Getter
+ private Collection<String> columnNames;
+
+ @Getter
+ private Collection<LocalDataQueryResultRow> rows;
+
+ /**
+ * Execute query.
+ *
+ */
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public void executeQuery() {
+ QueryableRALExecutor executor = TypedSPILoader.getService(QueryableRALExecutor.class, sqlStatement.getClass());
+ rows = getRows(executor);
+ columnNames = executor.getColumnNames();
+ }
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ private Collection<LocalDataQueryResultRow> getRows(final QueryableRALExecutor executor) {
+ if (executor instanceof InstanceContextAwareQueryableRALExecutor) {
+ ((InstanceContextAwareQueryableRALExecutor) executor).setInstanceContext(contextManager.getInstanceContext());
+ }
+ if (executor instanceof DatabaseAwareQueryableRALExecutor) {
+ ((DatabaseAwareQueryableRALExecutor) executor).setDatabase(getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement, currentDatabaseName)));
+ }
+ if (executor instanceof ConnectionSizeAwareQueryableRALExecutor) {
+ ((ConnectionSizeAwareQueryableRALExecutor) executor).setConnectionSize(getConnectionSize());
+ }
+ return executor.getRows(sqlStatement, contextManager.getMetaDataContexts().getMetaData());
+ }
+
+ protected abstract ShardingSphereDatabase getDatabase(String databaseName);
+
+ protected abstract int getConnectionSize();
+}
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/update/UpdatableRALExecuteEngine.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/update/UpdatableRALExecuteEngine.java
new file mode 100644
index 00000000000..b0aa9c42d46
--- /dev/null
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/update/UpdatableRALExecuteEngine.java
@@ -0,0 +1,53 @@
+/*
+ * 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.type.ral.update;
+
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.distsql.handler.util.DatabaseNameUtils;
+import org.apache.shardingsphere.distsql.statement.ral.updatable.UpdatableRALStatement;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+
+import java.sql.SQLException;
+
+/**
+ * Updatable RAL execute engine.
+ */
+@RequiredArgsConstructor
+public abstract class UpdatableRALExecuteEngine {
+
+ private final UpdatableRALStatement sqlStatement;
+
+ private final String currentDatabaseName;
+
+ /**
+ * Execute update.
+ *
+ * @throws SQLException SQL exception
+ */
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public void executeUpdate() throws SQLException {
+ UpdatableRALExecutor executor = TypedSPILoader.getService(UpdatableRALExecutor.class, sqlStatement.getClass());
+ if (executor instanceof DatabaseAwareUpdatableRALExecutor) {
+ ((DatabaseAwareUpdatableRALExecutor) executor).setDatabase(getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement, currentDatabaseName)));
+ }
+ executor.executeUpdate(sqlStatement);
+ }
+
+ protected abstract ShardingSphereDatabase getDatabase(String databaseName);
+}
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/RuleDefinitionExecuteEngine.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/RuleDefinitionExecuteEngine.java
new file mode 100644
index 00000000000..99d2874b4e6
--- /dev/null
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/RuleDefinitionExecuteEngine.java
@@ -0,0 +1,67 @@
+/*
+ * 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.type.rdl.rule.engine;
+
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.database.DatabaseRuleDefinitionExecuteEngine;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.global.GlobalRuleDefinitionExecuteEngine;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.legacy.LegacyGlobalRuleDefinitionExecuteEngine;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.util.DatabaseNameUtils;
+import org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+
+import java.util.Optional;
+
+/**
+ * Rule definition execute engine.
+ */
+@RequiredArgsConstructor
+public abstract class RuleDefinitionExecuteEngine {
+
+ private final RuleDefinitionStatement sqlStatement;
+
+ private final String currentDatabaseName;
+
+ private final ContextManager contextManager;
+
+ /**
+ * Execute update.
+ */
+ @SuppressWarnings("rawtypes")
+ public void executeUpdate() {
+ Optional<DatabaseRuleDefinitionExecutor> databaseExecutor = TypedSPILoader.findService(DatabaseRuleDefinitionExecutor.class, sqlStatement.getClass());
+ if (databaseExecutor.isPresent()) {
+ new DatabaseRuleDefinitionExecuteEngine(
+ sqlStatement, contextManager, getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement, currentDatabaseName)), databaseExecutor.get()).executeUpdate();
+ } else {
+ String modeType = contextManager.getInstanceContext().getModeConfiguration().getType();
+ GlobalRuleDefinitionExecutor globalExecutor = TypedSPILoader.getService(GlobalRuleDefinitionExecutor.class, sqlStatement.getClass());
+ if ("Cluster".equals(modeType) || "Standalone".equals(modeType)) {
+ new GlobalRuleDefinitionExecuteEngine(sqlStatement, contextManager, globalExecutor).executeUpdate();
+ } else {
+ new LegacyGlobalRuleDefinitionExecuteEngine(sqlStatement, contextManager).executeUpdate();
+ }
+ }
+ }
+
+ protected abstract ShardingSphereDatabase getDatabase(String databaseName);
+}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/DatabaseRuleUpdater.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/DatabaseRuleDefinitionExecuteEngine.java
similarity index 67%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/DatabaseRuleUpdater.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/DatabaseRuleDefinitionExecuteEngine.java
index 951fbb68221..a0f9a013bbf 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/DatabaseRuleUpdater.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/DatabaseRuleDefinitionExecuteEngine.java
@@ -15,30 +15,29 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database;
+package org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.database;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database.execute.DatabaseRuleRDLExecuteEngineFactory;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.backend.util.DatabaseNameUtils;
+import org.apache.shardingsphere.mode.manager.ContextManager;
import java.util.Optional;
/**
- * Database rule updater.
+ * Database rule definition execute engine.
*/
@RequiredArgsConstructor
-public final class DatabaseRuleUpdater {
+public final class DatabaseRuleDefinitionExecuteEngine {
private final RuleDefinitionStatement sqlStatement;
- private final ConnectionSession connectionSession;
+ private final ContextManager contextManager;
+
+ private final ShardingSphereDatabase database;
@SuppressWarnings("rawtypes")
private final DatabaseRuleDefinitionExecutor executor;
@@ -48,13 +47,12 @@ public final class DatabaseRuleUpdater {
*/
@SuppressWarnings("unchecked")
public void executeUpdate() {
- ShardingSphereDatabase database = ProxyContext.getInstance().getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement, connectionSession));
Class<? extends RuleConfiguration> ruleConfigClass = executor.getRuleConfigurationClass();
RuleConfiguration currentRuleConfig = findCurrentRuleConfiguration(database, ruleConfigClass).orElse(null);
executor.checkSQLStatement(database, sqlStatement, currentRuleConfig);
if (getRefreshStatus(currentRuleConfig)) {
- ProxyContext.getInstance().getContextManager().getMetaDataContexts().getPersistService().getMetaDataVersionPersistService()
- .switchActiveVersion(DatabaseRuleRDLExecuteEngineFactory.newInstance(executor).execute(sqlStatement, database, currentRuleConfig));
+ contextManager.getMetaDataContexts().getPersistService().getMetaDataVersionPersistService()
+ .switchActiveVersion(DatabaseRuleOperatorFactory.newInstance(contextManager, executor).operate(sqlStatement, database, currentRuleConfig));
}
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/DatabaseRuleRDLExecuteEngine.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/DatabaseRuleOperator.java
similarity index 83%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/DatabaseRuleRDLExecuteEngine.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/DatabaseRuleOperator.java
index dbfd3997aa2..0a640e89155 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/DatabaseRuleRDLExecuteEngine.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/DatabaseRuleOperator.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database.execute;
+package org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.database;
import org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
@@ -25,17 +25,17 @@ import org.apache.shardingsphere.infra.metadata.version.MetaDataVersion;
import java.util.Collection;
/**
- * Database rule RDL execute engine.
+ * Database rule operator.
*/
-public interface DatabaseRuleRDLExecuteEngine {
+public interface DatabaseRuleOperator {
/**
- * Execute when rule changed.
+ * Operate rule change.
*
* @param sqlStatement SQL statement
* @param database database
* @param currentRuleConfig current rule configuration
* @return meta data versions
*/
- Collection<MetaDataVersion> execute(RuleDefinitionStatement sqlStatement, ShardingSphereDatabase database, RuleConfiguration currentRuleConfig);
+ Collection<MetaDataVersion> operate(RuleDefinitionStatement sqlStatement, ShardingSphereDatabase database, RuleConfiguration currentRuleConfig);
}
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/DatabaseRuleOperatorFactory.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/DatabaseRuleOperatorFactory.java
new file mode 100644
index 00000000000..527257be09f
--- /dev/null
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/DatabaseRuleOperatorFactory.java
@@ -0,0 +1,59 @@
+/*
+ * 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.type.rdl.rule.engine.database;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.database.type.AlterDatabaseRuleOperator;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.database.type.CreateDatabaseRuleOperator;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.database.type.DropDatabaseRuleOperator;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.UnsupportedSQLOperationException;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+
+/**
+ * Database rule operator factory.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class DatabaseRuleOperatorFactory {
+
+ /**
+ * Create new instance of database rule operator.
+ *
+ * @param contextManager context manager
+ * @param executor database rule definition executor
+ * @return created instance
+ * @throws UnsupportedSQLOperationException if invalid database rule definition executor
+ */
+ @SuppressWarnings("rawtypes")
+ public static DatabaseRuleOperator newInstance(final ContextManager contextManager, final DatabaseRuleDefinitionExecutor executor) {
+ if (executor instanceof DatabaseRuleCreateExecutor) {
+ return new CreateDatabaseRuleOperator(contextManager, (DatabaseRuleCreateExecutor) executor);
+ }
+ if (executor instanceof DatabaseRuleAlterExecutor) {
+ return new AlterDatabaseRuleOperator(contextManager, (DatabaseRuleAlterExecutor) executor);
+ }
+ if (executor instanceof DatabaseRuleDropExecutor) {
+ return new DropDatabaseRuleOperator(contextManager, (DatabaseRuleDropExecutor) executor);
+ }
+ throw new UnsupportedSQLOperationException(String.format("Cannot support RDL executor type `%s`", executor.getClass().getName()));
+ }
+}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/type/AlterDatabaseRuleRDLExecuteEngine.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/type/AlterDatabaseRuleOperator.java
similarity index 80%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/type/AlterDatabaseRuleRDLExecuteEngine.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/type/AlterDatabaseRuleOperator.java
index 5c707a88eb8..48d585b0bf2 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/type/AlterDatabaseRuleRDLExecuteEngine.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/type/AlterDatabaseRuleOperator.java
@@ -15,10 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database.execute.type;
+package org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.database.type;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleAlterExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.database.DatabaseRuleOperator;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
import org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.config.rule.decorator.RuleConfigurationDecorator;
@@ -26,8 +27,7 @@ import org.apache.shardingsphere.infra.instance.mode.ModeContextManager;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.version.MetaDataVersion;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database.execute.DatabaseRuleRDLExecuteEngine;
+import org.apache.shardingsphere.mode.manager.ContextManager;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -35,20 +35,22 @@ import java.util.Map.Entry;
import java.util.stream.Collectors;
/**
- * Alter database rule RDL execute engine.
+ * Alter database rule operator.
*/
@RequiredArgsConstructor
-public final class AlterDatabaseRuleRDLExecuteEngine implements DatabaseRuleRDLExecuteEngine {
+public final class AlterDatabaseRuleOperator implements DatabaseRuleOperator {
+
+ private final ContextManager contextManager;
@SuppressWarnings("rawtypes")
private final DatabaseRuleAlterExecutor executor;
@Override
@SuppressWarnings("unchecked")
- public Collection<MetaDataVersion> execute(final RuleDefinitionStatement sqlStatement, final ShardingSphereDatabase database, final RuleConfiguration currentRuleConfig) {
+ public Collection<MetaDataVersion> operate(final RuleDefinitionStatement sqlStatement, final ShardingSphereDatabase database, final RuleConfiguration currentRuleConfig) {
RuleConfiguration toBeAlteredRuleConfig = executor.buildToBeAlteredRuleConfiguration(currentRuleConfig, sqlStatement);
executor.updateCurrentRuleConfiguration(currentRuleConfig, toBeAlteredRuleConfig);
- ModeContextManager modeContextManager = ProxyContext.getInstance().getContextManager().getInstanceContext().getModeContextManager();
+ ModeContextManager modeContextManager = contextManager.getInstanceContext().getModeContextManager();
RuleConfiguration toBeDroppedRuleConfig = executor.buildToBeDroppedRuleConfiguration(currentRuleConfig, toBeAlteredRuleConfig);
modeContextManager.removeRuleConfigurationItem(database.getName(), toBeDroppedRuleConfig);
return modeContextManager.alterRuleConfiguration(database.getName(), decorateRuleConfiguration(database, toBeAlteredRuleConfig));
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/type/CreateDatabaseRuleRDLExecuteEngine.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/type/CreateDatabaseRuleOperator.java
similarity index 80%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/type/CreateDatabaseRuleRDLExecuteEngine.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/type/CreateDatabaseRuleOperator.java
index 303da53960e..6ee5d70b649 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/type/CreateDatabaseRuleRDLExecuteEngine.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/type/CreateDatabaseRuleOperator.java
@@ -15,10 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database.execute.type;
+package org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.database.type;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.database.DatabaseRuleOperator;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
import org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.config.rule.decorator.RuleConfigurationDecorator;
@@ -26,8 +27,7 @@ import org.apache.shardingsphere.infra.instance.mode.ModeContextManager;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.version.MetaDataVersion;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database.execute.DatabaseRuleRDLExecuteEngine;
+import org.apache.shardingsphere.mode.manager.ContextManager;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -35,19 +35,21 @@ import java.util.Map.Entry;
import java.util.stream.Collectors;
/**
- * Create database rule RDL execute engine.
+ * Create database rule operator.
*/
@RequiredArgsConstructor
-public final class CreateDatabaseRuleRDLExecuteEngine implements DatabaseRuleRDLExecuteEngine {
+public final class CreateDatabaseRuleOperator implements DatabaseRuleOperator {
+
+ private final ContextManager contextManager;
@SuppressWarnings("rawtypes")
private final DatabaseRuleCreateExecutor executor;
@Override
@SuppressWarnings("unchecked")
- public Collection<MetaDataVersion> execute(final RuleDefinitionStatement sqlStatement, final ShardingSphereDatabase database, final RuleConfiguration currentRuleConfig) {
+ public Collection<MetaDataVersion> operate(final RuleDefinitionStatement sqlStatement, final ShardingSphereDatabase database, final RuleConfiguration currentRuleConfig) {
RuleConfiguration toBeCreatedRuleConfig = executor.buildToBeCreatedRuleConfiguration(currentRuleConfig, sqlStatement);
- ModeContextManager modeContextManager = ProxyContext.getInstance().getContextManager().getInstanceContext().getModeContextManager();
+ ModeContextManager modeContextManager = contextManager.getInstanceContext().getModeContextManager();
if (null == currentRuleConfig) {
return modeContextManager.alterRuleConfiguration(database.getName(), decorateRuleConfiguration(database, toBeCreatedRuleConfig));
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/type/DropDatabaseRuleRDLExecuteEngine.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/type/DropDatabaseRuleOperator.java
similarity index 73%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/type/DropDatabaseRuleRDLExecuteEngine.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/type/DropDatabaseRuleOperator.java
index 7bc84f7daf5..d7c41bf6148 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/type/DropDatabaseRuleRDLExecuteEngine.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/type/DropDatabaseRuleOperator.java
@@ -15,11 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database.execute.type;
+package org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.database.type;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.database.DatabaseRuleOperator;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
+import org.apache.shardingsphere.distsql.statement.rdl.rule.aware.StaticDataSourceContainedRuleAwareStatement;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.config.rule.scope.DatabaseRuleConfiguration;
import org.apache.shardingsphere.infra.instance.mode.ModeContextManager;
@@ -27,30 +29,29 @@ import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.version.MetaDataVersion;
import org.apache.shardingsphere.infra.rule.identifier.type.StaticDataSourceContainedRule;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.NewYamlRuleConfigurationSwapperEngine;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database.execute.DatabaseRuleRDLExecuteEngine;
-import org.apache.shardingsphere.readwritesplitting.distsql.handler.update.DropReadwriteSplittingRuleExecutor;
-import org.apache.shardingsphere.readwritesplitting.distsql.statement.DropReadwriteSplittingRuleStatement;
+import org.apache.shardingsphere.mode.manager.ContextManager;
import java.util.Collection;
import java.util.Collections;
/**
- * Drop database rule RDL execute engine.
+ * Drop database rule operator.
*/
@RequiredArgsConstructor
-public final class DropDatabaseRuleRDLExecuteEngine implements DatabaseRuleRDLExecuteEngine {
+public final class DropDatabaseRuleOperator implements DatabaseRuleOperator {
+
+ private final ContextManager contextManager;
@SuppressWarnings("rawtypes")
private final DatabaseRuleDropExecutor executor;
@Override
@SuppressWarnings("unchecked")
- public Collection<MetaDataVersion> execute(final RuleDefinitionStatement sqlStatement, final ShardingSphereDatabase database, final RuleConfiguration currentRuleConfig) {
+ public Collection<MetaDataVersion> operate(final RuleDefinitionStatement sqlStatement, final ShardingSphereDatabase database, final RuleConfiguration currentRuleConfig) {
if (!executor.hasAnyOneToBeDropped(sqlStatement, currentRuleConfig)) {
return Collections.emptyList();
}
- ModeContextManager modeContextManager = ProxyContext.getInstance().getContextManager().getInstanceContext().getModeContextManager();
+ ModeContextManager modeContextManager = contextManager.getInstanceContext().getModeContextManager();
RuleConfiguration toBeDroppedRuleConfig = executor.buildToBeDroppedRuleConfiguration(currentRuleConfig, sqlStatement);
// TODO remove updateCurrentRuleConfiguration after update refactor completed.
if (executor.updateCurrentRuleConfiguration(sqlStatement, currentRuleConfig) && ((DatabaseRuleConfiguration) currentRuleConfig).isEmpty()) {
@@ -59,9 +60,9 @@ public final class DropDatabaseRuleRDLExecuteEngine implements DatabaseRuleRDLEx
.ifPresent(optional -> modeContextManager.removeRuleConfiguration(database.getName(), optional.getRuleTagName().toLowerCase()));
return Collections.emptyList();
}
- if (executor instanceof DropReadwriteSplittingRuleExecutor) {
+ if (sqlStatement instanceof StaticDataSourceContainedRuleAwareStatement) {
database.getRuleMetaData().findSingleRule(StaticDataSourceContainedRule.class)
- .ifPresent(optional -> ((DropReadwriteSplittingRuleStatement) sqlStatement).getNames().forEach(optional::cleanStorageNodeDataSource));
+ .ifPresent(optional -> ((StaticDataSourceContainedRuleAwareStatement) sqlStatement).getNames().forEach(optional::cleanStorageNodeDataSource));
// TODO refactor to new metadata refresh way
}
modeContextManager.removeRuleConfigurationItem(database.getName(), toBeDroppedRuleConfig);
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/global/GlobalRuleUpdater.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/global/GlobalRuleDefinitionExecuteEngine.java
similarity index 88%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/global/GlobalRuleUpdater.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/global/GlobalRuleDefinitionExecuteEngine.java
index 92850d77f51..b32614c9fca 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/global/GlobalRuleUpdater.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/global/GlobalRuleDefinitionExecuteEngine.java
@@ -15,26 +15,27 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.global;
+package org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.global;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor;
import org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import java.util.Collection;
/**
- * Global rule updater.
+ * Global rule definition execute engine.
*/
@RequiredArgsConstructor
-public final class GlobalRuleUpdater {
+public final class GlobalRuleDefinitionExecuteEngine {
private final RuleDefinitionStatement sqlStatement;
+ private final ContextManager contextManager;
+
@SuppressWarnings("rawtypes")
private final GlobalRuleDefinitionExecutor executor;
@@ -44,7 +45,6 @@ public final class GlobalRuleUpdater {
@SuppressWarnings("unchecked")
public void executeUpdate() {
Class<? extends RuleConfiguration> ruleConfigClass = executor.getRuleConfigurationClass();
- ContextManager contextManager = ProxyContext.getInstance().getContextManager();
Collection<RuleConfiguration> ruleConfigs = contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getConfigurations();
RuleConfiguration currentRuleConfig = findCurrentRuleConfiguration(ruleConfigs, ruleConfigClass);
executor.checkSQLStatement(currentRuleConfig, sqlStatement);
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/legacy/LegacyGlobalRuleUpdater.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/legacy/LegacyGlobalRuleDefinitionExecuteEngine.java
similarity index 89%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/legacy/LegacyGlobalRuleUpdater.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/legacy/LegacyGlobalRuleDefinitionExecuteEngine.java
index 00ab41ccd02..dcd75983dc1 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/legacy/LegacyGlobalRuleUpdater.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/legacy/LegacyGlobalRuleDefinitionExecuteEngine.java
@@ -15,29 +15,30 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.legacy;
+package org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.legacy;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor;
import org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import java.util.Collection;
import java.util.LinkedList;
// TODO Remove when metadata structure adjustment completed. #25485
/**
- * Legacy global rule updater.
+ * Legacy global rule definition execute engine.
*/
@RequiredArgsConstructor
-public final class LegacyGlobalRuleUpdater {
+public final class LegacyGlobalRuleDefinitionExecuteEngine {
private final RuleDefinitionStatement sqlStatement;
+ private final ContextManager contextManager;
+
/**
* Execute update.
*/
@@ -45,7 +46,6 @@ public final class LegacyGlobalRuleUpdater {
public void executeUpdate() {
GlobalRuleDefinitionExecutor executor = TypedSPILoader.getService(GlobalRuleDefinitionExecutor.class, sqlStatement.getClass());
Class<? extends RuleConfiguration> ruleConfigClass = executor.getRuleConfigurationClass();
- ContextManager contextManager = ProxyContext.getInstance().getContextManager();
Collection<RuleConfiguration> ruleConfigs = contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getConfigurations();
RuleConfiguration currentRuleConfig = findCurrentRuleConfiguration(ruleConfigs, ruleConfigClass);
executor.checkSQLStatement(currentRuleConfig, sqlStatement);
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/database/DatabaseRuleAlterExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/database/DatabaseRuleAlterExecutor.java
similarity index 99%
rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/database/DatabaseRuleAlterExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/database/DatabaseRuleAlterExecutor.java
index ff2eae63e65..12adcda1b28 100644
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/database/DatabaseRuleAlterExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/database/DatabaseRuleAlterExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.handler.type.rdl.rule.database;
+package org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/database/DatabaseRuleCreateExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/database/DatabaseRuleCreateExecutor.java
similarity index 99%
rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/database/DatabaseRuleCreateExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/database/DatabaseRuleCreateExecutor.java
index 1ee8c85820c..190dfdf4da4 100644
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/database/DatabaseRuleCreateExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/database/DatabaseRuleCreateExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.handler.type.rdl.rule.database;
+package org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/database/DatabaseRuleDefinitionExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/database/DatabaseRuleDefinitionExecutor.java
similarity index 99%
rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/database/DatabaseRuleDefinitionExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/database/DatabaseRuleDefinitionExecutor.java
index 50bad8280eb..4ce12ce7ed3 100644
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/database/DatabaseRuleDefinitionExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/database/DatabaseRuleDefinitionExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.handler.type.rdl.rule.database;
+package org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/database/DatabaseRuleDropExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/database/DatabaseRuleDropExecutor.java
similarity index 99%
rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/database/DatabaseRuleDropExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/database/DatabaseRuleDropExecutor.java
index f2fa056846a..f4068e1b8ea 100644
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/database/DatabaseRuleDropExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/database/DatabaseRuleDropExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.handler.type.rdl.rule.database;
+package org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/global/GlobalRuleDefinitionExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/global/GlobalRuleDefinitionExecutor.java
similarity index 99%
rename from infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/global/GlobalRuleDefinitionExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/global/GlobalRuleDefinitionExecutor.java
index 8a38ffad3d0..24a4e02bee8 100644
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/global/GlobalRuleDefinitionExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/spi/global/GlobalRuleDefinitionExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.handler.type.rdl.rule.global;
+package org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global;
import org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rql/RQLExecuteEngine.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rql/RQLExecuteEngine.java
new file mode 100644
index 00000000000..62addb0312c
--- /dev/null
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rql/RQLExecuteEngine.java
@@ -0,0 +1,105 @@
+/*
+ * 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.type.rql;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.distsql.handler.type.rql.aware.DatabaseAwareRQLExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rql.aware.DatabaseRuleAwareRQLExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rql.aware.GlobalRuleAwareRQLExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rql.aware.MetaDataAwareRQLExecutor;
+import org.apache.shardingsphere.distsql.handler.util.DatabaseNameUtils;
+import org.apache.shardingsphere.distsql.statement.rql.RQLStatement;
+import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Optional;
+
+/**
+ * RQL execute engine.
+ */
+@RequiredArgsConstructor
+public abstract class RQLExecuteEngine {
+
+ private final RQLStatement sqlStatement;
+
+ private final String currentDatabaseName;
+
+ private final ContextManager contextManager;
+
+ @Getter
+ private Collection<String> columnNames;
+
+ @Getter
+ private Collection<LocalDataQueryResultRow> rows;
+
+ /**
+ * Execute query.
+ *
+ * @throws SQLException SQL exception
+ */
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public void executeQuery() throws SQLException {
+ RQLExecutor executor = TypedSPILoader.getService(RQLExecutor.class, sqlStatement.getClass());
+ columnNames = executor.getColumnNames();
+ if (executor instanceof DatabaseAwareRQLExecutor) {
+ setUpDatabaseAwareExecutor((DatabaseAwareRQLExecutor) executor);
+ }
+ if (executor instanceof GlobalRuleAwareRQLExecutor) {
+ setUpGlobalRuleAwareExecutor((GlobalRuleAwareRQLExecutor) executor);
+ }
+ if (executor instanceof MetaDataAwareRQLExecutor) {
+ ((MetaDataAwareRQLExecutor<?>) executor).setMetaDataContexts(contextManager.getMetaDataContexts());
+ }
+ if (null == rows) {
+ rows = executor.getRows(sqlStatement);
+ }
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private void setUpDatabaseAwareExecutor(final DatabaseAwareRQLExecutor executor) {
+ ShardingSphereDatabase database = getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement, currentDatabaseName));
+ ((DatabaseAwareRQLExecutor<?>) executor).setDatabase(database);
+ if (executor instanceof DatabaseRuleAwareRQLExecutor) {
+ Optional<ShardingSphereRule> rule = database.getRuleMetaData().findSingleRule(((DatabaseRuleAwareRQLExecutor) executor).getRuleClass());
+ if (rule.isPresent()) {
+ ((DatabaseRuleAwareRQLExecutor) executor).setRule(rule.get());
+ } else {
+ rows = Collections.emptyList();
+ }
+ }
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private void setUpGlobalRuleAwareExecutor(final GlobalRuleAwareRQLExecutor executor) {
+ Optional<ShardingSphereRule> rule = contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(executor.getRuleClass());
+ if (rule.isPresent()) {
+ executor.setRule(rule.get());
+ } else {
+ rows = Collections.emptyList();
+ }
+ }
+
+ protected abstract ShardingSphereDatabase getDatabase(String databaseName);
+}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/aware/MetaDataAwareRQLExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rql/aware/MetaDataAwareRQLExecutor.java
similarity index 94%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/aware/MetaDataAwareRQLExecutor.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rql/aware/MetaDataAwareRQLExecutor.java
index 6062fdc635f..d4998d4b260 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/aware/MetaDataAwareRQLExecutor.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rql/aware/MetaDataAwareRQLExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rql.aware;
+package org.apache.shardingsphere.distsql.handler.type.rql.aware;
import org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor;
import org.apache.shardingsphere.distsql.statement.rql.RQLStatement;
diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/util/DatabaseNameUtils.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/util/DatabaseNameUtils.java
new file mode 100644
index 00000000000..9f6769d8003
--- /dev/null
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/util/DatabaseNameUtils.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.util;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DatabaseSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.available.FromDatabaseAvailable;
+
+import java.util.Optional;
+
+/**
+ * Database name utility class.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class DatabaseNameUtils {
+
+ /**
+ * Get database name.
+ *
+ * @param sqlStatement SQL statement
+ * @param currentDatabaseName current database name
+ * @return database name
+ */
+ public static String getDatabaseName(final SQLStatement sqlStatement, final String currentDatabaseName) {
+ Optional<DatabaseSegment> databaseSegment = sqlStatement instanceof FromDatabaseAvailable ? ((FromDatabaseAvailable) sqlStatement).getDatabase() : Optional.empty();
+ return databaseSegment.map(optional -> optional.getIdentifier().getValue()).orElse(currentDatabaseName);
+ }
+}
diff --git a/kernel/global-clock/distsql/handler/src/main/java/org/apache/shardingsphere/globalclock/distsql/handler/update/AlterGlobalClockRuleExecutor.java b/kernel/global-clock/distsql/handler/src/main/java/org/apache/shardingsphere/globalclock/distsql/handler/update/AlterGlobalClockRuleExecutor.java
index 0eb27e0af00..918095d6b0f 100644
--- a/kernel/global-clock/distsql/handler/src/main/java/org/apache/shardingsphere/globalclock/distsql/handler/update/AlterGlobalClockRuleExecutor.java
+++ b/kernel/global-clock/distsql/handler/src/main/java/org/apache/shardingsphere/globalclock/distsql/handler/update/AlterGlobalClockRuleExecutor.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.globalclock.distsql.handler.update;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor;
import org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
import org.apache.shardingsphere.globalclock.distsql.statement.updatable.AlterGlobalClockRuleStatement;
diff --git a/kernel/global-clock/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor b/kernel/global-clock/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor
similarity index 100%
rename from kernel/global-clock/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor
rename to kernel/global-clock/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor
diff --git a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/LoadSingleTableExecutor.java b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/LoadSingleTableExecutor.java
index 71efb4db89d..e0656c75f33 100644
--- a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/LoadSingleTableExecutor.java
+++ b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/LoadSingleTableExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.single.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
import org.apache.shardingsphere.infra.database.DatabaseTypeEngine;
import org.apache.shardingsphere.infra.database.core.metadata.database.DialectDatabaseMetaData;
import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
diff --git a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/SetDefaultSingleTableStorageUnitExecutor.java b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/SetDefaultSingleTableStorageUnitExecutor.java
index d48bc21a52c..4c0b40d6e43 100644
--- a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/SetDefaultSingleTableStorageUnitExecutor.java
+++ b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/SetDefaultSingleTableStorageUnitExecutor.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.single.distsql.handler.update;
import com.google.common.base.Strings;
import org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
diff --git a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutor.java b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutor.java
index 2584b20bf45..d2773a33270 100644
--- a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutor.java
+++ b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutor.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.single.distsql.handler.update;
import com.google.common.base.Splitter;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleAlterExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.datanode.DataNode;
diff --git a/kernel/single/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor b/kernel/single/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
similarity index 100%
rename from kernel/single/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor
rename to kernel/single/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
diff --git a/kernel/sql-federation/distsql/handler/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/handler/update/AlterSQLFederationRuleExecutor.java b/kernel/sql-federation/distsql/handler/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/handler/update/AlterSQLFederationRuleExecutor.java
index 59c5f5e638b..2611d68373b 100644
--- a/kernel/sql-federation/distsql/handler/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/handler/update/AlterSQLFederationRuleExecutor.java
+++ b/kernel/sql-federation/distsql/handler/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/handler/update/AlterSQLFederationRuleExecutor.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sqlfederation.distsql.handler.update;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor;
import org.apache.shardingsphere.sql.parser.api.CacheOption;
import org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration;
import org.apache.shardingsphere.sqlfederation.distsql.segment.CacheOptionSegment;
diff --git a/kernel/sql-federation/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor b/kernel/sql-federation/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor
similarity index 100%
rename from kernel/sql-federation/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor
rename to kernel/sql-federation/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor
diff --git a/kernel/sql-parser/distsql/handler/src/main/java/org/apache/shardingsphere/parser/distsql/handler/update/AlterSQLParserRuleExecutor.java b/kernel/sql-parser/distsql/handler/src/main/java/org/apache/shardingsphere/parser/distsql/handler/update/AlterSQLParserRuleExecutor.java
index 6d2c69784e6..ef86bbe7fb4 100644
--- a/kernel/sql-parser/distsql/handler/src/main/java/org/apache/shardingsphere/parser/distsql/handler/update/AlterSQLParserRuleExecutor.java
+++ b/kernel/sql-parser/distsql/handler/src/main/java/org/apache/shardingsphere/parser/distsql/handler/update/AlterSQLParserRuleExecutor.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.parser.distsql.handler.update;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor;
import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
import org.apache.shardingsphere.parser.distsql.segment.CacheOptionSegment;
import org.apache.shardingsphere.parser.distsql.statement.updatable.AlterSQLParserRuleStatement;
diff --git a/kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor b/kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor
similarity index 100%
rename from kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor
rename to kernel/sql-parser/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor
diff --git a/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/update/AlterSQLTranslatorRuleExecutor.java b/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/update/AlterSQLTranslatorRuleExecutor.java
index ffe2c8ee1e1..b111158acae 100644
--- a/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/update/AlterSQLTranslatorRuleExecutor.java
+++ b/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/update/AlterSQLTranslatorRuleExecutor.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sqltranslator.distsql.handler.update;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration;
import org.apache.shardingsphere.sqltranslator.distsql.statement.updateable.AlterSQLTranslatorRuleStatement;
diff --git a/kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor b/kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor
similarity index 100%
rename from kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor
rename to kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor
diff --git a/kernel/traffic/distsql/handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleExecutor.java b/kernel/traffic/distsql/handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleExecutor.java
index 98d8fe23990..498b8cac816 100644
--- a/kernel/traffic/distsql/handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleExecutor.java
+++ b/kernel/traffic/distsql/handler/src/main/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.traffic.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
diff --git a/kernel/traffic/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor b/kernel/traffic/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor
similarity index 100%
rename from kernel/traffic/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor
rename to kernel/traffic/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor
diff --git a/kernel/transaction/distsql/handler/src/main/java/org/apache/shardingsphere/transaction/distsql/handler/update/AlterTransactionRuleExecutor.java b/kernel/transaction/distsql/handler/src/main/java/org/apache/shardingsphere/transaction/distsql/handler/update/AlterTransactionRuleExecutor.java
index 692209ce027..a69f9697985 100644
--- a/kernel/transaction/distsql/handler/src/main/java/org/apache/shardingsphere/transaction/distsql/handler/update/AlterTransactionRuleExecutor.java
+++ b/kernel/transaction/distsql/handler/src/main/java/org/apache/shardingsphere/transaction/distsql/handler/update/AlterTransactionRuleExecutor.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.transaction.distsql.handler.update;
import org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.transaction.api.TransactionType;
diff --git a/kernel/transaction/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor b/kernel/transaction/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor
similarity index 100%
rename from kernel/transaction/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor
rename to kernel/transaction/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.global.GlobalRuleDefinitionExecutor
diff --git a/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/statement/DropReadwriteSplittingRuleStatement.java b/parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/rdl/rule/aware/StaticDataSourceContainedRuleAwareStatement.java
similarity index 61%
copy from features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/statement/DropReadwriteSplittingRuleStatement.java
copy to parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/rdl/rule/aware/StaticDataSourceContainedRuleAwareStatement.java
index 8d1e29d65e1..57dba6f58d8 100644
--- a/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/statement/DropReadwriteSplittingRuleStatement.java
+++ b/parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/rdl/rule/aware/StaticDataSourceContainedRuleAwareStatement.java
@@ -15,23 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.readwritesplitting.distsql.statement;
-
-import lombok.Getter;
-import org.apache.shardingsphere.distsql.statement.rdl.rule.type.DropRuleStatement;
+package org.apache.shardingsphere.distsql.statement.rdl.rule.aware;
import java.util.Collection;
/**
- * Drop readwrite-splitting rule statement.
+ * Static data source contained rule aware statement.
*/
-@Getter
-public final class DropReadwriteSplittingRuleStatement extends DropRuleStatement {
-
- private final Collection<String> names;
+public interface StaticDataSourceContainedRuleAwareStatement {
- public DropReadwriteSplittingRuleStatement(final boolean ifExists, final Collection<String> names) {
- super(ifExists);
- this.names = names;
- }
+ /**
+ * Get names.
+ *
+ * @return names
+ */
+ Collection<String> getNames();
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandler.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandler.java
index df3c613651c..2fded2bd2fe 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandler.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandler.java
@@ -17,16 +17,11 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.ral;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.ConnectionSizeAwareQueryableRALExecutor;
-import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.DatabaseAwareQueryableRALExecutor;
-import org.apache.shardingsphere.distsql.handler.type.ral.query.aware.InstanceContextAwareQueryableRALExecutor;
-import org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecutor;
+import org.apache.shardingsphere.distsql.handler.type.ral.query.QueryableRALExecuteEngine;
import org.apache.shardingsphere.distsql.statement.ral.queryable.QueryableRALStatement;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataMergedResult;
-import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.distsql.DistSQLBackendHandler;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
@@ -35,7 +30,6 @@ import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.backend.util.DatabaseNameUtils;
import java.sql.SQLException;
import java.sql.Types;
@@ -46,13 +40,8 @@ import java.util.stream.Collectors;
/**
* Queryable RAL backend handler.
- *
- * @param <T> type of queryable RAL statement
*/
-@RequiredArgsConstructor
-public final class QueryableRALBackendHandler<T extends QueryableRALStatement> implements DistSQLBackendHandler {
-
- private final T sqlStatement;
+public final class QueryableRALBackendHandler extends QueryableRALExecuteEngine implements DistSQLBackendHandler {
private final ConnectionSession connectionSession;
@@ -60,36 +49,23 @@ public final class QueryableRALBackendHandler<T extends QueryableRALStatement> i
private MergedResult mergedResult;
- @SuppressWarnings("unchecked")
+ public QueryableRALBackendHandler(final QueryableRALStatement sqlStatement, final ConnectionSession connectionSession) {
+ super(sqlStatement, connectionSession.getDatabaseName(), ProxyContext.getInstance().getContextManager());
+ this.connectionSession = connectionSession;
+ }
+
@Override
public ResponseHeader execute() {
- QueryableRALExecutor<T> executor = TypedSPILoader.getService(QueryableRALExecutor.class, sqlStatement.getClass());
- mergedResult = getMergedResult(executor);
- queryHeaders = createQueryHeader(executor.getColumnNames());
+ executeQuery();
+ mergedResult = new LocalDataMergedResult(getRows());
+ queryHeaders = createQueryHeader(getColumnNames());
return new QueryResponseHeader(queryHeaders);
}
- private MergedResult getMergedResult(final QueryableRALExecutor<T> executor) {
- if (executor instanceof InstanceContextAwareQueryableRALExecutor) {
- ((InstanceContextAwareQueryableRALExecutor<T>) executor).setInstanceContext(ProxyContext.getInstance().getContextManager().getInstanceContext());
- }
- if (executor instanceof DatabaseAwareQueryableRALExecutor) {
- ((DatabaseAwareQueryableRALExecutor<T>) executor).setDatabase(ProxyContext.getInstance().getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement, connectionSession)));
- }
- if (executor instanceof ConnectionSizeAwareQueryableRALExecutor) {
- ((ConnectionSizeAwareQueryableRALExecutor<T>) executor).setConnectionSize(connectionSession.getDatabaseConnectionManager().getConnectionSize());
- }
- return createMergedResult(executor.getRows(sqlStatement, ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData()));
- }
-
private List<QueryHeader> createQueryHeader(final Collection<String> columnNames) {
return columnNames.stream().map(each -> new QueryHeader("", "", each, each, Types.CHAR, "CHAR", 255, 0, false, false, false, false)).collect(Collectors.toList());
}
- private MergedResult createMergedResult(final Collection<LocalDataQueryResultRow> rows) {
- return new LocalDataMergedResult(rows);
- }
-
@Override
public boolean next() throws SQLException {
return null != mergedResult && mergedResult.next();
@@ -103,4 +79,14 @@ public final class QueryableRALBackendHandler<T extends QueryableRALStatement> i
}
return new QueryResponseRow(cells);
}
+
+ @Override
+ protected ShardingSphereDatabase getDatabase(final String databaseName) {
+ return ProxyContext.getInstance().getDatabase(databaseName);
+ }
+
+ @Override
+ protected int getConnectionSize() {
+ return connectionSession.getDatabaseConnectionManager().getConnectionSize();
+ }
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java
index f00ec339135..9931923e27f 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java
@@ -40,7 +40,7 @@ public final class RALBackendHandlerFactory {
*/
public static ProxyBackendHandler newInstance(final RALStatement sqlStatement, final ConnectionSession connectionSession) {
return sqlStatement instanceof QueryableRALStatement
- ? new QueryableRALBackendHandler<>((QueryableRALStatement) sqlStatement, connectionSession)
- : new UpdatableRALBackendHandler<>((UpdatableRALStatement) sqlStatement, connectionSession);
+ ? new QueryableRALBackendHandler((QueryableRALStatement) sqlStatement, connectionSession)
+ : new UpdatableRALBackendHandler((UpdatableRALStatement) sqlStatement, connectionSession);
}
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/UpdatableRALBackendHandler.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/UpdatableRALBackendHandler.java
index b8d70e5acbb..3ae72ea5253 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/UpdatableRALBackendHandler.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/UpdatableRALBackendHandler.java
@@ -17,40 +17,37 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.ral;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.handler.type.ral.update.UpdatableRALExecutor;
-import org.apache.shardingsphere.distsql.handler.type.ral.update.DatabaseAwareUpdatableRALExecutor;
+import org.apache.shardingsphere.distsql.handler.type.ral.update.UpdatableRALExecuteEngine;
import org.apache.shardingsphere.distsql.statement.ral.updatable.UpdatableRALStatement;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.distsql.DistSQLBackendHandler;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.backend.util.DatabaseNameUtils;
import java.sql.SQLException;
/**
* Updatable RAL backend handler.
- *
- * @param <T> type of SQL statement
*/
-@RequiredArgsConstructor
-public final class UpdatableRALBackendHandler<T extends UpdatableRALStatement> implements DistSQLBackendHandler {
+public final class UpdatableRALBackendHandler extends UpdatableRALExecuteEngine implements DistSQLBackendHandler {
private final UpdatableRALStatement sqlStatement;
- private final ConnectionSession connectionSession;
+ public UpdatableRALBackendHandler(final UpdatableRALStatement sqlStatement, final ConnectionSession connectionSession) {
+ super(sqlStatement, connectionSession.getDatabaseName());
+ this.sqlStatement = sqlStatement;
+ }
- @SuppressWarnings("unchecked")
@Override
public ResponseHeader execute() throws SQLException {
- UpdatableRALExecutor<T> updater = TypedSPILoader.getService(UpdatableRALExecutor.class, sqlStatement.getClass());
- if (updater instanceof DatabaseAwareUpdatableRALExecutor) {
- ((DatabaseAwareUpdatableRALExecutor<T>) updater).setDatabase(ProxyContext.getInstance().getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement, connectionSession)));
- }
- updater.executeUpdate((T) sqlStatement);
+ executeUpdate();
return new UpdateResponseHeader(sqlStatement);
}
+
+ @Override
+ protected ShardingSphereDatabase getDatabase(final String databaseName) {
+ return ProxyContext.getInstance().getDatabase(databaseName);
+ }
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/RDLBackendHandlerFactory.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/RDLBackendHandlerFactory.java
index 9d35e089d32..679ffa59839 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/RDLBackendHandlerFactory.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/RDLBackendHandlerFactory.java
@@ -30,7 +30,7 @@ import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.distsql.DistSQLBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.resource.ResourceDefinitionBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.RuleDefinitionBackendHandler;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.legacy.LegacyRuleDefinitionBackendHandler;
+import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.LegacyRuleDefinitionBackendHandler;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.util.DatabaseNameUtils;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/legacy/LegacyRuleDefinitionBackendHandler.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/LegacyRuleDefinitionBackendHandler.java
similarity index 95%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/legacy/LegacyRuleDefinitionBackendHandler.java
rename to proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/LegacyRuleDefinitionBackendHandler.java
index 9437e3ebcc9..47bd94f47e7 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/legacy/LegacyRuleDefinitionBackendHandler.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/LegacyRuleDefinitionBackendHandler.java
@@ -15,13 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.legacy;
+package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleAlterExecutor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor;
import org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.config.rule.decorator.RuleConfigurationDecorator;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
index e5178e13c23..98449df90ef 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
@@ -17,47 +17,35 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.global.GlobalRuleDefinitionExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.engine.RuleDefinitionExecuteEngine;
import org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.distsql.DistSQLBackendHandler;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database.DatabaseRuleUpdater;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.global.GlobalRuleUpdater;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.legacy.LegacyGlobalRuleUpdater;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import java.util.Optional;
-
/**
* Rule definition backend handler.
*/
-@RequiredArgsConstructor
-public final class RuleDefinitionBackendHandler implements DistSQLBackendHandler {
+public final class RuleDefinitionBackendHandler extends RuleDefinitionExecuteEngine implements DistSQLBackendHandler {
private final RuleDefinitionStatement sqlStatement;
- private final ConnectionSession connectionSession;
+ public RuleDefinitionBackendHandler(final RuleDefinitionStatement sqlStatement, final ConnectionSession connectionSession) {
+ super(sqlStatement, connectionSession.getDatabaseName(), ProxyContext.getInstance().getContextManager());
+ this.sqlStatement = sqlStatement;
+ }
- @SuppressWarnings("rawtypes")
@Override
public ResponseHeader execute() {
- Optional<DatabaseRuleDefinitionExecutor> databaseExecutor = TypedSPILoader.findService(DatabaseRuleDefinitionExecutor.class, sqlStatement.getClass());
- if (databaseExecutor.isPresent()) {
- new DatabaseRuleUpdater(sqlStatement, connectionSession, databaseExecutor.get()).executeUpdate();
- } else {
- String modeType = ProxyContext.getInstance().getContextManager().getInstanceContext().getModeConfiguration().getType();
- GlobalRuleDefinitionExecutor globalExecutor = TypedSPILoader.getService(GlobalRuleDefinitionExecutor.class, sqlStatement.getClass());
- if ("Cluster".equals(modeType) || "Standalone".equals(modeType)) {
- new GlobalRuleUpdater(sqlStatement, globalExecutor).executeUpdate();
- } else {
- new LegacyGlobalRuleUpdater(sqlStatement).executeUpdate();
- }
- }
+ executeUpdate();
return new UpdateResponseHeader(sqlStatement);
}
+
+ @Override
+ protected ShardingSphereDatabase getDatabase(final String databaseName) {
+ return ProxyContext.getInstance().getDatabase(databaseName);
+ }
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/DatabaseRuleRDLExecuteEngineFactory.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/DatabaseRuleRDLExecuteEngineFactory.java
deleted file mode 100644
index 402953435c0..00000000000
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/database/execute/DatabaseRuleRDLExecuteEngineFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database.execute;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleAlterExecutor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDropExecutor;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor;
-import org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.UnsupportedSQLOperationException;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database.execute.type.AlterDatabaseRuleRDLExecuteEngine;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database.execute.type.CreateDatabaseRuleRDLExecuteEngine;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.database.execute.type.DropDatabaseRuleRDLExecuteEngine;
-
-/**
- * Database rule RDL execute engine factory.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class DatabaseRuleRDLExecuteEngineFactory {
-
- /**
- * Create new instance of database RDL execute engine.
- * @param executor database rule RDL executor
- * @return created instance
- * @throws UnsupportedSQLOperationException if invalid database rule RDL executor
- */
- @SuppressWarnings("rawtypes")
- public static DatabaseRuleRDLExecuteEngine newInstance(final DatabaseRuleDefinitionExecutor executor) {
- if (executor instanceof DatabaseRuleCreateExecutor) {
- return new CreateDatabaseRuleRDLExecuteEngine((DatabaseRuleCreateExecutor) executor);
- }
- if (executor instanceof DatabaseRuleAlterExecutor) {
- return new AlterDatabaseRuleRDLExecuteEngine((DatabaseRuleAlterExecutor) executor);
- }
- if (executor instanceof DatabaseRuleDropExecutor) {
- return new DropDatabaseRuleRDLExecuteEngine((DatabaseRuleDropExecutor) executor);
- }
- throw new UnsupportedSQLOperationException(String.format("Cannot support RDL executor type `%s`", executor.getClass().getName()));
- }
-}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLBackendHandler.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLBackendHandler.java
index df6c2a3556c..c667078fb20 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLBackendHandler.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/RQLBackendHandler.java
@@ -17,94 +17,49 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.rql;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.handler.type.rql.RQLExecutor;
-import org.apache.shardingsphere.distsql.handler.type.rql.aware.DatabaseAwareRQLExecutor;
-import org.apache.shardingsphere.distsql.handler.type.rql.aware.DatabaseRuleAwareRQLExecutor;
-import org.apache.shardingsphere.distsql.handler.type.rql.aware.GlobalRuleAwareRQLExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rql.RQLExecuteEngine;
import org.apache.shardingsphere.distsql.statement.rql.RQLStatement;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataMergedResult;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.distsql.DistSQLBackendHandler;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rql.aware.MetaDataAwareRQLExecutor;
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;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.backend.util.DatabaseNameUtils;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
-import java.util.Optional;
import java.util.stream.Collectors;
/**
* RQL backend handler.
*/
-@RequiredArgsConstructor
-public final class RQLBackendHandler implements DistSQLBackendHandler {
-
- private final RQLStatement sqlStatement;
-
- private final ConnectionSession connectionSession;
+public final class RQLBackendHandler extends RQLExecuteEngine implements DistSQLBackendHandler {
private List<QueryHeader> queryHeaders;
private MergedResult mergedResult;
- @SuppressWarnings({"rawtypes", "unchecked"})
+ public RQLBackendHandler(final RQLStatement sqlStatement, final ConnectionSession connectionSession) {
+ super(sqlStatement, connectionSession.getDatabaseName(), ProxyContext.getInstance().getContextManager());
+ }
+
@Override
public ResponseHeader execute() throws SQLException {
- RQLExecutor executor = TypedSPILoader.getService(RQLExecutor.class, sqlStatement.getClass());
- queryHeaders = createQueryHeader(executor.getColumnNames());
- if (executor instanceof DatabaseAwareRQLExecutor) {
- setUpDatabaseAwareExecutor((DatabaseAwareRQLExecutor) executor);
- }
- if (executor instanceof GlobalRuleAwareRQLExecutor) {
- setUpGlobalRuleAwareExecutor((GlobalRuleAwareRQLExecutor) executor);
- }
- if (executor instanceof MetaDataAwareRQLExecutor) {
- ((MetaDataAwareRQLExecutor<?>) executor).setMetaDataContexts(ProxyContext.getInstance().getContextManager().getMetaDataContexts());
- }
- mergedResult = null == mergedResult ? createMergedResult(executor.getRows(sqlStatement)) : mergedResult;
+ executeQuery();
+ queryHeaders = createQueryHeader(getColumnNames());
+ mergedResult = null == mergedResult ? createMergedResult(getRows()) : mergedResult;
return new QueryResponseHeader(queryHeaders);
}
- @SuppressWarnings({"rawtypes", "unchecked"})
- private void setUpDatabaseAwareExecutor(final DatabaseAwareRQLExecutor executor) {
- ShardingSphereDatabase database = ProxyContext.getInstance().getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement, connectionSession));
- ((DatabaseAwareRQLExecutor<?>) executor).setDatabase(database);
- if (executor instanceof DatabaseRuleAwareRQLExecutor) {
- Optional<ShardingSphereRule> rule = database.getRuleMetaData().findSingleRule(((DatabaseRuleAwareRQLExecutor) executor).getRuleClass());
- if (rule.isPresent()) {
- ((DatabaseRuleAwareRQLExecutor) executor).setRule(rule.get());
- } else {
- mergedResult = createMergedResult(Collections.emptyList());
- }
- }
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- private void setUpGlobalRuleAwareExecutor(final GlobalRuleAwareRQLExecutor executor) {
- Optional<ShardingSphereRule> rule = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(executor.getRuleClass());
- if (rule.isPresent()) {
- executor.setRule(rule.get());
- } else {
- mergedResult = createMergedResult(Collections.emptyList());
- }
- }
-
private List<QueryHeader> createQueryHeader(final Collection<String> columnNames) {
return columnNames.stream().map(each -> new QueryHeader("", "", each, each, Types.CHAR, "CHAR", 255, 0, false, false, false, false)).collect(Collectors.toList());
}
@@ -126,4 +81,9 @@ public final class RQLBackendHandler implements DistSQLBackendHandler {
}
return new QueryResponseRow(cells);
}
+
+ @Override
+ protected ShardingSphereDatabase getDatabase(final String databaseName) {
+ return ProxyContext.getInstance().getDatabase(databaseName);
+ }
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/type/readwritesplitting/ShowStatusFromReadwriteSplittingRulesExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/type/readwritesplitting/ShowStatusFromReadwriteSplittingRulesExecutor.java
index a7041416dff..27fb97eed9f 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/type/readwritesplitting/ShowStatusFromReadwriteSplittingRulesExecutor.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/type/readwritesplitting/ShowStatusFromReadwriteSplittingRulesExecutor.java
@@ -34,7 +34,7 @@ import org.apache.shardingsphere.mode.event.storage.StorageNodeRole;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.service.StorageNodeStatusService;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rql.aware.MetaDataAwareRQLExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rql.aware.MetaDataAwareRQLExecutor;
import org.apache.shardingsphere.readwritesplitting.distsql.statement.ShowStatusFromReadwriteSplittingRulesStatement;
import java.util.Arrays;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/fixture/FixtureDatabaseRuleCreateExecutor.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/fixture/FixtureDatabaseRuleCreateExecutor.java
index 8e82259e8e0..d398a3901ff 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/fixture/FixtureDatabaseRuleCreateExecutor.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/fixture/FixtureDatabaseRuleCreateExecutor.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.handler.distsql.fixture;
-import org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleCreateExecutor;
+import org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
public final class FixtureDatabaseRuleCreateExecutor implements DatabaseRuleCreateExecutor<CreateFixtureRuleStatement, FixtureRuleConfiguration> {
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandlerTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandlerTest.java
index dc4554e5a57..ccc65a5760e 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandlerTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandlerTest.java
@@ -62,7 +62,7 @@ class QueryableRALBackendHandlerTest {
@Test
void assertExecuteWithNoDatabase() {
when(ProxyContext.getInstance().getDatabase(null)).thenThrow(NoDatabaseSelectedException.class);
- assertThrows(NoDatabaseSelectedException.class, () -> new QueryableRALBackendHandler<>(mock(ExportDatabaseConfigurationStatement.class), mock(ConnectionSession.class)).execute());
+ assertThrows(NoDatabaseSelectedException.class, () -> new QueryableRALBackendHandler(mock(ExportDatabaseConfigurationStatement.class), mock(ConnectionSession.class)).execute());
}
@Test
@@ -74,12 +74,12 @@ class QueryableRALBackendHandlerTest {
when(ProxyContext.getInstance().getDatabase("unknown")).thenThrow(UnknownDatabaseException.class);
ContextManager contextManager = new ContextManager(metaDataContexts, mock(InstanceContext.class));
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
- assertThrows(UnknownDatabaseException.class, () -> new QueryableRALBackendHandler<>(mock(ExportDatabaseConfigurationStatement.class), connectionSession).execute());
+ assertThrows(UnknownDatabaseException.class, () -> new QueryableRALBackendHandler(mock(ExportDatabaseConfigurationStatement.class), connectionSession).execute());
}
@Test
void assertExecuteWithAbstractStatement() {
- assertThrows(ServiceProviderNotFoundException.class, () -> new QueryableRALBackendHandler<>(mock(QueryableRALStatement.class), mock(ConnectionSession.class)).execute());
+ assertThrows(ServiceProviderNotFoundException.class, () -> new QueryableRALBackendHandler(mock(QueryableRALStatement.class), mock(ConnectionSession.class)).execute());
}
@Test
@@ -89,7 +89,7 @@ class QueryableRALBackendHandlerTest {
when(database.getProtocolType()).thenReturn(TypedSPILoader.getService(DatabaseType.class, "FIXTURE"));
when(database.getSchema("foo_db")).thenReturn(new ShardingSphereSchema(createTableMap(), Collections.emptyMap()));
when(ProxyContext.getInstance().getDatabase("foo_db")).thenReturn(database);
- assertDoesNotThrow(() -> new QueryableRALBackendHandler<>(createSqlStatement(), mock(ConnectionSession.class)).execute());
+ assertDoesNotThrow(() -> new QueryableRALBackendHandler(createSqlStatement(), mock(ConnectionSession.class)).execute());
}
private Map<String, ShardingSphereTable> createTableMap() {
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdaterTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdaterTest.java
index 3a5e4d68057..59acfb21f42 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdaterTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdaterTest.java
@@ -59,7 +59,7 @@ class RefreshTableMetaDataUpdaterTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
when(database.getName()).thenReturn("foo_db");
when(ProxyContext.getInstance().getDatabase("foo_db")).thenReturn(database);
- UpdatableRALBackendHandler<?> backendHandler = new UpdatableRALBackendHandler<>(new RefreshTableMetaDataStatement(), mockConnectionSession("foo_db"));
+ UpdatableRALBackendHandler backendHandler = new UpdatableRALBackendHandler(new RefreshTableMetaDataStatement(), mockConnectionSession("foo_db"));
assertThrows(EmptyStorageUnitException.class, backendHandler::execute);
}
@@ -68,7 +68,7 @@ class RefreshTableMetaDataUpdaterTest {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
when(ProxyContext.getInstance().databaseExists("foo_db")).thenReturn(true);
- UpdatableRALBackendHandler<?> backendHandler = new UpdatableRALBackendHandler<>(
+ UpdatableRALBackendHandler backendHandler = new UpdatableRALBackendHandler(
new RefreshTableMetaDataStatement("t_order", "ds_1", null), mockConnectionSession("foo_db"));
assertThrows(MissingRequiredStorageUnitsException.class, backendHandler::execute);
}
@@ -81,7 +81,7 @@ class RefreshTableMetaDataUpdaterTest {
when(database.getName()).thenReturn("foo_db");
when(database.getProtocolType()).thenReturn(TypedSPILoader.getService(DatabaseType.class, "FIXTURE"));
when(ProxyContext.getInstance().getDatabase("foo_db")).thenReturn(database);
- UpdatableRALBackendHandler<?> backendHandler = new UpdatableRALBackendHandler<>(new RefreshTableMetaDataStatement(), mockConnectionSession("foo_db"));
+ UpdatableRALBackendHandler backendHandler = new UpdatableRALBackendHandler(new RefreshTableMetaDataStatement(), mockConnectionSession("foo_db"));
ResponseHeader actual = backendHandler.execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
}
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdatableRALBackendHandlerTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdatableRALBackendHandlerTest.java
index 69ee52a6d15..49da56ea5ee 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdatableRALBackendHandlerTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdatableRALBackendHandlerTest.java
@@ -41,7 +41,7 @@ class SetDistVariableUpdatableRALBackendHandlerTest {
@Test
void assertNotSupportedVariable() {
- UpdatableRALBackendHandler<?> handler = new UpdatableRALBackendHandler<>(new SetDistVariableStatement("unsupported", "XXX"), connectionSession);
+ UpdatableRALBackendHandler handler = new UpdatableRALBackendHandler(new SetDistVariableStatement("unsupported", "XXX"), connectionSession);
assertThrows(UnsupportedVariableException.class, handler::execute);
}
}
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/LegacyRuleDefinitionBackendHandlerTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/LegacyRuleDefinitionBackendHandlerTest.java
index 9775df1220e..febe8bf989b 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/LegacyRuleDefinitionBackendHandlerTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/LegacyRuleDefinitionBackendHandlerTest.java
@@ -24,7 +24,6 @@ import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.distsql.fixture.CreateFixtureRuleStatement;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.legacy.LegacyRuleDefinitionBackendHandler;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
diff --git a/proxy/backend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor b/proxy/backend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor
similarity index 100%
rename from proxy/backend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.database.DatabaseRuleDefinitionExecutor
rename to proxy/backend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor