You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2022/02/15 16:36:21 UTC

[shardingsphere] branch master updated: [DistSQL] Refactor RAL's AlterStatementExecutor (#15415)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 7aec88d  [DistSQL] Refactor RAL's AlterStatementExecutor (#15415)
7aec88d is described below

commit 7aec88dcf3e0981dd12e8c9bdf066c7f5a96d1f9
Author: lanchengx <52...@users.noreply.github.com>
AuthorDate: Wed Feb 16 00:34:49 2022 +0800

    [DistSQL] Refactor RAL's AlterStatementExecutor (#15415)
    
    * Refactor RAL factory.
    
    * Refactor RAL factory.
    
    * Refactor RAL factory, adjust the executor of the `alter` type.
    
    * Refactor RAL factory, adjust the executor of the `alter` type.
    
    * Refactor RAL factory.
    
    * Modify class name.
    
    * Modify class name.
    
    * Modify name.
    
    * Modify name.
---
 .../distsql/ral/QueryableRALBackendHandler.java    | 84 +++++++++++++++++++++
 .../text/distsql/ral/RALBackendHandler.java        | 85 ++++++++++++++++++++++
 .../text/distsql/ral/RALBackendHandlerFactory.java | 55 ++++++++++++--
 ...ecutor.java => UpdatableRALBackendHandler.java} | 23 +++---
 .../ral/common/AlterDistSQLBackendHandler.java     | 47 ------------
 .../common/CommonDistSQLBackendHandlerFactory.java | 11 +--
 .../alter/AlterStatementExecutorFactory.java       | 56 --------------
 .../AlterSQLParserRuleHandler.java}                | 16 ++--
 .../AlterTrafficRuleHandler.java}                  | 14 ++--
 .../AlterTransactionRuleHandler.java}              | 16 ++--
 .../CreateTrafficRuleHandler.java                  | 14 ++--
 ...java => QueryableScalingRALBackendHandler.java} |  6 +-
 ... QueryableScalingRALBackendHandlerFactory.java} |  6 +-
 ...java => UpdatableScalingRALBackendHandler.java} |  4 +-
 ... UpdatableScalingRALBackendHandlerFactory.java} |  6 +-
 .../rql/rule/SchemaRulesCountResultSet.java        |  4 +-
 .../alter/AlterSQLParserRuleExecutorTest.java      | 11 +--
 .../common/alter/AlterTrafficRuleHandlerTest.java  | 20 ++---
 .../create/CreateTrafficRuleHandlerTest.java       | 19 ++---
 19 files changed, 290 insertions(+), 207 deletions(-)

diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/QueryableRALBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/QueryableRALBackendHandler.java
new file mode 100644
index 0000000..b1ff41e
--- /dev/null
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/QueryableRALBackendHandler.java
@@ -0,0 +1,84 @@
+/*
+ * 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.text.distsql.ral;
+
+import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+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.data.impl.TextQueryResponseCell;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
+import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
+import org.apache.shardingsphere.sharding.merge.dal.common.MultipleLocalDataMergedResult;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Queryable RAL backend handler.
+ */
+public abstract class QueryableRALBackendHandler<E extends RALStatement, R extends QueryableRALBackendHandler> extends RALBackendHandler<E, R> {
+    
+    private List<QueryHeader> queryHeaders;
+    
+    private MultipleLocalDataMergedResult mergedResult;
+    
+    @Override
+    protected final ResponseHeader handle(final ContextManager contextManager, final E sqlStatement) {
+        queryHeaders = createQueryHeader(getColumnNames());
+        mergedResult = createMergedResult(getRows());
+        return new QueryResponseHeader(queryHeaders);
+    }
+    
+    @Override
+    public final boolean next() throws SQLException {
+        return null != mergedResult && mergedResult.next();
+    }
+    
+    @Override
+    public final Collection<Object> getRowData() throws SQLException {
+        return createQueryResponseRow(queryHeaders.size(), mergedResult).getData();
+    }
+    
+    protected abstract Collection<List<Object>> getRows();
+    
+    protected abstract Collection<String> getColumnNames();
+    
+    private MultipleLocalDataMergedResult createMergedResult(final Collection<List<Object>> rows) {
+        return new MultipleLocalDataMergedResult(rows);
+    }
+    
+    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 QueryResponseRow createQueryResponseRow(final int size, final MultipleLocalDataMergedResult mergedResult) {
+        List<QueryResponseCell> cells = new ArrayList<>(size);
+        for (int i = 0; i < size; i++) {
+            cells.add(new TextQueryResponseCell(mergedResult.getValue(i + 1, Object.class)));
+        }
+        return new QueryResponseRow(cells);
+    }
+}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandler.java
new file mode 100644
index 0000000..ac8425c
--- /dev/null
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandler.java
@@ -0,0 +1,85 @@
+/*
+ * 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.text.distsql.ral;
+
+import com.google.common.base.Preconditions;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
+
+import java.sql.SQLException;
+
+/**
+ * RAL backend handler.
+ */
+public abstract class RALBackendHandler<E extends RALStatement, R extends RALBackendHandler> implements TextProtocolBackendHandler {
+    
+    // CHECKSTYLE:OFF
+    protected E sqlStatement;
+    // CHECKSTYLE:ON
+    
+    @Override
+    public final ResponseHeader execute() throws SQLException {
+        Preconditions.checkArgument(null != sqlStatement, "sql statement cannot be empty.");
+        ContextManager contextManager = ProxyContext.getInstance().getContextManager();
+        return handle(contextManager, sqlStatement);
+    }
+    
+    protected abstract ResponseHeader handle(ContextManager contextManager, E sqlStatement) throws DistSQLException;
+    
+    /**
+     * Method to initialize handler, this method needs to be rewritten when the handler has properties other than sql statement.
+     *
+     * @param parameter parameters required by handler
+     * @return the object itself
+     */
+    public R init(final HandlerParameter<E> parameter) {
+        initStatement(parameter.getStatement());
+        return (R) this;
+    }
+    
+    /**
+     * Initialize statement.
+     * @param statement RAL statement
+     * @return the object itself
+     */
+    public final R initStatement(final E statement) {
+        sqlStatement = statement;
+        return (R) this;
+    }
+    
+    @Getter
+    @Setter
+    @AllArgsConstructor
+    public static class HandlerParameter<E extends RALStatement> {
+        
+        private E statement;
+        
+        private DatabaseType databaseType;
+        
+        private ConnectionSession connectionSession;
+    }
+}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
index bd8ad32..8fc8e69 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
@@ -24,15 +24,26 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.CommonDistSQLState
 import org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatement;
 import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
 import org.apache.shardingsphere.distsql.parser.statement.ral.UpdatableRALStatement;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.alter.AlterSQLParserRuleStatement;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.alter.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.distsql.parser.statement.rdl.create.AlterTrafficRuleStatement;
