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 956bfb8f757 Add SQLRouter.getType() (#34012)
956bfb8f757 is described below
commit 956bfb8f7579b41833e2b560fc7e37ffdc44c35d
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Dec 11 20:02:13 2024 +0800
Add SQLRouter.getType() (#34012)
* Add SQLRouter.getType()
* Add SQLRouter.getType()
---
.../broadcast/route/BroadcastSQLRouter.java | 10 +++++---
.../route/ReadwriteSplittingSQLRouter.java | 10 +++++---
.../shadow/route/ShadowSQLRouter.java | 10 +++++---
.../sharding/route/engine/ShardingSQLRouter.java | 10 +++++---
.../shardingsphere/infra/route/SQLRouter.java | 17 ++++++++++++-
.../infra/route/engine/SQLRouteEngine.java | 19 +++++++-------
.../{type => lifecycle}/DecorateSQLRouter.java | 4 +--
.../{type => lifecycle}/EntranceSQLRouter.java | 4 +--
.../infra/route/type/DataSourceSQLRouter.java | 29 ----------------------
.../infra/route/type/TableSQLRouter.java | 29 ----------------------
...e.java => DataNodeSQLRouterFailureFixture.java} | 10 +++++---
...rFixture.java => DataNodeSQLRouterFixture.java} | 12 ++++++---
.../fixture/router/DataSourceSQLRouterFixture.java | 12 ++++++---
...org.apache.shardingsphere.infra.route.SQLRouter | 4 +--
.../single/route/SingleSQLRouter.java | 12 ++++++---
15 files changed, 90 insertions(+), 102 deletions(-)
diff --git
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/BroadcastSQLRouter.java
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/BroadcastSQLRouter.java
index e9926f0b89b..108609b2083 100644
---
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/BroadcastSQLRouter.java
+++
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/BroadcastSQLRouter.java
@@ -25,8 +25,7 @@ import
org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.infra.route.context.RouteContext;
-import org.apache.shardingsphere.infra.route.type.EntranceSQLRouter;
-import org.apache.shardingsphere.infra.route.type.TableSQLRouter;
+import org.apache.shardingsphere.infra.route.lifecycle.EntranceSQLRouter;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import java.util.Collection;
@@ -35,7 +34,7 @@ import java.util.Collection;
* Broadcast SQL router.
*/
@HighFrequencyInvocation
-public final class BroadcastSQLRouter implements
EntranceSQLRouter<BroadcastRule>, TableSQLRouter<BroadcastRule> {
+public final class BroadcastSQLRouter implements
EntranceSQLRouter<BroadcastRule> {
@Override
public RouteContext createRouteContext(final QueryContext queryContext,
final RuleMetaData globalRuleMetaData, final ShardingSphereDatabase database,
@@ -47,6 +46,11 @@ public final class BroadcastSQLRouter implements
EntranceSQLRouter<BroadcastRule
return BroadcastRouteEngineFactory.newInstance(queryContext,
broadcastTableNames).route(rule);
}
+ @Override
+ public Type getType() {
+ return Type.DATA_NODE;
+ }
+
@Override
public int getOrder() {
return BroadcastOrder.ORDER;
diff --git
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/route/ReadwriteSplittingSQLRouter.java
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/route/ReadwriteSplittingSQLRouter.java
index ece2708b683..d872b027037 100644
---
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/route/ReadwriteSplittingSQLRouter.java
+++
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/route/ReadwriteSplittingSQLRouter.java
@@ -23,8 +23,7 @@ import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteMapper;
import org.apache.shardingsphere.infra.route.context.RouteUnit;
-import org.apache.shardingsphere.infra.route.type.DataSourceSQLRouter;
-import org.apache.shardingsphere.infra.route.type.DecorateSQLRouter;
+import org.apache.shardingsphere.infra.route.lifecycle.DecorateSQLRouter;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import
org.apache.shardingsphere.readwritesplitting.constant.ReadwriteSplittingOrder;
import
org.apache.shardingsphere.readwritesplitting.rule.ReadwriteSplittingRule;
@@ -36,7 +35,7 @@ import java.util.LinkedList;
* Readwrite-splitting SQL router.
*/
@HighFrequencyInvocation
-public final class ReadwriteSplittingSQLRouter implements
DecorateSQLRouter<ReadwriteSplittingRule>,
DataSourceSQLRouter<ReadwriteSplittingRule> {
+public final class ReadwriteSplittingSQLRouter implements
DecorateSQLRouter<ReadwriteSplittingRule> {
@Override
public void decorateRouteContext(final RouteContext routeContext, final
QueryContext queryContext, final ShardingSphereDatabase database,
@@ -56,6 +55,11 @@ public final class ReadwriteSplittingSQLRouter implements
DecorateSQLRouter<Read
routeContext.getRouteUnits().addAll(toBeAdded);
}
+ @Override
+ public Type getType() {
+ return Type.DATA_SOURCE;
+ }
+
@Override
public int getOrder() {
return ReadwriteSplittingOrder.ORDER;
diff --git
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java
index adb914fd2a5..61bb68455ba 100644
---
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java
+++
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java
@@ -20,11 +20,10 @@ package org.apache.shardingsphere.shadow.route;
import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.route.type.DataSourceSQLRouter;
-import org.apache.shardingsphere.infra.route.type.DecorateSQLRouter;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteMapper;
import org.apache.shardingsphere.infra.route.context.RouteUnit;
+import org.apache.shardingsphere.infra.route.lifecycle.DecorateSQLRouter;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import org.apache.shardingsphere.shadow.constant.ShadowOrder;
import
org.apache.shardingsphere.shadow.route.retriever.ShadowDataSourceMappingsRetrieverFactory;
@@ -39,7 +38,7 @@ import java.util.Optional;
* Shadow SQL router.
*/
@HighFrequencyInvocation
-public final class ShadowSQLRouter implements DecorateSQLRouter<ShadowRule>,
DataSourceSQLRouter<ShadowRule> {
+public final class ShadowSQLRouter implements DecorateSQLRouter<ShadowRule> {
@Override
public void decorateRouteContext(final RouteContext routeContext, final
QueryContext queryContext, final ShardingSphereDatabase database,
@@ -62,6 +61,11 @@ public final class ShadowSQLRouter implements
DecorateSQLRouter<ShadowRule>, Dat
routeContext.getRouteUnits().addAll(toBeAddedRouteUnit);
}
+ @Override
+ public Type getType() {
+ return Type.DATA_SOURCE;
+ }
+
@Override
public int getOrder() {
return ShadowOrder.ORDER;
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingSQLRouter.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingSQLRouter.java
index 1d62baef30a..534362fc6d5 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingSQLRouter.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingSQLRouter.java
@@ -23,8 +23,7 @@ import
org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.infra.route.context.RouteContext;
-import org.apache.shardingsphere.infra.route.type.EntranceSQLRouter;
-import org.apache.shardingsphere.infra.route.type.TableSQLRouter;
+import org.apache.shardingsphere.infra.route.lifecycle.EntranceSQLRouter;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import org.apache.shardingsphere.sharding.cache.route.CachedShardingSQLRouter;
import org.apache.shardingsphere.sharding.constant.ShardingOrder;
@@ -46,7 +45,7 @@ import java.util.Optional;
* Sharding SQL router.
*/
@HighFrequencyInvocation
-public final class ShardingSQLRouter implements
EntranceSQLRouter<ShardingRule>, TableSQLRouter<ShardingRule> {
+public final class ShardingSQLRouter implements
EntranceSQLRouter<ShardingRule> {
@Override
public RouteContext createRouteContext(final QueryContext queryContext,
final RuleMetaData globalRuleMetaData, final ShardingSphereDatabase database,
@@ -93,6 +92,11 @@ public final class ShardingSQLRouter implements
EntranceSQLRouter<ShardingRule>,
ShardingRouteContextCheckerFactory.newInstance(sqlStatement,
shardingConditions).ifPresent(optional -> optional.check(rule, queryContext,
database, props, routeContext));
}
+ @Override
+ public Type getType() {
+ return Type.DATA_NODE;
+ }
+
@Override
public int getOrder() {
return ShardingOrder.ORDER;
diff --git
a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/SQLRouter.java
b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/SQLRouter.java
index bdc408773d2..e3cdbcb093d 100644
---
a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/SQLRouter.java
+++
b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/SQLRouter.java
@@ -22,10 +22,25 @@ import
org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPI;
/**
- * SQL Router.
+ * SQL router.
*
* @param <T> type of rule
*/
@SingletonSPI
public interface SQLRouter<T extends ShardingSphereRule> extends OrderedSPI<T>
{
+
+ /**
+ * Get SQL router type.
+ *
+ * @return SQL router type
+ */
+ Type getType();
+
+ /**
+ * SQL router type.
+ */
+ enum Type {
+
+ DATA_NODE, DATA_SOURCE
+ }
}
diff --git
a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/SQLRouteEngine.java
b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/SQLRouteEngine.java
index d238d8e140f..09e60bb2a9c 100644
---
a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/SQLRouteEngine.java
+++
b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/SQLRouteEngine.java
@@ -27,14 +27,13 @@ import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.infra.route.SQLRouter;
+import org.apache.shardingsphere.infra.route.SQLRouter.Type;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteMapper;
import org.apache.shardingsphere.infra.route.context.RouteUnit;
import
org.apache.shardingsphere.infra.route.engine.tableless.router.TablelessSQLRouter;
-import org.apache.shardingsphere.infra.route.type.DataSourceSQLRouter;
-import org.apache.shardingsphere.infra.route.type.DecorateSQLRouter;
-import org.apache.shardingsphere.infra.route.type.EntranceSQLRouter;
-import org.apache.shardingsphere.infra.route.type.TableSQLRouter;
+import org.apache.shardingsphere.infra.route.lifecycle.DecorateSQLRouter;
+import org.apache.shardingsphere.infra.route.lifecycle.EntranceSQLRouter;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
@@ -55,7 +54,7 @@ public final class SQLRouteEngine {
private final ConfigurationProperties props;
@SuppressWarnings("rawtypes")
- private final Map<ShardingSphereRule, SQLRouter> tableRouters;
+ private final Map<ShardingSphereRule, SQLRouter> dataNodeRouters;
@SuppressWarnings("rawtypes")
private final Map<ShardingSphereRule, SQLRouter> dataSourceRouters;
@@ -64,15 +63,15 @@ public final class SQLRouteEngine {
public SQLRouteEngine(final Collection<ShardingSphereRule> rules, final
ConfigurationProperties props) {
this.props = props;
Map<ShardingSphereRule, SQLRouter> routers =
OrderedSPILoader.getServices(SQLRouter.class, rules);
- tableRouters = filterRouters(routers, TableSQLRouter.class);
- dataSourceRouters = filterRouters(routers, DataSourceSQLRouter.class);
+ dataNodeRouters = filterRouters(routers, Type.DATA_NODE);
+ dataSourceRouters = filterRouters(routers, Type.DATA_SOURCE);
}
@SuppressWarnings("rawtypes")
- private Map<ShardingSphereRule, SQLRouter> filterRouters(final
Map<ShardingSphereRule, SQLRouter> routers, final Class<? extends SQLRouter>
targetClass) {
+ private Map<ShardingSphereRule, SQLRouter> filterRouters(final
Map<ShardingSphereRule, SQLRouter> routers, final Type type) {
Map<ShardingSphereRule, SQLRouter> result = new LinkedHashMap<>();
for (Entry<ShardingSphereRule, SQLRouter> entry : routers.entrySet()) {
- if (targetClass.isAssignableFrom(entry.getValue().getClass())) {
+ if (type == entry.getValue().getType()) {
result.put(entry.getKey(), entry.getValue());
}
}
@@ -95,7 +94,7 @@ public final class SQLRouteEngine {
return result;
}
Collection<String> tableNames =
SQLStatementContextExtractor.getTableNames(database,
queryContext.getSqlStatementContext());
- result = route(queryContext, globalRuleMetaData, database,
tableRouters, tableNames, result);
+ result = route(queryContext, globalRuleMetaData, database,
dataNodeRouters, tableNames, result);
result = new TablelessSQLRouter().route(queryContext,
globalRuleMetaData, database, tableNames, result);
result = route(queryContext, globalRuleMetaData, database,
dataSourceRouters, tableNames, result);
if (result.getRouteUnits().isEmpty() && 1 ==
database.getResourceMetaData().getStorageUnits().size()) {
diff --git
a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/type/DecorateSQLRouter.java
b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/lifecycle/DecorateSQLRouter.java
similarity index 95%
rename from
infra/route/src/main/java/org/apache/shardingsphere/infra/route/type/DecorateSQLRouter.java
rename to
infra/route/src/main/java/org/apache/shardingsphere/infra/route/lifecycle/DecorateSQLRouter.java
index 7bdaaf402a2..8a144bbbaa8 100644
---
a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/type/DecorateSQLRouter.java
+++
b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/lifecycle/DecorateSQLRouter.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.route.type;
+package org.apache.shardingsphere.infra.route.lifecycle;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -27,7 +27,7 @@ import
org.apache.shardingsphere.infra.session.query.QueryContext;
import java.util.Collection;
/**
- * Decorate SQL Router.
+ * Decorate SQL router.
*
* @param <T> type of rule
*/
diff --git
a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/type/EntranceSQLRouter.java
b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/lifecycle/EntranceSQLRouter.java
similarity index 96%
rename from
infra/route/src/main/java/org/apache/shardingsphere/infra/route/type/EntranceSQLRouter.java
rename to
infra/route/src/main/java/org/apache/shardingsphere/infra/route/lifecycle/EntranceSQLRouter.java
index d0ca1d8de1b..d102a62cd9b 100644
---
a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/type/EntranceSQLRouter.java
+++
b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/lifecycle/EntranceSQLRouter.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.route.type;
+package org.apache.shardingsphere.infra.route.lifecycle;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -28,7 +28,7 @@ import
org.apache.shardingsphere.infra.session.query.QueryContext;
import java.util.Collection;
/**
- * Entrance SQL Router.
+ * Entrance SQL router.
*
* @param <T> type of rule
*/
diff --git
a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/type/DataSourceSQLRouter.java
b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/type/DataSourceSQLRouter.java
deleted file mode 100644
index e31f925bb47..00000000000
---
a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/type/DataSourceSQLRouter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.route.type;
-
-import org.apache.shardingsphere.infra.route.SQLRouter;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-
-/**
- * Decorate SQL Router.
- *
- * @param <T> type of rule
- */
-public interface DataSourceSQLRouter<T extends ShardingSphereRule> extends
SQLRouter<T> {
-}
diff --git
a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/type/TableSQLRouter.java
b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/type/TableSQLRouter.java
deleted file mode 100644
index 7814413b6df..00000000000
---
a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/type/TableSQLRouter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.route.type;
-
-import org.apache.shardingsphere.infra.route.SQLRouter;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-
-/**
- * Decorate SQL Router.
- *
- * @param <T> type of rule
- */
-public interface TableSQLRouter<T extends ShardingSphereRule> extends
SQLRouter<T> {
-}
diff --git
a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/TableSQLRouterFailureFixture.java
b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/DataNodeSQLRouterFailureFixture.java
similarity index 86%
rename from
infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/TableSQLRouterFailureFixture.java
rename to
infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/DataNodeSQLRouterFailureFixture.java
index 778c4b8141d..5701a5641e7 100644
---
a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/TableSQLRouterFailureFixture.java
+++
b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/DataNodeSQLRouterFailureFixture.java
@@ -21,13 +21,12 @@ import
org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import
org.apache.shardingsphere.infra.route.fixture.rule.RouteFailureRuleFixture;
-import org.apache.shardingsphere.infra.route.type.DecorateSQLRouter;
-import org.apache.shardingsphere.infra.route.type.TableSQLRouter;
+import org.apache.shardingsphere.infra.route.lifecycle.DecorateSQLRouter;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import java.util.Collection;
-public final class TableSQLRouterFailureFixture implements
DecorateSQLRouter<RouteFailureRuleFixture>,
TableSQLRouter<RouteFailureRuleFixture> {
+public final class DataNodeSQLRouterFailureFixture implements
DecorateSQLRouter<RouteFailureRuleFixture> {
@Override
public void decorateRouteContext(final RouteContext routeContext, final
QueryContext queryContext, final ShardingSphereDatabase database,
@@ -35,6 +34,11 @@ public final class TableSQLRouterFailureFixture implements
DecorateSQLRouter<Rou
throw new UnsupportedOperationException("Route failure.");
}
+ @Override
+ public Type getType() {
+ return Type.DATA_NODE;
+ }
+
@Override
public int getOrder() {
return 1;
diff --git
a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/TableSQLRouterFixture.java
b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/DataNodeSQLRouterFixture.java
similarity index 87%
rename from
infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/TableSQLRouterFixture.java
rename to
infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/DataNodeSQLRouterFixture.java
index a3cc7486e75..140980e124f 100644
---
a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/TableSQLRouterFixture.java
+++
b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/DataNodeSQLRouterFixture.java
@@ -20,19 +20,18 @@ package
org.apache.shardingsphere.infra.route.fixture.router;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
-import org.apache.shardingsphere.infra.route.type.DecorateSQLRouter;
-import org.apache.shardingsphere.infra.route.type.EntranceSQLRouter;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteMapper;
import org.apache.shardingsphere.infra.route.context.RouteUnit;
import
org.apache.shardingsphere.infra.route.fixture.rule.TableRouteRuleFixture;
-import org.apache.shardingsphere.infra.route.type.TableSQLRouter;
+import org.apache.shardingsphere.infra.route.lifecycle.DecorateSQLRouter;
+import org.apache.shardingsphere.infra.route.lifecycle.EntranceSQLRouter;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import java.util.Collection;
import java.util.Collections;
-public final class TableSQLRouterFixture implements
EntranceSQLRouter<TableRouteRuleFixture>,
DecorateSQLRouter<TableRouteRuleFixture>, TableSQLRouter<TableRouteRuleFixture>
{
+public final class DataNodeSQLRouterFixture implements
EntranceSQLRouter<TableRouteRuleFixture>,
DecorateSQLRouter<TableRouteRuleFixture> {
@Override
public RouteContext createRouteContext(final QueryContext queryContext,
final RuleMetaData globalRuleMetaData, final ShardingSphereDatabase database,
final TableRouteRuleFixture rule,
@@ -48,6 +47,11 @@ public final class TableSQLRouterFixture implements
EntranceSQLRouter<TableRoute
routeContext.getRouteUnits().add(new RouteUnit(new RouteMapper("ds",
"ds_0"), Collections.emptyList()));
}
+ @Override
+ public Type getType() {
+ return Type.DATA_NODE;
+ }
+
@Override
public int getOrder() {
return -10;
diff --git
a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/DataSourceSQLRouterFixture.java
b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/DataSourceSQLRouterFixture.java
index 5453e622e9c..7d2a27a4d89 100644
---
a/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/DataSourceSQLRouterFixture.java
+++
b/infra/route/src/test/java/org/apache/shardingsphere/infra/route/fixture/router/DataSourceSQLRouterFixture.java
@@ -24,15 +24,14 @@ import
org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteMapper;
import org.apache.shardingsphere.infra.route.context.RouteUnit;
import
org.apache.shardingsphere.infra.route.fixture.rule.DataSourceRouteRuleFixture;
-import org.apache.shardingsphere.infra.route.type.DataSourceSQLRouter;
-import org.apache.shardingsphere.infra.route.type.DecorateSQLRouter;
-import org.apache.shardingsphere.infra.route.type.EntranceSQLRouter;
+import org.apache.shardingsphere.infra.route.lifecycle.DecorateSQLRouter;
+import org.apache.shardingsphere.infra.route.lifecycle.EntranceSQLRouter;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import java.util.Collection;
import java.util.Collections;
-public final class DataSourceSQLRouterFixture implements
EntranceSQLRouter<DataSourceRouteRuleFixture>,
DecorateSQLRouter<DataSourceRouteRuleFixture>,
DataSourceSQLRouter<DataSourceRouteRuleFixture> {
+public final class DataSourceSQLRouterFixture implements
EntranceSQLRouter<DataSourceRouteRuleFixture>,
DecorateSQLRouter<DataSourceRouteRuleFixture> {
@Override
public RouteContext createRouteContext(final QueryContext queryContext,
final RuleMetaData globalRuleMetaData, final ShardingSphereDatabase database,
final DataSourceRouteRuleFixture rule,
@@ -48,6 +47,11 @@ public final class DataSourceSQLRouterFixture implements
EntranceSQLRouter<DataS
routeContext.getRouteUnits().add(new RouteUnit(new RouteMapper("ds",
"ds_0"), Collections.emptyList()));
}
+ @Override
+ public Type getType() {
+ return Type.DATA_SOURCE;
+ }
+
@Override
public int getOrder() {
return 0;
diff --git
a/infra/route/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.route.SQLRouter
b/infra/route/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.route.SQLRouter
index e128183dfbd..bc1d8169d2d 100644
---
a/infra/route/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.route.SQLRouter
+++
b/infra/route/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.route.SQLRouter
@@ -15,6 +15,6 @@
# limitations under the License.
#
-org.apache.shardingsphere.infra.route.fixture.router.TableSQLRouterFixture
+org.apache.shardingsphere.infra.route.fixture.router.DataNodeSQLRouterFixture
org.apache.shardingsphere.infra.route.fixture.router.DataSourceSQLRouterFixture
-org.apache.shardingsphere.infra.route.fixture.router.TableSQLRouterFailureFixture
+org.apache.shardingsphere.infra.route.fixture.router.DataNodeSQLRouterFailureFixture
diff --git
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/route/SingleSQLRouter.java
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/route/SingleSQLRouter.java
index 53aef4832ae..15ab2450ddd 100644
---
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/route/SingleSQLRouter.java
+++
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/route/SingleSQLRouter.java
@@ -28,9 +28,8 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.QualifiedTable;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteMapper;
import org.apache.shardingsphere.infra.route.context.RouteUnit;
-import org.apache.shardingsphere.infra.route.type.DecorateSQLRouter;
-import org.apache.shardingsphere.infra.route.type.EntranceSQLRouter;
-import org.apache.shardingsphere.infra.route.type.TableSQLRouter;
+import org.apache.shardingsphere.infra.route.lifecycle.DecorateSQLRouter;
+import org.apache.shardingsphere.infra.route.lifecycle.EntranceSQLRouter;
import
org.apache.shardingsphere.infra.rule.attribute.table.TableMapperRuleAttribute;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import org.apache.shardingsphere.single.constant.SingleOrder;
@@ -46,7 +45,7 @@ import java.util.LinkedList;
* Single SQL router.
*/
@HighFrequencyInvocation
-public final class SingleSQLRouter implements EntranceSQLRouter<SingleRule>,
DecorateSQLRouter<SingleRule>, TableSQLRouter<SingleRule> {
+public final class SingleSQLRouter implements EntranceSQLRouter<SingleRule>,
DecorateSQLRouter<SingleRule> {
@Override
public RouteContext createRouteContext(final QueryContext queryContext,
final RuleMetaData globalRuleMetaData, final ShardingSphereDatabase database,
@@ -113,6 +112,11 @@ public final class SingleSQLRouter implements
EntranceSQLRouter<SingleRule>, Dec
return result;
}
+ @Override
+ public Type getType() {
+ return Type.DATA_NODE;
+ }
+
@Override
public int getOrder() {
return SingleOrder.ORDER;