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

duanzhengqiang 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 74ec4d8581e Move RuleDefinitionExecuteEngine to distsql module (#29974)
74ec4d8581e is described below

commit 74ec4d8581e84f78b9f0174d341adf30662a5356
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Feb 4 11:45:50 2024 +0800

    Move RuleDefinitionExecuteEngine to distsql module (#29974)
    
    * Move RuleDefinitionExecuteEngine to distsql module
    
    * Refactor DistSQLUpdateExecuteEngine
    
    * Refactor DistSQLUpdateExecuteEngine
---
 .../type/update/DistSQLUpdateExecuteEngine.java    | 71 +++++++++++++++++++---
 .../rule/engine}/RuleDefinitionExecuteEngine.java  |  5 +-
 .../LegacyDatabaseRuleDefinitionExecuteEngine.java |  2 +-
 .../distsql/DistSQLBackendHandlerFactory.java      |  3 +-
 .../distsql/rdl/RDLBackendHandlerFactory.java      | 49 ---------------
 .../rdl/rule/RuleDefinitionBackendHandler.java     | 50 ---------------
 .../distsql/DistSQLBackendHandlerFactoryTest.java  | 33 ++++------
 7 files changed, 81 insertions(+), 132 deletions(-)

diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/update/DistSQLUpdateExecuteEngine.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/update/DistSQLUpdateExecuteEngine.java
index ca2b0925a5e..c300f272c6a 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/update/DistSQLUpdateExecuteEngine.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/update/DistSQLUpdateExecuteEngine.java
@@ -17,12 +17,18 @@
 
 package org.apache.shardingsphere.distsql.handler.type.update;
 
-import lombok.RequiredArgsConstructor;
 import 
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorDatabaseAware;
 import 
org.apache.shardingsphere.distsql.handler.aware.DistSQLExecutorRuleAware;
 import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorClusterModeRequired;
+import 
org.apache.shardingsphere.distsql.handler.type.update.rdl.rule.engine.database.DatabaseRuleDefinitionExecuteEngine;
+import 
org.apache.shardingsphere.distsql.handler.type.update.rdl.rule.engine.global.GlobalRuleDefinitionExecuteEngine;
+import 
org.apache.shardingsphere.distsql.handler.type.update.rdl.rule.engine.legacy.LegacyDatabaseRuleDefinitionExecuteEngine;
+import 
org.apache.shardingsphere.distsql.handler.type.update.rdl.rule.engine.legacy.LegacyGlobalRuleDefinitionExecuteEngine;
+import 
org.apache.shardingsphere.distsql.handler.type.update.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor;
+import 
org.apache.shardingsphere.distsql.handler.type.update.rdl.rule.spi.global.GlobalRuleDefinitionExecutor;
 import org.apache.shardingsphere.distsql.handler.util.DatabaseNameUtils;
 import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
+import 
org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.UnsupportedSQLOperationException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -36,25 +42,76 @@ import java.util.Optional;
 /**
  * DistSQL update execute engine.
  */
-@RequiredArgsConstructor
 public abstract class DistSQLUpdateExecuteEngine {
     
     private final DistSQLStatement sqlStatement;
     
-    private final String currentDatabaseName;
-    
     private final ContextManager contextManager;
     
+    private final String databaseName;
+    
+    public DistSQLUpdateExecuteEngine(final DistSQLStatement sqlStatement, 
final String currentDatabaseName, final ContextManager contextManager) {
+        this.sqlStatement = sqlStatement;
+        this.contextManager = contextManager;
+        databaseName = DatabaseNameUtils.getDatabaseName(sqlStatement, 
currentDatabaseName);
+    }
+    
     /**
      * Execute update.
      * 
      * @throws SQLException SQL exception
      */
-    @SuppressWarnings({"unchecked", "rawtypes"})
     public void executeUpdate() throws SQLException {
+        if (sqlStatement instanceof RuleDefinitionStatement) {
+            executeRuleDefinitionUpdate();
+        } else {
+            executeNormalUpdate();
+        }
+    }
+    
+    @SuppressWarnings("rawtypes")
+    private void executeRuleDefinitionUpdate() {
+        Optional<DatabaseRuleDefinitionExecutor> databaseExecutor = 
TypedSPILoader.findService(DatabaseRuleDefinitionExecutor.class, 
sqlStatement.getClass());
+        if (databaseExecutor.isPresent()) {
+            executeDatabaseRuleDefinitionUpdate(databaseExecutor.get());
+        } else {
+            
executeGlobalRuleDefinitionUpdate(TypedSPILoader.getService(GlobalRuleDefinitionExecutor.class,
 sqlStatement.getClass()));
+        }
+    }
+    
+    @SuppressWarnings("rawtypes")
+    private void executeDatabaseRuleDefinitionUpdate(final 
DatabaseRuleDefinitionExecutor databaseExecutor) {
+        if (isNormalRuleUpdater()) {
+            new DatabaseRuleDefinitionExecuteEngine(
+                    (RuleDefinitionStatement) sqlStatement, contextManager, 
getDatabase(databaseName), databaseExecutor).executeUpdate();
+        } else {
+            // TODO Remove when metadata structure adjustment completed. #25485
+            new LegacyDatabaseRuleDefinitionExecuteEngine(
+                    (RuleDefinitionStatement) sqlStatement, contextManager, 
getDatabase(databaseName), databaseExecutor).executeUpdate();
+        }
+    }
+    
+    @SuppressWarnings("rawtypes")
+    private void executeGlobalRuleDefinitionUpdate(final 
GlobalRuleDefinitionExecutor globalExecutor) {
+        if (isNormalRuleUpdater()) {
+            new GlobalRuleDefinitionExecuteEngine((RuleDefinitionStatement) 
sqlStatement, contextManager, globalExecutor).executeUpdate();
+        } else {
+            // TODO Remove when metadata structure adjustment completed. #25485
+            new 
LegacyGlobalRuleDefinitionExecuteEngine((RuleDefinitionStatement) sqlStatement, 
contextManager, globalExecutor).executeUpdate();
+        }
+    }
+    
+    // TODO Remove when metadata structure adjustment completed. #25485
+    private boolean isNormalRuleUpdater() {
+        String modeType = 
contextManager.getInstanceContext().getModeConfiguration().getType();
+        return "Cluster".equals(modeType) || "Standalone".equals(modeType);
+    }
+    
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    private void executeNormalUpdate() throws SQLException {
         DistSQLUpdateExecutor executor = 
TypedSPILoader.getService(DistSQLUpdateExecutor.class, sqlStatement.getClass());
         if (executor instanceof DistSQLExecutorDatabaseAware) {
-            ((DistSQLExecutorDatabaseAware) 
executor).setDatabase(getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement,
 currentDatabaseName)));
+            ((DistSQLExecutorDatabaseAware) 
executor).setDatabase(getDatabase(databaseName));
         }
         if (executor instanceof DistSQLExecutorRuleAware) {
             setRule((DistSQLExecutorRuleAware) executor);
@@ -78,7 +135,7 @@ public abstract class DistSQLUpdateExecuteEngine {
     
     private Optional<ShardingSphereRule> findRule(final 
Class<ShardingSphereRule> ruleClass) {
         Optional<ShardingSphereRule> globalRule = 
contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ruleClass);
-        return globalRule.isPresent() ? globalRule : 
getDatabase(DatabaseNameUtils.getDatabaseName(sqlStatement, 
currentDatabaseName)).getRuleMetaData().findSingleRule(ruleClass);
+        return globalRule.isPresent() ? globalRule : 
getDatabase(databaseName).getRuleMetaData().findSingleRule(ruleClass);
     }
     
     protected abstract ShardingSphereDatabase getDatabase(String databaseName);
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionExecuteEngine.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/update/rdl/rule/engine/RuleDefinitionExecuteEngine.java
similarity index 94%
rename from 
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionExecuteEngine.java
rename to 
infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/update/rdl/rule/engine/RuleDefinitionExecuteEngine.java
index fec426ee8b9..fa29350550e 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionExecuteEngine.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/update/rdl/rule/engine/RuleDefinitionExecuteEngine.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule;
+package org.apache.shardingsphere.distsql.handler.type.update.rdl.rule.engine;
 
 import lombok.RequiredArgsConstructor;
 import 
org.apache.shardingsphere.distsql.handler.type.update.rdl.rule.engine.database.DatabaseRuleDefinitionExecuteEngine;
@@ -28,12 +28,11 @@ import 
org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatem
 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 
org.apache.shardingsphere.proxy.backend.handler.distsql.legacy.LegacyDatabaseRuleDefinitionExecuteEngine;
+import 
org.apache.shardingsphere.distsql.handler.type.update.rdl.rule.engine.legacy.LegacyDatabaseRuleDefinitionExecuteEngine;
 
 import java.util.Optional;
 
 /**
- *  // TODO Remove this to distsql-handler module.
  * Rule definition execute engine.
  */
 @RequiredArgsConstructor
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/legacy/LegacyDatabaseRuleDefinitionExecuteEngine.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/update/rdl/rule/engine/legacy/LegacyDatabaseRuleDefinitionExecuteEngine.java
similarity index 99%
rename from 
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/legacy/LegacyDatabaseRuleDefinitionExecuteEngine.java
rename to 
infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/update/rdl/rule/engine/legacy/LegacyDatabaseRuleDefinitionExecuteEngine.java
index 3567760b1d6..9adc429429b 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/legacy/LegacyDatabaseRuleDefinitionExecuteEngine.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/update/rdl/rule/engine/legacy/LegacyDatabaseRuleDefinitionExecuteEngine.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.proxy.backend.handler.distsql.legacy;
+package 
org.apache.shardingsphere.distsql.handler.type.update.rdl.rule.engine.legacy;
 
 import lombok.RequiredArgsConstructor;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactory.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactory.java
index 346dd006095..144853b5d10 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactory.java
+++ 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactory.java
@@ -27,7 +27,6 @@ import 
org.apache.shardingsphere.distsql.statement.rul.RULStatement;
 import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.UnsupportedSQLOperationException;
 import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
 import 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.RALBackendHandlerFactory;
-import 
org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.RDLBackendHandlerFactory;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 
 /**
@@ -49,7 +48,7 @@ public final class DistSQLBackendHandlerFactory {
             return new DistSQLQueryBackendHandler(sqlStatement, 
connectionSession);
         }
         if (sqlStatement instanceof RDLStatement) {
-            return RDLBackendHandlerFactory.newInstance((RDLStatement) 
sqlStatement, connectionSession);
+            return new DistSQLUpdateBackendHandler(sqlStatement, 
connectionSession);
         }
         if (sqlStatement instanceof RALStatement) {
             return RALBackendHandlerFactory.newInstance((RALStatement) 
sqlStatement, connectionSession);
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
deleted file mode 100644
index 288876c3a9e..00000000000
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/RDLBackendHandlerFactory.java
+++ /dev/null
@@ -1,49 +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;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.distsql.statement.rdl.RDLStatement;
-import 
org.apache.shardingsphere.distsql.statement.rdl.resource.ResourceDefinitionStatement;
-import 
org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
-import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
-import 
org.apache.shardingsphere.proxy.backend.handler.distsql.DistSQLUpdateBackendHandler;
-import 
org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.rule.RuleDefinitionBackendHandler;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-
-/**
- * RDL backend handler factory.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class RDLBackendHandlerFactory {
-    
-    /**
-     * Create new instance of RDL backend handler.
-     * 
-     * @param sqlStatement RDL statement
-     * @param connectionSession connection session
-     * @return RDL backend handler
-     */
-    public static ProxyBackendHandler newInstance(final RDLStatement 
sqlStatement, final ConnectionSession connectionSession) {
-        if (sqlStatement instanceof ResourceDefinitionStatement) {
-            return new DistSQLUpdateBackendHandler(sqlStatement, 
connectionSession);
-        }
-        return new RuleDefinitionBackendHandler((RuleDefinitionStatement) 
sqlStatement, connectionSession);
-    }
-}
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
deleted file mode 100644
index 724df30bf90..00000000000
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
+++ /dev/null
@@ -1,50 +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;
-
-import 
org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
-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;
-
-/**
- * Rule definition backend handler.
- */
-public final class RuleDefinitionBackendHandler extends 
RuleDefinitionExecuteEngine implements DistSQLBackendHandler {
-    
-    private final RuleDefinitionStatement sqlStatement;
-    
-    public RuleDefinitionBackendHandler(final RuleDefinitionStatement 
sqlStatement, final ConnectionSession connectionSession) {
-        super(sqlStatement, connectionSession.getDatabaseName(), 
ProxyContext.getInstance().getContextManager());
-        this.sqlStatement = sqlStatement;
-    }
-    
-    @Override
-    public ResponseHeader execute() {
-        executeUpdate();
-        return new UpdateResponseHeader(sqlStatement);
-    }
-    
-    @Override
-    protected ShardingSphereDatabase getDatabase(final String databaseName) {
-        return ProxyContext.getInstance().getDatabase(databaseName);
-    }
-}
diff --git 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java
 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java
index a571871e3a7..de39252e1bc 100644
--- 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java
+++ 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java
@@ -22,7 +22,6 @@ import 
org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
 import 
org.apache.shardingsphere.distsql.statement.rdl.resource.unit.type.AlterStorageUnitStatement;
 import 
org.apache.shardingsphere.distsql.statement.rdl.resource.unit.type.RegisterStorageUnitStatement;
 import 
org.apache.shardingsphere.distsql.statement.rdl.resource.unit.type.UnregisterStorageUnitStatement;
-import 
org.apache.shardingsphere.distsql.statement.rql.resource.ShowStorageUnitsStatement;
 import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
 import org.apache.shardingsphere.infra.instance.mode.ModeContextManager;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -31,7 +30,6 @@ import 
org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import 
org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.RDLBackendHandlerFactory;
 import 
org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
 import 
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
@@ -115,41 +113,41 @@ class DistSQLBackendHandlerFactoryTest {
     
     @Test
     void assertExecuteDataSourcesContext() throws SQLException {
-        
assertThat(RDLBackendHandlerFactory.newInstance(mock(RegisterStorageUnitStatement.class),
 connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+        assertThat(new 
DistSQLUpdateBackendHandler(mock(RegisterStorageUnitStatement.class), 
connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
     }
     
     @Test
     void assertExecuteShardingTableRuleContext() throws SQLException {
         
when(ProxyContext.getInstance().getDatabase("foo_db").getRuleMetaData()).thenReturn(new
 RuleMetaData(Collections.emptyList()));
-        
assertThat(RDLBackendHandlerFactory.newInstance(mock(CreateShardingTableRuleStatement.class),
 connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+        assertThat(new 
DistSQLUpdateBackendHandler(mock(CreateShardingTableRuleStatement.class), 
connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
     }
     
     @Test
     void assertExecuteAddResourceContext() throws SQLException {
-        
assertThat(RDLBackendHandlerFactory.newInstance(mock(RegisterStorageUnitStatement.class),
 connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+        assertThat(new 
DistSQLUpdateBackendHandler(mock(RegisterStorageUnitStatement.class), 
connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
     }
     
     @Test
     void assertExecuteAlterResourceContext() throws SQLException {
-        
assertThat(RDLBackendHandlerFactory.newInstance(mock(AlterStorageUnitStatement.class),
 connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+        assertThat(new 
DistSQLUpdateBackendHandler(mock(AlterStorageUnitStatement.class), 
connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
     }
     
     @Test
     void assertExecuteAlterShadowRuleContext() throws SQLException {
         mockRuleMetaData();
-        
assertThat(RDLBackendHandlerFactory.newInstance(mock(AlterShadowRuleStatement.class),
 connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+        assertThat(new 
DistSQLUpdateBackendHandler(mock(AlterShadowRuleStatement.class), 
connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
     }
     
     @Test
     void assertExecuteCreateShadowRuleContext() throws SQLException {
         mockRuleMetaData();
-        
assertThat(RDLBackendHandlerFactory.newInstance(mock(CreateShadowRuleStatement.class),
 connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+        assertThat(new 
DistSQLUpdateBackendHandler(mock(CreateShadowRuleStatement.class), 
connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
     }
     
     @Test
     void assertExecuteDropShadowRuleContext() throws SQLException {
         mockRuleMetaData();
-        
assertThat(RDLBackendHandlerFactory.newInstance(mock(DropShadowRuleStatement.class),
 connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+        assertThat(new 
DistSQLUpdateBackendHandler(mock(DropShadowRuleStatement.class), 
connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
     }
     
     @Test
@@ -157,7 +155,7 @@ class DistSQLBackendHandlerFactoryTest {
         mockRuleMetaData();
         AlterDefaultShadowAlgorithmStatement statement = new 
AlterDefaultShadowAlgorithmStatement(
                 new ShadowAlgorithmSegment("foo", new 
AlgorithmSegment("SQL_HINT", PropertiesBuilder.build(new Property("type", 
"value")))));
-        assertThat(RDLBackendHandlerFactory.newInstance(statement, 
connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+        assertThat(new DistSQLUpdateBackendHandler(statement, 
connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
     }
     
     @Test
@@ -181,32 +179,27 @@ class DistSQLBackendHandlerFactoryTest {
     @Test
     void assertExecuteDropShadowAlgorithmContext() throws SQLException {
         mockRuleMetaData();
-        
assertThat(RDLBackendHandlerFactory.newInstance(mock(DropShadowAlgorithmStatement.class),
 connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+        assertThat(new 
DistSQLUpdateBackendHandler(mock(DropShadowAlgorithmStatement.class), 
connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
     }
     
     @Test
     void assertExecuteDropResourceContext() throws SQLException {
-        
assertThat(RDLBackendHandlerFactory.newInstance(mock(UnregisterStorageUnitStatement.class),
 connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+        assertThat(new 
DistSQLUpdateBackendHandler(mock(UnregisterStorageUnitStatement.class), 
connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
     }
     
     @Test
     void assertExecuteDropReadwriteSplittingRuleContext() {
-        assertThrows(MissingRequiredRuleException.class, () -> 
RDLBackendHandlerFactory.newInstance(mock(DropReadwriteSplittingRuleStatement.class),
 connectionSession).execute());
+        assertThrows(MissingRequiredRuleException.class, () -> new 
DistSQLUpdateBackendHandler(mock(DropReadwriteSplittingRuleStatement.class), 
connectionSession).execute());
     }
     
     @Test
     void assertExecuteCreateReadwriteSplittingRuleContext() throws 
SQLException {
-        
assertThat(RDLBackendHandlerFactory.newInstance(mock(CreateReadwriteSplittingRuleStatement.class),
 connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+        assertThat(new 
DistSQLUpdateBackendHandler(mock(CreateReadwriteSplittingRuleStatement.class), 
connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
     }
     
     @Test
     void assertExecuteAlterReadwriteSplittingRuleContext() {
-        assertThrows(MissingRequiredRuleException.class, () -> 
RDLBackendHandlerFactory.newInstance(mock(AlterReadwriteSplittingRuleStatement.class),
 connectionSession).execute());
-    }
-    
-    @Test
-    void assertExecuteShowResourceContext() throws SQLException {
-        assertThat(new 
DistSQLQueryBackendHandler(mock(ShowStorageUnitsStatement.class), 
connectionSession).execute(), instanceOf(QueryResponseHeader.class));
+        assertThrows(MissingRequiredRuleException.class, () -> new 
DistSQLUpdateBackendHandler(mock(AlterReadwriteSplittingRuleStatement.class), 
connectionSession).execute());
     }
     
     private void mockRuleMetaData() {

Reply via email to