You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/05/01 03:29:31 UTC

[shardingsphere] branch master updated: Add TrafficAlgorithmFactory and TrafficLoadBalanceAlgorithmFactory (#17245)

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

zhonghongsheng 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 f11c983d808 Add TrafficAlgorithmFactory and TrafficLoadBalanceAlgorithmFactory (#17245)
f11c983d808 is described below

commit f11c983d808ff8851ab4e32b9a4ac1ed0cfc31ec
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun May 1 11:29:25 2022 +0800

    Add TrafficAlgorithmFactory and TrafficLoadBalanceAlgorithmFactory (#17245)
    
    * Add TrafficAlgorithmFactory
    
    * Add TrafficLoadBalanceAlgorithmFactory
---
 ...tabaseDiscoveryHeartbeatQueryResultSetTest.java |  3 +-
 ...scoveryProviderAlgorithmQueryResultSetTest.java |  3 +-
 .../DatabaseDiscoveryRuleQueryResultSetTest.java   |  3 +-
 .../generator/EncryptAlterTableTokenGenerator.java |  2 +-
 .../engine/condition/ShardingConditionsTest.java   |  5 +-
 .../DefaultShardingStrategyQueryResultSet.java     |  4 +-
 .../traffic/factory/TrafficAlgorithmFactory.java   | 59 ++++++++++++++++++
 .../TrafficLoadBalanceAlgorithmFactory.java        | 59 ++++++++++++++++++
 .../shardingsphere/traffic/rule/TrafficRule.java   | 13 ++--
 .../mysql/executor/NoResourceShowExecutor.java     |  2 +-
 .../common/updatable/AlterTrafficRuleHandler.java  | 53 ++++++++---------
 .../common/updatable/CreateTrafficRuleHandler.java | 69 +++++++++++-----------
 .../queryable/ShowInstanceModeHandlerTest.java     |  3 +-
 .../queryable/ShowTableMetadataHandlerTest.java    |  2 +-
 .../queryable/ShowTrafficRulesHandlerTest.java     |  3 +-
 .../queryable/ShowTransactionRuleHandlerTest.java  |  5 +-
 .../queryable/ShowVariableBackendHandlerTest.java  | 11 ++--
 .../updatable/AlterTrafficRuleHandlerTest.java     |  8 ---
 .../updatable/CreateTrafficRuleHandlerTest.java    |  8 ---
 19 files changed, 208 insertions(+), 107 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryHeartbeatQueryResultSetTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscover [...]
index b64316f061a..bab53d7cb44 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryHeartbeatQueryResultSetTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryHeartbeatQueryResultSetTest.java
@@ -31,6 +31,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
@@ -50,7 +51,7 @@ public final class DatabaseDiscoveryHeartbeatQueryResultSetTest {
         DistSQLResultSet resultSet = new DatabaseDiscoveryHeartbeatQueryResultSet();
         resultSet.init(metaData, mock(ShowDatabaseDiscoveryRulesStatement.class));
         Collection<String> columnNames = resultSet.getColumnNames();
-        ArrayList<Object> actual = new ArrayList<>(resultSet.getRowData());
+        List<Object> actual = new ArrayList<>(resultSet.getRowData());
         assertThat(columnNames.size(), is(2));
         assertThat(actual.size(), is(2));
         assertThat(actual.get(0), is("test_name"));
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryProviderAlgorithmQueryResultSetTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/Database [...]
index e3153797f69..f282311c867 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryProviderAlgorithmQueryResultSetTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryProviderAlgorithmQueryResultSetTest.java
@@ -31,6 +31,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
@@ -50,7 +51,7 @@ public final class DatabaseDiscoveryProviderAlgorithmQueryResultSetTest {
         DistSQLResultSet resultSet = new DatabaseDiscoveryTypeQueryResultSet();
         resultSet.init(metaData, mock(ShowDatabaseDiscoveryRulesStatement.class));
         Collection<String> columnNames = resultSet.getColumnNames();
-        ArrayList<Object> actual = new ArrayList<>(resultSet.getRowData());
+        List<Object> actual = new ArrayList<>(resultSet.getRowData());
         assertThat(columnNames.size(), is(3));
         assertThat(actual.size(), is(3));
         assertThat(actual.get(0), is("test_name"));
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRuleQueryResultSetTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRule [...]
index af9a0416954..aa7a89f8783 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRuleQueryResultSetTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRuleQueryResultSetTest.java
@@ -33,6 +33,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
@@ -55,7 +56,7 @@ public final class DatabaseDiscoveryRuleQueryResultSetTest {
         DistSQLResultSet resultSet = new DatabaseDiscoveryRuleQueryResultSet();
         resultSet.init(metaData, mock(ShowDatabaseDiscoveryRulesStatement.class));
         Collection<String> columnNames = resultSet.getColumnNames();
-        ArrayList<Object> actual = new ArrayList<>(resultSet.getRowData());
+        List<Object> actual = new ArrayList<>(resultSet.getRowData());
         assertThat(columnNames.size(), is(5));
         assertThat(columnNames.containsAll(Arrays.asList("group_name", "data_source_names", "primary_data_source_name", "discovery_type", "discovery_heartbeat")), is(true));
         assertThat(actual.size(), is(5));
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAlterTableTokenGenerator.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAlterTableTokenGenerator.java
index f14fb2f9ae3..3cc1c121e72 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAlterTableTokenGenerator.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAlterTableTokenGenerator.java
@@ -80,7 +80,7 @@ public final class EncryptAlterTableTokenGenerator implements CollectionSQLToken
     
     private Collection<SQLToken> mergeDropColumnStatement(final Collection<SQLToken> dropCollection, final String leftJoiner, final String rightJoiner) {
         Collection<SQLToken> result = new LinkedList<>();
-        ArrayList<String> dropColumnList = new ArrayList<>();
+        List<String> dropColumnList = new ArrayList<>();
         int lastStartIndex = -1;
         for (int i = 0; i < dropCollection.size(); i++) {
             SQLToken token = (SQLToken) ((List) dropCollection).get(i);
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/ShardingConditionsTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/ShardingConditionsTest.java
index 30b4fe4eb7b..e038c65e133 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/ShardingConditionsTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/ShardingConditionsTest.java
@@ -28,6 +28,7 @@ import org.mockito.junit.MockitoJUnitRunner;
 
 import java.util.Collections;
 import java.util.LinkedList;
+import java.util.List;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertFalse;
@@ -76,7 +77,7 @@ public final class ShardingConditionsTest {
     }
     
     private ShardingConditions createSingleShardingConditions() {
-        LinkedList<ShardingCondition> result = new LinkedList<>();
+        List<ShardingCondition> result = new LinkedList<>();
         ShardingConditionValue shardingConditionValue = new ListShardingConditionValue<>("order_id", "t_order", Collections.singleton(1L));
         AlwaysFalseShardingCondition shardingCondition = new AlwaysFalseShardingCondition();
         shardingCondition.getValues().add(shardingConditionValue);
@@ -86,7 +87,7 @@ public final class ShardingConditionsTest {
     }
     
     private ShardingConditions createMultipleShardingConditions() {
-        LinkedList<ShardingCondition> result = new LinkedList<>();
+        List<ShardingCondition> result = new LinkedList<>();
         ShardingConditionValue shardingConditionValue1 = new ListShardingConditionValue<>("user_id", "t_order", Collections.singleton(1L));
         ShardingConditionValue shardingConditionValue2 = new ListShardingConditionValue<>("order_id", "t_order", Collections.singleton(1L));
         ShardingCondition shardingCondition = new ShardingCondition();
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/DefaultShardingStrategyQueryResultSet.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/DefaultShardingStrategyQueryResultSet.java
index 2eabd5fff13..29b7dd44410 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/DefaultShardingStrategyQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/DefaultShardingStrategyQueryResultSet.java
@@ -45,8 +45,8 @@ public final class DefaultShardingStrategyQueryResultSet implements DistSQLResul
     
     @Override
     public void init(final ShardingSphereMetaData metaData, final SQLStatement sqlStatement) {
-        Optional<ShardingRuleConfiguration> shardingRuleConfiguration = metaData.getRuleMetaData().findRuleConfiguration(ShardingRuleConfiguration.class).stream().findAny();
-        shardingRuleConfiguration.ifPresent(op -> data = buildData(op).entrySet().iterator());
+        Optional<ShardingRuleConfiguration> shardingRuleConfig = metaData.getRuleMetaData().findRuleConfiguration(ShardingRuleConfiguration.class).stream().findAny();
+        shardingRuleConfig.ifPresent(optional -> data = buildData(optional).entrySet().iterator());
     }
     
     private Map<String, LinkedList<Object>> buildData(final ShardingRuleConfiguration ruleConfiguration) {
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficAlgorithmFactory.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficAlgorithmFactory.java
new file mode 100644
index 00000000000..5cbfb01aa31
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficAlgorithmFactory.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.traffic.factory;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmFactory;
+import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
+import org.apache.shardingsphere.traffic.spi.TrafficAlgorithm;
+
+import java.util.Properties;
+
+/**
+ * Traffic algorithm factory.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class TrafficAlgorithmFactory {
+    
+    static {
+        ShardingSphereServiceLoader.register(TrafficAlgorithm.class);
+    }
+    
+    /**
+     * Create new instance of traffic algorithm.
+     * 
+     * @param trafficAlgorithmConfig traffic algorithm configuration
+     * @return new instance of traffic algorithm
+     */
+    public static TrafficAlgorithm newInstance(final ShardingSphereAlgorithmConfiguration trafficAlgorithmConfig) {
+        return ShardingSphereAlgorithmFactory.createAlgorithm(trafficAlgorithmConfig, TrafficAlgorithm.class);
+    }
+    
+    /**
+     * Judge whether contains traffic algorithm.
+     *
+     * @param trafficAlgorithmType traffic algorithm type
+     * @return contains traffic algorithm or not
+     */
+    public static boolean contains(final String trafficAlgorithmType) {
+        return TypedSPIRegistry.findRegisteredService(TrafficAlgorithm.class, trafficAlgorithmType, new Properties()).isPresent();
+    }
+}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactory.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactory.java
new file mode 100644
index 00000000000..e4f76021536
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactory.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.traffic.factory;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmFactory;
+import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
+import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
+
+import java.util.Properties;
+
+/**
+ * Traffic load balance algorithm factory.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class TrafficLoadBalanceAlgorithmFactory {
+    
+    static {
+        ShardingSphereServiceLoader.register(TrafficLoadBalanceAlgorithm.class);
+    }
+    
+    /**
+     * Create new instance of traffic load balance algorithm.
+     * 
+     * @param trafficLoadBalanceAlgorithmConfig traffic load balance algorithm configuration
+     * @return new instance of traffic load balance algorithm
+     */
+    public static TrafficLoadBalanceAlgorithm newInstance(final ShardingSphereAlgorithmConfiguration trafficLoadBalanceAlgorithmConfig) {
+        return ShardingSphereAlgorithmFactory.createAlgorithm(trafficLoadBalanceAlgorithmConfig, TrafficLoadBalanceAlgorithm.class);
+    }
+    
+    /**
+     * Judge whether contains traffic load balance algorithm.
+     *
+     * @param trafficLoadBalanceAlgorithmType traffic load balance algorithm type
+     * @return contains traffic load balance algorithm or not
+     */
+    public static boolean contains(final String trafficLoadBalanceAlgorithmType) {
+        return TypedSPIRegistry.findRegisteredService(TrafficLoadBalanceAlgorithm.class, trafficLoadBalanceAlgorithmType, new Properties()).isPresent();
+    }
+}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/rule/TrafficRule.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/rule/TrafficRule.java
index 1e78d42fd2b..7a9435f519e 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/rule/TrafficRule.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/rule/TrafficRule.java
@@ -22,10 +22,8 @@ import lombok.Getter;
 import org.apache.shardingsphere.infra.binder.LogicSQL;
 import org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContext;
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmFactory;
 import org.apache.shardingsphere.infra.hint.SQLHintProperties;
 import org.apache.shardingsphere.infra.rule.identifier.scope.GlobalRule;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
 import org.apache.shardingsphere.traffic.api.config.TrafficStrategyConfiguration;
@@ -36,6 +34,8 @@ import org.apache.shardingsphere.traffic.api.traffic.segment.SegmentTrafficAlgor
 import org.apache.shardingsphere.traffic.api.traffic.segment.SegmentTrafficValue;
 import org.apache.shardingsphere.traffic.api.traffic.transaction.TransactionTrafficAlgorithm;
 import org.apache.shardingsphere.traffic.api.traffic.transaction.TransactionTrafficValue;
+import org.apache.shardingsphere.traffic.factory.TrafficAlgorithmFactory;
+import org.apache.shardingsphere.traffic.factory.TrafficLoadBalanceAlgorithmFactory;
 import org.apache.shardingsphere.traffic.spi.TrafficAlgorithm;
 import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
 
@@ -55,11 +55,6 @@ import java.util.Properties;
  */
 public final class TrafficRule implements GlobalRule {
     
-    static {
-        ShardingSphereServiceLoader.register(TrafficAlgorithm.class);
-        ShardingSphereServiceLoader.register(TrafficLoadBalanceAlgorithm.class);
-    }
-    
     @Getter
     private final Collection<TrafficStrategyRule> strategyRules;
     
@@ -72,7 +67,7 @@ public final class TrafficRule implements GlobalRule {
     private Map<String, TrafficAlgorithm> createTrafficAlgorithms(final Map<String, ShardingSphereAlgorithmConfiguration> trafficAlgorithms) {
         Map<String, TrafficAlgorithm> result = new LinkedHashMap<>();
         for (Entry<String, ShardingSphereAlgorithmConfiguration> entry : trafficAlgorithms.entrySet()) {
-            result.put(entry.getKey(), ShardingSphereAlgorithmFactory.createAlgorithm(entry.getValue(), TrafficAlgorithm.class));
+            result.put(entry.getKey(), TrafficAlgorithmFactory.newInstance(entry.getValue()));
         }
         return result;
     }
@@ -80,7 +75,7 @@ public final class TrafficRule implements GlobalRule {
     private Map<String, TrafficLoadBalanceAlgorithm> createTrafficLoadBalanceAlgorithms(final Map<String, ShardingSphereAlgorithmConfiguration> loadBalancers) {
         Map<String, TrafficLoadBalanceAlgorithm> result = new LinkedHashMap<>();
         for (Entry<String, ShardingSphereAlgorithmConfiguration> entry : loadBalancers.entrySet()) {
-            result.put(entry.getKey(), ShardingSphereAlgorithmFactory.createAlgorithm(entry.getValue(), TrafficLoadBalanceAlgorithm.class));
+            result.put(entry.getKey(), TrafficLoadBalanceAlgorithmFactory.newInstance(entry.getValue()));
         }
         return result;
     }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/NoResourceShowExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/NoResourceShowExecutor.java
index 6c896c02ed3..8997aa85431 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/NoResourceShowExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/NoResourceShowExecutor.java
@@ -71,7 +71,7 @@ public final class NoResourceShowExecutor implements DatabaseAdminQueryExecutor
             rows.add(new MemoryQueryResultDataRow(Collections.singletonList("")));
             return new RawMemoryQueryResult(getQueryResultMetaData(), rows);
         }
-        ArrayList<Object> row = new ArrayList<>(expressions);
+        List<Object> row = new ArrayList<>(expressions);
         row.replaceAll(each -> "");
         rows.add(new MemoryQueryResultDataRow(row));
         return new RawMemoryQueryResult(getQueryResultMetaData(), rows);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandler.java
index 728b6a8c063..01a9b8f9fb3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandler.java
@@ -28,16 +28,14 @@ import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 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.type.typed.TypedSPIRegistry;
 import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
 import org.apache.shardingsphere.traffic.api.config.TrafficStrategyConfiguration;
-import org.apache.shardingsphere.traffic.spi.TrafficAlgorithm;
-import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
+import org.apache.shardingsphere.traffic.factory.TrafficAlgorithmFactory;
+import org.apache.shardingsphere.traffic.factory.TrafficLoadBalanceAlgorithmFactory;
 
-import java.util.ArrayList;
 import java.util.Collection;
+import java.util.LinkedList;
 import java.util.Optional;
-import java.util.Properties;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -48,50 +46,49 @@ public final class AlterTrafficRuleHandler extends UpdatableRALBackendHandler<Al
     
     @Override
     protected void update(final ContextManager contextManager, final AlterTrafficRuleStatement sqlStatement) throws DistSQLException {
-        Optional<TrafficRuleConfiguration> currentConfiguration = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData()
+        Optional<TrafficRuleConfiguration> currentConfig = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData()
                 .findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
-        check(sqlStatement, currentConfiguration);
-        TrafficRuleConfiguration toBeAlteredConfiguration = TrafficRuleConverter.convert(sqlStatement.getSegments());
-        updateToRepository(toBeAlteredConfiguration, currentConfiguration.get());
+        DistSQLException.predictionThrow(currentConfig.isPresent(), () -> new RequiredRuleMissedException("Traffic"));
+        check(sqlStatement, currentConfig.get());
+        TrafficRuleConfiguration toBeAlteredConfig = TrafficRuleConverter.convert(sqlStatement.getSegments());
+        updateToRepository(toBeAlteredConfig, currentConfig.get());
     }
     
-    private void check(final AlterTrafficRuleStatement sqlStatement, final Optional<TrafficRuleConfiguration> currentConfiguration) throws DistSQLException {
-        DistSQLException.predictionThrow(currentConfiguration.isPresent(), () -> new RequiredRuleMissedException("Traffic"));
-        Collection<String> currentRuleNames = currentConfiguration.get().getTrafficStrategies().stream().map(TrafficStrategyConfiguration::getName).collect(Collectors.toSet());
+    private void check(final AlterTrafficRuleStatement sqlStatement, final TrafficRuleConfiguration currentConfig) throws DistSQLException {
+        Collection<String> currentRuleNames = currentConfig.getTrafficStrategies().stream().map(TrafficStrategyConfiguration::getName).collect(Collectors.toSet());
         Set<String> notExistRuleNames = sqlStatement.getSegments().stream().map(TrafficRuleSegment::getName).filter(each -> !currentRuleNames.contains(each)).collect(Collectors.toSet());
         DistSQLException.predictionThrow(notExistRuleNames.isEmpty(), () -> new RequiredRuleMissedException("Traffic", notExistRuleNames));
-        Collection<String> invalidAlgorithmNames = getInvalidAlgorithmNames(sqlStatement.getSegments());
+        Collection<String> invalidAlgorithmNames = getInvalidAlgorithmNames();
         DistSQLException.predictionThrow(invalidAlgorithmNames.isEmpty(), () -> new InvalidAlgorithmConfigurationException("traffic", invalidAlgorithmNames));
     }
     
-    private Collection<String> getInvalidAlgorithmNames(final Collection<TrafficRuleSegment> segments) {
-        Collection<String> result = new ArrayList<>(segments.size());
+    private Collection<String> getInvalidAlgorithmNames() {
+        Collection<String> result = new LinkedList<>();
         sqlStatement.getSegments().forEach(each -> {
-            if (!TypedSPIRegistry.findRegisteredService(TrafficAlgorithm.class, each.getAlgorithm().getName(), new Properties()).isPresent()) {
+            if (!TrafficAlgorithmFactory.contains(each.getAlgorithm().getName())) {
                 result.add(each.getAlgorithm().getName());
             }
-            if (null != each.getLoadBalancer()
-                    && !TypedSPIRegistry.findRegisteredService(TrafficLoadBalanceAlgorithm.class, each.getLoadBalancer().getName(), new Properties()).isPresent()) {
+            if (null != each.getLoadBalancer() && !TrafficLoadBalanceAlgorithmFactory.contains(each.getLoadBalancer().getName())) {
                 result.add(each.getLoadBalancer().getName());
             }
         });
         return result;
     }
     
-    private void updateToRepository(final TrafficRuleConfiguration toBeAlteredConfiguration, final TrafficRuleConfiguration currentConfiguration) {
-        Collection<String> toBeAlteredConfigurationNames = toBeAlteredConfiguration.getTrafficStrategies().stream().map(TrafficStrategyConfiguration::getName).collect(Collectors.toSet());
-        currentConfiguration.getTrafficStrategies().removeIf(each -> toBeAlteredConfigurationNames.contains(each.getName()));
-        currentConfiguration.getTrafficStrategies().addAll(toBeAlteredConfiguration.getTrafficStrategies());
-        currentConfiguration.getTrafficAlgorithms().putAll(toBeAlteredConfiguration.getTrafficAlgorithms());
-        currentConfiguration.getLoadBalancers().putAll(toBeAlteredConfiguration.getLoadBalancers());
-        getUnusedLoadBalancer(currentConfiguration).forEach(each -> currentConfiguration.getLoadBalancers().remove(each));
+    private void updateToRepository(final TrafficRuleConfiguration toBeAlteredConfig, final TrafficRuleConfiguration currentConfig) {
+        Collection<String> toBeAlteredConfigNames = toBeAlteredConfig.getTrafficStrategies().stream().map(TrafficStrategyConfiguration::getName).collect(Collectors.toSet());
+        currentConfig.getTrafficStrategies().removeIf(each -> toBeAlteredConfigNames.contains(each.getName()));
+        currentConfig.getTrafficStrategies().addAll(toBeAlteredConfig.getTrafficStrategies());
+        currentConfig.getTrafficAlgorithms().putAll(toBeAlteredConfig.getTrafficAlgorithms());
+        currentConfig.getLoadBalancers().putAll(toBeAlteredConfig.getLoadBalancers());
+        getUnusedLoadBalancer(currentConfig).forEach(each -> currentConfig.getLoadBalancers().remove(each));
         MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
         Optional<MetaDataPersistService> metaDataPersistService = metaDataContexts.getMetaDataPersistService();
         metaDataPersistService.ifPresent(op -> op.getGlobalRuleService().persist(metaDataContexts.getGlobalRuleMetaData().getConfigurations(), true));
     }
     
-    private Collection<String> getUnusedLoadBalancer(final TrafficRuleConfiguration configuration) {
-        Collection<String> currentlyInUse = configuration.getTrafficStrategies().stream().map(TrafficStrategyConfiguration::getLoadBalancerName).collect(Collectors.toSet());
-        return configuration.getLoadBalancers().keySet().stream().filter(each -> !currentlyInUse.contains(each)).collect(Collectors.toSet());
+    private Collection<String> getUnusedLoadBalancer(final TrafficRuleConfiguration config) {
+        Collection<String> currentlyInUse = config.getTrafficStrategies().stream().map(TrafficStrategyConfiguration::getLoadBalancerName).collect(Collectors.toSet());
+        return config.getLoadBalancers().keySet().stream().filter(each -> !currentlyInUse.contains(each)).collect(Collectors.toSet());
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandler.java
index 62dbd48e5cb..62132bb78a6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandler.java
@@ -29,16 +29,14 @@ import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 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.type.typed.TypedSPIRegistry;
 import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
 import org.apache.shardingsphere.traffic.api.config.TrafficStrategyConfiguration;
-import org.apache.shardingsphere.traffic.spi.TrafficAlgorithm;
-import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
+import org.apache.shardingsphere.traffic.factory.TrafficAlgorithmFactory;
+import org.apache.shardingsphere.traffic.factory.TrafficLoadBalanceAlgorithmFactory;
 
-import java.util.ArrayList;
 import java.util.Collection;
+import java.util.LinkedList;
 import java.util.Optional;
-import java.util.Properties;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -49,48 +47,49 @@ public final class CreateTrafficRuleHandler extends UpdatableRALBackendHandler<C
     
     @Override
     protected void update(final ContextManager contextManager, final CreateTrafficRuleStatement sqlStatement) throws DistSQLException {
-        Optional<TrafficRuleConfiguration> trafficRuleConfiguration = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData()
+        Optional<TrafficRuleConfiguration> trafficRuleConfig = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData()
                 .findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
-        check(sqlStatement, trafficRuleConfiguration);
-        TrafficRuleConfiguration toBeCreatedConfiguration = TrafficRuleConverter.convert(sqlStatement.getSegments());
-        updateToRepository(toBeCreatedConfiguration, trafficRuleConfiguration);
+        if (trafficRuleConfig.isPresent()) {
+            checkTrafficRuleConfiguration(sqlStatement, trafficRuleConfig.get());
+        }
+        checkInvalidAlgorithmNames();
+        updateToRepository(TrafficRuleConverter.convert(sqlStatement.getSegments()), trafficRuleConfig.orElse(null));
     }
     
-    private void check(final CreateTrafficRuleStatement sqlStatement, final Optional<TrafficRuleConfiguration> trafficRuleConfiguration) throws DistSQLException {
-        if (trafficRuleConfiguration.isPresent()) {
-            Collection<String> currentRuleNames = trafficRuleConfiguration.get().getTrafficStrategies().stream().map(TrafficStrategyConfiguration::getName).collect(Collectors.toSet());
-            Set<String> duplicatedRuleNames = sqlStatement.getSegments().stream().map(TrafficRuleSegment::getName).filter(currentRuleNames::contains).collect(Collectors.toSet());
-            DistSQLException.predictionThrow(duplicatedRuleNames.isEmpty(), () -> new DuplicateRuleException("traffic", duplicatedRuleNames));
-        }
-        Collection<String> invalidAlgorithmNames = getInvalidAlgorithmNames(sqlStatement.getSegments());
-        DistSQLException.predictionThrow(invalidAlgorithmNames.isEmpty(), () -> new InvalidAlgorithmConfigurationException("traffic", invalidAlgorithmNames));
+    private void checkTrafficRuleConfiguration(final CreateTrafficRuleStatement sqlStatement, final TrafficRuleConfiguration trafficRuleConfig) throws DistSQLException {
+        Collection<String> currentRuleNames = trafficRuleConfig.getTrafficStrategies().stream().map(TrafficStrategyConfiguration::getName).collect(Collectors.toSet());
+        Set<String> duplicatedRuleNames = sqlStatement.getSegments().stream().map(TrafficRuleSegment::getName).filter(currentRuleNames::contains).collect(Collectors.toSet());
+        DistSQLException.predictionThrow(duplicatedRuleNames.isEmpty(), () -> new DuplicateRuleException("traffic", duplicatedRuleNames));
     }
     
-    private Collection<String> getInvalidAlgorithmNames(final Collection<TrafficRuleSegment> segments) {
-        Collection<String> result = new ArrayList<>(segments.size());
-        sqlStatement.getSegments().forEach(each -> {
-            if (!TypedSPIRegistry.findRegisteredService(TrafficAlgorithm.class, each.getAlgorithm().getName(), new Properties()).isPresent()) {
-                result.add(each.getAlgorithm().getName());
+    private void checkInvalidAlgorithmNames() throws DistSQLException {
+        Collection<String> invalidAlgorithmNames = new LinkedList<>();
+        for (TrafficRuleSegment each : sqlStatement.getSegments()) {
+            if (!TrafficAlgorithmFactory.contains(each.getAlgorithm().getName())) {
+                invalidAlgorithmNames.add(each.getAlgorithm().getName());
             }
-            if (null != each.getLoadBalancer()
-                    && !TypedSPIRegistry.findRegisteredService(TrafficLoadBalanceAlgorithm.class, each.getLoadBalancer().getName(), new Properties()).isPresent()) {
-                result.add(each.getLoadBalancer().getName());
+            if (null != each.getLoadBalancer() && !TrafficLoadBalanceAlgorithmFactory.contains(each.getLoadBalancer().getName())) {
+                invalidAlgorithmNames.add(each.getLoadBalancer().getName());
             }
-        });
-        return result;
+        }
+        DistSQLException.predictionThrow(invalidAlgorithmNames.isEmpty(), () -> new InvalidAlgorithmConfigurationException("traffic", invalidAlgorithmNames));
     }
     
-    private void updateToRepository(final TrafficRuleConfiguration toBeCreatedRuleConfiguration, final Optional<TrafficRuleConfiguration> currentRuleConfiguration) {
+    private void updateToRepository(final TrafficRuleConfiguration toBeCreatedRuleConfig, final TrafficRuleConfiguration currentRuleConfig) {
         MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
-        Collection<RuleConfiguration> globalRuleConfigurations = metaDataContexts.getGlobalRuleMetaData().getConfigurations();
-        if (currentRuleConfiguration.isPresent()) {
-            currentRuleConfiguration.get().getTrafficStrategies().addAll(toBeCreatedRuleConfiguration.getTrafficStrategies());
-            currentRuleConfiguration.get().getTrafficAlgorithms().putAll(toBeCreatedRuleConfiguration.getTrafficAlgorithms());
-            currentRuleConfiguration.get().getLoadBalancers().putAll(toBeCreatedRuleConfiguration.getLoadBalancers());
+        Collection<RuleConfiguration> globalRuleConfigs = metaDataContexts.getGlobalRuleMetaData().getConfigurations();
+        if (null == currentRuleConfig) {
+            globalRuleConfigs.add(toBeCreatedRuleConfig);
         } else {
-            globalRuleConfigurations.add(toBeCreatedRuleConfiguration);
+            setUpCurrentRuleConfiguration(toBeCreatedRuleConfig, currentRuleConfig);
         }
         Optional<MetaDataPersistService> metaDataPersistService = metaDataContexts.getMetaDataPersistService();
-        metaDataPersistService.ifPresent(op -> op.getGlobalRuleService().persist(globalRuleConfigurations, true));
+        metaDataPersistService.ifPresent(optional -> optional.getGlobalRuleService().persist(globalRuleConfigs, true));
+    }
+    
+    private void setUpCurrentRuleConfiguration(final TrafficRuleConfiguration toBeCreatedRuleConfig, final TrafficRuleConfiguration currentRuleConfig) {
+        currentRuleConfig.getTrafficStrategies().addAll(toBeCreatedRuleConfig.getTrafficStrategies());
+        currentRuleConfig.getTrafficAlgorithms().putAll(toBeCreatedRuleConfig.getTrafficAlgorithms());
+        currentRuleConfig.getLoadBalancers().putAll(toBeCreatedRuleConfig.getLoadBalancers());
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java
index 117cb5fa765..984436d8970 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java
@@ -27,6 +27,7 @@ import org.junit.Test;
 
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -46,7 +47,7 @@ public final class ShowInstanceModeHandlerTest {
         ProxyContext.getInstance().init(contextManager);
         handler.execute();
         handler.next();
-        ArrayList<Object> data = new ArrayList<>(handler.getRowData());
+        List<Object> data = new ArrayList<>(handler.getRowData());
         assertThat(data.size(), is(5));
         assertThat(data.get(0), is("127.0.0.1@3309"));
         assertThat(data.get(1), is("Cluster"));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTableMetadataHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTableMetadataHandlerTest.java
index c9db12ccc28..f7d9ec67ec9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTableMetadataHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTableMetadataHandlerTest.java
@@ -60,7 +60,7 @@ public final class ShowTableMetadataHandlerTest {
         ShowTableMetadataHandler handler = new ShowTableMetadataHandler().init(getParameter(createSqlStatement(), connectionSession));
         handler.execute();
         handler.next();
-        ArrayList<Object> data = new ArrayList<>(handler.getRowData());
+        List<Object> data = new ArrayList<>(handler.getRowData());
         assertThat(data.size(), is(4));
         assertThat(data.get(0), is("db_name"));
         assertThat(data.get(1), is("t_order"));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java
index 83adeb8d675..3b0f7b3871a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java
@@ -31,6 +31,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -52,7 +53,7 @@ public class ShowTrafficRulesHandlerTest {
         ProxyContext.getInstance().init(contextManager);
         handler.execute();
         handler.next();
-        ArrayList<Object> data = new ArrayList<>(handler.getRowData());
+        List<Object> data = new ArrayList<>(handler.getRowData());
         assertThat(data.size(), is(6));
         assertThat(data.get(0), is("rule_name_1"));
         assertThat(data.get(1), is("olap,order_by"));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java
index 324d758a5ee..5e3ae8126bb 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java
@@ -28,6 +28,7 @@ import org.junit.Test;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.List;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.containsString;
@@ -48,7 +49,7 @@ public final class ShowTransactionRuleHandlerTest {
         ProxyContext.getInstance().init(contextManager);
         handler.execute();
         handler.next();
-        ArrayList<Object> data = new ArrayList<>(handler.getRowData());
+        List<Object> data = new ArrayList<>(handler.getRowData());
         assertThat(data.size(), is(3));
         assertThat(data.get(0), is("XA"));
         assertThat(data.get(1), is("Atomikos"));
@@ -64,7 +65,7 @@ public final class ShowTransactionRuleHandlerTest {
         ProxyContext.getInstance().init(contextManager);
         handler.execute();
         handler.next();
-        ArrayList<Object> data = new ArrayList<>(handler.getRowData());
+        List<Object> data = new ArrayList<>(handler.getRowData());
         assertThat(data.size(), is(3));
         assertThat(data.get(0), is("LOCAL"));
         assertThat(data.get(1), is(""));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowVariableBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowVariableBackendHandlerTest.java
index bcda9a6364c..9001e44b9ac 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowVariableBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowVariableBackendHandlerTest.java
@@ -39,6 +39,7 @@ import org.junit.Test;
 
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
@@ -71,7 +72,7 @@ public final class ShowVariableBackendHandlerTest {
         assertThat(actual, instanceOf(QueryResponseHeader.class));
         assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(2));
         backendHandler.next();
-        ArrayList<Object> rowData = new ArrayList<>(backendHandler.getRowData());
+        List<Object> rowData = new ArrayList<>(backendHandler.getRowData());
         assertThat(rowData.get(0), is("transaction_type"));
         assertThat(rowData.get(1), is("LOCAL"));
     }
@@ -85,7 +86,7 @@ public final class ShowVariableBackendHandlerTest {
         assertThat(actual, instanceOf(QueryResponseHeader.class));
         assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(2));
         backendHandler.next();
-        ArrayList<Object> rowData = new ArrayList<>(backendHandler.getRowData());
+        List<Object> rowData = new ArrayList<>(backendHandler.getRowData());
         assertThat(rowData.get(0), is("cached_connections"));
         assertThat(rowData.get(1), is("0"));
     }
@@ -108,7 +109,7 @@ public final class ShowVariableBackendHandlerTest {
         assertThat(actual, instanceOf(QueryResponseHeader.class));
         assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(2));
         backendHandler.next();
-        ArrayList<Object> rowData = new ArrayList<>(backendHandler.getRowData());
+        List<Object> rowData = new ArrayList<>(backendHandler.getRowData());
         assertThat(rowData.get(0), is("agent_plugins_enabled"));
         assertThat(rowData.get(1), is(Boolean.TRUE.toString()));
     }
@@ -130,7 +131,7 @@ public final class ShowVariableBackendHandlerTest {
         assertThat(actual, instanceOf(QueryResponseHeader.class));
         assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(2));
         backendHandler.next();
-        ArrayList<Object> rowData = new ArrayList<>(backendHandler.getRowData());
+        List<Object> rowData = new ArrayList<>(backendHandler.getRowData());
         assertThat(rowData.get(0), is("sql_show"));
         assertThat(rowData.get(1), is(Boolean.TRUE.toString()));
     }
@@ -149,7 +150,7 @@ public final class ShowVariableBackendHandlerTest {
         assertThat(actual, instanceOf(QueryResponseHeader.class));
         assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(2));
         backendHandler.next();
-        ArrayList<Object> rowData = new ArrayList<>(backendHandler.getRowData());
+        List<Object> rowData = new ArrayList<>(backendHandler.getRowData());
         assertThat(rowData.get(0), is("sql_show"));
         assertThat(rowData.get(1), is(Boolean.FALSE.toString()));
     }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java
index b7d572d5118..500b06f81ef 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java
@@ -26,11 +26,8 @@ import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmCo
 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.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
 import org.apache.shardingsphere.traffic.api.config.TrafficStrategyConfiguration;
-import org.apache.shardingsphere.traffic.spi.TrafficAlgorithm;
-import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
 import org.junit.Test;
 
 import java.sql.SQLException;
@@ -47,11 +44,6 @@ import static org.mockito.Mockito.when;
 
 public final class AlterTrafficRuleHandlerTest {
     
-    static {
-        ShardingSphereServiceLoader.register(TrafficAlgorithm.class);
-        ShardingSphereServiceLoader.register(TrafficLoadBalanceAlgorithm.class);
-    }
-    
     @Test(expected = RequiredRuleMissedException.class)
     public void assertCheckWithEmptyRule() throws SQLException {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java
index ce412556fc7..9b7b60fc945 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java
@@ -26,11 +26,8 @@ import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleExcep
 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.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
 import org.apache.shardingsphere.traffic.api.config.TrafficStrategyConfiguration;
-import org.apache.shardingsphere.traffic.spi.TrafficAlgorithm;
-import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
 import org.junit.Test;
 
 import java.sql.SQLException;
@@ -47,11 +44,6 @@ import static org.mockito.Mockito.when;
 
 public final class CreateTrafficRuleHandlerTest {
     
-    static {
-        ShardingSphereServiceLoader.register(TrafficAlgorithm.class);
-        ShardingSphereServiceLoader.register(TrafficLoadBalanceAlgorithm.class);
-    }
-    
     @Test(expected = InvalidAlgorithmConfigurationException.class)
     public void assertCheckWithEmptyRuleAndInvalidAlgorithmType() throws SQLException {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);