From 37c264ded004797bea9c1a1547bb0b42ab5dae9d Mon Sep 17 00:00:00 2001
From: terrymanu
Date: Sat, 1 Sep 2018 16:34:47 +0800
Subject: [PATCH 1/6] fix #1205, add SQLExecutePrepareTemplate &
SQLExecutePrepareCallback
---
.../prepare/SQLExecutePrepareCallback.java | 52 ++++++++++++
.../prepare/SQLExecutePrepareTemplate.java | 82 +++++++++++++++++++
.../statement/ShardingPreparedStatement.java | 42 +++++-----
.../core/statement/ShardingStatement.java | 41 ++++------
.../ConnectionStrictlyExecuteEngine.java | 52 +++++-------
5 files changed, 193 insertions(+), 76 deletions(-)
create mode 100644 sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareCallback.java
create mode 100644 sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareTemplate.java
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareCallback.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareCallback.java
new file mode 100644
index 0000000000000..92449bbfc6902
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareCallback.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed 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 io.shardingsphere.core.executor.sql.prepare;
+
+import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
+import io.shardingsphere.core.routing.SQLExecutionUnit;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * SQL execute prepare callback.
+ *
+ * @author zhangliang
+ */
+public interface SQLExecutePrepareCallback {
+
+ /**
+ * Get connection.
+ *
+ * @param dataSourceName data source name
+ * @return connection
+ * @throws SQLException SQL exception
+ */
+ Connection getConnection(String dataSourceName) throws SQLException;
+
+ /**
+ * Create statement execute unit.
+ *
+ * @param connection connection
+ * @param isReturnGeneratedKeys is return generated keys
+ * @param sqlExecutionUnit SQL execution unit
+ * @return statement execute unit
+ * @throws SQLException SQL exception
+ */
+ StatementExecuteUnit createStatementExecuteUnit(Connection connection, boolean isReturnGeneratedKeys, SQLExecutionUnit sqlExecutionUnit) throws SQLException;
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareTemplate.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareTemplate.java
new file mode 100644
index 0000000000000..bd45c31a0fe46
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareTemplate.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed 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 io.shardingsphere.core.executor.sql.prepare;
+
+import com.google.common.collect.Lists;
+import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
+import io.shardingsphere.core.routing.SQLExecutionUnit;
+import io.shardingsphere.core.routing.SQLUnit;
+import lombok.RequiredArgsConstructor;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * SQL execute prepare template.
+ *
+ * @author zhaojun
+ * @author zhangliang
+ */
+@RequiredArgsConstructor
+public final class SQLExecutePrepareTemplate {
+
+ private final int maxConnectionsSizePerQuery;
+
+ /**
+ * Get statement execute units.
+ *
+ * @param sqlUnitGroups SQL unit groups
+ * @param isReturnGeneratedKeys is return generated keys
+ * @param callback SQL execute prepare callback
+ * @return key is data source name, value is statement execute unit groups
+ * @throws SQLException SQL exception
+ */
+ public Map>> getStatementExecuteUnits(
+ final Map> sqlUnitGroups, final boolean isReturnGeneratedKeys, final SQLExecutePrepareCallback callback) throws SQLException {
+ Map>> result = new HashMap<>(sqlUnitGroups.size(), 1);
+ for (Entry> entry : sqlUnitGroups.entrySet()) {
+ result.put(entry.getKey(), partitionSQLUnits(entry.getKey(), entry.getValue(), isReturnGeneratedKeys, callback));
+ }
+ return result;
+ }
+
+ private List> partitionSQLUnits(
+ final String dataSourceName, final List sqlUnits, final boolean isReturnGeneratedKeys, final SQLExecutePrepareCallback callback) throws SQLException {
+ List> result = new LinkedList<>();
+ int desiredPartitionSize = Math.max(sqlUnits.size() / maxConnectionsSizePerQuery, 1);
+ for (List each : Lists.partition(sqlUnits, desiredPartitionSize)) {
+ // TODO get connection sync to prevent dead lock
+ result.add(getStatementExecuteUnitGroup(callback.getConnection(dataSourceName), dataSourceName, isReturnGeneratedKeys, each, callback));
+ }
+ return result;
+ }
+
+ private List getStatementExecuteUnitGroup(final Connection connection, final String dataSourceName, final boolean isReturnGeneratedKeys,
+ final List sqlUnitGroup, final SQLExecutePrepareCallback callback) throws SQLException {
+ List result = new LinkedList<>();
+ for (SQLUnit each : sqlUnitGroup) {
+ result.add(callback.createStatementExecuteUnit(connection, isReturnGeneratedKeys, new SQLExecutionUnit(dataSourceName, each)));
+ }
+ return result;
+ }
+}
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
index d0ff0d4491d04..c3b566b5aa51c 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
@@ -24,6 +24,8 @@
import io.shardingsphere.core.constant.ConnectionMode;
import io.shardingsphere.core.constant.SQLType;
import io.shardingsphere.core.event.ShardingEventBusInstance;
+import io.shardingsphere.core.event.merger.MergeEvent;
+import io.shardingsphere.core.event.routing.RoutingEvent;
import io.shardingsphere.core.executor.batch.BatchPreparedStatementUnit;
import io.shardingsphere.core.executor.batch.ConnectionStrictlyBatchPreparedStatementExecutor;
import io.shardingsphere.core.executor.batch.MemoryStrictlyBatchPreparedStatementExecutor;
@@ -32,6 +34,9 @@
import io.shardingsphere.core.executor.prepared.PreparedStatementExecutor;
import io.shardingsphere.core.executor.prepared.PreparedStatementUnit;
import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
+import io.shardingsphere.core.executor.sql.prepare.SQLExecutePrepareCallback;
+import io.shardingsphere.core.executor.sql.prepare.SQLExecutePrepareTemplate;
import io.shardingsphere.core.executor.sql.result.MemoryQueryResult;
import io.shardingsphere.core.executor.sql.result.StreamQueryResult;
import io.shardingsphere.core.jdbc.adapter.AbstractShardingPreparedStatementAdapter;
@@ -44,7 +49,6 @@
import io.shardingsphere.core.merger.MergeEngineFactory;
import io.shardingsphere.core.merger.MergedResult;
import io.shardingsphere.core.merger.QueryResult;
-import io.shardingsphere.core.event.merger.MergeEvent;
import io.shardingsphere.core.metadata.table.executor.TableMetaDataLoader;
import io.shardingsphere.core.parsing.parser.sql.dal.DALStatement;
import io.shardingsphere.core.parsing.parser.sql.dml.insert.InsertStatement;
@@ -53,8 +57,6 @@
import io.shardingsphere.core.routing.PreparedStatementRoutingEngine;
import io.shardingsphere.core.routing.SQLExecutionUnit;
import io.shardingsphere.core.routing.SQLRouteResult;
-import io.shardingsphere.core.routing.SQLUnit;
-import io.shardingsphere.core.event.routing.RoutingEvent;
import io.shardingsphere.core.routing.router.sharding.GeneratedKey;
import lombok.AccessLevel;
import lombok.Getter;
@@ -268,25 +270,21 @@ private Collection getExecuteUnitsForMemoryStrictly() thr
return result;
}
+ @SuppressWarnings("unchecked")
private Map>> getExecuteUnitsForConnectionStrictly() throws SQLException {
- Map> sqlUnitGroups = routeResult.getSQLUnitGroups();
- Map>> result = new HashMap<>(sqlUnitGroups.size(), 1);
- for (Entry> entry : sqlUnitGroups.entrySet()) {
- String dataSourceName = entry.getKey();
- int desiredPartitionSize = entry.getValue().size() / connection.getShardingDataSource().getShardingContext().getMaxConnectionsSizePerQuery();
- for (List sqlUnitList : Lists.partition(new ArrayList<>(entry.getValue()), 0 == desiredPartitionSize ? 1 : desiredPartitionSize)) {
- Connection connection = this.connection.getConnection(dataSourceName);
- List preparedStatementUnits = new LinkedList<>();
- for (SQLUnit each : sqlUnitList) {
- preparedStatementUnits.add(getPreparedStatementUnit(connection, new SQLExecutionUnit(dataSourceName, each)));
- }
- if (!result.containsKey(dataSourceName)) {
- result.put(dataSourceName, new LinkedList>());
- }
- result.get(dataSourceName).add(preparedStatementUnits);
+ SQLExecutePrepareTemplate sqlExecutePrepareTemplate = new SQLExecutePrepareTemplate(connection.getShardingDataSource().getShardingContext().getMaxConnectionsSizePerQuery());
+ return (Map) sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getSQLUnitGroups(), returnGeneratedKeys, new SQLExecutePrepareCallback() {
+
+ @Override
+ public Connection getConnection(final String dataSourceName) throws SQLException {
+ return ShardingPreparedStatement.this.connection.getConnection(dataSourceName);
}
- }
- return result;
+
+ @Override
+ public StatementExecuteUnit createStatementExecuteUnit(final Connection connection, final boolean isReturnGeneratedKeys, final SQLExecutionUnit sqlExecutionUnit) throws SQLException {
+ return getPreparedStatementUnit(connection, sqlExecutionUnit);
+ }
+ });
}
private PreparedStatementUnit getPreparedStatementUnit(final Connection connection, final SQLExecutionUnit sqlExecutionUnit) throws SQLException {
@@ -336,8 +334,8 @@ public int[] executeBatch() throws SQLException {
private Map>> partitionBatchPreparedStatementUnitGroups() {
Map>> result = new HashMap<>(batchStatementUnits.size(), 1);
for (Entry> entry : getBatchPreparedStatementUnitGroups().entrySet()) {
- int desiredPartitionSize = entry.getValue().size() / connection.getShardingDataSource().getShardingContext().getMaxConnectionsSizePerQuery();
- result.put(entry.getKey(), Lists.partition(entry.getValue(), 0 == desiredPartitionSize ? 1 : desiredPartitionSize));
+ int desiredPartitionSize = Math.max(entry.getValue().size() / connection.getShardingDataSource().getShardingContext().getMaxConnectionsSizePerQuery(), 1);
+ result.put(entry.getKey(), Lists.partition(entry.getValue(), desiredPartitionSize));
}
return result;
}
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
index a4f2b3b0bb710..0d30ed7662347 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
@@ -18,11 +18,15 @@
package io.shardingsphere.core.jdbc.core.statement;
import com.google.common.base.Optional;
-import com.google.common.collect.Lists;
import io.shardingsphere.core.constant.ConnectionMode;
import io.shardingsphere.core.constant.SQLType;
import io.shardingsphere.core.event.ShardingEventBusInstance;
+import io.shardingsphere.core.event.merger.MergeEvent;
+import io.shardingsphere.core.event.routing.RoutingEvent;
import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
+import io.shardingsphere.core.executor.sql.prepare.SQLExecutePrepareCallback;
+import io.shardingsphere.core.executor.sql.prepare.SQLExecutePrepareTemplate;
import io.shardingsphere.core.executor.sql.result.MemoryQueryResult;
import io.shardingsphere.core.executor.sql.result.StreamQueryResult;
import io.shardingsphere.core.executor.statement.ConnectionStrictlyStatementExecutor;
@@ -39,7 +43,6 @@
import io.shardingsphere.core.merger.MergeEngineFactory;
import io.shardingsphere.core.merger.MergedResult;
import io.shardingsphere.core.merger.QueryResult;
-import io.shardingsphere.core.event.merger.MergeEvent;
import io.shardingsphere.core.metadata.table.executor.TableMetaDataLoader;
import io.shardingsphere.core.parsing.parser.sql.dal.DALStatement;
import io.shardingsphere.core.parsing.parser.sql.dml.insert.InsertStatement;
@@ -47,9 +50,7 @@
import io.shardingsphere.core.parsing.parser.sql.dql.select.SelectStatement;
import io.shardingsphere.core.routing.SQLExecutionUnit;
import io.shardingsphere.core.routing.SQLRouteResult;
-import io.shardingsphere.core.routing.SQLUnit;
import io.shardingsphere.core.routing.StatementRoutingEngine;
-import io.shardingsphere.core.event.routing.RoutingEvent;
import io.shardingsphere.core.routing.router.sharding.GeneratedKey;
import lombok.AccessLevel;
import lombok.Getter;
@@ -60,11 +61,9 @@
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
/**
* Statement that support sharding.
@@ -259,25 +258,21 @@ private Collection getExecuteUnitsForMemoryStrictly() throws SQLE
return result;
}
+ @SuppressWarnings("unchecked")
private Map>> getExecuteUnitsForConnectionStrictly() throws SQLException {
- Map> sqlUnitGroups = routeResult.getSQLUnitGroups();
- Map>> result = new HashMap<>(sqlUnitGroups.size(), 1);
- for (Entry> entry : sqlUnitGroups.entrySet()) {
- String dataSourceName = entry.getKey();
- int desiredPartitionSize = entry.getValue().size() / connection.getShardingDataSource().getShardingContext().getMaxConnectionsSizePerQuery();
- for (List sqlUnitList : Lists.partition(new ArrayList<>(entry.getValue()), 0 == desiredPartitionSize ? 1 : desiredPartitionSize)) {
- Connection connection = this.connection.getConnection(dataSourceName);
- List statementUnits = new LinkedList<>();
- for (SQLUnit each : sqlUnitList) {
- statementUnits.add(getStatementUnit(connection, new SQLExecutionUnit(dataSourceName, each)));
- }
- if (!result.containsKey(dataSourceName)) {
- result.put(dataSourceName, new LinkedList>());
- }
- result.get(dataSourceName).add(statementUnits);
+ SQLExecutePrepareTemplate sqlExecutePrepareTemplate = new SQLExecutePrepareTemplate(connection.getShardingDataSource().getShardingContext().getMaxConnectionsSizePerQuery());
+ return (Map) sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getSQLUnitGroups(), returnGeneratedKeys, new SQLExecutePrepareCallback() {
+
+ @Override
+ public Connection getConnection(final String dataSourceName) throws SQLException {
+ return ShardingStatement.this.connection.getConnection(dataSourceName);
}
- }
- return result;
+
+ @Override
+ public StatementExecuteUnit createStatementExecuteUnit(final Connection connection, final boolean isReturnGeneratedKeys, final SQLExecutionUnit sqlExecutionUnit) throws SQLException {
+ return getStatementUnit(connection, sqlExecutionUnit);
+ }
+ });
}
private StatementUnit getStatementUnit(final Connection connection, final SQLExecutionUnit sqlExecutionUnit) throws SQLException {
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java b/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java
index 2c39479b27602..175be337ff6e0 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java
@@ -17,11 +17,12 @@
package io.shardingsphere.proxy.backend.jdbc.execute.memory;
-import com.google.common.collect.Lists;
import io.shardingsphere.core.constant.SQLType;
import io.shardingsphere.core.executor.sql.SQLExecuteCallback;
import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
+import io.shardingsphere.core.executor.sql.prepare.SQLExecutePrepareCallback;
+import io.shardingsphere.core.executor.sql.prepare.SQLExecutePrepareTemplate;
import io.shardingsphere.core.executor.sql.result.MemoryQueryResult;
import io.shardingsphere.core.executor.sql.threadlocal.ExecutorDataMap;
import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
@@ -29,7 +30,6 @@
import io.shardingsphere.core.parsing.parser.sql.dml.insert.InsertStatement;
import io.shardingsphere.core.routing.SQLExecutionUnit;
import io.shardingsphere.core.routing.SQLRouteResult;
-import io.shardingsphere.core.routing.SQLUnit;
import io.shardingsphere.proxy.backend.BackendExecutorContext;
import io.shardingsphere.proxy.backend.jdbc.connection.BackendConnection;
import io.shardingsphere.proxy.backend.jdbc.execute.JDBCExecuteEngine;
@@ -46,13 +46,9 @@
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
/**
* Connection strictly execute engine.
@@ -62,10 +58,13 @@
*/
public final class ConnectionStrictlyExecuteEngine extends JDBCExecuteEngine {
+ private final SQLExecutePrepareTemplate sqlExecutePrepareTemplate;
+
private final SQLExecuteTemplate sqlExecuteTemplate;
public ConnectionStrictlyExecuteEngine(final BackendConnection backendConnection, final JDBCExecutorWrapper jdbcExecutorWrapper) {
super(backendConnection, jdbcExecutorWrapper);
+ sqlExecutePrepareTemplate = new SQLExecutePrepareTemplate(RuleRegistry.getInstance().getMaxConnectionsSizePerQuery());
sqlExecuteTemplate = new SQLExecuteTemplate(BackendExecutorContext.getInstance().getExecuteEngine());
}
@@ -76,7 +75,9 @@ public ExecuteResponse execute(final SQLRouteResult routeResult) throws SQLExcep
SQLType sqlType = routeResult.getSqlStatement().getType();
boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
Map dataMap = ExecutorDataMap.getDataMap();
- Collection executeResponseUnits = sqlExecuteTemplate.execute((Map) partitionStatementExecuteUnits(routeResult, isReturnGeneratedKeys),
+ Map>> statementExecuteUnits =
+ sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getSQLUnitGroups(), isReturnGeneratedKeys, new ConnectionStrictlySQLExecutePrepareCallback());
+ Collection executeResponseUnits = sqlExecuteTemplate.execute((Map) statementExecuteUnits,
new FirstConnectionStrictlySQLExecuteCallback(sqlType, isExceptionThrown, dataMap, isReturnGeneratedKeys),
new ConnectionStrictlySQLExecuteCallback(sqlType, isExceptionThrown, dataMap, isReturnGeneratedKeys));
ExecuteResponseUnit firstExecuteResponseUnit = executeResponseUnits.iterator().next();
@@ -84,30 +85,6 @@ public ExecuteResponse execute(final SQLRouteResult routeResult) throws SQLExcep
? getExecuteQueryResponse(((ExecuteQueryResponseUnit) firstExecuteResponseUnit).getQueryResponsePackets(), executeResponseUnits) : new ExecuteUpdateResponse(executeResponseUnits);
}
- private Map>> partitionStatementExecuteUnits(final SQLRouteResult routeResult, final boolean isReturnGeneratedKeys) throws SQLException {
- Map> sqlUnitGroups = routeResult.getSQLUnitGroups();
- Map>> result = new HashMap<>(sqlUnitGroups.size(), 1);
- for (Entry> entry : sqlUnitGroups.entrySet()) {
- result.put(entry.getKey(), getStatementExecuteUnitGroup(entry.getKey(), entry.getValue(), isReturnGeneratedKeys));
- }
- return result;
- }
-
- private List> getStatementExecuteUnitGroup(final String dataSourceName, final Collection sqlUnits, final boolean isReturnGeneratedKeys) throws SQLException {
- List> result = new LinkedList<>();
- int desiredPartitionSize = sqlUnits.size() / RuleRegistry.getInstance().getMaxConnectionsSizePerQuery();
- for (List sqlUnitGroup : Lists.partition(new ArrayList<>(sqlUnits), 0 == desiredPartitionSize ? 1 : desiredPartitionSize)) {
- Connection connection = getBackendConnection().getConnection(dataSourceName);
- List statementExecuteUnitGroup = new LinkedList<>();
- for (SQLUnit each : sqlUnitGroup) {
- statementExecuteUnitGroup.add(
- new ProxyStatementExecuteUnit(new SQLExecutionUnit(dataSourceName, each), getJdbcExecutorWrapper().createStatement(connection, each.getSql(), isReturnGeneratedKeys)));
- }
- result.add(statementExecuteUnitGroup);
- }
- return result;
- }
-
private ExecuteResponse getExecuteQueryResponse(final QueryResponsePackets queryResponsePackets, final Collection executeResponseUnits) {
ExecuteQueryResponse result = new ExecuteQueryResponse(queryResponsePackets);
for (ExecuteResponseUnit each : executeResponseUnits) {
@@ -121,6 +98,19 @@ protected QueryResult createQueryResult(final ResultSet resultSet) throws SQLExc
return new MemoryQueryResult(resultSet);
}
+ private final class ConnectionStrictlySQLExecutePrepareCallback implements SQLExecutePrepareCallback {
+
+ @Override
+ public Connection getConnection(final String dataSourceName) throws SQLException {
+ return getBackendConnection().getConnection(dataSourceName);
+ }
+
+ @Override
+ public StatementExecuteUnit createStatementExecuteUnit(final Connection connection, final boolean isReturnGeneratedKeys, final SQLExecutionUnit sqlExecutionUnit) throws SQLException {
+ return new ProxyStatementExecuteUnit(sqlExecutionUnit, getJdbcExecutorWrapper().createStatement(connection, sqlExecutionUnit.getSqlUnit().getSql(), isReturnGeneratedKeys));
+ }
+ }
+
private final class FirstConnectionStrictlySQLExecuteCallback extends SQLExecuteCallback {
private final boolean isReturnGeneratedKeys;
From 6ef1a0ffa2dd36e575a6b518c62daf35168e802e Mon Sep 17 00:00:00 2001
From: terrymanu
Date: Sat, 1 Sep 2018 16:47:49 +0800
Subject: [PATCH 2/6] fix #1205, remove isReturnGeneratedKeys from
SQLExecutePrepareCallback
---
.../sql/prepare/SQLExecutePrepareCallback.java | 3 +--
.../sql/prepare/SQLExecutePrepareTemplate.java | 17 +++++++----------
.../statement/ShardingPreparedStatement.java | 4 ++--
.../jdbc/core/statement/ShardingStatement.java | 4 ++--
.../memory/ConnectionStrictlyExecuteEngine.java | 8 ++++++--
5 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareCallback.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareCallback.java
index 92449bbfc6902..266f990b6e59d 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareCallback.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareCallback.java
@@ -43,10 +43,9 @@ public interface SQLExecutePrepareCallback {
* Create statement execute unit.
*
* @param connection connection
- * @param isReturnGeneratedKeys is return generated keys
* @param sqlExecutionUnit SQL execution unit
* @return statement execute unit
* @throws SQLException SQL exception
*/
- StatementExecuteUnit createStatementExecuteUnit(Connection connection, boolean isReturnGeneratedKeys, SQLExecutionUnit sqlExecutionUnit) throws SQLException;
+ StatementExecuteUnit createStatementExecuteUnit(Connection connection, SQLExecutionUnit sqlExecutionUnit) throws SQLException;
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareTemplate.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareTemplate.java
index bd45c31a0fe46..6ea40968ccfd1 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareTemplate.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareTemplate.java
@@ -46,36 +46,33 @@ public final class SQLExecutePrepareTemplate {
* Get statement execute units.
*
* @param sqlUnitGroups SQL unit groups
- * @param isReturnGeneratedKeys is return generated keys
* @param callback SQL execute prepare callback
* @return key is data source name, value is statement execute unit groups
* @throws SQLException SQL exception
*/
- public Map>> getStatementExecuteUnits(
- final Map> sqlUnitGroups, final boolean isReturnGeneratedKeys, final SQLExecutePrepareCallback callback) throws SQLException {
+ public Map>> getStatementExecuteUnits(final Map> sqlUnitGroups, final SQLExecutePrepareCallback callback) throws SQLException {
Map>> result = new HashMap<>(sqlUnitGroups.size(), 1);
for (Entry> entry : sqlUnitGroups.entrySet()) {
- result.put(entry.getKey(), partitionSQLUnits(entry.getKey(), entry.getValue(), isReturnGeneratedKeys, callback));
+ result.put(entry.getKey(), partitionSQLUnits(entry.getKey(), entry.getValue(), callback));
}
return result;
}
- private List> partitionSQLUnits(
- final String dataSourceName, final List sqlUnits, final boolean isReturnGeneratedKeys, final SQLExecutePrepareCallback callback) throws SQLException {
+ private List> partitionSQLUnits(final String dataSourceName, final List sqlUnits, final SQLExecutePrepareCallback callback) throws SQLException {
List> result = new LinkedList<>();
int desiredPartitionSize = Math.max(sqlUnits.size() / maxConnectionsSizePerQuery, 1);
for (List each : Lists.partition(sqlUnits, desiredPartitionSize)) {
// TODO get connection sync to prevent dead lock
- result.add(getStatementExecuteUnitGroup(callback.getConnection(dataSourceName), dataSourceName, isReturnGeneratedKeys, each, callback));
+ result.add(getStatementExecuteUnitGroup(callback.getConnection(dataSourceName), dataSourceName, each, callback));
}
return result;
}
- private List getStatementExecuteUnitGroup(final Connection connection, final String dataSourceName, final boolean isReturnGeneratedKeys,
- final List sqlUnitGroup, final SQLExecutePrepareCallback callback) throws SQLException {
+ private List getStatementExecuteUnitGroup(
+ final Connection connection, final String dataSourceName, final List sqlUnitGroup, final SQLExecutePrepareCallback callback) throws SQLException {
List result = new LinkedList<>();
for (SQLUnit each : sqlUnitGroup) {
- result.add(callback.createStatementExecuteUnit(connection, isReturnGeneratedKeys, new SQLExecutionUnit(dataSourceName, each)));
+ result.add(callback.createStatementExecuteUnit(connection, new SQLExecutionUnit(dataSourceName, each)));
}
return result;
}
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
index c3b566b5aa51c..d0c054279a928 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
@@ -273,7 +273,7 @@ private Collection getExecuteUnitsForMemoryStrictly() thr
@SuppressWarnings("unchecked")
private Map>> getExecuteUnitsForConnectionStrictly() throws SQLException {
SQLExecutePrepareTemplate sqlExecutePrepareTemplate = new SQLExecutePrepareTemplate(connection.getShardingDataSource().getShardingContext().getMaxConnectionsSizePerQuery());
- return (Map) sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getSQLUnitGroups(), returnGeneratedKeys, new SQLExecutePrepareCallback() {
+ return (Map) sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getSQLUnitGroups(), new SQLExecutePrepareCallback() {
@Override
public Connection getConnection(final String dataSourceName) throws SQLException {
@@ -281,7 +281,7 @@ public Connection getConnection(final String dataSourceName) throws SQLException
}
@Override
- public StatementExecuteUnit createStatementExecuteUnit(final Connection connection, final boolean isReturnGeneratedKeys, final SQLExecutionUnit sqlExecutionUnit) throws SQLException {
+ public StatementExecuteUnit createStatementExecuteUnit(final Connection connection, final SQLExecutionUnit sqlExecutionUnit) throws SQLException {
return getPreparedStatementUnit(connection, sqlExecutionUnit);
}
});
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
index 0d30ed7662347..02062583219cb 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
@@ -261,7 +261,7 @@ private Collection getExecuteUnitsForMemoryStrictly() throws SQLE
@SuppressWarnings("unchecked")
private Map>> getExecuteUnitsForConnectionStrictly() throws SQLException {
SQLExecutePrepareTemplate sqlExecutePrepareTemplate = new SQLExecutePrepareTemplate(connection.getShardingDataSource().getShardingContext().getMaxConnectionsSizePerQuery());
- return (Map) sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getSQLUnitGroups(), returnGeneratedKeys, new SQLExecutePrepareCallback() {
+ return (Map) sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getSQLUnitGroups(), new SQLExecutePrepareCallback() {
@Override
public Connection getConnection(final String dataSourceName) throws SQLException {
@@ -269,7 +269,7 @@ public Connection getConnection(final String dataSourceName) throws SQLException
}
@Override
- public StatementExecuteUnit createStatementExecuteUnit(final Connection connection, final boolean isReturnGeneratedKeys, final SQLExecutionUnit sqlExecutionUnit) throws SQLException {
+ public StatementExecuteUnit createStatementExecuteUnit(final Connection connection, final SQLExecutionUnit sqlExecutionUnit) throws SQLException {
return getStatementUnit(connection, sqlExecutionUnit);
}
});
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java b/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java
index 175be337ff6e0..f95d0adda0754 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java
@@ -42,6 +42,7 @@
import io.shardingsphere.proxy.backend.jdbc.wrapper.JDBCExecutorWrapper;
import io.shardingsphere.proxy.config.RuleRegistry;
import io.shardingsphere.proxy.transport.mysql.packet.command.query.QueryResponsePackets;
+import lombok.RequiredArgsConstructor;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -76,7 +77,7 @@ public ExecuteResponse execute(final SQLRouteResult routeResult) throws SQLExcep
boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
Map dataMap = ExecutorDataMap.getDataMap();
Map>> statementExecuteUnits =
- sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getSQLUnitGroups(), isReturnGeneratedKeys, new ConnectionStrictlySQLExecutePrepareCallback());
+ sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getSQLUnitGroups(), new ConnectionStrictlySQLExecutePrepareCallback(isReturnGeneratedKeys));
Collection executeResponseUnits = sqlExecuteTemplate.execute((Map) statementExecuteUnits,
new FirstConnectionStrictlySQLExecuteCallback(sqlType, isExceptionThrown, dataMap, isReturnGeneratedKeys),
new ConnectionStrictlySQLExecuteCallback(sqlType, isExceptionThrown, dataMap, isReturnGeneratedKeys));
@@ -98,15 +99,18 @@ protected QueryResult createQueryResult(final ResultSet resultSet) throws SQLExc
return new MemoryQueryResult(resultSet);
}
+ @RequiredArgsConstructor
private final class ConnectionStrictlySQLExecutePrepareCallback implements SQLExecutePrepareCallback {
+ private final boolean isReturnGeneratedKeys;
+
@Override
public Connection getConnection(final String dataSourceName) throws SQLException {
return getBackendConnection().getConnection(dataSourceName);
}
@Override
- public StatementExecuteUnit createStatementExecuteUnit(final Connection connection, final boolean isReturnGeneratedKeys, final SQLExecutionUnit sqlExecutionUnit) throws SQLException {
+ public StatementExecuteUnit createStatementExecuteUnit(final Connection connection, final SQLExecutionUnit sqlExecutionUnit) throws SQLException {
return new ProxyStatementExecuteUnit(sqlExecutionUnit, getJdbcExecutorWrapper().createStatement(connection, sqlExecutionUnit.getSqlUnit().getSql(), isReturnGeneratedKeys));
}
}
From 78ea549c1dd5741b8a278f158929b86ab413007c Mon Sep 17 00:00:00 2001
From: terrymanu
Date: Sat, 1 Sep 2018 16:49:44 +0800
Subject: [PATCH 3/6] fix #1205, move io.shardingsphere.core.executor.sql =>
io.shardingsphere.core.executor.sql.execute
---
.../executor/sql/{ => execute}/SQLExecuteCallback.java | 7 ++++---
.../executor/sql/{ => execute}/SQLExecuteTemplate.java | 5 +++--
.../sql/{ => execute}/result/MemoryQueryResult.java | 2 +-
.../sql/{ => execute}/result/StreamQueryResult.java | 2 +-
.../sql/{ => execute}/threadlocal/ExecutorDataMap.java | 2 +-
.../threadlocal/ExecutorExceptionHandler.java | 2 +-
.../core/executor/fixture/ExecutorTestUtil.java | 2 +-
.../threadlocal/ExecutorExceptionHandlerTest.java | 2 +-
sharding-core/src/test/resources/logback-test.xml | 2 +-
.../transaction/api/AbstractSoftTransaction.java | 2 +-
.../transaction/api/SoftTransactionManager.java | 2 +-
.../executor/batch/BatchPreparedStatementExecutor.java | 6 +++---
...nnectionStrictlyBatchPreparedStatementExecutor.java | 4 ++--
.../MemoryStrictlyBatchPreparedStatementExecutor.java | 4 ++--
.../ConnectionStrictlyPreparedStatementExecutor.java | 4 ++--
.../MemoryStrictlyPreparedStatementExecutor.java | 4 ++--
.../executor/prepared/PreparedStatementExecutor.java | 6 +++---
.../statement/ConnectionStrictlyStatementExecutor.java | 4 ++--
.../statement/MemoryStrictlyStatementExecutor.java | 4 ++--
.../core/executor/statement/StatementExecutor.java | 6 +++---
.../jdbc/core/statement/ShardingPreparedStatement.java | 6 +++---
.../core/jdbc/core/statement/ShardingStatement.java | 6 +++---
.../core/executor/AbstractBaseExecutorTest.java | 4 ++--
.../core/executor/StatementExecutorTest.java | 2 +-
.../core/executor/fixture/ExecutorTestUtil.java | 2 +-
sharding-jdbc/src/test/resources/logback-test.xml | 2 +-
.../execution/OverallExecuteEventListener.java | 2 +-
.../listener/execution/SQLExecuteEventListener.java | 2 +-
.../listener/execution/ExecuteEventListenerTest.java | 8 ++++----
.../memory/ConnectionStrictlyExecuteEngine.java | 10 +++++-----
.../execute/stream/MemoryStrictlyExecuteEngine.java | 10 +++++-----
31 files changed, 64 insertions(+), 62 deletions(-)
rename sharding-core/src/main/java/io/shardingsphere/core/executor/sql/{ => execute}/SQLExecuteCallback.java (92%)
rename sharding-core/src/main/java/io/shardingsphere/core/executor/sql/{ => execute}/SQLExecuteTemplate.java (95%)
rename sharding-core/src/main/java/io/shardingsphere/core/executor/sql/{ => execute}/result/MemoryQueryResult.java (98%)
rename sharding-core/src/main/java/io/shardingsphere/core/executor/sql/{ => execute}/result/StreamQueryResult.java (99%)
rename sharding-core/src/main/java/io/shardingsphere/core/executor/sql/{ => execute}/threadlocal/ExecutorDataMap.java (95%)
rename sharding-core/src/main/java/io/shardingsphere/core/executor/sql/{ => execute}/threadlocal/ExecutorExceptionHandler.java (97%)
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/SQLExecuteCallback.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteCallback.java
similarity index 92%
rename from sharding-core/src/main/java/io/shardingsphere/core/executor/sql/SQLExecuteCallback.java
rename to sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteCallback.java
index 981776c1d6469..9e615b07032d4 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/SQLExecuteCallback.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteCallback.java
@@ -15,7 +15,7 @@
*
*/
-package io.shardingsphere.core.executor.sql;
+package io.shardingsphere.core.executor.sql.execute;
import com.google.common.eventbus.EventBus;
import io.shardingsphere.core.constant.SQLType;
@@ -24,8 +24,9 @@
import io.shardingsphere.core.executor.ShardingGroupExecuteCallback;
import io.shardingsphere.core.event.executor.sql.SQLExecutionEvent;
import io.shardingsphere.core.event.executor.sql.SQLExecutionEventFactory;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorDataMap;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorDataMap;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import lombok.RequiredArgsConstructor;
import java.sql.SQLException;
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/SQLExecuteTemplate.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteTemplate.java
similarity index 95%
rename from sharding-core/src/main/java/io/shardingsphere/core/executor/sql/SQLExecuteTemplate.java
rename to sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteTemplate.java
index 1229905e28348..4f2b6018f8b2d 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/SQLExecuteTemplate.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteTemplate.java
@@ -15,12 +15,13 @@
*
*/
-package io.shardingsphere.core.executor.sql;
+package io.shardingsphere.core.executor.sql.execute;
import io.shardingsphere.core.event.ShardingEventBusInstance;
import io.shardingsphere.core.executor.ShardingExecuteEngine;
import io.shardingsphere.core.event.executor.overall.OverallExecutionEvent;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import lombok.RequiredArgsConstructor;
import java.sql.SQLException;
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/result/MemoryQueryResult.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/result/MemoryQueryResult.java
similarity index 98%
rename from sharding-core/src/main/java/io/shardingsphere/core/executor/sql/result/MemoryQueryResult.java
rename to sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/result/MemoryQueryResult.java
index bfe4e9ad25d68..cc1ec14c969ec 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/result/MemoryQueryResult.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/result/MemoryQueryResult.java
@@ -15,7 +15,7 @@
*
*/
-package io.shardingsphere.core.executor.sql.result;
+package io.shardingsphere.core.executor.sql.execute.result;
import io.shardingsphere.core.merger.QueryResult;
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/result/StreamQueryResult.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/result/StreamQueryResult.java
similarity index 99%
rename from sharding-core/src/main/java/io/shardingsphere/core/executor/sql/result/StreamQueryResult.java
rename to sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/result/StreamQueryResult.java
index 14f35326eff35..47ebbe87344ee 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/result/StreamQueryResult.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/result/StreamQueryResult.java
@@ -15,7 +15,7 @@
*
*/
-package io.shardingsphere.core.executor.sql.result;
+package io.shardingsphere.core.executor.sql.execute.result;
import io.shardingsphere.core.merger.QueryResult;
import lombok.RequiredArgsConstructor;
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/threadlocal/ExecutorDataMap.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/threadlocal/ExecutorDataMap.java
similarity index 95%
rename from sharding-core/src/main/java/io/shardingsphere/core/executor/sql/threadlocal/ExecutorDataMap.java
rename to sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/threadlocal/ExecutorDataMap.java
index c5ba8044a8f74..81705c6fee097 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/threadlocal/ExecutorDataMap.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/threadlocal/ExecutorDataMap.java
@@ -15,7 +15,7 @@
*
*/
-package io.shardingsphere.core.executor.sql.threadlocal;
+package io.shardingsphere.core.executor.sql.execute.threadlocal;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/threadlocal/ExecutorExceptionHandler.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/threadlocal/ExecutorExceptionHandler.java
similarity index 97%
rename from sharding-core/src/main/java/io/shardingsphere/core/executor/sql/threadlocal/ExecutorExceptionHandler.java
rename to sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/threadlocal/ExecutorExceptionHandler.java
index a7ea0ff623378..c2f7eda8817dc 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/threadlocal/ExecutorExceptionHandler.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/threadlocal/ExecutorExceptionHandler.java
@@ -15,7 +15,7 @@
*
*/
-package io.shardingsphere.core.executor.sql.threadlocal;
+package io.shardingsphere.core.executor.sql.execute.threadlocal;
import io.shardingsphere.core.exception.ShardingException;
import lombok.AccessLevel;
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java b/sharding-core/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java
index f32be35633a70..ac7fa872a5c47 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java
@@ -20,7 +20,7 @@
import io.shardingsphere.core.event.ShardingEventType;
import io.shardingsphere.core.event.executor.overall.OverallExecutionEvent;
import io.shardingsphere.core.event.executor.sql.SQLExecutionEvent;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/executor/threadlocal/ExecutorExceptionHandlerTest.java b/sharding-core/src/test/java/io/shardingsphere/core/executor/threadlocal/ExecutorExceptionHandlerTest.java
index 31ebdf840ca7a..526266e95a21c 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/executor/threadlocal/ExecutorExceptionHandlerTest.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/executor/threadlocal/ExecutorExceptionHandlerTest.java
@@ -18,7 +18,7 @@
package io.shardingsphere.core.executor.threadlocal;
import io.shardingsphere.core.executor.fixture.ExecutorTestUtil;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import org.junit.After;
import org.junit.Test;
diff --git a/sharding-core/src/test/resources/logback-test.xml b/sharding-core/src/test/resources/logback-test.xml
index 1c3c8ab4c1cb4..524b5568ceb50 100644
--- a/sharding-core/src/test/resources/logback-test.xml
+++ b/sharding-core/src/test/resources/logback-test.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/api/AbstractSoftTransaction.java b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/api/AbstractSoftTransaction.java
index 39562fe04e2dc..93f0c43ae54f4 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/api/AbstractSoftTransaction.java
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/api/AbstractSoftTransaction.java
@@ -18,7 +18,7 @@
package io.shardingsphere.transaction.api;
import com.google.common.base.Preconditions;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import io.shardingsphere.core.jdbc.core.connection.ShardingConnection;
import io.shardingsphere.transaction.constants.SoftTransactionType;
import lombok.Getter;
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/api/SoftTransactionManager.java b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/api/SoftTransactionManager.java
index 0765c77ef463b..95e4b56df92c7 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/api/SoftTransactionManager.java
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/main/java/io/shardingsphere/transaction/api/SoftTransactionManager.java
@@ -20,7 +20,7 @@
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.shardingsphere.core.event.ShardingEventBusInstance;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorDataMap;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorDataMap;
import io.shardingsphere.transaction.api.config.SoftTransactionConfiguration;
import io.shardingsphere.transaction.bed.BEDSoftTransaction;
import io.shardingsphere.transaction.bed.sync.BestEffortsDeliveryListener;
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/batch/BatchPreparedStatementExecutor.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/batch/BatchPreparedStatementExecutor.java
index 276b35476a179..52268a8f5f09d 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/batch/BatchPreparedStatementExecutor.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/batch/BatchPreparedStatementExecutor.java
@@ -19,10 +19,10 @@
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.sql.SQLExecuteCallback;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback;
import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorDataMap;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorDataMap;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import lombok.RequiredArgsConstructor;
import java.sql.SQLException;
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/batch/ConnectionStrictlyBatchPreparedStatementExecutor.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/batch/ConnectionStrictlyBatchPreparedStatementExecutor.java
index 238a9ba5c7cff..ef9ab3c931f02 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/batch/ConnectionStrictlyBatchPreparedStatementExecutor.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/batch/ConnectionStrictlyBatchPreparedStatementExecutor.java
@@ -19,8 +19,8 @@
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.sql.SQLExecuteCallback;
-import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate;
import java.sql.SQLException;
import java.util.Collection;
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/batch/MemoryStrictlyBatchPreparedStatementExecutor.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/batch/MemoryStrictlyBatchPreparedStatementExecutor.java
index 114f9890ab199..e83bf8660106d 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/batch/MemoryStrictlyBatchPreparedStatementExecutor.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/batch/MemoryStrictlyBatchPreparedStatementExecutor.java
@@ -19,8 +19,8 @@
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.sql.SQLExecuteCallback;
-import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate;
import java.sql.SQLException;
import java.util.Collection;
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/prepared/ConnectionStrictlyPreparedStatementExecutor.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/prepared/ConnectionStrictlyPreparedStatementExecutor.java
index 93012ea703838..e2ec56f64b44d 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/prepared/ConnectionStrictlyPreparedStatementExecutor.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/prepared/ConnectionStrictlyPreparedStatementExecutor.java
@@ -18,8 +18,8 @@
package io.shardingsphere.core.executor.prepared;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.sql.SQLExecuteCallback;
-import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate;
import java.sql.SQLException;
import java.util.List;
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/prepared/MemoryStrictlyPreparedStatementExecutor.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/prepared/MemoryStrictlyPreparedStatementExecutor.java
index 451cd1201bdc6..79da5902b4204 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/prepared/MemoryStrictlyPreparedStatementExecutor.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/prepared/MemoryStrictlyPreparedStatementExecutor.java
@@ -18,8 +18,8 @@
package io.shardingsphere.core.executor.prepared;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.sql.SQLExecuteCallback;
-import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate;
import java.sql.SQLException;
import java.util.Collection;
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/prepared/PreparedStatementExecutor.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/prepared/PreparedStatementExecutor.java
index fa9bb708d833c..87cd021600742 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/prepared/PreparedStatementExecutor.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/prepared/PreparedStatementExecutor.java
@@ -18,10 +18,10 @@
package io.shardingsphere.core.executor.prepared;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.sql.SQLExecuteCallback;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback;
import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorDataMap;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorDataMap;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import lombok.RequiredArgsConstructor;
import java.sql.PreparedStatement;
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/statement/ConnectionStrictlyStatementExecutor.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/statement/ConnectionStrictlyStatementExecutor.java
index 57113637ee519..df76a718160cb 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/statement/ConnectionStrictlyStatementExecutor.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/statement/ConnectionStrictlyStatementExecutor.java
@@ -18,8 +18,8 @@
package io.shardingsphere.core.executor.statement;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.sql.SQLExecuteCallback;
-import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate;
import java.sql.SQLException;
import java.util.List;
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/statement/MemoryStrictlyStatementExecutor.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/statement/MemoryStrictlyStatementExecutor.java
index b53e8f59de405..5417d660a1081 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/statement/MemoryStrictlyStatementExecutor.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/statement/MemoryStrictlyStatementExecutor.java
@@ -18,8 +18,8 @@
package io.shardingsphere.core.executor.statement;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.sql.SQLExecuteCallback;
-import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate;
import java.sql.SQLException;
import java.util.Collection;
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/statement/StatementExecutor.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/statement/StatementExecutor.java
index 891a4d8c959d4..26fd232f07a93 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/statement/StatementExecutor.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/statement/StatementExecutor.java
@@ -18,10 +18,10 @@
package io.shardingsphere.core.executor.statement;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.sql.SQLExecuteCallback;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback;
import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorDataMap;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorDataMap;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import lombok.RequiredArgsConstructor;
import java.sql.ResultSet;
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
index d0c054279a928..07eee134d6c46 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
@@ -33,12 +33,12 @@
import io.shardingsphere.core.executor.prepared.MemoryStrictlyPreparedStatementExecutor;
import io.shardingsphere.core.executor.prepared.PreparedStatementExecutor;
import io.shardingsphere.core.executor.prepared.PreparedStatementUnit;
-import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate;
import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
import io.shardingsphere.core.executor.sql.prepare.SQLExecutePrepareCallback;
import io.shardingsphere.core.executor.sql.prepare.SQLExecutePrepareTemplate;
-import io.shardingsphere.core.executor.sql.result.MemoryQueryResult;
-import io.shardingsphere.core.executor.sql.result.StreamQueryResult;
+import io.shardingsphere.core.executor.sql.execute.result.MemoryQueryResult;
+import io.shardingsphere.core.executor.sql.execute.result.StreamQueryResult;
import io.shardingsphere.core.jdbc.adapter.AbstractShardingPreparedStatementAdapter;
import io.shardingsphere.core.jdbc.core.ShardingContext;
import io.shardingsphere.core.jdbc.core.connection.ShardingConnection;
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
index 02062583219cb..4ad43dc3c606c 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
@@ -23,12 +23,12 @@
import io.shardingsphere.core.event.ShardingEventBusInstance;
import io.shardingsphere.core.event.merger.MergeEvent;
import io.shardingsphere.core.event.routing.RoutingEvent;
-import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate;
import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
import io.shardingsphere.core.executor.sql.prepare.SQLExecutePrepareCallback;
import io.shardingsphere.core.executor.sql.prepare.SQLExecutePrepareTemplate;
-import io.shardingsphere.core.executor.sql.result.MemoryQueryResult;
-import io.shardingsphere.core.executor.sql.result.StreamQueryResult;
+import io.shardingsphere.core.executor.sql.execute.result.MemoryQueryResult;
+import io.shardingsphere.core.executor.sql.execute.result.StreamQueryResult;
import io.shardingsphere.core.executor.statement.ConnectionStrictlyStatementExecutor;
import io.shardingsphere.core.executor.statement.MemoryStrictlyStatementExecutor;
import io.shardingsphere.core.executor.statement.StatementExecutor;
diff --git a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/AbstractBaseExecutorTest.java b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/AbstractBaseExecutorTest.java
index ddd26bdc1b9ef..86e2f9b024a3b 100644
--- a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/AbstractBaseExecutorTest.java
+++ b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/AbstractBaseExecutorTest.java
@@ -23,8 +23,8 @@
import io.shardingsphere.core.executor.fixture.TestDMLExecutionEventListener;
import io.shardingsphere.core.executor.fixture.TestDQLExecutionEventListener;
import io.shardingsphere.core.executor.fixture.TestOverallExecutionEventListener;
-import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import lombok.AccessLevel;
import lombok.Getter;
import org.junit.After;
diff --git a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/StatementExecutorTest.java b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/StatementExecutorTest.java
index 84116d0a65085..7012b10c41c47 100644
--- a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/StatementExecutorTest.java
+++ b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/StatementExecutorTest.java
@@ -19,7 +19,7 @@
import io.shardingsphere.core.constant.SQLType;
import io.shardingsphere.core.event.ShardingEventType;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import io.shardingsphere.core.executor.statement.MemoryStrictlyStatementExecutor;
import io.shardingsphere.core.executor.statement.StatementExecutor;
import io.shardingsphere.core.executor.statement.StatementUnit;
diff --git a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java
index f32be35633a70..ac7fa872a5c47 100644
--- a/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java
+++ b/sharding-jdbc/src/test/java/io/shardingsphere/core/executor/fixture/ExecutorTestUtil.java
@@ -20,7 +20,7 @@
import io.shardingsphere.core.event.ShardingEventType;
import io.shardingsphere.core.event.executor.overall.OverallExecutionEvent;
import io.shardingsphere.core.event.executor.sql.SQLExecutionEvent;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
diff --git a/sharding-jdbc/src/test/resources/logback-test.xml b/sharding-jdbc/src/test/resources/logback-test.xml
index 1c3c8ab4c1cb4..524b5568ceb50 100644
--- a/sharding-jdbc/src/test/resources/logback-test.xml
+++ b/sharding-jdbc/src/test/resources/logback-test.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/execution/OverallExecuteEventListener.java b/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/execution/OverallExecuteEventListener.java
index 8d9099eb87d3c..46d4e5c21d821 100644
--- a/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/execution/OverallExecuteEventListener.java
+++ b/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/execution/OverallExecuteEventListener.java
@@ -22,7 +22,7 @@
import io.opentracing.ActiveSpan;
import io.opentracing.tag.Tags;
import io.shardingsphere.core.event.executor.overall.OverallExecutionEvent;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorDataMap;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorDataMap;
import io.shardingsphere.opentracing.ShardingTags;
import io.shardingsphere.opentracing.ShardingTracer;
import io.shardingsphere.opentracing.listener.OpenTracingListener;
diff --git a/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/execution/SQLExecuteEventListener.java b/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/execution/SQLExecuteEventListener.java
index c1ab184e8151c..23ae8da1cefd2 100644
--- a/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/execution/SQLExecuteEventListener.java
+++ b/sharding-opentracing/src/main/java/io/shardingsphere/opentracing/listener/execution/SQLExecuteEventListener.java
@@ -24,7 +24,7 @@
import io.opentracing.Span;
import io.opentracing.tag.Tags;
import io.shardingsphere.core.event.executor.sql.SQLExecutionEvent;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorDataMap;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorDataMap;
import io.shardingsphere.opentracing.ShardingTags;
import io.shardingsphere.opentracing.ShardingTracer;
import io.shardingsphere.opentracing.listener.OpenTracingListener;
diff --git a/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/listener/execution/ExecuteEventListenerTest.java b/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/listener/execution/ExecuteEventListenerTest.java
index e9f21f0a2b034..12449abb5efcc 100644
--- a/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/listener/execution/ExecuteEventListenerTest.java
+++ b/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/listener/execution/ExecuteEventListenerTest.java
@@ -20,11 +20,11 @@
import io.shardingsphere.core.constant.SQLType;
import io.shardingsphere.core.executor.ShardingExecuteEngine;
import io.shardingsphere.core.executor.batch.BatchPreparedStatementUnit;
-import io.shardingsphere.core.executor.sql.SQLExecuteCallback;
-import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate;
import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorDataMap;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorDataMap;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import io.shardingsphere.core.executor.statement.StatementUnit;
import io.shardingsphere.core.routing.SQLExecutionUnit;
import io.shardingsphere.core.routing.SQLUnit;
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java b/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java
index f95d0adda0754..a77bb65c225ef 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java
@@ -18,14 +18,14 @@
package io.shardingsphere.proxy.backend.jdbc.execute.memory;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.sql.SQLExecuteCallback;
-import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate;
import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
import io.shardingsphere.core.executor.sql.prepare.SQLExecutePrepareCallback;
import io.shardingsphere.core.executor.sql.prepare.SQLExecutePrepareTemplate;
-import io.shardingsphere.core.executor.sql.result.MemoryQueryResult;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorDataMap;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.execute.result.MemoryQueryResult;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorDataMap;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import io.shardingsphere.core.merger.QueryResult;
import io.shardingsphere.core.parsing.parser.sql.dml.insert.InsertStatement;
import io.shardingsphere.core.routing.SQLExecutionUnit;
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/stream/MemoryStrictlyExecuteEngine.java b/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/stream/MemoryStrictlyExecuteEngine.java
index 3f4f03cfc9329..2ff21fc52563b 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/stream/MemoryStrictlyExecuteEngine.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/stream/MemoryStrictlyExecuteEngine.java
@@ -18,12 +18,12 @@
package io.shardingsphere.proxy.backend.jdbc.execute.stream;
import io.shardingsphere.core.constant.SQLType;
-import io.shardingsphere.core.executor.sql.SQLExecuteCallback;
-import io.shardingsphere.core.executor.sql.SQLExecuteTemplate;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback;
+import io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate;
import io.shardingsphere.core.executor.sql.StatementExecuteUnit;
-import io.shardingsphere.core.executor.sql.result.StreamQueryResult;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorDataMap;
-import io.shardingsphere.core.executor.sql.threadlocal.ExecutorExceptionHandler;
+import io.shardingsphere.core.executor.sql.execute.result.StreamQueryResult;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorDataMap;
+import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler;
import io.shardingsphere.core.merger.QueryResult;
import io.shardingsphere.core.parsing.parser.sql.dml.insert.InsertStatement;
import io.shardingsphere.core.routing.SQLExecutionUnit;
From 44cbca7b08339802b80944ca060bf47bcd646ccb Mon Sep 17 00:00:00 2001
From: terrymanu
Date: Sat, 1 Sep 2018 17:17:12 +0800
Subject: [PATCH 4/6] fix #1205, use data node instead of actual table name on
table metadata
---
.../table/executor/TableMetaDataLoader.java | 25 ++++++++++---------
.../shardingsphere/core/rule/TableRule.java | 8 +++---
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataLoader.java b/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataLoader.java
index bd621cefd5d5e..fb8cddc54e192 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataLoader.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataLoader.java
@@ -25,6 +25,7 @@
import io.shardingsphere.core.metadata.datasource.ShardingDataSourceMetaData;
import io.shardingsphere.core.metadata.table.ColumnMetaData;
import io.shardingsphere.core.metadata.table.TableMetaData;
+import io.shardingsphere.core.rule.DataNode;
import io.shardingsphere.core.rule.ShardingDataSourceNames;
import io.shardingsphere.core.rule.ShardingRule;
import lombok.RequiredArgsConstructor;
@@ -71,33 +72,33 @@ public TableMetaData load(final String logicTableName, final ShardingRule shardi
return actualTableMetaDataList.iterator().next();
}
- private List load(final Map> dataNodeGroups, final ShardingDataSourceNames shardingDataSourceNames) throws SQLException {
- return executeEngine.groupExecute(partitionDataNodeGroups(dataNodeGroups), new ShardingGroupExecuteCallback() {
+ private List load(final Map> dataNodeGroups, final ShardingDataSourceNames shardingDataSourceNames) throws SQLException {
+ return executeEngine.groupExecute(partitionDataNodeGroups(dataNodeGroups), new ShardingGroupExecuteCallback() {
@Override
- public Collection execute(final String dataSourceName, final Collection actualTableNames) throws SQLException {
+ public Collection execute(final String dataSourceName, final Collection dataNodes) throws SQLException {
DataSourceMetaData dataSourceMetaData = shardingDataSourceMetaData.getActualDataSourceMetaData(dataSourceName);
String catalog = null == dataSourceMetaData ? null : dataSourceMetaData.getSchemeName();
- return load(shardingDataSourceNames.getRawMasterDataSourceName(dataSourceName), catalog, actualTableNames);
+ return load(shardingDataSourceNames.getRawMasterDataSourceName(dataSourceName), catalog, dataNodes);
}
});
}
- private Collection load(final String dataSourceName, final String catalog, final Collection actualTableNames) throws SQLException {
+ private Collection load(final String dataSourceName, final String catalog, final Collection dataNodes) throws SQLException {
Collection result = new LinkedList<>();
try (Connection connection = connectionManager.getConnection(dataSourceName)) {
- for (String each : actualTableNames) {
- result.add(new TableMetaData(isTableExist(connection, catalog, each) ? getColumnMetaDataList(connection, catalog, each) : Collections.emptyList()));
+ for (DataNode each : dataNodes) {
+ result.add(new TableMetaData(isTableExist(connection, catalog, each.getTableName()) ? getColumnMetaDataList(connection, catalog, each.getTableName()) : Collections.emptyList()));
}
}
return result;
}
- private Map>> partitionDataNodeGroups(final Map> dataNodeGroups) {
- Map>> result = new HashMap<>(dataNodeGroups.size(), 1);
- for (Entry> entry : dataNodeGroups.entrySet()) {
- int desiredPartitionSize = entry.getValue().size() / maxConnectionsSizePerQuery;
- result.put(entry.getKey(), Lists.partition(entry.getValue(), 0 == desiredPartitionSize ? 1 : desiredPartitionSize));
+ private Map>> partitionDataNodeGroups(final Map> dataNodeGroups) {
+ Map>> result = new HashMap<>(dataNodeGroups.size(), 1);
+ for (Entry> entry : dataNodeGroups.entrySet()) {
+ int desiredPartitionSize = Math.max(entry.getValue().size() / maxConnectionsSizePerQuery, 1);
+ result.put(entry.getKey(), Lists.partition(entry.getValue(), desiredPartitionSize));
}
return result;
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/rule/TableRule.java b/sharding-core/src/main/java/io/shardingsphere/core/rule/TableRule.java
index 526bb64e371be..41fdd3c5f68af 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/rule/TableRule.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/rule/TableRule.java
@@ -112,14 +112,14 @@ private List generateDataNodes(final List actualDataNodes, fin
*
* @return data node groups, key is data source name, value is tables belong to this data source
*/
- public Map> getDataNodeGroups() {
- Map> result = new LinkedHashMap<>(actualDataNodes.size(), 1);
+ public Map> getDataNodeGroups() {
+ Map> result = new LinkedHashMap<>(actualDataNodes.size(), 1);
for (DataNode each : actualDataNodes) {
String dataSourceName = each.getDataSourceName();
if (!result.containsKey(dataSourceName)) {
- result.put(dataSourceName, new LinkedList());
+ result.put(dataSourceName, new LinkedList());
}
- result.get(dataSourceName).add(each.getTableName());
+ result.get(dataSourceName).add(each);
}
return result;
}
From 0593fe05dca1867d46c98e4769cd5d18b28d8c23 Mon Sep 17 00:00:00 2001
From: terrymanu
Date: Sat, 1 Sep 2018 17:35:41 +0800
Subject: [PATCH 5/6] fix #1205, remove useless key for group execution
---
.../core/executor/ShardingExecuteEngine.java | 12 ++++++------
.../core/executor/ShardingGroupExecuteCallback.java | 5 ++---
.../executor/sql/execute/SQLExecuteCallback.java | 2 +-
.../metadata/table/executor/TableMetaDataLoader.java | 3 ++-
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/ShardingExecuteEngine.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/ShardingExecuteEngine.java
index d8d57746f1887..0a1ba23031474 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/ShardingExecuteEngine.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/ShardingExecuteEngine.java
@@ -156,33 +156,33 @@ public List groupExecute(
Collection firstInputs = firstInputGroup.next();
inputs.put(firstKey, Lists.newArrayList(firstInputGroup));
Collection>> restResultFutures = asyncGroupExecute(inputs, callback);
- return getGroupResults(syncGroupExecute(firstKey, firstInputs, null == firstCallback ? callback : firstCallback), restResultFutures);
+ return getGroupResults(syncGroupExecute(firstInputs, null == firstCallback ? callback : firstCallback), restResultFutures);
}
private Collection>> asyncGroupExecute(final Map>> inputs, final ShardingGroupExecuteCallback callback) {
Collection>> result = new LinkedList<>();
for (Entry>> entry : inputs.entrySet()) {
- result.addAll(asyncGroupExecute(entry.getKey(), entry.getValue(), callback));
+ result.addAll(asyncGroupExecute(entry.getValue(), callback));
}
return result;
}
- private Collection>> asyncGroupExecute(final String key, final List> inputs, final ShardingGroupExecuteCallback callback) {
+ private Collection>> asyncGroupExecute(final List> inputs, final ShardingGroupExecuteCallback callback) {
Collection>> result = new LinkedList<>();
for (final List each : inputs) {
result.add(executorService.submit(new Callable>() {
@Override
public Collection call() throws SQLException {
- return callback.execute(key, each);
+ return callback.execute(each);
}
}));
}
return result;
}
- private Collection syncGroupExecute(final String key, final Collection inputs, final ShardingGroupExecuteCallback callback) throws SQLException {
- return callback.execute(key, inputs);
+ private Collection syncGroupExecute(final Collection inputs, final ShardingGroupExecuteCallback callback) throws SQLException {
+ return callback.execute(inputs);
}
private List getGroupResults(final Collection firstResults, final Collection>> restFutures) throws SQLException {
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/ShardingGroupExecuteCallback.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/ShardingGroupExecuteCallback.java
index 9b47403fab565..861fac925cde8 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/ShardingGroupExecuteCallback.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/ShardingGroupExecuteCallback.java
@@ -33,10 +33,9 @@ public interface ShardingGroupExecuteCallback {
/**
* Execute callback.
*
- * @param key input key
- * @param values input values
+ * @param inputs input values
* @return execute result
* @throws SQLException throw when execute failure
*/
- Collection execute(String key, Collection values) throws SQLException;
+ Collection execute(Collection inputs) throws SQLException;
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteCallback.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteCallback.java
index 9e615b07032d4..cd5ffc6adbc45 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteCallback.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteCallback.java
@@ -60,7 +60,7 @@ public final T execute(final StatementExecuteUnit executeUnit) throws SQLExcepti
}
@Override
- public final Collection execute(final String dataSourceName, final Collection executeUnits) throws SQLException {
+ public final Collection execute(final Collection executeUnits) throws SQLException {
Collection result = new LinkedList<>();
for (StatementExecuteUnit each : executeUnits) {
result.add(execute0(each));
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataLoader.java b/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataLoader.java
index fb8cddc54e192..3568bad98b022 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataLoader.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataLoader.java
@@ -76,7 +76,8 @@ private List load(final Map> dataNodeGroup
return executeEngine.groupExecute(partitionDataNodeGroups(dataNodeGroups), new ShardingGroupExecuteCallback() {
@Override
- public Collection execute(final String dataSourceName, final Collection dataNodes) throws SQLException {
+ public Collection execute(final Collection dataNodes) throws SQLException {
+ String dataSourceName = dataNodes.iterator().next().getDataSourceName();
DataSourceMetaData dataSourceMetaData = shardingDataSourceMetaData.getActualDataSourceMetaData(dataSourceName);
String catalog = null == dataSourceMetaData ? null : dataSourceMetaData.getSchemeName();
return load(shardingDataSourceNames.getRawMasterDataSourceName(dataSourceName), catalog, dataNodes);
From b94a8ee71333bf9b9b45768f926ac15062a127bc Mon Sep 17 00:00:00 2001
From: terrymanu
Date: Sat, 1 Sep 2018 17:48:38 +0800
Subject: [PATCH 6/6] fix #1205, move SQLRouteResult.getSQLUnitGroups =>
SQLExecutePrepareTemplate
---
.../prepare/SQLExecutePrepareTemplate.java | 18 +++++++++++++++--
.../core/routing/SQLRouteResult.java | 20 -------------------
.../statement/ShardingPreparedStatement.java | 2 +-
.../core/statement/ShardingStatement.java | 2 +-
.../ConnectionStrictlyExecuteEngine.java | 2 +-
5 files changed, 19 insertions(+), 25 deletions(-)
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareTemplate.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareTemplate.java
index 6ea40968ccfd1..8b29eb32dad5b 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareTemplate.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/prepare/SQLExecutePrepareTemplate.java
@@ -25,7 +25,9 @@
import java.sql.Connection;
import java.sql.SQLException;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -45,12 +47,13 @@ public final class SQLExecutePrepareTemplate {
/**
* Get statement execute units.
*
- * @param sqlUnitGroups SQL unit groups
+ * @param sqlExecutionUnits units execution SQL units
* @param callback SQL execute prepare callback
* @return key is data source name, value is statement execute unit groups
* @throws SQLException SQL exception
*/
- public Map>> getStatementExecuteUnits(final Map> sqlUnitGroups, final SQLExecutePrepareCallback callback) throws SQLException {
+ public Map>> getStatementExecuteUnits(final Collection sqlExecutionUnits, final SQLExecutePrepareCallback callback) throws SQLException {
+ Map> sqlUnitGroups = getSQLUnitGroups(sqlExecutionUnits);
Map>> result = new HashMap<>(sqlUnitGroups.size(), 1);
for (Entry> entry : sqlUnitGroups.entrySet()) {
result.put(entry.getKey(), partitionSQLUnits(entry.getKey(), entry.getValue(), callback));
@@ -58,6 +61,17 @@ public Map>> getStatementExecuteUnits(fi
return result;
}
+ private Map> getSQLUnitGroups(final Collection sqlExecutionUnits) {
+ Map> result = new LinkedHashMap<>(sqlExecutionUnits.size(), 1);
+ for (SQLExecutionUnit each : sqlExecutionUnits) {
+ if (!result.containsKey(each.getDataSource())) {
+ result.put(each.getDataSource(), new LinkedList());
+ }
+ result.get(each.getDataSource()).add(each.getSqlUnit());
+ }
+ return result;
+ }
+
private List> partitionSQLUnits(final String dataSourceName, final List sqlUnits, final SQLExecutePrepareCallback callback) throws SQLException {
List> result = new LinkedList<>();
int desiredPartitionSize = Math.max(sqlUnits.size() / maxConnectionsSizePerQuery, 1);
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/routing/SQLRouteResult.java b/sharding-core/src/main/java/io/shardingsphere/core/routing/SQLRouteResult.java
index 4b893f69372bb..3a926ac32a584 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/routing/SQLRouteResult.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/routing/SQLRouteResult.java
@@ -22,11 +22,7 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
/**
@@ -49,20 +45,4 @@ public final class SQLRouteResult {
public SQLRouteResult(final SQLStatement sqlStatement) {
this(sqlStatement, null);
}
-
- /**
- * Get SQL units grouped by data source name.
- *
- * @return SQL units grouped by data source name.
- */
- public Map> getSQLUnitGroups() {
- Map> result = new LinkedHashMap<>(executionUnits.size(), 1);
- for (SQLExecutionUnit each : executionUnits) {
- if (!result.containsKey(each.getDataSource())) {
- result.put(each.getDataSource(), new LinkedList());
- }
- result.get(each.getDataSource()).add(each.getSqlUnit());
- }
- return result;
- }
}
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
index 07eee134d6c46..d8207ee7e6675 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingPreparedStatement.java
@@ -273,7 +273,7 @@ private Collection getExecuteUnitsForMemoryStrictly() thr
@SuppressWarnings("unchecked")
private Map>> getExecuteUnitsForConnectionStrictly() throws SQLException {
SQLExecutePrepareTemplate sqlExecutePrepareTemplate = new SQLExecutePrepareTemplate(connection.getShardingDataSource().getShardingContext().getMaxConnectionsSizePerQuery());
- return (Map) sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getSQLUnitGroups(), new SQLExecutePrepareCallback() {
+ return (Map) sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getExecutionUnits(), new SQLExecutePrepareCallback() {
@Override
public Connection getConnection(final String dataSourceName) throws SQLException {
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
index 4ad43dc3c606c..c95d1c61fb9da 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/core/statement/ShardingStatement.java
@@ -261,7 +261,7 @@ private Collection getExecuteUnitsForMemoryStrictly() throws SQLE
@SuppressWarnings("unchecked")
private Map>> getExecuteUnitsForConnectionStrictly() throws SQLException {
SQLExecutePrepareTemplate sqlExecutePrepareTemplate = new SQLExecutePrepareTemplate(connection.getShardingDataSource().getShardingContext().getMaxConnectionsSizePerQuery());
- return (Map) sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getSQLUnitGroups(), new SQLExecutePrepareCallback() {
+ return (Map) sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getExecutionUnits(), new SQLExecutePrepareCallback() {
@Override
public Connection getConnection(final String dataSourceName) throws SQLException {
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java b/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java
index a77bb65c225ef..11d0ccbd22bcb 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/jdbc/execute/memory/ConnectionStrictlyExecuteEngine.java
@@ -77,7 +77,7 @@ public ExecuteResponse execute(final SQLRouteResult routeResult) throws SQLExcep
boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
Map dataMap = ExecutorDataMap.getDataMap();
Map>> statementExecuteUnits =
- sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getSQLUnitGroups(), new ConnectionStrictlySQLExecutePrepareCallback(isReturnGeneratedKeys));
+ sqlExecutePrepareTemplate.getStatementExecuteUnits(routeResult.getExecutionUnits(), new ConnectionStrictlySQLExecutePrepareCallback(isReturnGeneratedKeys));
Collection executeResponseUnits = sqlExecuteTemplate.execute((Map) statementExecuteUnits,
new FirstConnectionStrictlySQLExecuteCallback(sqlType, isExceptionThrown, dataMap, isReturnGeneratedKeys),
new ConnectionStrictlySQLExecuteCallback(sqlType, isExceptionThrown, dataMap, isReturnGeneratedKeys));