Skip to content

Commit

Permalink
for apache#768, move sharding router to sharding package
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Apr 28, 2018
1 parent 97a48ef commit dc952aa
Show file tree
Hide file tree
Showing 17 changed files with 25 additions and 427 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import io.shardingjdbc.core.parsing.parser.sql.dml.DMLStatement;
import io.shardingjdbc.core.parsing.parser.sql.dml.insert.InsertStatement;
import io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement;
import io.shardingjdbc.core.routing.router.GeneratedKey;
import io.shardingjdbc.core.routing.router.sharding.GeneratedKey;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import io.shardingjdbc.core.parsing.parser.context.condition.Condition;
import io.shardingjdbc.core.parsing.parser.context.condition.GeneratedKeyCondition;
import io.shardingjdbc.core.parsing.parser.context.condition.OrCondition;
import io.shardingjdbc.core.routing.router.GeneratedKey;
import io.shardingjdbc.core.routing.router.sharding.GeneratedKey;
import lombok.RequiredArgsConstructor;

import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import io.shardingjdbc.core.rewrite.placeholder.SchemaPlaceholder;
import io.shardingjdbc.core.rewrite.placeholder.TablePlaceholder;
import io.shardingjdbc.core.routing.SQLUnit;
import io.shardingjdbc.core.routing.router.GeneratedKey;
import io.shardingjdbc.core.routing.router.sharding.GeneratedKey;
import io.shardingjdbc.core.routing.type.RoutingTable;
import io.shardingjdbc.core.routing.type.TableUnit;
import io.shardingjdbc.core.rule.BindingTableRule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import io.shardingjdbc.core.metadata.ShardingMetaData;
import io.shardingjdbc.core.parsing.parser.sql.SQLStatement;
import io.shardingjdbc.core.routing.router.masterslave.ShardingMasterSlaveRouter;
import io.shardingjdbc.core.routing.router.SQLRouter;
import io.shardingjdbc.core.routing.router.SQLRouterFactory;
import io.shardingjdbc.core.routing.router.sharding.ShardingRouter;
import io.shardingjdbc.core.routing.router.sharding.ShardingRouterFactory;
import io.shardingjdbc.core.rule.ShardingRule;

import java.util.List;
Expand All @@ -37,15 +37,15 @@ public final class PreparedStatementRoutingEngine {

private final String logicSQL;

private final SQLRouter sqlRouter;
private final ShardingRouter shardingRouter;

private final ShardingMasterSlaveRouter masterSlaveRouter;

private SQLStatement sqlStatement;

public PreparedStatementRoutingEngine(final String logicSQL, final ShardingRule shardingRule, final ShardingMetaData shardingMetaData, final DatabaseType databaseType, final boolean showSQL) {
this.logicSQL = logicSQL;
sqlRouter = SQLRouterFactory.createSQLRouter(shardingRule, shardingMetaData, databaseType, showSQL);
shardingRouter = ShardingRouterFactory.createSQLRouter(shardingRule, shardingMetaData, databaseType, showSQL);
masterSlaveRouter = new ShardingMasterSlaveRouter(shardingRule.getMasterSlaveRules());
}

Expand All @@ -59,8 +59,8 @@ public PreparedStatementRoutingEngine(final String logicSQL, final ShardingRule
*/
public SQLRouteResult route(final List<Object> parameters) {
if (null == sqlStatement) {
sqlStatement = sqlRouter.parse(logicSQL, true);
sqlStatement = shardingRouter.parse(logicSQL, true);
}
return masterSlaveRouter.route(sqlRouter.route(logicSQL, parameters, sqlStatement));
return masterSlaveRouter.route(shardingRouter.route(logicSQL, parameters, sqlStatement));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package io.shardingjdbc.core.routing;

import io.shardingjdbc.core.parsing.parser.sql.SQLStatement;
import io.shardingjdbc.core.routing.router.GeneratedKey;
import io.shardingjdbc.core.routing.router.sharding.GeneratedKey;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import io.shardingjdbc.core.metadata.ShardingMetaData;
import io.shardingjdbc.core.parsing.parser.sql.SQLStatement;
import io.shardingjdbc.core.routing.router.masterslave.ShardingMasterSlaveRouter;
import io.shardingjdbc.core.routing.router.SQLRouter;
import io.shardingjdbc.core.routing.router.SQLRouterFactory;
import io.shardingjdbc.core.routing.router.sharding.ShardingRouter;
import io.shardingjdbc.core.routing.router.sharding.ShardingRouterFactory;
import io.shardingjdbc.core.rule.ShardingRule;

import java.util.Collections;
Expand All @@ -35,12 +35,12 @@
*/
public final class StatementRoutingEngine {

private final SQLRouter sqlRouter;
private final ShardingRouter shardingRouter;

private final ShardingMasterSlaveRouter masterSlaveRouter;

public StatementRoutingEngine(final ShardingRule shardingRule, final ShardingMetaData shardingMetaData, final DatabaseType databaseType, final boolean showSQL) {
sqlRouter = SQLRouterFactory.createSQLRouter(shardingRule, shardingMetaData, databaseType, showSQL);
shardingRouter = ShardingRouterFactory.createSQLRouter(shardingRule, shardingMetaData, databaseType, showSQL);
masterSlaveRouter = new ShardingMasterSlaveRouter(shardingRule.getMasterSlaveRules());
}

Expand All @@ -51,7 +51,7 @@ public StatementRoutingEngine(final ShardingRule shardingRule, final ShardingMet
* @return route result
*/
public SQLRouteResult route(final String logicSQL) {
SQLStatement sqlStatement = sqlRouter.parse(logicSQL, false);
return masterSlaveRouter.route(sqlRouter.route(logicSQL, Collections.emptyList(), sqlStatement));
SQLStatement sqlStatement = shardingRouter.parse(logicSQL, false);
return masterSlaveRouter.route(shardingRouter.route(logicSQL, Collections.emptyList(), sqlStatement));
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit dc952aa

Please sign in to comment.