+import org.apache.shardingsphere.distsql.parser.statement.rdl.create.CreateTrafficRuleStatement;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.RALBackendHandler.HandlerParameter;
 import org.apache.shardingsphere.proxy.backend.text.distsql.ral.advanced.AdvancedDistSQLBackendHandlerFactory;
-import org.apache.shardingsphere.proxy.backend.text.distsql.ral.query.QueryableRALBackendHandlerFactory;
 import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.CommonDistSQLBackendHandlerFactory;
-import org.apache.shardingsphere.proxy.backend.text.distsql.ral.update.UpdatableRALBackendHandlerFactory;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatable.AlterSQLParserRuleHandler;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatable.AlterTrafficRuleHandler;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatable.AlterTransactionRuleHandler;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatable.CreateTrafficRuleHandler;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.query.QueryableScalingRALBackendHandlerFactory;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.update.UpdatableScalingRALBackendHandlerFactory;
 
 import java.sql.SQLException;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
 /**
  * RAL backend handler factory.
@@ -40,6 +51,15 @@ import java.sql.SQLException;
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class RALBackendHandlerFactory {
     
+    private static Map<String, Class<? extends RALBackendHandler>> handlerMap = new LinkedHashMap<>();
+    
+    static {
+        handlerMap.put(CreateTrafficRuleStatement.class.getName(), CreateTrafficRuleHandler.class);
+        handlerMap.put(AlterSQLParserRuleStatement.class.getName(), AlterSQLParserRuleHandler.class);
+        handlerMap.put(AlterTrafficRuleStatement.class.getName(), AlterTrafficRuleHandler.class);
+        handlerMap.put(AlterTransactionRuleStatement.class.getName(), AlterTransactionRuleHandler.class);
+    }
+    
     /**
      * Create new instance of RAL backend handler.
      *
@@ -50,18 +70,39 @@ public final class RALBackendHandlerFactory {
      * @throws SQLException SQL exception
      */
     public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final RALStatement sqlStatement, final ConnectionSession connectionSession) throws SQLException {
+        TextProtocolBackendHandler result = null;
         if (sqlStatement instanceof QueryableRALStatement) {
-            return QueryableRALBackendHandlerFactory.newInstance((QueryableRALStatement) sqlStatement, connectionSession);
+            result = QueryableScalingRALBackendHandlerFactory.newInstance((QueryableRALStatement) sqlStatement, connectionSession);
         }
         if (sqlStatement instanceof UpdatableRALStatement) {
-            return UpdatableRALBackendHandlerFactory.newInstance((UpdatableRALStatement) sqlStatement);
+            result = UpdatableScalingRALBackendHandlerFactory.newInstance((UpdatableRALStatement) sqlStatement);
         }
         if (sqlStatement instanceof CommonDistSQLStatement) {
-            return CommonDistSQLBackendHandlerFactory.newInstance((CommonDistSQLStatement) sqlStatement, connectionSession);
+            result = CommonDistSQLBackendHandlerFactory.newInstance((CommonDistSQLStatement) sqlStatement, connectionSession);
         }
         if (sqlStatement instanceof AdvancedDistSQLStatement) {
-            return AdvancedDistSQLBackendHandlerFactory.newInstance(databaseType, (AdvancedDistSQLStatement) sqlStatement, connectionSession);
+            result = AdvancedDistSQLBackendHandlerFactory.newInstance(databaseType, (AdvancedDistSQLStatement) sqlStatement, connectionSession);
+        }
+        if (result == null) {
+            HandlerParameter parameter = new HandlerParameter(sqlStatement, databaseType, connectionSession);
+            result = getHandler(sqlStatement, parameter);
+        }
+        return result;
+    }
+    
+    private static RALBackendHandler newInstance(final Class<? extends RALBackendHandler> clazz) {
+        try {
+            return clazz.newInstance();
+        } catch (final InstantiationException | IllegalAccessException ex) {
+            throw new UnsupportedOperationException(String.format("Can not find public constructor for class `%s`", clazz.getName()));
+        }
+    }
+    
+    private static RALBackendHandler getHandler(final RALStatement sqlStatement, final HandlerParameter<RALStatement> parameter) {
+        Class<? extends RALBackendHandler> clazz = handlerMap.get(sqlStatement.getClass().getName());
+        if (null == clazz) {
+            throw new UnsupportedOperationException(sqlStatement.getClass().getCanonicalName());
         }
-        throw new UnsupportedOperationException(sqlStatement.getClass().getCanonicalName());
+        return newInstance(clazz).init(parameter);
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterStatementExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/UpdatableRALBackendHandler.java
similarity index 57%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterStatementExecutor.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/UpdatableRALBackendHandler.java
index 92c79f8..e862f2b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterStatementExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/UpdatableRALBackendHandler.java
@@ -15,21 +15,24 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter;
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral;
 
+import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
 import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
+import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
 
 /**
- * Alter statement executor.
+ * Updatable RAL backend handler .
  */
-public interface AlterStatementExecutor {
+public abstract class UpdatableRALBackendHandler<E extends RALStatement, R extends UpdatableRALBackendHandler> extends RALBackendHandler<E, R> {
     
-    /**
-     * Execute alter statement.
-     *
-     * @return backend response
-     * @throws DistSQLException DistSQL exception
-     */
-    ResponseHeader execute() throws DistSQLException;
+    @Override
+    protected final ResponseHeader handle(final ContextManager contextManager, final E sqlStatement) throws DistSQLException {
+        doHandle(contextManager, sqlStatement);
+        return new UpdateResponseHeader(sqlStatement);
+    }
+    
+    protected abstract void doHandle(ContextManager contextManager, E sqlStatement) throws DistSQLException;
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/AlterDistSQLBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/AlterDistSQLBackendHandler.java
deleted file mode 100644
index d601628..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/AlterDistSQLBackendHandler.java
+++ /dev/null
@@ -1,47 +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.text.distsql.ral.common;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.common.AlterDistSQLStatement;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
-import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter.AlterStatementExecutor;
-import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter.AlterStatementExecutorFactory;
-
-import java.sql.SQLException;
-
-/**
- * Alter dist sql backend handler.
- */
-@RequiredArgsConstructor
-@Getter
-public final class AlterDistSQLBackendHandler implements TextProtocolBackendHandler {
-    
-    private final AlterDistSQLStatement sqlStatement;
-    
-    private final ConnectionSession connectionSession;
-    
-    @Override
-    public ResponseHeader execute() throws SQLException {
-        AlterStatementExecutor alterStatementExecutor = AlterStatementExecutorFactory.newInstance(sqlStatement, connectionSession);
-        return alterStatementExecutor.execute();
-    }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/CommonDistSQLBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/CommonDistSQLBackendHandlerFactory.java
index d265d55..2e729b6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/CommonDistSQLBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/CommonDistSQLBackendHandlerFactory.java
@@ -20,16 +20,13 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.distsql.parser.statement.ral.CommonDistSQLStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.common.AlterDistSQLStatement;
 import org.apache.shardingsphere.distsql.parser.statement.ral.common.HintDistSQLStatement;
 import org.apache.shardingsphere.distsql.parser.statement.ral.common.RefreshTableMetadataStatement;
 import org.apache.shardingsphere.distsql.parser.statement.ral.common.SetDistSQLStatement;
 import org.apache.shardingsphere.distsql.parser.statement.ral.common.ShowDistSQLStatement;
 import org.apache.shardingsphere.distsql.parser.statement.ral.common.drop.DropTrafficRuleStatement;
-import org.apache.shardingsphere.distsql.parser.statement.rdl.create.CreateTrafficRuleStatement;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
-import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.create.CreateTrafficRuleHandler;
 import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.drop.DropTrafficRuleHandler;
 
 import java.sql.SQLException;
@@ -61,15 +58,9 @@ public final class CommonDistSQLBackendHandlerFactory {
         if (sqlStatement instanceof RefreshTableMetadataStatement) {
             return new RefreshTableMetadataHandler((RefreshTableMetadataStatement) sqlStatement, connectionSession);
         }
-        if (sqlStatement instanceof AlterDistSQLStatement) {
-            return new AlterDistSQLBackendHandler((AlterDistSQLStatement) sqlStatement, connectionSession);
-        }
         if (sqlStatement instanceof DropTrafficRuleStatement) {
             return new DropTrafficRuleHandler((DropTrafficRuleStatement) sqlStatement);
         }
-        if (sqlStatement instanceof CreateTrafficRuleStatement) {
-            return new CreateTrafficRuleHandler((CreateTrafficRuleStatement) sqlStatement);
-        }
-        throw new UnsupportedOperationException(sqlStatement.getClass().getCanonicalName());
+        return null;
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterStatementExecutorFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterStatementExecutorFactory.java
deleted file mode 100644
index 3a98a2e..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterStatementExecutorFactory.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.text.distsql.ral.common.alter;
-
-import org.apache.shardingsphere.distsql.parser.statement.ral.common.AlterDistSQLStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.common.alter.AlterSQLParserRuleStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.common.alter.AlterTransactionRuleStatement;
-import org.apache.shardingsphere.distsql.parser.statement.rdl.create.AlterTrafficRuleStatement;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter.excutor.AlterSQLParserRuleExecutor;
-import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter.excutor.AlterTrafficRuleExecutor;
-import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter.excutor.AlterTransactionRuleExecutor;
-
-import java.sql.SQLException;
-
-/**
- * Alter statement executor factory.
- */
-public final class AlterStatementExecutorFactory {
-    
-    /**
-     * Alter statement executor instance.
-     *
-     * @param sqlStatement alter dist SQL statement
-     * @param connectionSession connection session
-     * @return alter command executor
-     * @throws SQLException SQL exception
-     */
-    public static AlterStatementExecutor newInstance(final AlterDistSQLStatement sqlStatement, final ConnectionSession connectionSession) throws SQLException {
-        if (sqlStatement instanceof AlterTransactionRuleStatement) {
-            return new AlterTransactionRuleExecutor((AlterTransactionRuleStatement) sqlStatement);
-        }
-        if (sqlStatement instanceof AlterSQLParserRuleStatement) {
-            return new AlterSQLParserRuleExecutor((AlterSQLParserRuleStatement) sqlStatement);
-        }
-        if (sqlStatement instanceof AlterTrafficRuleStatement) {
-            return new AlterTrafficRuleExecutor((AlterTrafficRuleStatement) sqlStatement);
-        }
-        throw new UnsupportedOperationException(sqlStatement.getClass().getCanonicalName());
-    }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/excutor/AlterSQLParserRuleExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandler.java
similarity index 90%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/excutor/AlterSQLParserRuleExecutor.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandler.java
index c6c6d7d..acf7aa0 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/excutor/AlterSQLParserRuleExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandler.java
@@ -15,20 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter.excutor;
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatable;
 
-import lombok.AllArgsConstructor;
 import org.apache.shardingsphere.distsql.parser.segment.CacheOptionSegment;
 import org.apache.shardingsphere.distsql.parser.statement.ral.common.alter.AlterSQLParserRuleStatement;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
 import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
 import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
 import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-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.text.distsql.ral.common.alter.AlterStatementExecutor;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.UpdatableRALBackendHandler;
 import org.apache.shardingsphere.sql.parser.api.CacheOption;
 
 import java.util.Collection;
@@ -37,15 +35,11 @@ import java.util.Optional;
 /**
  * Alter SQL parser rule statement executor.
  */
-@AllArgsConstructor
-public final class AlterSQLParserRuleExecutor implements AlterStatementExecutor {
-    
-    private final AlterSQLParserRuleStatement sqlStatement;
+public final class AlterSQLParserRuleHandler extends UpdatableRALBackendHandler<AlterSQLParserRuleStatement, AlterSQLParserRuleHandler> {
     
     @Override
-    public ResponseHeader execute() {
+    protected void doHandle(final ContextManager contextManager, final AlterSQLParserRuleStatement sqlStatement) {
         updateSQLParserRule();
-        return new UpdateResponseHeader(sqlStatement);
     }
     
     private void updateSQLParserRule() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/excutor/AlterTrafficRuleExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandler.java
similarity index 92%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/excutor/AlterTrafficRuleExecutor.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandler.java
index 56d5ad4..c4ed985 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/excutor/AlterTrafficRuleExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter.excutor;
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatable;
 
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.distsql.parser.segment.TrafficRuleSegment;
@@ -23,12 +23,11 @@ import org.apache.shardingsphere.distsql.parser.statement.rdl.create.AlterTraffi
 import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
 import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
 import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
+import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
 import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-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.text.distsql.ral.common.alter.AlterStatementExecutor;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.UpdatableRALBackendHandler;
 import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.convert.TrafficRuleConverter;
 import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
 import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
@@ -47,18 +46,15 @@ import java.util.stream.Collectors;
  * Alter traffic rule handler.
  */
 @RequiredArgsConstructor
-public final class AlterTrafficRuleExecutor implements AlterStatementExecutor {
-    
-    private final AlterTrafficRuleStatement sqlStatement;
+public final class AlterTrafficRuleHandler extends UpdatableRALBackendHandler<AlterTrafficRuleStatement, AlterTrafficRuleHandler> {
     
     @Override
-    public ResponseHeader execute() throws DistSQLException {
+    protected void doHandle(final ContextManager contextManager, final AlterTrafficRuleStatement sqlStatement) throws DistSQLException {
         Optional<TrafficRuleConfiguration> currentConfiguration = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData()
                 .findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
         check(sqlStatement, currentConfiguration);
         TrafficRuleConfiguration toBeAlteredConfiguration = TrafficRuleConverter.convert(sqlStatement.getSegments());
         updateToRepository(toBeAlteredConfiguration, currentConfiguration.get());
-        return new UpdateResponseHeader(sqlStatement);
     }
     
     private void check(final AlterTrafficRuleStatement sqlStatement, final Optional<TrafficRuleConfiguration> currentConfiguration) throws DistSQLException {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/excutor/AlterTransactionRuleExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandler.java
similarity index 84%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/excutor/AlterTransactionRuleExecutor.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandler.java
index 76079c5..0397a71 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/excutor/AlterTransactionRuleExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandler.java
@@ -15,18 +15,16 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter.excutor;
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatable;
 
-import lombok.AllArgsConstructor;
 import org.apache.shardingsphere.distsql.parser.statement.ral.common.alter.AlterTransactionRuleStatement;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
 import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-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.text.distsql.ral.common.alter.AlterStatementExecutor;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.UpdatableRALBackendHandler;
 import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
 
 import java.util.Collection;
@@ -35,15 +33,11 @@ import java.util.Optional;
 /**
  * Alter transaction rule statement executor.
  */
-@AllArgsConstructor
-public final class AlterTransactionRuleExecutor implements AlterStatementExecutor {
-    
-    private final AlterTransactionRuleStatement sqlStatement;
+public final class AlterTransactionRuleHandler extends UpdatableRALBackendHandler<AlterTransactionRuleStatement, AlterTrafficRuleHandler> {
     
     @Override
-    public ResponseHeader execute() {
+    protected void doHandle(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement) {
         updateTransactionRule();
-        return new UpdateResponseHeader(sqlStatement);
     }
     
     private void updateTransactionRule() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/create/CreateTrafficRuleHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandler.java
similarity index 91%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/create/CreateTrafficRuleHandler.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandler.java
index 14a3c34..0bdbae7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/create/CreateTrafficRuleHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.create;
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatable;
 
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.distsql.parser.segment.TrafficRuleSegment;
@@ -24,12 +24,11 @@ import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
 import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
 import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
 import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-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.text.TextProtocolBackendHandler;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.UpdatableRALBackendHandler;
 import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.convert.TrafficRuleConverter;
 import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
 import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
@@ -48,18 +47,15 @@ import java.util.stream.Collectors;
  * Create traffic rule handler.
  */
 @RequiredArgsConstructor
-public final class CreateTrafficRuleHandler implements TextProtocolBackendHandler {
-    
-    private final CreateTrafficRuleStatement sqlStatement;
+public final class CreateTrafficRuleHandler extends UpdatableRALBackendHandler<CreateTrafficRuleStatement, CreateTrafficRuleHandler> {
     
     @Override
-    public ResponseHeader execute() throws DistSQLException {
+    protected void doHandle(final ContextManager contextManager, final CreateTrafficRuleStatement sqlStatement) throws DistSQLException {
         Optional<TrafficRuleConfiguration> trafficRuleConfiguration = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData()
                 .findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
         check(sqlStatement, trafficRuleConfiguration);
         TrafficRuleConfiguration toBeCreatedConfiguration = TrafficRuleConverter.convert(sqlStatement.getSegments());
         updateToRepository(toBeCreatedConfiguration, trafficRuleConfiguration);
-        return new UpdateResponseHeader(sqlStatement);
     }
     
     private void check(final CreateTrafficRuleStatement sqlStatement, final Optional<TrafficRuleConfiguration> trafficRuleConfiguration) throws DistSQLException {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableScalingRALBackendHandler.java
similarity index 89%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandler.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableScalingRALBackendHandler.java
index 1d3bcfd..8a54c64 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableScalingRALBackendHandler.java
@@ -32,13 +32,13 @@ import java.util.Collection;
 import java.util.List;
 
 /**
- * Queryable RAL backend handler.
+ * Queryable scaling RAL backend handler.
  */
-public final class QueryableRALBackendHandler extends SchemaRequiredBackendHandler<RALStatement> {
+public final class QueryableScalingRALBackendHandler extends SchemaRequiredBackendHandler<RALStatement> {
     
     private final DistSQLResultSet resultSet;
     
-    public QueryableRALBackendHandler(final RALStatement sqlStatement, final ConnectionSession connectionSession, final DistSQLResultSet resultSet) {
+    public QueryableScalingRALBackendHandler(final RALStatement sqlStatement, final ConnectionSession connectionSession, final DistSQLResultSet resultSet) {
         super(sqlStatement, connectionSession);
         this.resultSet = resultSet;
     }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableScalingRALBackendHandlerFactory.java
similarity index 90%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandlerFactory.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableScalingRALBackendHandlerFactory.java
index 7aae25f..1b11c2a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableScalingRALBackendHandlerFactory.java
@@ -29,10 +29,10 @@ import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
 import java.util.Properties;
 
 /**
- * Queryable RAL backend handler factory.
+ * Queryable scaling RAL backend handler factory.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class QueryableRALBackendHandlerFactory {
+public final class QueryableScalingRALBackendHandlerFactory {
     
     static {
         ShardingSphereServiceLoader.register(DistSQLResultSet.class);
@@ -47,6 +47,6 @@ public final class QueryableRALBackendHandlerFactory {
      */
     public static TextProtocolBackendHandler newInstance(final QueryableRALStatement sqlStatement, final ConnectionSession connectionSession) {
         DistSQLResultSet resultSet = TypedSPIRegistry.getRegisteredService(DistSQLResultSet.class, sqlStatement.getClass().getCanonicalName(), new Properties());
-        return new QueryableRALBackendHandler(sqlStatement, connectionSession, resultSet);
+        return new QueryableScalingRALBackendHandler(sqlStatement, connectionSession, resultSet);
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/update/UpdatableRALBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/update/UpdatableScalingRALBackendHandler.java
similarity index 93%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/update/UpdatableRALBackendHandler.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/update/UpdatableScalingRALBackendHandler.java
index 79f7661..37a895d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/update/UpdatableRALBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/update/UpdatableScalingRALBackendHandler.java
@@ -29,10 +29,10 @@ import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
 import java.util.Properties;
 
 /**
- * Updatable RAL backend handler factory.
+ * Updatable scaling RAL backend handler factory.
  */
 @Setter
-public final class UpdatableRALBackendHandler implements TextProtocolBackendHandler {
+public final class UpdatableScalingRALBackendHandler implements TextProtocolBackendHandler {
     
     static {
         ShardingSphereServiceLoader.register(RALUpdater.class);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/update/UpdatableRALBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/update/UpdatableScalingRALBackendHandlerFactory.java
similarity index 89%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/update/UpdatableRALBackendHandlerFactory.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/update/UpdatableScalingRALBackendHandlerFactory.java
index 9631dcf..937b3bf 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/update/UpdatableRALBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/update/UpdatableScalingRALBackendHandlerFactory.java
@@ -25,10 +25,10 @@ import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
 import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
 
 /**
- * Updatable RAL backend handler factory.
+ *  Updatable scaling RAL backend handler factory.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class UpdatableRALBackendHandlerFactory {
+public final class UpdatableScalingRALBackendHandlerFactory {
     
     static {
         ShardingSphereServiceLoader.register(RALUpdater.class);
@@ -41,7 +41,7 @@ public final class UpdatableRALBackendHandlerFactory {
      * @return queryable RAL backend handler
      */
     public static TextProtocolBackendHandler newInstance(final UpdatableRALStatement sqlStatement) {
-        UpdatableRALBackendHandler result = new UpdatableRALBackendHandler();
+        UpdatableScalingRALBackendHandler result = new UpdatableScalingRALBackendHandler();
         result.setSqlStatement(sqlStatement);
         return result;
     }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/SchemaRulesCountResultSet.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/SchemaRulesCountResultSet.java
index b38b8ee..bec7a17 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/SchemaRulesCountResultSet.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/SchemaRulesCountResultSet.java
@@ -156,8 +156,8 @@ public final class SchemaRulesCountResultSet implements DistSQLResultSet {
             dataMap.putIfAbsent(dataKey, buildRow(feature, type, DEFAULT_COUNT));
             return;
         }
-        Class<? extends RuleConfiguration> clz = FEATURE_MAP.get(feature);
-        if (!(ruleConfiguration.getClass().getCanonicalName().equals(clz.getCanonicalName()))) {
+        Class<? extends RuleConfiguration> clazz = FEATURE_MAP.get(feature);
+        if (!(ruleConfiguration.getClass().getCanonicalName().equals(clazz.getCanonicalName()))) {
             dataMap.putIfAbsent(dataKey, buildRow(feature, type, DEFAULT_COUNT));
             return;
         }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterSQLParserRuleExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterSQLParserRuleExecutorTest.java
index cb86e65..f87af8d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterSQLParserRuleExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterSQLParserRuleExecutorTest.java
@@ -24,11 +24,12 @@ import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
 import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter.excutor.AlterSQLParserRuleExecutor;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatable.AlterSQLParserRuleHandler;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.junit.MockitoJUnitRunner;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.LinkedList;
 
@@ -44,11 +45,11 @@ import static org.mockito.Mockito.when;
 public final class AlterSQLParserRuleExecutorTest {
     
     @Test
-    public void assertExecuteWithoutCurrentRuleConfiguration() {
+    public void assertExecuteWithoutCurrentRuleConfiguration() throws SQLException {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().getConfigurations()).thenReturn(new LinkedList<>());
         ProxyContext.getInstance().init(contextManager);
-        new AlterSQLParserRuleExecutor(getSQLStatement()).execute();
+        new AlterSQLParserRuleHandler().initStatement(getSQLStatement()).execute();
         Collection<RuleConfiguration> globalRuleConfigurations = contextManager.getMetaDataContexts().getGlobalRuleMetaData().getConfigurations();
         RuleConfiguration ruleConfiguration = globalRuleConfigurations.stream().filter(configuration -> configuration instanceof SQLParserRuleConfiguration).findAny().orElse(null);
         assertNotNull(ruleConfiguration);
@@ -63,13 +64,13 @@ public final class AlterSQLParserRuleExecutorTest {
     }
     
     @Test
-    public void assertExecuteWithDefaultRuleConfiguration() {
+    public void assertExecuteWithDefaultRuleConfiguration() throws SQLException {
         Collection<RuleConfiguration> globalRuleConfiguration = new LinkedList<>();
         globalRuleConfiguration.add(new DefaultSQLParserRuleConfigurationBuilder().build());
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().getConfigurations()).thenReturn(globalRuleConfiguration);
         ProxyContext.getInstance().init(contextManager);
-        new AlterSQLParserRuleExecutor(getSQLStatement()).execute();
+        new AlterSQLParserRuleHandler().initStatement(getSQLStatement()).execute();
         Collection<RuleConfiguration> globalRuleConfigurations = contextManager.getMetaDataContexts().getGlobalRuleMetaData().getConfigurations();
         RuleConfiguration ruleConfiguration = globalRuleConfigurations.stream().filter(configuration -> configuration instanceof SQLParserRuleConfiguration).findAny().orElse(null);
         assertNotNull(ruleConfiguration);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterTrafficRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterTrafficRuleHandlerTest.java
index 223dc4c..545112f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterTrafficRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterTrafficRuleHandlerTest.java
@@ -22,12 +22,11 @@ import org.apache.shardingsphere.distsql.parser.segment.TrafficRuleSegment;
 import org.apache.shardingsphere.distsql.parser.statement.rdl.create.AlterTrafficRuleStatement;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
 import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
 import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter.excutor.AlterTrafficRuleExecutor;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatable.AlterTrafficRuleHandler;
 import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
 import org.apache.shardingsphere.traffic.api.config.TrafficStrategyConfiguration;
@@ -35,6 +34,7 @@ import org.apache.shardingsphere.traffic.spi.TrafficAlgorithm;
 import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
 import org.junit.Test;
 
+import java.sql.SQLException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -54,37 +54,37 @@ public class AlterTrafficRuleHandlerTest {
     }
     
     @Test(expected = RequiredRuleMissedException.class)
-    public void assertCheckWithEmptyRule() throws DistSQLException {
+    public void assertCheckWithEmptyRule() throws SQLException {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(new LinkedList<>());
         ProxyContext.getInstance().init(contextManager);
         TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("input_rule_name", Arrays.asList("olap", "order_by"),
                 new AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", new Properties()));
-        new AlterTrafficRuleExecutor(getSQLStatement(trafficRuleSegment)).execute();
+        new AlterTrafficRuleHandler().initStatement(getSQLStatement(trafficRuleSegment)).execute();
     }
     
     @Test(expected = InvalidAlgorithmConfigurationException.class)
-    public void assertCheckWithInvalidAlgorithmType() throws DistSQLException {
+    public void assertCheckWithInvalidAlgorithmType() throws SQLException {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
         ProxyContext.getInstance().init(contextManager);
         TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("rule_name_1", Arrays.asList("olap", "order_by"), 
                 new AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", new Properties()));
-        new AlterTrafficRuleExecutor(getSQLStatement(trafficRuleSegment)).execute();
+        new AlterTrafficRuleHandler().initStatement(getSQLStatement(trafficRuleSegment)).execute();
     }
     
     @Test(expected = RequiredRuleMissedException.class)
-    public void assertCheckWithNotExistRuleName() throws DistSQLException {
+    public void assertCheckWithNotExistRuleName() throws SQLException {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
         ProxyContext.getInstance().init(contextManager);
         TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("rule_name_3", Arrays.asList("olap", "order_by"), 
                 new AlgorithmSegment("TEST", new Properties()), new AlgorithmSegment("TEST", new Properties()));
-        new AlterTrafficRuleExecutor(getSQLStatement(trafficRuleSegment)).execute();
+        new AlterTrafficRuleHandler().initStatement(getSQLStatement(trafficRuleSegment)).execute();
     }
     
     @Test
-    public void assertCheckSuccess() throws DistSQLException {
+    public void assertCheckSuccess() throws SQLException {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
         ProxyContext.getInstance().init(contextManager);
@@ -92,7 +92,7 @@ public class AlterTrafficRuleHandlerTest {
                 new AlgorithmSegment("TEST", new Properties()), new AlgorithmSegment("TEST", new Properties()));
         TrafficRuleSegment trafficRuleSegment2 = new TrafficRuleSegment("rule_name_2", Collections.emptyList(),
                 new AlgorithmSegment("TEST", new Properties()), null);
-        new AlterTrafficRuleExecutor(getSQLStatement(trafficRuleSegment1, trafficRuleSegment2)).execute();
+        new AlterTrafficRuleHandler().initStatement(getSQLStatement(trafficRuleSegment1, trafficRuleSegment2)).execute();
     }
     
     private Collection<RuleConfiguration> createTrafficRule() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/create/CreateTrafficRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/create/CreateTrafficRuleHandlerTest.java
index 2f16763..5fb3d0e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/create/CreateTrafficRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/create/CreateTrafficRuleHandlerTest.java
@@ -22,11 +22,11 @@ import org.apache.shardingsphere.distsql.parser.segment.TrafficRuleSegment;
 import org.apache.shardingsphere.distsql.parser.statement.rdl.create.CreateTrafficRuleStatement;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
 import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
 import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatable.CreateTrafficRuleHandler;
 import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
 import org.apache.shardingsphere.traffic.api.config.TrafficStrategyConfiguration;
@@ -34,6 +34,7 @@ import org.apache.shardingsphere.traffic.spi.TrafficAlgorithm;
 import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
 import org.junit.Test;
 
+import java.sql.SQLException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -53,37 +54,37 @@ public class CreateTrafficRuleHandlerTest {
     }
     
     @Test(expected = InvalidAlgorithmConfigurationException.class)
-    public void assertCheckWithEmptyRuleAndInvalidAlgorithmType() throws DistSQLException {
+    public void assertCheckWithEmptyRuleAndInvalidAlgorithmType() throws SQLException {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(new LinkedList<>());
         ProxyContext.getInstance().init(contextManager);
         TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("input_rule_name", Arrays.asList("olap", "order_by"),
                 new AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", new Properties()));
-        new CreateTrafficRuleHandler(getSQLStatement(trafficRuleSegment)).execute();
+        new CreateTrafficRuleHandler().initStatement(getSQLStatement(trafficRuleSegment)).execute();
     }
     
     @Test(expected = InvalidAlgorithmConfigurationException.class)
-    public void assertCheckWithInvalidAlgorithmType() throws DistSQLException {
+    public void assertCheckWithInvalidAlgorithmType() throws SQLException {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
         ProxyContext.getInstance().init(contextManager);
         TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("input_rule_name", Arrays.asList("olap", "order_by"), 
                 new AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", new Properties()));
-        new CreateTrafficRuleHandler(getSQLStatement(trafficRuleSegment)).execute();
+        new CreateTrafficRuleHandler().initStatement(getSQLStatement(trafficRuleSegment)).execute();
     }
     
     @Test(expected = DuplicateRuleException.class)
-    public void assertCheckWithDuplicatedRuleName() throws DistSQLException {
+    public void assertCheckWithDuplicatedRuleName() throws SQLException {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
         ProxyContext.getInstance().init(contextManager);
         TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("rule_name_1", Arrays.asList("olap", "order_by"), 
                 new AlgorithmSegment("TEST", new Properties()), new AlgorithmSegment("TEST", new Properties()));
-        new CreateTrafficRuleHandler(getSQLStatement(trafficRuleSegment)).execute();
+        new CreateTrafficRuleHandler().initStatement(getSQLStatement(trafficRuleSegment)).execute();
     }
     
     @Test
-    public void assertCheckSuccess() throws DistSQLException {
+    public void assertCheckSuccess() throws SQLException {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
         ProxyContext.getInstance().init(contextManager);
@@ -91,7 +92,7 @@ public class CreateTrafficRuleHandlerTest {
                 new AlgorithmSegment("TEST", new Properties()), new AlgorithmSegment("TEST", new Properties()));
         TrafficRuleSegment trafficRuleSegment2 = new TrafficRuleSegment("rule_name_4", Collections.emptyList(),
                 new AlgorithmSegment("TEST", new Properties()), null);
-        new CreateTrafficRuleHandler(getSQLStatement(trafficRuleSegment1, trafficRuleSegment2)).execute();
+        new CreateTrafficRuleHandler().initStatement(getSQLStatement(trafficRuleSegment1, trafficRuleSegment2)).execute();
     }
     
     private Collection<RuleConfiguration> createTrafficRule() {