You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2020/11/21 08:52:00 UTC
[shardingsphere] branch master updated: Scandalize of executor's
class names (#8265)
This is an automated email from the ASF dual-hosted git repository.
menghaoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 3fb6cb9 Scandalize of executor's class names (#8265)
3fb6cb9 is described below
commit 3fb6cb96c05e25ea14f8f039d28e1a8fead64250
Author: Liang Zhang <te...@163.com>
AuthorDate: Sat Nov 21 16:51:36 2020 +0800
Scandalize of executor's class names (#8265)
* Move GroupEngine to same package
* Rename ExecuteGroupEngine to ExecutionGroupEngine
* Rename InputGroup to ExecutionGroup
---
.../{InputGroup.java => ExecutionGroup.java} | 6 +-
.../infra/executor/kernel/ExecutorKernel.java | 42 +++++-----
...gine.java => AbstractExecutionGroupEngine.java} | 26 +++----
...Decorator.java => ExecutionGroupDecorator.java} | 14 ++--
...eGroupEngine.java => ExecutionGroupEngine.java} | 10 +--
.../raw/RawExecutionGroupDecorator.java} | 8 +-
.../raw/RawExecutionGroupEngine.java} | 22 +++---
.../ResourceManagedExecutionGroupEngine.java} | 26 +++----
.../PreparedStatementExecutionGroupEngine.java} | 12 +--
.../jdbc/StatementExecutionGroupEngine.java} | 12 +--
.../executor/sql/raw/execute/RawJDBCExecutor.java | 24 +++---
.../sql/resourced/jdbc/executor/SQLExecutor.java | 15 ++--
...utorEngineTest.java => ExecutorKernelTest.java} | 26 +++----
...PreparedStatementExecutionGroupEngineTest.java} | 23 +++---
.../jdbc/StatementExecutionGroupEngineTest.java} | 24 +++---
.../driver/executor/AbstractStatementExecutor.java | 21 ++---
.../driver/executor/PreparedStatementExecutor.java | 14 ++--
.../driver/executor/StatementExecutor.java | 58 +++++++-------
.../batch/BatchPreparedStatementExecutor.java | 26 +++----
.../statement/ShardingSpherePreparedStatement.java | 46 +++++------
.../core/statement/ShardingSphereStatement.java | 90 +++++++++++-----------
.../executor/PreparedStatementExecutorTest.java | 36 ++++-----
.../driver/executor/StatementExecutorTest.java | 50 ++++++------
.../batch/BatchPreparedStatementExecutorTest.java | 26 +++----
.../execute/engine/jdbc/JDBCExecuteEngine.java | 20 ++---
.../jdbc/execute/engine/jdbc/RawProxyExecutor.java | 13 ++--
.../jdbc/statement/accessor/JDBCAccessor.java | 8 +-
.../accessor/impl/PreparedStatementAccessor.java | 10 +--
.../statement/accessor/impl/StatementAccessor.java | 8 +-
29 files changed, 358 insertions(+), 358 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/InputGroup.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/ExecutionGroup.java
similarity index 90%
rename from shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/InputGroup.java
rename to shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/ExecutionGroup.java
index 8b57fc5..80c27fb 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/InputGroup.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/ExecutionGroup.java
@@ -23,13 +23,13 @@ import lombok.RequiredArgsConstructor;
import java.util.List;
/**
- * Input group.
+ * Execution group.
*
- * @param <T> type of input value
+ * @param <T> type of execution input value
*/
@RequiredArgsConstructor
@Getter
-public final class InputGroup<T> {
+public final class ExecutionGroup<T> {
private final List<T> inputs;
}
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorKernel.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorKernel.java
index 972c7a5..209d398 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorKernel.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorKernel.java
@@ -46,21 +46,21 @@ public final class ExecutorKernel implements AutoCloseable {
/**
* Execute.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param callback executor callback
* @param <I> type of input value
* @param <O> type of return value
* @return execute result
* @throws SQLException throw if execute failure
*/
- public <I, O> List<O> execute(final Collection<InputGroup<I>> inputGroups, final ExecutorCallback<I, O> callback) throws SQLException {
- return execute(inputGroups, null, callback, false);
+ public <I, O> List<O> execute(final Collection<ExecutionGroup<I>> executionGroups, final ExecutorCallback<I, O> callback) throws SQLException {
+ return execute(executionGroups, null, callback, false);
}
/**
* Execute.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param firstCallback first executor callback
* @param callback other executor callback
* @param serial whether using multi thread execute or not
@@ -69,44 +69,44 @@ public final class ExecutorKernel implements AutoCloseable {
* @return execute result
* @throws SQLException throw if execute failure
*/
- public <I, O> List<O> execute(final Collection<InputGroup<I>> inputGroups,
+ public <I, O> List<O> execute(final Collection<ExecutionGroup<I>> executionGroups,
final ExecutorCallback<I, O> firstCallback, final ExecutorCallback<I, O> callback, final boolean serial) throws SQLException {
- if (inputGroups.isEmpty()) {
+ if (executionGroups.isEmpty()) {
return Collections.emptyList();
}
- return serial ? serialExecute(inputGroups.iterator(), firstCallback, callback) : parallelExecute(inputGroups.iterator(), firstCallback, callback);
+ return serial ? serialExecute(executionGroups.iterator(), firstCallback, callback) : parallelExecute(executionGroups.iterator(), firstCallback, callback);
}
- private <I, O> List<O> serialExecute(final Iterator<InputGroup<I>> inputGroups, final ExecutorCallback<I, O> firstCallback, final ExecutorCallback<I, O> callback) throws SQLException {
- InputGroup<I> firstInputs = inputGroups.next();
+ private <I, O> List<O> serialExecute(final Iterator<ExecutionGroup<I>> executionGroups, final ExecutorCallback<I, O> firstCallback, final ExecutorCallback<I, O> callback) throws SQLException {
+ ExecutionGroup<I> firstInputs = executionGroups.next();
List<O> result = new LinkedList<>(syncExecute(firstInputs, null == firstCallback ? callback : firstCallback));
- while (inputGroups.hasNext()) {
- result.addAll(syncExecute(inputGroups.next(), callback));
+ while (executionGroups.hasNext()) {
+ result.addAll(syncExecute(executionGroups.next(), callback));
}
return result;
}
- private <I, O> List<O> parallelExecute(final Iterator<InputGroup<I>> inputGroups, final ExecutorCallback<I, O> firstCallback, final ExecutorCallback<I, O> callback) throws SQLException {
- InputGroup<I> firstInputs = inputGroups.next();
- Collection<ListenableFuture<Collection<O>>> restResultFutures = asyncExecute(inputGroups, callback);
+ private <I, O> List<O> parallelExecute(final Iterator<ExecutionGroup<I>> executionGroups, final ExecutorCallback<I, O> firstCallback, final ExecutorCallback<I, O> callback) throws SQLException {
+ ExecutionGroup<I> firstInputs = executionGroups.next();
+ Collection<ListenableFuture<Collection<O>>> restResultFutures = asyncExecute(executionGroups, callback);
return getGroupResults(syncExecute(firstInputs, null == firstCallback ? callback : firstCallback), restResultFutures);
}
- private <I, O> Collection<O> syncExecute(final InputGroup<I> inputGroup, final ExecutorCallback<I, O> callback) throws SQLException {
- return callback.execute(inputGroup.getInputs(), true, ExecutorDataMap.getValue());
+ private <I, O> Collection<O> syncExecute(final ExecutionGroup<I> executionGroup, final ExecutorCallback<I, O> callback) throws SQLException {
+ return callback.execute(executionGroup.getInputs(), true, ExecutorDataMap.getValue());
}
- private <I, O> Collection<ListenableFuture<Collection<O>>> asyncExecute(final Iterator<InputGroup<I>> inputGroups, final ExecutorCallback<I, O> callback) {
+ private <I, O> Collection<ListenableFuture<Collection<O>>> asyncExecute(final Iterator<ExecutionGroup<I>> executionGroups, final ExecutorCallback<I, O> callback) {
Collection<ListenableFuture<Collection<O>>> result = new LinkedList<>();
- while (inputGroups.hasNext()) {
- result.add(asyncExecute(inputGroups.next(), callback));
+ while (executionGroups.hasNext()) {
+ result.add(asyncExecute(executionGroups.next(), callback));
}
return result;
}
- private <I, O> ListenableFuture<Collection<O>> asyncExecute(final InputGroup<I> inputGroup, final ExecutorCallback<I, O> callback) {
+ private <I, O> ListenableFuture<Collection<O>> asyncExecute(final ExecutionGroup<I> executionGroup, final ExecutorCallback<I, O> callback) {
Map<String, Object> dataMap = ExecutorDataMap.getValue();
- return executorService.getExecutorService().submit(() -> callback.execute(inputGroup.getInputs(), false, dataMap));
+ return executorService.getExecutorService().submit(() -> callback.execute(executionGroup.getInputs(), false, dataMap));
}
private <O> List<O> getGroupResults(final Collection<O> firstResults, final Collection<ListenableFuture<Collection<O>>> restFutures) throws SQLException {
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/AbstractExecuteGroupEngine.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/AbstractExecutionGroupEngine.java
similarity index 70%
rename from shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/AbstractExecuteGroupEngine.java
rename to shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/AbstractExecutionGroupEngine.java
index c8a5436..55c3117 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/AbstractExecuteGroupEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/AbstractExecutionGroupEngine.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.infra.executor.sql.group;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
import org.apache.shardingsphere.infra.executor.sql.context.SQLUnit;
import org.apache.shardingsphere.infra.route.context.RouteContext;
@@ -34,33 +34,33 @@ import java.util.Map;
import java.util.Map.Entry;
/**
- * Abstract execute group engine.
+ * Abstract execution group engine.
*
* @param <T> type of input value
*/
-public abstract class AbstractExecuteGroupEngine<T> implements ExecuteGroupEngine<T> {
+public abstract class AbstractExecutionGroupEngine<T> implements ExecutionGroupEngine<T> {
static {
- ShardingSphereServiceLoader.register(ExecuteGroupDecorator.class);
+ ShardingSphereServiceLoader.register(ExecutionGroupDecorator.class);
}
@SuppressWarnings("rawtypes")
- private final Map<ShardingSphereRule, ExecuteGroupDecorator> decorators;
+ private final Map<ShardingSphereRule, ExecutionGroupDecorator> decorators;
- protected AbstractExecuteGroupEngine(final Collection<ShardingSphereRule> rules) {
- decorators = OrderedSPIRegistry.getRegisteredServices(rules, ExecuteGroupDecorator.class);
+ protected AbstractExecutionGroupEngine(final Collection<ShardingSphereRule> rules) {
+ decorators = OrderedSPIRegistry.getRegisteredServices(rules, ExecutionGroupDecorator.class);
}
@Override
- public final Collection<InputGroup<T>> group(final RouteContext routeContext, final Collection<ExecutionUnit> executionUnits) throws SQLException {
- Collection<InputGroup<T>> result = new LinkedList<>();
+ public final Collection<ExecutionGroup<T>> group(final RouteContext routeContext, final Collection<ExecutionUnit> executionUnits) throws SQLException {
+ Collection<ExecutionGroup<T>> result = new LinkedList<>();
for (Entry<String, List<SQLUnit>> entry : aggregateSQLUnitGroups(executionUnits).entrySet()) {
result.addAll(group(entry.getKey(), entry.getValue()));
}
return decorate(routeContext, result);
}
- protected abstract List<InputGroup<T>> group(String dataSourceName, List<SQLUnit> sqlUnits) throws SQLException;
+ protected abstract List<ExecutionGroup<T>> group(String dataSourceName, List<SQLUnit> sqlUnits) throws SQLException;
private Map<String, List<SQLUnit>> aggregateSQLUnitGroups(final Collection<ExecutionUnit> executionUnits) {
Map<String, List<SQLUnit>> result = new LinkedHashMap<>(executionUnits.size(), 1);
@@ -74,9 +74,9 @@ public abstract class AbstractExecuteGroupEngine<T> implements ExecuteGroupEngin
}
@SuppressWarnings({"unchecked", "rawtypes"})
- private Collection<InputGroup<T>> decorate(final RouteContext routeContext, final Collection<InputGroup<T>> inputGroups) {
- Collection<InputGroup<T>> result = inputGroups;
- for (Entry<ShardingSphereRule, ExecuteGroupDecorator> each : decorators.entrySet()) {
+ private Collection<ExecutionGroup<T>> decorate(final RouteContext routeContext, final Collection<ExecutionGroup<T>> executionGroups) {
+ Collection<ExecutionGroup<T>> result = executionGroups;
+ for (Entry<ShardingSphereRule, ExecutionGroupDecorator> each : decorators.entrySet()) {
result = each.getValue().decorate(routeContext, each.getKey(), result);
}
return result;
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecuteGroupDecorator.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecutionGroupDecorator.java
similarity index 73%
rename from shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecuteGroupDecorator.java
rename to shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecutionGroupDecorator.java
index 3599231..6dbc7c6 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecuteGroupDecorator.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecutionGroupDecorator.java
@@ -20,25 +20,25 @@ package org.apache.shardingsphere.infra.executor.sql.group;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.spi.ordered.OrderedSPI;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import java.util.Collection;
/**
- * Execute group decorator.
+ * Execution group decorator.
*
* @param <T> type of input value
* @param <R> type of ShardingSphere rule
*/
-public interface ExecuteGroupDecorator<T, R extends ShardingSphereRule> extends OrderedSPI<R> {
+public interface ExecutionGroupDecorator<T, R extends ShardingSphereRule> extends OrderedSPI<R> {
/**
- * Decorate input groups.
+ * Decorate execution groups.
*
* @param routeContext route context
* @param rule ShardingSphere rule
- * @param inputGroups input groups to be decorated
- * @return decorated input groups.
+ * @param executionGroups execution groups to be decorated
+ * @return decorated execution groups
*/
- Collection<InputGroup<T>> decorate(RouteContext routeContext, R rule, Collection<InputGroup<T>> inputGroups);
+ Collection<ExecutionGroup<T>> decorate(RouteContext routeContext, R rule, Collection<ExecutionGroup<T>> executionGroups);
}
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecuteGroupEngine.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecutionGroupEngine.java
similarity index 81%
rename from shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecuteGroupEngine.java
rename to shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecutionGroupEngine.java
index ad387d6..192e9ef 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecuteGroupEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecutionGroupEngine.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.infra.executor.sql.group;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
import org.apache.shardingsphere.infra.route.context.RouteContext;
@@ -25,19 +25,19 @@ import java.sql.SQLException;
import java.util.Collection;
/**
- * Execute group engine.
+ * Execution group engine.
*
* @param <T> type of input value
*/
-public interface ExecuteGroupEngine<T> {
+public interface ExecutionGroupEngine<T> {
/**
* Group execution units.
*
* @param routeContext route context
* @param executionUnits execution units
- * @return execution input groups
+ * @return execution groups
* @throws SQLException SQL exception
*/
- Collection<InputGroup<T>> group(RouteContext routeContext, Collection<ExecutionUnit> executionUnits) throws SQLException;
+ Collection<ExecutionGroup<T>> group(RouteContext routeContext, Collection<ExecutionUnit> executionUnits) throws SQLException;
}
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/group/RawExecuteGroupDecorator.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/raw/RawExecutionGroupDecorator.java
similarity index 81%
rename from shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/group/RawExecuteGroupDecorator.java
rename to shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/raw/RawExecutionGroupDecorator.java
index 4bcdd7a..626ef21 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/group/RawExecuteGroupDecorator.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/raw/RawExecutionGroupDecorator.java
@@ -15,16 +15,16 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.executor.sql.raw.group;
+package org.apache.shardingsphere.infra.executor.sql.group.raw;
-import org.apache.shardingsphere.infra.executor.sql.group.ExecuteGroupDecorator;
+import org.apache.shardingsphere.infra.executor.sql.group.ExecutionGroupDecorator;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
/**
- * Raw execute group decorator.
+ * Raw execution group decorator.
*
* @param <T> type of input value
* @param <R> type of ShardingSphere rule
*/
-public interface RawExecuteGroupDecorator<T, R extends ShardingSphereRule> extends ExecuteGroupDecorator<T, R> {
+public interface RawExecutionGroupDecorator<T, R extends ShardingSphereRule> extends ExecutionGroupDecorator<T, R> {
}
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/group/RawExecuteGroupEngine.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/raw/RawExecutionGroupEngine.java
similarity index 72%
rename from shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/group/RawExecuteGroupEngine.java
rename to shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/raw/RawExecutionGroupEngine.java
index 3908ed7..4c5ebd9 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/group/RawExecuteGroupEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/raw/RawExecutionGroupEngine.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.executor.sql.raw.group;
+package org.apache.shardingsphere.infra.executor.sql.group.raw;
import com.google.common.collect.Lists;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
-import org.apache.shardingsphere.infra.executor.sql.group.AbstractExecuteGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.AbstractExecutionGroupEngine;
import org.apache.shardingsphere.infra.executor.sql.raw.RawSQLExecuteUnit;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
import org.apache.shardingsphere.infra.executor.sql.context.SQLUnit;
@@ -31,34 +31,34 @@ import java.util.LinkedList;
import java.util.List;
/**
- * Raw execute group engine.
+ * Raw execution group engine.
*/
-public final class RawExecuteGroupEngine extends AbstractExecuteGroupEngine<RawSQLExecuteUnit> {
+public final class RawExecutionGroupEngine extends AbstractExecutionGroupEngine<RawSQLExecuteUnit> {
private final int maxConnectionsSizePerQuery;
- public RawExecuteGroupEngine(final int maxConnectionsSizePerQuery, final Collection<ShardingSphereRule> rules) {
+ public RawExecutionGroupEngine(final int maxConnectionsSizePerQuery, final Collection<ShardingSphereRule> rules) {
super(rules);
this.maxConnectionsSizePerQuery = maxConnectionsSizePerQuery;
}
@Override
- protected List<InputGroup<RawSQLExecuteUnit>> group(final String dataSourceName, final List<SQLUnit> sqlUnits) {
- List<InputGroup<RawSQLExecuteUnit>> result = new LinkedList<>();
+ protected List<ExecutionGroup<RawSQLExecuteUnit>> group(final String dataSourceName, final List<SQLUnit> sqlUnits) {
+ List<ExecutionGroup<RawSQLExecuteUnit>> result = new LinkedList<>();
int desiredPartitionSize = Math.max(0 == sqlUnits.size() % maxConnectionsSizePerQuery ? sqlUnits.size() / maxConnectionsSizePerQuery : sqlUnits.size() / maxConnectionsSizePerQuery + 1, 1);
List<List<SQLUnit>> sqlUnitPartitions = Lists.partition(sqlUnits, desiredPartitionSize);
ConnectionMode connectionMode = maxConnectionsSizePerQuery < sqlUnits.size() ? ConnectionMode.CONNECTION_STRICTLY : ConnectionMode.MEMORY_STRICTLY;
for (List<SQLUnit> each : sqlUnitPartitions) {
- result.add(generateSQLExecuteGroup(dataSourceName, each, connectionMode));
+ result.add(createSQLExecutionGroup(dataSourceName, each, connectionMode));
}
return result;
}
- private InputGroup<RawSQLExecuteUnit> generateSQLExecuteGroup(final String dataSourceName, final List<SQLUnit> sqlUnitGroup, final ConnectionMode connectionMode) {
+ private ExecutionGroup<RawSQLExecuteUnit> createSQLExecutionGroup(final String dataSourceName, final List<SQLUnit> sqlUnitGroup, final ConnectionMode connectionMode) {
List<RawSQLExecuteUnit> rawSQLExecuteUnits = new LinkedList<>();
for (SQLUnit each : sqlUnitGroup) {
rawSQLExecuteUnits.add(new RawSQLExecuteUnit(new ExecutionUnit(dataSourceName, each), connectionMode));
}
- return new InputGroup<>(rawSQLExecuteUnits);
+ return new ExecutionGroup<>(rawSQLExecuteUnits);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/group/ResourceManagedExecuteGroupEngine.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/ResourceManagedExecutionGroupEngine.java
similarity index 76%
rename from shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/group/ResourceManagedExecuteGroupEngine.java
rename to shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/ResourceManagedExecutionGroupEngine.java
index 565c9ca..dca6244 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/group/ResourceManagedExecuteGroupEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/ResourceManagedExecutionGroupEngine.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.executor.sql.resourced.group;
+package org.apache.shardingsphere.infra.executor.sql.group.resourced;
import com.google.common.collect.Lists;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
-import org.apache.shardingsphere.infra.executor.sql.group.AbstractExecuteGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.AbstractExecutionGroupEngine;
import org.apache.shardingsphere.infra.executor.sql.resourced.ExecutionConnection;
import org.apache.shardingsphere.infra.executor.sql.resourced.ResourceManagedExecuteUnit;
import org.apache.shardingsphere.infra.executor.sql.resourced.StorageResourceOption;
@@ -34,15 +34,15 @@ import java.util.LinkedList;
import java.util.List;
/**
- * Resource managed execute group engine.
+ * Resource managed execution group engine.
*
* @param <U> type of storage resource execute unit
* @param <E> type of execution connection
* @param <C> type of resource connection
* @param <O> type of storage resource option
*/
-public abstract class ResourceManagedExecuteGroupEngine
- <U extends ResourceManagedExecuteUnit, E extends ExecutionConnection<C, ?, O>, C, O extends StorageResourceOption> extends AbstractExecuteGroupEngine<U> {
+public abstract class ResourceManagedExecutionGroupEngine
+ <U extends ResourceManagedExecuteUnit, E extends ExecutionConnection<C, ?, O>, C, O extends StorageResourceOption> extends AbstractExecutionGroupEngine<U> {
private final int maxConnectionsSizePerQuery;
@@ -50,7 +50,7 @@ public abstract class ResourceManagedExecuteGroupEngine
private final O option;
- protected ResourceManagedExecuteGroupEngine(final int maxConnectionsSizePerQuery, final E executionConnection, final O option, final Collection<ShardingSphereRule> rules) {
+ protected ResourceManagedExecutionGroupEngine(final int maxConnectionsSizePerQuery, final E executionConnection, final O option, final Collection<ShardingSphereRule> rules) {
super(rules);
this.maxConnectionsSizePerQuery = maxConnectionsSizePerQuery;
this.executionConnection = executionConnection;
@@ -58,26 +58,26 @@ public abstract class ResourceManagedExecuteGroupEngine
}
@Override
- protected final List<InputGroup<U>> group(final String dataSourceName, final List<SQLUnit> sqlUnits) throws SQLException {
- List<InputGroup<U>> result = new LinkedList<>();
+ protected final List<ExecutionGroup<U>> group(final String dataSourceName, final List<SQLUnit> sqlUnits) throws SQLException {
+ List<ExecutionGroup<U>> result = new LinkedList<>();
int desiredPartitionSize = Math.max(0 == sqlUnits.size() % maxConnectionsSizePerQuery ? sqlUnits.size() / maxConnectionsSizePerQuery : sqlUnits.size() / maxConnectionsSizePerQuery + 1, 1);
List<List<SQLUnit>> sqlUnitPartitions = Lists.partition(sqlUnits, desiredPartitionSize);
ConnectionMode connectionMode = maxConnectionsSizePerQuery < sqlUnits.size() ? ConnectionMode.CONNECTION_STRICTLY : ConnectionMode.MEMORY_STRICTLY;
List<C> connections = executionConnection.getConnections(dataSourceName, sqlUnitPartitions.size(), connectionMode);
int count = 0;
for (List<SQLUnit> each : sqlUnitPartitions) {
- result.add(generateSQLExecuteGroup(dataSourceName, each, connections.get(count++), connectionMode));
+ result.add(createSQLExecutionGroup(dataSourceName, each, connections.get(count++), connectionMode));
}
return result;
}
- private InputGroup<U> generateSQLExecuteGroup(final String dataSourceName, final List<SQLUnit> sqlUnitGroup,
- final C connection, final ConnectionMode connectionMode) throws SQLException {
+ private ExecutionGroup<U> createSQLExecutionGroup(final String dataSourceName, final List<SQLUnit> sqlUnitGroup,
+ final C connection, final ConnectionMode connectionMode) throws SQLException {
List<U> result = new LinkedList<>();
for (SQLUnit each : sqlUnitGroup) {
result.add(createStorageResourceExecuteUnit(new ExecutionUnit(dataSourceName, each), executionConnection, connection, connectionMode, option));
}
- return new InputGroup<>(result);
+ return new ExecutionGroup<>(result);
}
protected abstract U createStorageResourceExecuteUnit(ExecutionUnit executionUnit, E executionConnection, C connection, ConnectionMode connectionMode, O option) throws SQLException;
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/group/PreparedStatementExecuteGroupEngine.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/jdbc/PreparedStatementExecutionGroupEngine.java
similarity index 80%
rename from shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/group/PreparedStatementExecuteGroupEngine.java
rename to shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/jdbc/PreparedStatementExecutionGroupEngine.java
index d8fab29..8ef76e4 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/group/PreparedStatementExecuteGroupEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/jdbc/PreparedStatementExecutionGroupEngine.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.group;
+package org.apache.shardingsphere.infra.executor.sql.group.resourced.jdbc;
import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementExecuteUnit;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementOption;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.connection.JDBCExecutionConnection;
-import org.apache.shardingsphere.infra.executor.sql.resourced.group.ResourceManagedExecuteGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.resourced.ResourceManagedExecutionGroupEngine;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import java.sql.Connection;
@@ -32,12 +32,12 @@ import java.util.Collection;
import java.util.List;
/**
- * Execute group engine for prepared statement.
+ * Execution group engine for prepared statement.
*/
-public final class PreparedStatementExecuteGroupEngine extends ResourceManagedExecuteGroupEngine<StatementExecuteUnit, JDBCExecutionConnection, Connection, StatementOption> {
+public final class PreparedStatementExecutionGroupEngine extends ResourceManagedExecutionGroupEngine<StatementExecuteUnit, JDBCExecutionConnection, Connection, StatementOption> {
- public PreparedStatementExecuteGroupEngine(final int maxConnectionsSizePerQuery,
- final JDBCExecutionConnection executionConnection, final StatementOption option, final Collection<ShardingSphereRule> rules) {
+ public PreparedStatementExecutionGroupEngine(final int maxConnectionsSizePerQuery,
+ final JDBCExecutionConnection executionConnection, final StatementOption option, final Collection<ShardingSphereRule> rules) {
super(maxConnectionsSizePerQuery, executionConnection, option, rules);
}
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/group/StatementExecuteGroupEngine.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/jdbc/StatementExecutionGroupEngine.java
similarity index 78%
rename from shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/group/StatementExecuteGroupEngine.java
rename to shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/jdbc/StatementExecutionGroupEngine.java
index 3d5ae78..794c425 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/group/StatementExecuteGroupEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/jdbc/StatementExecutionGroupEngine.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.group;
+package org.apache.shardingsphere.infra.executor.sql.group.resourced.jdbc;
import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementExecuteUnit;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementOption;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.connection.JDBCExecutionConnection;
-import org.apache.shardingsphere.infra.executor.sql.resourced.group.ResourceManagedExecuteGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.resourced.ResourceManagedExecutionGroupEngine;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import java.sql.Connection;
@@ -31,12 +31,12 @@ import java.sql.Statement;
import java.util.Collection;
/**
- * Execute group engine for statement.
+ * Execution group engine for statement.
*/
-public final class StatementExecuteGroupEngine extends ResourceManagedExecuteGroupEngine<StatementExecuteUnit, JDBCExecutionConnection, Connection, StatementOption> {
+public final class StatementExecutionGroupEngine extends ResourceManagedExecutionGroupEngine<StatementExecuteUnit, JDBCExecutionConnection, Connection, StatementOption> {
- public StatementExecuteGroupEngine(final int maxConnectionsSizePerQuery,
- final JDBCExecutionConnection executionConnection, final StatementOption option, final Collection<ShardingSphereRule> rules) {
+ public StatementExecutionGroupEngine(final int maxConnectionsSizePerQuery,
+ final JDBCExecutionConnection executionConnection, final StatementOption option, final Collection<ShardingSphereRule> rules) {
super(maxConnectionsSizePerQuery, executionConnection, option, rules);
}
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/execute/RawJDBCExecutor.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/execute/RawJDBCExecutor.java
index 54ce16b..52581d6 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/execute/RawJDBCExecutor.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/execute/RawJDBCExecutor.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.infra.executor.sql.raw.execute;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorKernel;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.query.QueryResult;
import org.apache.shardingsphere.infra.executor.sql.raw.RawSQLExecuteUnit;
import org.apache.shardingsphere.infra.executor.sql.raw.execute.callback.RawSQLExecutorCallback;
@@ -47,25 +47,25 @@ public final class RawJDBCExecutor {
/**
* Execute query.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param callback raw SQL execute callback
* @return Query results
* @throws SQLException SQL exception
*/
- public List<QueryResult> executeQuery(final Collection<InputGroup<RawSQLExecuteUnit>> inputGroups, final RawSQLExecutorCallback callback) throws SQLException {
- return doExecute(inputGroups, callback).stream().map(each -> ((ExecuteQueryResult) each).getQueryResult()).collect(Collectors.toList());
+ public List<QueryResult> executeQuery(final Collection<ExecutionGroup<RawSQLExecuteUnit>> executionGroups, final RawSQLExecutorCallback callback) throws SQLException {
+ return doExecute(executionGroups, callback).stream().map(each -> ((ExecuteQueryResult) each).getQueryResult()).collect(Collectors.toList());
}
/**
* Execute update.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param callback raw SQL execute callback
* @return update count
* @throws SQLException SQL exception
*/
- public int executeUpdate(final Collection<InputGroup<RawSQLExecuteUnit>> inputGroups, final RawSQLExecutorCallback callback) throws SQLException {
- List<Integer> results = doExecute(inputGroups, callback).stream().map(each -> ((ExecuteUpdateResult) each).getUpdateCount()).collect(Collectors.toList());
+ public int executeUpdate(final Collection<ExecutionGroup<RawSQLExecuteUnit>> executionGroups, final RawSQLExecutorCallback callback) throws SQLException {
+ List<Integer> results = doExecute(executionGroups, callback).stream().map(each -> ((ExecuteUpdateResult) each).getUpdateCount()).collect(Collectors.toList());
// TODO check is need to accumulate
// TODO refresh metadata
return accumulate(results);
@@ -82,13 +82,13 @@ public final class RawJDBCExecutor {
/**
* Execute.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param callback raw SQL execute callback
* @return return true if is DQL, false if is DML
* @throws SQLException SQL exception
*/
- public boolean execute(final Collection<InputGroup<RawSQLExecuteUnit>> inputGroups, final RawSQLExecutorCallback callback) throws SQLException {
- List<ExecuteResult> results = doExecute(inputGroups, callback);
+ public boolean execute(final Collection<ExecutionGroup<RawSQLExecuteUnit>> executionGroups, final RawSQLExecutorCallback callback) throws SQLException {
+ List<ExecuteResult> results = doExecute(executionGroups, callback);
// TODO refresh metadata
if (null == results || results.isEmpty() || null == results.get(0)) {
return false;
@@ -97,9 +97,9 @@ public final class RawJDBCExecutor {
}
@SuppressWarnings("unchecked")
- private <T> List<T> doExecute(final Collection<InputGroup<RawSQLExecuteUnit>> inputGroups, final RawSQLExecutorCallback callback) throws SQLException {
+ private <T> List<T> doExecute(final Collection<ExecutionGroup<RawSQLExecuteUnit>> executionGroups, final RawSQLExecutorCallback callback) throws SQLException {
try {
- return executorKernel.execute((Collection) inputGroups, null, callback, serial);
+ return executorKernel.execute((Collection) executionGroups, null, callback, serial);
} catch (final SQLException ex) {
ExecutorExceptionHandler.handleException(ex);
return Collections.emptyList();
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/executor/SQLExecutor.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/executor/SQLExecutor.java
index e14d8b4..f57cef0 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/executor/SQLExecutor.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/executor/SQLExecutor.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.executor;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorKernel;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementExecuteUnit;
import java.sql.SQLException;
@@ -40,29 +40,30 @@ public final class SQLExecutor {
/**
* Execute.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param callback SQL execute callback
* @param <T> class type of return value
* @return execute result
* @throws SQLException SQL exception
*/
- public <T> List<T> execute(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final SQLExecutorCallback<T> callback) throws SQLException {
- return execute(inputGroups, null, callback);
+ public <T> List<T> execute(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, final SQLExecutorCallback<T> callback) throws SQLException {
+ return execute(executionGroups, null, callback);
}
/**
* Execute.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param firstCallback first SQL execute callback
* @param callback SQL execute callback
* @param <T> class type of return value
* @return execute result
* @throws SQLException SQL exception
*/
- public <T> List<T> execute(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final SQLExecutorCallback<T> firstCallback, final SQLExecutorCallback<T> callback) throws SQLException {
+ public <T> List<T> execute(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups,
+ final SQLExecutorCallback<T> firstCallback, final SQLExecutorCallback<T> callback) throws SQLException {
try {
- return executorKernel.execute(inputGroups, firstCallback, callback, serial);
+ return executorKernel.execute(executionGroups, firstCallback, callback, serial);
} catch (final SQLException ex) {
ExecutorExceptionHandler.handleException(ex);
return Collections.emptyList();
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorEngineTest.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorKernelTest.java
similarity index 74%
rename from shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorEngineTest.java
rename to shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorKernelTest.java
index 2bb65e2..09fff2d 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorEngineTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorKernelTest.java
@@ -32,13 +32,13 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
-public final class ExecutorEngineTest {
+public final class ExecutorKernelTest {
- private final ExecutorKernel executorEngine = new ExecutorKernel(10);
+ private final ExecutorKernel executorKernel = new ExecutorKernel(10);
private final CountDownLatch latch = new CountDownLatch(4);
- private Collection<InputGroup<Object>> inputGroups;
+ private Collection<ExecutionGroup<Object>> executionGroups;
private ExecutorCallbackFixture firstCallback;
@@ -46,20 +46,20 @@ public final class ExecutorEngineTest {
@Before
public void setUp() {
- inputGroups = createMockedInputGroups(2, 2);
+ executionGroups = createMockedExecutionGroups(2, 2);
firstCallback = new ExecutorCallbackFixture(latch);
callback = new ExecutorCallbackFixture(latch);
}
@After
public void tearDown() {
- executorEngine.close();
+ executorKernel.close();
}
- private Collection<InputGroup<Object>> createMockedInputGroups(final int groupSize, final int unitSize) {
- Collection<InputGroup<Object>> result = new LinkedList<>();
+ private Collection<ExecutionGroup<Object>> createMockedExecutionGroups(final int groupSize, final int unitSize) {
+ Collection<ExecutionGroup<Object>> result = new LinkedList<>();
for (int i = 0; i < groupSize; i++) {
- result.add(new InputGroup<>(createMockedInputs(unitSize)));
+ result.add(new ExecutionGroup<>(createMockedInputs(unitSize)));
}
return result;
}
@@ -74,29 +74,29 @@ public final class ExecutorEngineTest {
@Test
public void assertParallelExecuteWithoutFirstCallback() throws SQLException, InterruptedException {
- List<String> actual = executorEngine.execute(inputGroups, callback);
+ List<String> actual = executorKernel.execute(executionGroups, callback);
latch.await();
assertThat(actual.size(), is(4));
}
@Test
public void assertParallelExecuteWithFirstCallback() throws SQLException, InterruptedException {
- List<String> actual = executorEngine.execute(inputGroups, firstCallback, callback, false);
+ List<String> actual = executorKernel.execute(executionGroups, firstCallback, callback, false);
latch.await();
assertThat(actual.size(), is(4));
}
@Test
public void assertSerialExecute() throws SQLException, InterruptedException {
- List<String> actual = executorEngine.execute(inputGroups, firstCallback, callback, true);
+ List<String> actual = executorKernel.execute(executionGroups, firstCallback, callback, true);
latch.await();
assertThat(actual.size(), is(4));
}
@Test
- public void assertInputGroupIsEmpty() throws SQLException {
+ public void assertExecutionGroupIsEmpty() throws SQLException {
CountDownLatch latch = new CountDownLatch(1);
- List<String> actual = executorEngine.execute(new LinkedList<>(), new ExecutorCallbackFixture(latch));
+ List<String> actual = executorKernel.execute(new LinkedList<>(), new ExecutorCallbackFixture(latch));
latch.countDown();
assertThat(actual.size(), is(0));
}
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/StatementExecuteGroupEngineTest.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/jdbc/PreparedStatementExecutionGroupEngineTest.java
similarity index 81%
rename from shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/StatementExecuteGroupEngineTest.java
rename to shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/jdbc/PreparedStatementExecutionGroupEngineTest.java
index b4fbb20..38ef0ec 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/StatementExecuteGroupEngineTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/jdbc/PreparedStatementExecutionGroupEngineTest.java
@@ -15,16 +15,15 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.executor.sql.execute.jdbc.group;
+package org.apache.shardingsphere.infra.executor.sql.group.resourced.jdbc;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
import org.apache.shardingsphere.infra.executor.sql.context.SQLUnit;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementExecuteUnit;
-import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.connection.JDBCExecutionConnection;
-import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.group.StatementExecuteGroupEngine;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementOption;
+import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.connection.JDBCExecutionConnection;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.junit.Test;
@@ -46,28 +45,28 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
-public final class StatementExecuteGroupEngineTest {
+public final class PreparedStatementExecutionGroupEngineTest {
- private StatementExecuteGroupEngine executeGroupEngine;
+ private PreparedStatementExecutionGroupEngine groupEngine;
@Test
public void assertGetExecuteUnitGroupForOneShardMemoryStrictly() throws SQLException {
- executeGroupEngine = new StatementExecuteGroupEngine(
+ groupEngine = new PreparedStatementExecutionGroupEngine(
2, mockExecutionConnection(1, ConnectionMode.MEMORY_STRICTLY), new StatementOption(true), Collections.singletonList(mock(ShardingSphereRule.class)));
- Collection<InputGroup<StatementExecuteUnit>> actual = executeGroupEngine.group(mock(RouteContext.class), mockShardRouteUnit(1, 1));
+ Collection<ExecutionGroup<StatementExecuteUnit>> actual = groupEngine.group(mock(RouteContext.class), mockShardRouteUnit(1, 1));
assertThat(actual.size(), is(1));
- for (InputGroup<StatementExecuteUnit> each : actual) {
+ for (ExecutionGroup<StatementExecuteUnit> each : actual) {
assertThat(each.getInputs().size(), is(1));
}
}
@Test
public void assertGetExecuteUnitGroupForMultiShardConnectionStrictly() throws SQLException {
- executeGroupEngine = new StatementExecuteGroupEngine(
+ groupEngine = new PreparedStatementExecutionGroupEngine(
1, mockExecutionConnection(1, ConnectionMode.CONNECTION_STRICTLY), new StatementOption(true), Collections.singletonList(mock(ShardingSphereRule.class)));
- Collection<InputGroup<StatementExecuteUnit>> actual = executeGroupEngine.group(mock(RouteContext.class), mockShardRouteUnit(10, 2));
+ Collection<ExecutionGroup<StatementExecuteUnit>> actual = groupEngine.group(mock(RouteContext.class), mockShardRouteUnit(10, 2));
assertThat(actual.size(), is(10));
- for (InputGroup<StatementExecuteUnit> each : actual) {
+ for (ExecutionGroup<StatementExecuteUnit> each : actual) {
assertThat(each.getInputs().size(), is(2));
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/PreparedStatementExecuteGroupEngineTest.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/jdbc/StatementExecutionGroupEngineTest.java
similarity index 79%
rename from shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/PreparedStatementExecuteGroupEngineTest.java
rename to shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/jdbc/StatementExecutionGroupEngineTest.java
index a0584d7..2112e57 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/PreparedStatementExecuteGroupEngineTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/group/resourced/jdbc/StatementExecutionGroupEngineTest.java
@@ -15,16 +15,15 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.executor.sql.execute.jdbc.group;
+package org.apache.shardingsphere.infra.executor.sql.group.resourced.jdbc;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
import org.apache.shardingsphere.infra.executor.sql.context.SQLUnit;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementExecuteUnit;
-import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.connection.JDBCExecutionConnection;
-import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.group.PreparedStatementExecuteGroupEngine;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementOption;
+import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.connection.JDBCExecutionConnection;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.junit.Test;
@@ -46,28 +45,28 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
-public final class PreparedStatementExecuteGroupEngineTest {
+public final class StatementExecutionGroupEngineTest {
- private PreparedStatementExecuteGroupEngine preparedStatementExecuteGroupEngine;
+ private StatementExecutionGroupEngine groupEngine;
@Test
public void assertGetExecuteUnitGroupForOneShardMemoryStrictly() throws SQLException {
- preparedStatementExecuteGroupEngine = new PreparedStatementExecuteGroupEngine(
+ groupEngine = new StatementExecutionGroupEngine(
2, mockExecutionConnection(1, ConnectionMode.MEMORY_STRICTLY), new StatementOption(true), Collections.singletonList(mock(ShardingSphereRule.class)));
- Collection<InputGroup<StatementExecuteUnit>> actual = preparedStatementExecuteGroupEngine.group(mock(RouteContext.class), mockShardRouteUnit(1, 1));
+ Collection<ExecutionGroup<StatementExecuteUnit>> actual = groupEngine.group(mock(RouteContext.class), mockShardRouteUnit(1, 1));
assertThat(actual.size(), is(1));
- for (InputGroup<StatementExecuteUnit> each : actual) {
+ for (ExecutionGroup<StatementExecuteUnit> each : actual) {
assertThat(each.getInputs().size(), is(1));
}
}
@Test
public void assertGetExecuteUnitGroupForMultiShardConnectionStrictly() throws SQLException {
- preparedStatementExecuteGroupEngine = new PreparedStatementExecuteGroupEngine(
+ groupEngine = new StatementExecutionGroupEngine(
1, mockExecutionConnection(1, ConnectionMode.CONNECTION_STRICTLY), new StatementOption(true), Collections.singletonList(mock(ShardingSphereRule.class)));
- Collection<InputGroup<StatementExecuteUnit>> actual = preparedStatementExecuteGroupEngine.group(mock(RouteContext.class), mockShardRouteUnit(10, 2));
+ Collection<ExecutionGroup<StatementExecuteUnit>> actual = groupEngine.group(mock(RouteContext.class), mockShardRouteUnit(10, 2));
assertThat(actual.size(), is(10));
- for (InputGroup<StatementExecuteUnit> each : actual) {
+ for (ExecutionGroup<StatementExecuteUnit> each : actual) {
assertThat(each.getInputs().size(), is(2));
}
}
@@ -97,5 +96,4 @@ public final class PreparedStatementExecuteGroupEngineTest {
}
return result;
}
-
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/AbstractStatementExecutor.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/AbstractStatementExecutor.java
index 6ca642d..037ed38 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/AbstractStatementExecutor.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/AbstractStatementExecutor.java
@@ -22,7 +22,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
import org.apache.shardingsphere.infra.database.DefaultSchema;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.query.QueryResult;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementExecuteUnit;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.executor.SQLExecutor;
@@ -92,9 +92,9 @@ public abstract class AbstractStatementExecutor {
OrderedSPIRegistry.getRegisteredServices(Collections.singletonList(schema), SchemaChangedNotifier.class).values().forEach(each -> each.notify(schemaName, schema));
}
- protected final boolean executeAndRefreshMetaData(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final SQLStatement sqlStatement,
- final Collection<RouteUnit> routeUnits, final SQLExecutorCallback<Boolean> sqlExecutorCallback) throws SQLException {
- List<Boolean> result = sqlExecutor.execute(inputGroups, sqlExecutorCallback);
+ protected final boolean executeAndRefreshMetaData(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, final SQLStatement sqlStatement,
+ final Collection<RouteUnit> routeUnits, final SQLExecutorCallback<Boolean> sqlExecutorCallback) throws SQLException {
+ List<Boolean> result = sqlExecutor.execute(executionGroups, sqlExecutorCallback);
refreshSchema(metaDataContexts.getDefaultMetaData(), sqlStatement, routeUnits);
return null != result && !result.isEmpty() && null != result.get(0) && result.get(0);
}
@@ -102,31 +102,32 @@ public abstract class AbstractStatementExecutor {
/**
* Execute SQL.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param sqlStatement SQL statement
* @param routeUnits route units
* @return return true if is DQL, false if is DML
* @throws SQLException SQL exception
*/
- public abstract boolean execute(Collection<InputGroup<StatementExecuteUnit>> inputGroups, SQLStatement sqlStatement, Collection<RouteUnit> routeUnits) throws SQLException;
+ public abstract boolean execute(Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, SQLStatement sqlStatement, Collection<RouteUnit> routeUnits) throws SQLException;
/**
* Execute query.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @return result set list
* @throws SQLException SQL exception
*/
- public abstract List<QueryResult> executeQuery(Collection<InputGroup<StatementExecuteUnit>> inputGroups) throws SQLException;
+ public abstract List<QueryResult> executeQuery(Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups) throws SQLException;
/**
* Execute update.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param sqlStatementContext SQL statement context
* @param routeUnits route units
* @return effected records count
* @throws SQLException SQL exception
*/
- public abstract int executeUpdate(Collection<InputGroup<StatementExecuteUnit>> inputGroups, SQLStatementContext<?> sqlStatementContext, Collection<RouteUnit> routeUnits) throws SQLException;
+ public abstract int executeUpdate(Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups,
+ SQLStatementContext<?> sqlStatementContext, Collection<RouteUnit> routeUnits) throws SQLException;
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/PreparedStatementExecutor.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/PreparedStatementExecutor.java
index 89592c0..b0aa6e1 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/PreparedStatementExecutor.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/PreparedStatementExecutor.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.driver.executor;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.query.QueryResult;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementExecuteUnit;
@@ -53,10 +53,10 @@ public final class PreparedStatementExecutor extends AbstractStatementExecutor {
}
@Override
- public List<QueryResult> executeQuery(final Collection<InputGroup<StatementExecuteUnit>> inputGroups) throws SQLException {
+ public List<QueryResult> executeQuery(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups) throws SQLException {
boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
SQLExecutorCallback<QueryResult> sqlExecutorCallback = createDefaultSQLExecutorCallbackWithQueryResult(isExceptionThrown);
- return getSqlExecutor().execute(inputGroups, sqlExecutorCallback);
+ return getSqlExecutor().execute(executionGroups, sqlExecutorCallback);
}
private DefaultSQLExecutorCallback<QueryResult> createDefaultSQLExecutorCallbackWithQueryResult(final boolean isExceptionThrown) {
@@ -76,11 +76,11 @@ public final class PreparedStatementExecutor extends AbstractStatementExecutor {
}
@Override
- public int executeUpdate(final Collection<InputGroup<StatementExecuteUnit>> inputGroups,
+ public int executeUpdate(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups,
final SQLStatementContext<?> sqlStatementContext, final Collection<RouteUnit> routeUnits) throws SQLException {
boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
SQLExecutorCallback<Integer> sqlExecutorCallback = createDefaultSQLExecutorCallbackWithInteger(isExceptionThrown);
- List<Integer> results = getSqlExecutor().execute(inputGroups, sqlExecutorCallback);
+ List<Integer> results = getSqlExecutor().execute(executionGroups, sqlExecutorCallback);
refreshSchema(getMetaDataContexts().getDefaultMetaData(), sqlStatementContext.getSqlStatement(), routeUnits);
return isNeedAccumulate(getMetaDataContexts().getDefaultMetaData().getRuleMetaData().getRules().stream().filter(
rule -> rule instanceof DataNodeContainedRule).collect(Collectors.toList()), sqlStatementContext) ? accumulate(results) : results.get(0);
@@ -97,10 +97,10 @@ public final class PreparedStatementExecutor extends AbstractStatementExecutor {
}
@Override
- public boolean execute(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final SQLStatement sqlStatement, final Collection<RouteUnit> routeUnits) throws SQLException {
+ public boolean execute(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, final SQLStatement sqlStatement, final Collection<RouteUnit> routeUnits) throws SQLException {
boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
SQLExecutorCallback<Boolean> sqlExecutorCallback = createDefaultSQLExecutorCallbackWithBoolean(isExceptionThrown);
- return executeAndRefreshMetaData(inputGroups, sqlStatement, routeUnits, sqlExecutorCallback);
+ return executeAndRefreshMetaData(executionGroups, sqlStatement, routeUnits, sqlExecutorCallback);
}
private DefaultSQLExecutorCallback<Boolean> createDefaultSQLExecutorCallbackWithBoolean(final boolean isExceptionThrown) {
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/StatementExecutor.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/StatementExecutor.java
index adc54dd..48a3614 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/StatementExecutor.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/StatementExecutor.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.driver.executor;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.query.QueryResult;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementExecuteUnit;
@@ -52,7 +52,7 @@ public final class StatementExecutor extends AbstractStatementExecutor {
}
@Override
- public List<QueryResult> executeQuery(final Collection<InputGroup<StatementExecuteUnit>> inputGroups) throws SQLException {
+ public List<QueryResult> executeQuery(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups) throws SQLException {
boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
SQLExecutorCallback<QueryResult> sqlExecutorCallback = new DefaultSQLExecutorCallback<QueryResult>(getMetaDataContexts().getDatabaseType(), isExceptionThrown) {
@@ -66,62 +66,62 @@ public final class StatementExecutor extends AbstractStatementExecutor {
return ConnectionMode.MEMORY_STRICTLY == connectionMode ? new StreamJDBCQueryResult(resultSet) : new MemoryJDBCQueryResult(resultSet);
}
};
- return getSqlExecutor().execute(inputGroups, sqlExecutorCallback);
+ return getSqlExecutor().execute(executionGroups, sqlExecutorCallback);
}
@Override
- public int executeUpdate(final Collection<InputGroup<StatementExecuteUnit>> inputGroups,
+ public int executeUpdate(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups,
final SQLStatementContext<?> sqlStatementContext, final Collection<RouteUnit> routeUnits) throws SQLException {
- return executeUpdate(inputGroups, Statement::executeUpdate, sqlStatementContext, routeUnits);
+ return executeUpdate(executionGroups, Statement::executeUpdate, sqlStatementContext, routeUnits);
}
/**
* Execute update with auto generated keys.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param sqlStatementContext SQL statement context
* @param routeUnits route units
* @param autoGeneratedKeys auto generated keys' flag
* @return effected records count
* @throws SQLException SQL exception
*/
- public int executeUpdate(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final SQLStatementContext<?> sqlStatementContext,
+ public int executeUpdate(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, final SQLStatementContext<?> sqlStatementContext,
final Collection<RouteUnit> routeUnits, final int autoGeneratedKeys) throws SQLException {
- return executeUpdate(inputGroups, (statement, sql) -> statement.executeUpdate(sql, autoGeneratedKeys), sqlStatementContext, routeUnits);
+ return executeUpdate(executionGroups, (statement, sql) -> statement.executeUpdate(sql, autoGeneratedKeys), sqlStatementContext, routeUnits);
}
/**
* Execute update with column indexes.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param sqlStatementContext SQL statement context
* @param routeUnits route units
* @param columnIndexes column indexes
* @return effected records count
* @throws SQLException SQL exception
*/
- public int executeUpdate(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final SQLStatementContext<?> sqlStatementContext,
+ public int executeUpdate(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, final SQLStatementContext<?> sqlStatementContext,
final Collection<RouteUnit> routeUnits, final int[] columnIndexes) throws SQLException {
- return executeUpdate(inputGroups, (statement, sql) -> statement.executeUpdate(sql, columnIndexes), sqlStatementContext, routeUnits);
+ return executeUpdate(executionGroups, (statement, sql) -> statement.executeUpdate(sql, columnIndexes), sqlStatementContext, routeUnits);
}
/**
* Execute update with column names.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param sqlStatementContext SQL statement context
* @param routeUnits route units
* @param columnNames column names
* @return effected records count
* @throws SQLException SQL exception
*/
- public int executeUpdate(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final SQLStatementContext<?> sqlStatementContext,
+ public int executeUpdate(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, final SQLStatementContext<?> sqlStatementContext,
final Collection<RouteUnit> routeUnits, final String[] columnNames) throws SQLException {
- return executeUpdate(inputGroups, (statement, sql) -> statement.executeUpdate(sql, columnNames), sqlStatementContext, routeUnits);
+ return executeUpdate(executionGroups, (statement, sql) -> statement.executeUpdate(sql, columnNames), sqlStatementContext, routeUnits);
}
@SuppressWarnings({"unchecked", "rawtypes"})
- private int executeUpdate(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final Updater updater,
+ private int executeUpdate(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, final Updater updater,
final SQLStatementContext<?> sqlStatementContext, final Collection<RouteUnit> routeUnits) throws SQLException {
boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
SQLExecutorCallback sqlExecutorCallback = new DefaultSQLExecutorCallback<Integer>(getMetaDataContexts().getDatabaseType(), isExceptionThrown) {
@@ -131,7 +131,7 @@ public final class StatementExecutor extends AbstractStatementExecutor {
return updater.executeUpdate(statement, sql);
}
};
- List<Integer> results = getSqlExecutor().execute(inputGroups, sqlExecutorCallback);
+ List<Integer> results = getSqlExecutor().execute(executionGroups, sqlExecutorCallback);
refreshSchema(getMetaDataContexts().getDefaultMetaData(), sqlStatementContext.getSqlStatement(), routeUnits);
if (isNeedAccumulate(getMetaDataContexts().getDefaultMetaData().getRuleMetaData().getRules().stream().filter(
rule -> rule instanceof DataNodeContainedRule).collect(Collectors.toList()), sqlStatementContext)) {
@@ -141,57 +141,57 @@ public final class StatementExecutor extends AbstractStatementExecutor {
}
@Override
- public boolean execute(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final SQLStatement sqlStatement, final Collection<RouteUnit> routeUnits) throws SQLException {
- return execute(inputGroups, Statement::execute, sqlStatement, routeUnits);
+ public boolean execute(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, final SQLStatement sqlStatement, final Collection<RouteUnit> routeUnits) throws SQLException {
+ return execute(executionGroups, Statement::execute, sqlStatement, routeUnits);
}
/**
* Execute SQL with auto generated keys.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param sqlStatement SQL statement
* @param routeUnits route units
* @param autoGeneratedKeys auto generated keys' flag
* @return return true if is DQL, false if is DML
* @throws SQLException SQL exception
*/
- public boolean execute(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final SQLStatement sqlStatement,
+ public boolean execute(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, final SQLStatement sqlStatement,
final Collection<RouteUnit> routeUnits, final int autoGeneratedKeys) throws SQLException {
- return execute(inputGroups, (statement, sql) -> statement.execute(sql, autoGeneratedKeys), sqlStatement, routeUnits);
+ return execute(executionGroups, (statement, sql) -> statement.execute(sql, autoGeneratedKeys), sqlStatement, routeUnits);
}
/**
* Execute SQL with column indexes.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param sqlStatement SQL statement
* @param routeUnits route units
* @param columnIndexes column indexes
* @return return true if is DQL, false if is DML
* @throws SQLException SQL exception
*/
- public boolean execute(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final SQLStatement sqlStatement,
+ public boolean execute(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, final SQLStatement sqlStatement,
final Collection<RouteUnit> routeUnits, final int[] columnIndexes) throws SQLException {
- return execute(inputGroups, (statement, sql) -> statement.execute(sql, columnIndexes), sqlStatement, routeUnits);
+ return execute(executionGroups, (statement, sql) -> statement.execute(sql, columnIndexes), sqlStatement, routeUnits);
}
/**
* Execute SQL with column names.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param sqlStatement SQL statement
* @param routeUnits route units
* @param columnNames column names
* @return return true if is DQL, false if is DML
* @throws SQLException SQL exception
*/
- public boolean execute(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final SQLStatement sqlStatement,
+ public boolean execute(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, final SQLStatement sqlStatement,
final Collection<RouteUnit> routeUnits, final String[] columnNames) throws SQLException {
- return execute(inputGroups, (statement, sql) -> statement.execute(sql, columnNames), sqlStatement, routeUnits);
+ return execute(executionGroups, (statement, sql) -> statement.execute(sql, columnNames), sqlStatement, routeUnits);
}
@SuppressWarnings({"unchecked", "rawtypes"})
- private boolean execute(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final Executor executor,
+ private boolean execute(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, final Executor executor,
final SQLStatement sqlStatement, final Collection<RouteUnit> routeUnits) throws SQLException {
boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
SQLExecutorCallback sqlExecutorCallback = new DefaultSQLExecutorCallback<Boolean>(getMetaDataContexts().getDatabaseType(), isExceptionThrown) {
@@ -201,7 +201,7 @@ public final class StatementExecutor extends AbstractStatementExecutor {
return executor.execute(statement, sql);
}
};
- return executeAndRefreshMetaData(inputGroups, sqlStatement, routeUnits, sqlExecutorCallback);
+ return executeAndRefreshMetaData(executionGroups, sqlStatement, routeUnits, sqlExecutorCallback);
}
private interface Updater {
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutor.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutor.java
index fb1eddc..bbf1eec 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutor.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.driver.executor.batch;
import com.google.common.base.Preconditions;
import lombok.Getter;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementExecuteUnit;
@@ -52,7 +52,7 @@ public final class BatchPreparedStatementExecutor {
private final SQLExecutor sqlExecutor;
- private final Collection<InputGroup<StatementExecuteUnit>> inputGroups;
+ private final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups;
@Getter
private final Collection<BatchExecutionUnit> batchExecutionUnits;
@@ -62,17 +62,17 @@ public final class BatchPreparedStatementExecutor {
public BatchPreparedStatementExecutor(final MetaDataContexts metaDataContexts, final SQLExecutor sqlExecutor) {
this.metaDataContexts = metaDataContexts;
this.sqlExecutor = sqlExecutor;
- inputGroups = new LinkedList<>();
+ executionGroups = new LinkedList<>();
batchExecutionUnits = new LinkedList<>();
}
/**
* Initialize executor.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
*/
- public void init(final Collection<InputGroup<StatementExecuteUnit>> inputGroups) {
- this.inputGroups.addAll(inputGroups);
+ public void init(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups) {
+ this.executionGroups.addAll(executionGroups);
}
/**
@@ -126,7 +126,7 @@ public final class BatchPreparedStatementExecutor {
return statement.executeBatch();
}
};
- List<int[]> results = sqlExecutor.execute(inputGroups, callback);
+ List<int[]> results = sqlExecutor.execute(executionGroups, callback);
return isNeedAccumulate(
metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules().stream().filter(rule -> rule instanceof DataNodeContainedRule).collect(Collectors.toList()), sqlStatementContext)
? accumulate(results) : results.get(0);
@@ -139,7 +139,7 @@ public final class BatchPreparedStatementExecutor {
private int[] accumulate(final List<int[]> results) {
int[] result = new int[batchCount];
int count = 0;
- for (InputGroup<StatementExecuteUnit> each : inputGroups) {
+ for (ExecutionGroup<StatementExecuteUnit> each : executionGroups) {
for (StatementExecuteUnit eachUnit : each.getInputs()) {
Map<Integer, Integer> jdbcAndActualAddBatchCallTimesMap = Collections.emptyMap();
for (BatchExecutionUnit eachExecutionUnit : batchExecutionUnits) {
@@ -170,7 +170,7 @@ public final class BatchPreparedStatementExecutor {
*/
public List<Statement> getStatements() {
List<Statement> result = new LinkedList<>();
- for (InputGroup<StatementExecuteUnit> each : inputGroups) {
+ for (ExecutionGroup<StatementExecuteUnit> each : executionGroups) {
result.addAll(each.getInputs().stream().map(StatementExecuteUnit::getStorageResource).collect(Collectors.toList()));
}
return result;
@@ -183,12 +183,12 @@ public final class BatchPreparedStatementExecutor {
* @return parameter sets
*/
public List<List<Object>> getParameterSet(final Statement statement) {
- return inputGroups.stream().map(each -> findStatementExecuteUnit(statement, each)).filter(Optional::isPresent).findFirst().map(Optional::get)
+ return executionGroups.stream().map(each -> findStatementExecuteUnit(statement, each)).filter(Optional::isPresent).findFirst().map(Optional::get)
.map(this::getParameterSets).orElse(Collections.emptyList());
}
- private Optional<StatementExecuteUnit> findStatementExecuteUnit(final Statement statement, final InputGroup<StatementExecuteUnit> executeGroup) {
- return executeGroup.getInputs().stream().filter(each -> each.getStorageResource().equals(statement)).findFirst();
+ private Optional<StatementExecuteUnit> findStatementExecuteUnit(final Statement statement, final ExecutionGroup<StatementExecuteUnit> executionGroup) {
+ return executionGroup.getInputs().stream().filter(each -> each.getStorageResource().equals(statement)).findFirst();
}
private List<List<Object>> getParameterSets(final StatementExecuteUnit executeUnit) {
@@ -205,7 +205,7 @@ public final class BatchPreparedStatementExecutor {
public void clear() throws SQLException {
closeStatements();
getStatements().clear();
- inputGroups.clear();
+ executionGroups.clear();
batchCount = 0;
batchExecutionUnits.clear();
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
index 372159a..492589f 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
@@ -39,7 +39,7 @@ import org.apache.shardingsphere.infra.context.kernel.KernelProcessor;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.exception.ShardingSphereException;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.ExecutorConstant;
import org.apache.shardingsphere.infra.executor.sql.query.QueryResult;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionContext;
@@ -47,10 +47,10 @@ import org.apache.shardingsphere.infra.executor.sql.log.SQLLogger;
import org.apache.shardingsphere.infra.executor.sql.raw.RawSQLExecuteUnit;
import org.apache.shardingsphere.infra.executor.sql.raw.execute.RawJDBCExecutor;
import org.apache.shardingsphere.infra.executor.sql.raw.execute.callback.RawSQLExecutorCallback;
-import org.apache.shardingsphere.infra.executor.sql.raw.group.RawExecuteGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.raw.RawExecutionGroupEngine;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementExecuteUnit;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.executor.SQLExecutor;
-import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.group.PreparedStatementExecuteGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.resourced.jdbc.PreparedStatementExecutionGroupEngine;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementOption;
import org.apache.shardingsphere.infra.executor.sql.query.jdbc.StreamJDBCQueryResult;
import org.apache.shardingsphere.infra.merge.MergeEngine;
@@ -157,12 +157,12 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
executionContext = createExecutionContext();
List<QueryResult> queryResults;
if (ExecutorConstant.MANAGED_RESOURCE) {
- Collection<InputGroup<StatementExecuteUnit>> inputGroups = getInputGroups();
- cacheStatements(inputGroups);
+ Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups = createExecutionGroups();
+ cacheStatements(executionGroups);
reply();
- queryResults = preparedStatementExecutor.executeQuery(inputGroups);
+ queryResults = preparedStatementExecutor.executeQuery(executionGroups);
} else {
- queryResults = rawExecutor.executeQuery(getRawInputGroups(), new RawSQLExecutorCallback());
+ queryResults = rawExecutor.executeQuery(createRawExecutionGroups(), new RawSQLExecutorCallback());
}
MergedResult mergedResult = mergeQuery(queryResults);
result = new ShardingSphereResultSet(statements.stream().map(this::getResultSet).collect(Collectors.toList()), mergedResult, this, executionContext);
@@ -179,12 +179,12 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
clearPrevious();
executionContext = createExecutionContext();
if (ExecutorConstant.MANAGED_RESOURCE) {
- Collection<InputGroup<StatementExecuteUnit>> inputGroups = getInputGroups();
- cacheStatements(inputGroups);
+ Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups = createExecutionGroups();
+ cacheStatements(executionGroups);
reply();
- return preparedStatementExecutor.executeUpdate(inputGroups, executionContext.getSqlStatementContext(), executionContext.getRouteContext().getRouteUnits());
+ return preparedStatementExecutor.executeUpdate(executionGroups, executionContext.getSqlStatementContext(), executionContext.getRouteContext().getRouteUnits());
} else {
- return rawExecutor.executeUpdate(getRawInputGroups(), new RawSQLExecutorCallback());
+ return rawExecutor.executeUpdate(createRawExecutionGroups(), new RawSQLExecutorCallback());
}
} finally {
clearBatch();
@@ -197,28 +197,28 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
clearPrevious();
executionContext = createExecutionContext();
if (ExecutorConstant.MANAGED_RESOURCE) {
- Collection<InputGroup<StatementExecuteUnit>> inputGroups = getInputGroups();
- cacheStatements(inputGroups);
+ Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups = createExecutionGroups();
+ cacheStatements(executionGroups);
reply();
- return preparedStatementExecutor.execute(inputGroups, executionContext.getSqlStatementContext().getSqlStatement(), executionContext.getRouteContext().getRouteUnits());
+ return preparedStatementExecutor.execute(executionGroups, executionContext.getSqlStatementContext().getSqlStatement(), executionContext.getRouteContext().getRouteUnits());
} else {
// TODO process getStatement
- return rawExecutor.execute(getRawInputGroups(), new RawSQLExecutorCallback());
+ return rawExecutor.execute(createRawExecutionGroups(), new RawSQLExecutorCallback());
}
} finally {
clearBatch();
}
}
- private Collection<InputGroup<StatementExecuteUnit>> getInputGroups() throws SQLException {
+ private Collection<ExecutionGroup<StatementExecuteUnit>> createExecutionGroups() throws SQLException {
int maxConnectionsSizePerQuery = metaDataContexts.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
- return new PreparedStatementExecuteGroupEngine(maxConnectionsSizePerQuery, connection, statementOption,
+ return new PreparedStatementExecutionGroupEngine(maxConnectionsSizePerQuery, connection, statementOption,
metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules()).group(executionContext.getRouteContext(), executionContext.getExecutionUnits());
}
- private Collection<InputGroup<RawSQLExecuteUnit>> getRawInputGroups() throws SQLException {
+ private Collection<ExecutionGroup<RawSQLExecuteUnit>> createRawExecutionGroups() throws SQLException {
int maxConnectionsSizePerQuery = metaDataContexts.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
- return new RawExecuteGroupEngine(maxConnectionsSizePerQuery, metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules())
+ return new RawExecutionGroupEngine(maxConnectionsSizePerQuery, metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules())
.group(executionContext.getRouteContext(), executionContext.getExecutionUnits());
}
@@ -287,8 +287,8 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
replayMethodForStatements();
}
- private void cacheStatements(final Collection<InputGroup<StatementExecuteUnit>> inputGroups) {
- for (InputGroup<StatementExecuteUnit> each : inputGroups) {
+ private void cacheStatements(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups) {
+ for (ExecutionGroup<StatementExecuteUnit> each : executionGroups) {
statements.addAll(each.getInputs().stream().map(statementExecuteUnit -> (PreparedStatement) statementExecuteUnit.getStorageResource()).collect(Collectors.toList()));
parameterSets.addAll(each.getInputs().stream().map(input -> input.getExecutionUnit().getSqlUnit().getParameters()).collect(Collectors.toList()));
}
@@ -355,10 +355,10 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
}
private void initBatchPreparedStatementExecutor() throws SQLException {
- PreparedStatementExecuteGroupEngine executeGroupEngine = new PreparedStatementExecuteGroupEngine(
+ PreparedStatementExecutionGroupEngine groupEngine = new PreparedStatementExecutionGroupEngine(
metaDataContexts.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY),
connection, statementOption, metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules());
- batchPreparedStatementExecutor.init(executeGroupEngine.group(executionContext.getRouteContext(),
+ batchPreparedStatementExecutor.init(groupEngine.group(executionContext.getRouteContext(),
new ArrayList<>(batchPreparedStatementExecutor.getBatchExecutionUnits()).stream().map(BatchExecutionUnit::getExecutionUnit).collect(Collectors.toList())));
setBatchParametersForStatements();
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
index a529edd..f8d457e 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
@@ -37,7 +37,7 @@ import org.apache.shardingsphere.infra.context.kernel.KernelProcessor;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.exception.ShardingSphereException;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.ExecutorConstant;
import org.apache.shardingsphere.infra.executor.sql.query.QueryResult;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionContext;
@@ -45,10 +45,10 @@ import org.apache.shardingsphere.infra.executor.sql.log.SQLLogger;
import org.apache.shardingsphere.infra.executor.sql.raw.RawSQLExecuteUnit;
import org.apache.shardingsphere.infra.executor.sql.raw.execute.RawJDBCExecutor;
import org.apache.shardingsphere.infra.executor.sql.raw.execute.callback.RawSQLExecutorCallback;
-import org.apache.shardingsphere.infra.executor.sql.raw.group.RawExecuteGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.raw.RawExecutionGroupEngine;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementExecuteUnit;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.executor.SQLExecutor;
-import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.group.StatementExecuteGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.resourced.jdbc.StatementExecutionGroupEngine;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementOption;
import org.apache.shardingsphere.infra.executor.sql.query.jdbc.StreamJDBCQueryResult;
import org.apache.shardingsphere.infra.merge.MergeEngine;
@@ -126,11 +126,11 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
executionContext = createExecutionContext(sql);
List<QueryResult> queryResults;
if (ExecutorConstant.MANAGED_RESOURCE) {
- Collection<InputGroup<StatementExecuteUnit>> inputGroups = getInputGroups();
- cacheStatements(inputGroups);
- queryResults = statementExecutor.executeQuery(inputGroups);
+ Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups = createExecutionGroups();
+ cacheStatements(executionGroups);
+ queryResults = statementExecutor.executeQuery(executionGroups);
} else {
- queryResults = rawExecutor.executeQuery(getRawInputGroups(), new RawSQLExecutorCallback());
+ queryResults = rawExecutor.executeQuery(createRawExecutionGroups(), new RawSQLExecutorCallback());
}
MergedResult mergedResult = mergeQuery(queryResults);
result = new ShardingSphereResultSet(statements.stream().map(this::getResultSet).collect(Collectors.toList()), mergedResult, this, executionContext);
@@ -146,11 +146,11 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
try {
executionContext = createExecutionContext(sql);
if (ExecutorConstant.MANAGED_RESOURCE) {
- Collection<InputGroup<StatementExecuteUnit>> inputGroups = getInputGroups();
- cacheStatements(inputGroups);
- return statementExecutor.executeUpdate(inputGroups, executionContext.getSqlStatementContext(), executionContext.getRouteContext().getRouteUnits());
+ Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups = createExecutionGroups();
+ cacheStatements(executionGroups);
+ return statementExecutor.executeUpdate(executionGroups, executionContext.getSqlStatementContext(), executionContext.getRouteContext().getRouteUnits());
} else {
- return rawExecutor.executeUpdate(getRawInputGroups(), new RawSQLExecutorCallback());
+ return rawExecutor.executeUpdate(createRawExecutionGroups(), new RawSQLExecutorCallback());
}
} finally {
currentResultSet = null;
@@ -165,11 +165,11 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
try {
executionContext = createExecutionContext(sql);
if (ExecutorConstant.MANAGED_RESOURCE) {
- Collection<InputGroup<StatementExecuteUnit>> inputGroups = getInputGroups();
- cacheStatements(inputGroups);
- return statementExecutor.executeUpdate(inputGroups, executionContext.getSqlStatementContext(), executionContext.getRouteContext().getRouteUnits(), autoGeneratedKeys);
+ Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups = createExecutionGroups();
+ cacheStatements(executionGroups);
+ return statementExecutor.executeUpdate(executionGroups, executionContext.getSqlStatementContext(), executionContext.getRouteContext().getRouteUnits(), autoGeneratedKeys);
} else {
- return rawExecutor.executeUpdate(getRawInputGroups(), new RawSQLExecutorCallback());
+ return rawExecutor.executeUpdate(createRawExecutionGroups(), new RawSQLExecutorCallback());
}
} finally {
currentResultSet = null;
@@ -182,11 +182,11 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
try {
executionContext = createExecutionContext(sql);
if (ExecutorConstant.MANAGED_RESOURCE) {
- Collection<InputGroup<StatementExecuteUnit>> inputGroups = getInputGroups();
- cacheStatements(inputGroups);
- return statementExecutor.executeUpdate(inputGroups, executionContext.getSqlStatementContext(), executionContext.getRouteContext().getRouteUnits(), columnIndexes);
+ Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups = createExecutionGroups();
+ cacheStatements(executionGroups);
+ return statementExecutor.executeUpdate(executionGroups, executionContext.getSqlStatementContext(), executionContext.getRouteContext().getRouteUnits(), columnIndexes);
} else {
- return rawExecutor.executeUpdate(getRawInputGroups(), new RawSQLExecutorCallback());
+ return rawExecutor.executeUpdate(createRawExecutionGroups(), new RawSQLExecutorCallback());
}
} finally {
currentResultSet = null;
@@ -199,11 +199,11 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
try {
executionContext = createExecutionContext(sql);
if (ExecutorConstant.MANAGED_RESOURCE) {
- Collection<InputGroup<StatementExecuteUnit>> inputGroups = getInputGroups();
- cacheStatements(inputGroups);
- return statementExecutor.executeUpdate(inputGroups, executionContext.getSqlStatementContext(), executionContext.getRouteContext().getRouteUnits(), columnNames);
+ Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups = createExecutionGroups();
+ cacheStatements(executionGroups);
+ return statementExecutor.executeUpdate(executionGroups, executionContext.getSqlStatementContext(), executionContext.getRouteContext().getRouteUnits(), columnNames);
} else {
- return rawExecutor.executeUpdate(getRawInputGroups(), new RawSQLExecutorCallback());
+ return rawExecutor.executeUpdate(createRawExecutionGroups(), new RawSQLExecutorCallback());
}
} finally {
currentResultSet = null;
@@ -215,12 +215,12 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
try {
executionContext = createExecutionContext(sql);
if (ExecutorConstant.MANAGED_RESOURCE) {
- Collection<InputGroup<StatementExecuteUnit>> inputGroups = getInputGroups();
- cacheStatements(inputGroups);
- return statementExecutor.execute(inputGroups, executionContext.getSqlStatementContext().getSqlStatement(), executionContext.getRouteContext().getRouteUnits());
+ Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups = createExecutionGroups();
+ cacheStatements(executionGroups);
+ return statementExecutor.execute(executionGroups, executionContext.getSqlStatementContext().getSqlStatement(), executionContext.getRouteContext().getRouteUnits());
} else {
// TODO process getStatement
- return rawExecutor.execute(getRawInputGroups(), new RawSQLExecutorCallback());
+ return rawExecutor.execute(createRawExecutionGroups(), new RawSQLExecutorCallback());
}
} finally {
currentResultSet = null;
@@ -235,12 +235,12 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
try {
executionContext = createExecutionContext(sql);
if (ExecutorConstant.MANAGED_RESOURCE) {
- Collection<InputGroup<StatementExecuteUnit>> inputGroups = getInputGroups();
- cacheStatements(inputGroups);
- return statementExecutor.execute(inputGroups, executionContext.getSqlStatementContext().getSqlStatement(), executionContext.getRouteContext().getRouteUnits(), autoGeneratedKeys);
+ Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups = createExecutionGroups();
+ cacheStatements(executionGroups);
+ return statementExecutor.execute(executionGroups, executionContext.getSqlStatementContext().getSqlStatement(), executionContext.getRouteContext().getRouteUnits(), autoGeneratedKeys);
} else {
// TODO process getStatement
- return rawExecutor.execute(getRawInputGroups(), new RawSQLExecutorCallback());
+ return rawExecutor.execute(createRawExecutionGroups(), new RawSQLExecutorCallback());
}
} finally {
currentResultSet = null;
@@ -253,12 +253,12 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
try {
executionContext = createExecutionContext(sql);
if (ExecutorConstant.MANAGED_RESOURCE) {
- Collection<InputGroup<StatementExecuteUnit>> inputGroups = getInputGroups();
- cacheStatements(inputGroups);
- return statementExecutor.execute(inputGroups, executionContext.getSqlStatementContext().getSqlStatement(), executionContext.getRouteContext().getRouteUnits(), columnIndexes);
+ Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups = createExecutionGroups();
+ cacheStatements(executionGroups);
+ return statementExecutor.execute(executionGroups, executionContext.getSqlStatementContext().getSqlStatement(), executionContext.getRouteContext().getRouteUnits(), columnIndexes);
} else {
// TODO process getStatement
- return rawExecutor.execute(getRawInputGroups(), new RawSQLExecutorCallback());
+ return rawExecutor.execute(createRawExecutionGroups(), new RawSQLExecutorCallback());
}
} finally {
currentResultSet = null;
@@ -271,12 +271,12 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
try {
executionContext = createExecutionContext(sql);
if (ExecutorConstant.MANAGED_RESOURCE) {
- Collection<InputGroup<StatementExecuteUnit>> inputGroups = getInputGroups();
- cacheStatements(inputGroups);
- return statementExecutor.execute(inputGroups, executionContext.getSqlStatementContext().getSqlStatement(), executionContext.getRouteContext().getRouteUnits(), columnNames);
+ Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups = createExecutionGroups();
+ cacheStatements(executionGroups);
+ return statementExecutor.execute(executionGroups, executionContext.getSqlStatementContext().getSqlStatement(), executionContext.getRouteContext().getRouteUnits(), columnNames);
} else {
// TODO process getStatement
- return rawExecutor.execute(getRawInputGroups(), new RawSQLExecutorCallback());
+ return rawExecutor.execute(createRawExecutionGroups(), new RawSQLExecutorCallback());
}
} finally {
currentResultSet = null;
@@ -312,20 +312,20 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
return new LogicSQL(sqlStatementContext, sql, Collections.emptyList());
}
- private Collection<InputGroup<StatementExecuteUnit>> getInputGroups() throws SQLException {
+ private Collection<ExecutionGroup<StatementExecuteUnit>> createExecutionGroups() throws SQLException {
int maxConnectionsSizePerQuery = metaDataContexts.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
- return new StatementExecuteGroupEngine(maxConnectionsSizePerQuery, connection, statementOption,
+ return new StatementExecutionGroupEngine(maxConnectionsSizePerQuery, connection, statementOption,
metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules()).group(executionContext.getRouteContext(), executionContext.getExecutionUnits());
}
- private Collection<InputGroup<RawSQLExecuteUnit>> getRawInputGroups() throws SQLException {
+ private Collection<ExecutionGroup<RawSQLExecuteUnit>> createRawExecutionGroups() throws SQLException {
int maxConnectionsSizePerQuery = metaDataContexts.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
- return new RawExecuteGroupEngine(maxConnectionsSizePerQuery, metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules())
+ return new RawExecutionGroupEngine(maxConnectionsSizePerQuery, metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules())
.group(executionContext.getRouteContext(), executionContext.getExecutionUnits());
}
- private void cacheStatements(final Collection<InputGroup<StatementExecuteUnit>> inputGroups) {
- for (InputGroup<StatementExecuteUnit> each : inputGroups) {
+ private void cacheStatements(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups) {
+ for (ExecutionGroup<StatementExecuteUnit> each : executionGroups) {
statements.addAll(each.getInputs().stream().map(StatementExecuteUnit::getStorageResource).collect(Collectors.toList()));
}
statements.forEach(this::replayMethodsInvocation);
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/PreparedStatementExecutorTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/PreparedStatementExecutorTest.java
index 35f1200..1074586 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/PreparedStatementExecutorTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/PreparedStatementExecutorTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.driver.executor;
import org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.query.QueryResult;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
@@ -84,7 +84,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
when(resultSet.getString(1)).thenReturn("value");
when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
when(preparedStatement.executeQuery()).thenReturn(resultSet);
- assertThat(actual.executeQuery(getExecuteGroups(Collections.singletonList(preparedStatement), true)).iterator().next().getValue(1, String.class), is("value"));
+ assertThat(actual.executeQuery(getExecutionGroups(Collections.singletonList(preparedStatement), true)).iterator().next().getValue(1, String.class), is("value"));
}
@Test
@@ -105,7 +105,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
when(resultSet2.getInt(1)).thenReturn(2);
when(preparedStatement1.executeQuery()).thenReturn(resultSet1);
when(preparedStatement2.executeQuery()).thenReturn(resultSet2);
- List<QueryResult> result = actual.executeQuery(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), true));
+ List<QueryResult> result = actual.executeQuery(getExecutionGroups(Arrays.asList(preparedStatement1, preparedStatement2), true));
assertThat(String.valueOf(result.get(0).getValue(1, int.class)), is("1"));
assertThat(String.valueOf(result.get(1).getValue(1, int.class)), is("2"));
verify(preparedStatement1).executeQuery();
@@ -117,7 +117,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
PreparedStatement preparedStatement = getPreparedStatement();
SQLException ex = new SQLException("");
when(preparedStatement.executeQuery()).thenThrow(ex);
- assertThat(actual.executeQuery(getExecuteGroups(Collections.singletonList(preparedStatement), true)), is(Collections.singletonList((QueryResult) null)));
+ assertThat(actual.executeQuery(getExecutionGroups(Collections.singletonList(preparedStatement), true)), is(Collections.singletonList((QueryResult) null)));
verify(preparedStatement).executeQuery();
}
@@ -128,7 +128,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
SQLException ex = new SQLException("");
when(preparedStatement1.executeQuery()).thenThrow(ex);
when(preparedStatement2.executeQuery()).thenThrow(ex);
- List<QueryResult> actualResultSets = actual.executeQuery(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), true));
+ List<QueryResult> actualResultSets = actual.executeQuery(getExecutionGroups(Arrays.asList(preparedStatement1, preparedStatement2), true));
assertThat(actualResultSets, is(Arrays.asList((QueryResult) null, null)));
verify(preparedStatement1).executeQuery();
verify(preparedStatement2).executeQuery();
@@ -138,7 +138,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
public void assertExecuteUpdateForSinglePreparedStatementSuccess() throws SQLException {
PreparedStatement preparedStatement = getPreparedStatement();
when(preparedStatement.executeUpdate()).thenReturn(10);
- assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(preparedStatement), false), createSQLStatementContext(), null), is(10));
+ assertThat(actual.executeUpdate(getExecutionGroups(Collections.singletonList(preparedStatement), false), createSQLStatementContext(), null), is(10));
verify(preparedStatement).executeUpdate();
}
@@ -148,7 +148,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
PreparedStatement preparedStatement2 = getPreparedStatement();
when(preparedStatement1.executeUpdate()).thenReturn(10);
when(preparedStatement2.executeUpdate()).thenReturn(20);
- assertThat(actual.executeUpdate(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), createSQLStatementContext(), null), is(30));
+ assertThat(actual.executeUpdate(getExecutionGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), createSQLStatementContext(), null), is(30));
verify(preparedStatement1).executeUpdate();
verify(preparedStatement2).executeUpdate();
}
@@ -158,7 +158,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
PreparedStatement preparedStatement = getPreparedStatement();
SQLException ex = new SQLException("");
when(preparedStatement.executeUpdate()).thenThrow(ex);
- assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(preparedStatement), false), createSQLStatementContext(), null), is(0));
+ assertThat(actual.executeUpdate(getExecutionGroups(Collections.singletonList(preparedStatement), false), createSQLStatementContext(), null), is(0));
verify(preparedStatement).executeUpdate();
}
@@ -170,7 +170,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
= new SQLException("");
when(preparedStatement1.executeUpdate()).thenThrow(ex);
when(preparedStatement2.executeUpdate()).thenThrow(ex);
- assertThat(actual.executeUpdate(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), createSQLStatementContext(), null), is(0));
+ assertThat(actual.executeUpdate(getExecutionGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), createSQLStatementContext(), null), is(0));
verify(preparedStatement1).executeUpdate();
verify(preparedStatement2).executeUpdate();
}
@@ -179,7 +179,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
public void assertExecuteForSinglePreparedStatementSuccessWithDML() throws SQLException {
PreparedStatement preparedStatement = getPreparedStatement();
when(preparedStatement.execute()).thenReturn(false);
- assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(preparedStatement), false), mock(SQLStatement.class), null));
+ assertFalse(actual.execute(getExecutionGroups(Collections.singletonList(preparedStatement), false), mock(SQLStatement.class), null));
verify(preparedStatement).execute();
}
@@ -189,7 +189,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
PreparedStatement preparedStatement2 = getPreparedStatement();
when(preparedStatement1.execute()).thenReturn(false);
when(preparedStatement2.execute()).thenReturn(false);
- assertFalse(actual.execute(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), mock(SQLStatement.class), null));
+ assertFalse(actual.execute(getExecutionGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), mock(SQLStatement.class), null));
verify(preparedStatement1).execute();
verify(preparedStatement2).execute();
}
@@ -199,7 +199,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
PreparedStatement preparedStatement = getPreparedStatement();
SQLException ex = new SQLException("");
when(preparedStatement.execute()).thenThrow(ex);
- assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(preparedStatement), false), mock(SQLStatement.class), null));
+ assertFalse(actual.execute(getExecutionGroups(Collections.singletonList(preparedStatement), false), mock(SQLStatement.class), null));
verify(preparedStatement).execute();
}
@@ -210,7 +210,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
SQLException ex = new SQLException("");
when(preparedStatement1.execute()).thenThrow(ex);
when(preparedStatement2.execute()).thenThrow(ex);
- assertFalse(actual.execute(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), mock(SQLStatement.class), null));
+ assertFalse(actual.execute(getExecutionGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), mock(SQLStatement.class), null));
verify(preparedStatement1).execute();
verify(preparedStatement2).execute();
}
@@ -219,7 +219,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
public void assertExecuteForSinglePreparedStatementWithDQL() throws SQLException {
PreparedStatement preparedStatement = getPreparedStatement();
when(preparedStatement.execute()).thenReturn(true);
- assertTrue(actual.execute(getExecuteGroups(Collections.singletonList(preparedStatement), true), mock(SQLStatement.class), null));
+ assertTrue(actual.execute(getExecutionGroups(Collections.singletonList(preparedStatement), true), mock(SQLStatement.class), null));
verify(preparedStatement).execute();
}
@@ -229,7 +229,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
PreparedStatement preparedStatement2 = getPreparedStatement();
when(preparedStatement1.execute()).thenReturn(true);
when(preparedStatement2.execute()).thenReturn(true);
- assertTrue(actual.execute(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), true), mock(SQLStatement.class), null));
+ assertTrue(actual.execute(getExecutionGroups(Arrays.asList(preparedStatement1, preparedStatement2), true), mock(SQLStatement.class), null));
verify(preparedStatement1).execute();
verify(preparedStatement2).execute();
}
@@ -244,10 +244,10 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
return result;
}
- private Collection<InputGroup<StatementExecuteUnit>> getExecuteGroups(final List<PreparedStatement> preparedStatements, final boolean isQuery) {
- Collection<InputGroup<StatementExecuteUnit>> result = new LinkedList<>();
+ private Collection<ExecutionGroup<StatementExecuteUnit>> getExecutionGroups(final List<PreparedStatement> preparedStatements, final boolean isQuery) {
+ Collection<ExecutionGroup<StatementExecuteUnit>> result = new LinkedList<>();
List<StatementExecuteUnit> preparedStatementExecuteUnits = new LinkedList<>();
- result.add(new InputGroup<>(preparedStatementExecuteUnits));
+ result.add(new ExecutionGroup<>(preparedStatementExecuteUnits));
for (PreparedStatement each : preparedStatements) {
preparedStatementExecuteUnits.add(new StatementExecuteUnit(new ExecutionUnit("ds_0", new SQLUnit(isQuery ? DQL_SQL : DML_SQL, Collections.singletonList(1))),
ConnectionMode.MEMORY_STRICTLY, each));
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/StatementExecutorTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/StatementExecutorTest.java
index 4d57a22..aa3c6e5 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/StatementExecutorTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/StatementExecutorTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.driver.executor;
import org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.query.QueryResult;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
@@ -86,7 +86,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
when(resultSet.getString(1)).thenReturn("value");
when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
when(statement.executeQuery(DQL_SQL)).thenReturn(resultSet);
- assertThat(actual.executeQuery(getExecuteGroups(Collections.singletonList(statement), true)).iterator().next().getValue(1, String.class), is("value"));
+ assertThat(actual.executeQuery(createExecutionGroups(Collections.singletonList(statement), true)).iterator().next().getValue(1, String.class), is("value"));
verify(statement).executeQuery(DQL_SQL);
}
@@ -108,7 +108,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
when(resultSet2.getInt(1)).thenReturn(2);
when(statement1.executeQuery(DQL_SQL)).thenReturn(resultSet1);
when(statement2.executeQuery(DQL_SQL)).thenReturn(resultSet2);
- List<QueryResult> result = actual.executeQuery(getExecuteGroups(Arrays.asList(statement1, statement2), true));
+ List<QueryResult> result = actual.executeQuery(createExecutionGroups(Arrays.asList(statement1, statement2), true));
assertThat(String.valueOf(result.get(0).getValue(1, int.class)), is("1"));
assertThat(String.valueOf(result.get(1).getValue(1, int.class)), is("2"));
verify(statement1).executeQuery(DQL_SQL);
@@ -120,7 +120,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
Statement statement = getStatement();
SQLException ex = new SQLException("");
when(statement.executeQuery(DQL_SQL)).thenThrow(ex);
- assertThat(actual.executeQuery(getExecuteGroups(Collections.singletonList(statement), true)), is(Collections.singletonList((QueryResult) null)));
+ assertThat(actual.executeQuery(createExecutionGroups(Collections.singletonList(statement), true)), is(Collections.singletonList((QueryResult) null)));
verify(statement).executeQuery(DQL_SQL);
}
@@ -131,7 +131,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
SQLException ex = new SQLException("");
when(statement1.executeQuery(DQL_SQL)).thenThrow(ex);
when(statement2.executeQuery(DQL_SQL)).thenThrow(ex);
- List<QueryResult> actualResultSets = actual.executeQuery(getExecuteGroups(Arrays.asList(statement1, statement2), true));
+ List<QueryResult> actualResultSets = actual.executeQuery(createExecutionGroups(Arrays.asList(statement1, statement2), true));
assertThat(actualResultSets, is(Arrays.asList((QueryResult) null, null)));
verify(statement1).executeQuery(DQL_SQL);
verify(statement2).executeQuery(DQL_SQL);
@@ -141,7 +141,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
public void assertExecuteUpdateForSingleStatementSuccess() throws SQLException {
Statement statement = getStatement();
when(statement.executeUpdate(DML_SQL)).thenReturn(10);
- assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext(), null), is(10));
+ assertThat(actual.executeUpdate(createExecutionGroups(Collections.singletonList(statement), false), createSQLStatementContext(), null), is(10));
verify(statement).executeUpdate(DML_SQL);
}
@@ -151,7 +151,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
Statement statement2 = getStatement();
when(statement1.executeUpdate(DML_SQL)).thenReturn(10);
when(statement2.executeUpdate(DML_SQL)).thenReturn(20);
- assertThat(actual.executeUpdate(getExecuteGroups(Arrays.asList(statement1, statement2), false), createSQLStatementContext(), null), is(30));
+ assertThat(actual.executeUpdate(createExecutionGroups(Arrays.asList(statement1, statement2), false), createSQLStatementContext(), null), is(30));
verify(statement1).executeUpdate(DML_SQL);
verify(statement2).executeUpdate(DML_SQL);
}
@@ -161,7 +161,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
Statement statement = getStatement();
SQLException ex = new SQLException("");
when(statement.executeUpdate(DML_SQL)).thenThrow(ex);
- assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext(), null), is(0));
+ assertThat(actual.executeUpdate(createExecutionGroups(Collections.singletonList(statement), false), createSQLStatementContext(), null), is(0));
verify(statement).executeUpdate(DML_SQL);
}
@@ -172,7 +172,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
SQLException ex = new SQLException("");
when(statement1.executeUpdate(DML_SQL)).thenThrow(ex);
when(statement2.executeUpdate(DML_SQL)).thenThrow(ex);
- assertThat(actual.executeUpdate(getExecuteGroups(Arrays.asList(statement1, statement2), false), createSQLStatementContext(), null), is(0));
+ assertThat(actual.executeUpdate(createExecutionGroups(Arrays.asList(statement1, statement2), false), createSQLStatementContext(), null), is(0));
verify(statement1).executeUpdate(DML_SQL);
verify(statement2).executeUpdate(DML_SQL);
}
@@ -181,7 +181,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
public void assertExecuteUpdateWithAutoGeneratedKeys() throws SQLException {
Statement statement = getStatement();
when(statement.executeUpdate(DML_SQL, Statement.NO_GENERATED_KEYS)).thenReturn(10);
- assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext(), null, Statement.NO_GENERATED_KEYS), is(10));
+ assertThat(actual.executeUpdate(createExecutionGroups(Collections.singletonList(statement), false), createSQLStatementContext(), null, Statement.NO_GENERATED_KEYS), is(10));
verify(statement).executeUpdate(DML_SQL, Statement.NO_GENERATED_KEYS);
}
@@ -189,7 +189,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
public void assertExecuteUpdateWithColumnIndexes() throws SQLException {
Statement statement = getStatement();
when(statement.executeUpdate(DML_SQL, new int[] {1})).thenReturn(10);
- assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext(), null, new int[] {1}), is(10));
+ assertThat(actual.executeUpdate(createExecutionGroups(Collections.singletonList(statement), false), createSQLStatementContext(), null, new int[] {1}), is(10));
verify(statement).executeUpdate(DML_SQL, new int[] {1});
}
@@ -207,7 +207,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
public void assertExecuteUpdateWithColumnNames() throws SQLException {
Statement statement = getStatement();
when(statement.executeUpdate(DML_SQL, new String[] {"col"})).thenReturn(10);
- assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext(), null, new String[] {"col"}), is(10));
+ assertThat(actual.executeUpdate(createExecutionGroups(Collections.singletonList(statement), false), createSQLStatementContext(), null, new String[] {"col"}), is(10));
verify(statement).executeUpdate(DML_SQL, new String[] {"col"});
}
@@ -215,7 +215,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
public void assertExecuteForSingleStatementSuccessWithDML() throws SQLException {
Statement statement = getStatement();
when(statement.execute(DML_SQL)).thenReturn(false);
- assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), mock(SQLStatement.class), null));
+ assertFalse(actual.execute(createExecutionGroups(Collections.singletonList(statement), false), mock(SQLStatement.class), null));
verify(statement).execute(DML_SQL);
}
@@ -225,7 +225,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
Statement statement2 = getStatement();
when(statement1.execute(DML_SQL)).thenReturn(false);
when(statement2.execute(DML_SQL)).thenReturn(false);
- assertFalse(actual.execute(getExecuteGroups(Arrays.asList(statement1, statement2), false), mock(SQLStatement.class), null));
+ assertFalse(actual.execute(createExecutionGroups(Arrays.asList(statement1, statement2), false), mock(SQLStatement.class), null));
verify(statement1).execute(DML_SQL);
verify(statement2).execute(DML_SQL);
}
@@ -235,7 +235,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
Statement statement = getStatement();
SQLException ex = new SQLException("");
when(statement.execute(DML_SQL)).thenThrow(ex);
- assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), mock(SQLStatement.class), null));
+ assertFalse(actual.execute(createExecutionGroups(Collections.singletonList(statement), false), mock(SQLStatement.class), null));
verify(statement).execute(DML_SQL);
}
@@ -246,7 +246,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
SQLException ex = new SQLException("");
when(statement1.execute(DML_SQL)).thenThrow(ex);
when(statement2.execute(DML_SQL)).thenThrow(ex);
- assertFalse(actual.execute(getExecuteGroups(Arrays.asList(statement1, statement2), false), mock(SQLStatement.class), null));
+ assertFalse(actual.execute(createExecutionGroups(Arrays.asList(statement1, statement2), false), mock(SQLStatement.class), null));
verify(statement1).execute(DML_SQL);
verify(statement2).execute(DML_SQL);
}
@@ -255,7 +255,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
public void assertExecuteForSingleStatementWithDQL() throws SQLException {
Statement statement = getStatement();
when(statement.execute(DQL_SQL)).thenReturn(true);
- assertTrue(actual.execute(getExecuteGroups(Collections.singletonList(statement), true), mock(SQLStatement.class), null));
+ assertTrue(actual.execute(createExecutionGroups(Collections.singletonList(statement), true), mock(SQLStatement.class), null));
verify(statement).execute(DQL_SQL);
}
@@ -265,7 +265,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
Statement statement2 = getStatement();
when(statement1.execute(DQL_SQL)).thenReturn(true);
when(statement2.execute(DQL_SQL)).thenReturn(true);
- assertTrue(actual.execute(getExecuteGroups(Arrays.asList(statement1, statement2), true), mock(SQLStatement.class), null));
+ assertTrue(actual.execute(createExecutionGroups(Arrays.asList(statement1, statement2), true), mock(SQLStatement.class), null));
verify(statement1).execute(DQL_SQL);
verify(statement2).execute(DQL_SQL);
}
@@ -274,7 +274,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
public void assertExecuteWithAutoGeneratedKeys() throws SQLException {
Statement statement = getStatement();
when(statement.execute(DML_SQL, Statement.NO_GENERATED_KEYS)).thenReturn(false);
- assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), mock(SQLStatement.class), null, Statement.NO_GENERATED_KEYS));
+ assertFalse(actual.execute(createExecutionGroups(Collections.singletonList(statement), false), mock(SQLStatement.class), null, Statement.NO_GENERATED_KEYS));
verify(statement).execute(DML_SQL, Statement.NO_GENERATED_KEYS);
}
@@ -282,7 +282,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
public void assertExecuteWithColumnIndexes() throws SQLException {
Statement statement = getStatement();
when(statement.execute(DML_SQL, new int[] {1})).thenReturn(false);
- assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), mock(SQLStatement.class), null, new int[] {1}));
+ assertFalse(actual.execute(createExecutionGroups(Collections.singletonList(statement), false), mock(SQLStatement.class), null, new int[] {1}));
verify(statement).execute(DML_SQL, new int[] {1});
}
@@ -290,7 +290,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
public void assertExecuteWithColumnNames() throws SQLException {
Statement statement = getStatement();
when(statement.execute(DML_SQL, new String[] {"col"})).thenReturn(false);
- assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), mock(SQLStatement.class), null, new String[] {"col"}));
+ assertFalse(actual.execute(createExecutionGroups(Collections.singletonList(statement), false), mock(SQLStatement.class), null, new String[] {"col"}));
verify(statement).execute(DML_SQL, new String[] {"col"});
}
@@ -301,15 +301,15 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
SQLException ex = new SQLException("");
when(statement.execute(DML_SQL)).thenThrow(ex);
try {
- assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), mock(SQLStatement.class), null));
+ assertFalse(actual.execute(createExecutionGroups(Collections.singletonList(statement), false), mock(SQLStatement.class), null));
} catch (final SQLException ignored) {
}
}
- private Collection<InputGroup<StatementExecuteUnit>> getExecuteGroups(final List<Statement> statements, final boolean isQuery) {
- Collection<InputGroup<StatementExecuteUnit>> result = new LinkedList<>();
+ private Collection<ExecutionGroup<StatementExecuteUnit>> createExecutionGroups(final List<Statement> statements, final boolean isQuery) {
+ Collection<ExecutionGroup<StatementExecuteUnit>> result = new LinkedList<>();
List<StatementExecuteUnit> statementExecuteUnits = new LinkedList<>();
- result.add(new InputGroup<>(statementExecuteUnits));
+ result.add(new ExecutionGroup<>(statementExecuteUnits));
for (Statement each : statements) {
statementExecuteUnits.add(
new StatementExecuteUnit(new ExecutionUnit("ds_0", new SQLUnit(isQuery ? DQL_SQL : DML_SQL, Collections.singletonList(1))), ConnectionMode.MEMORY_STRICTLY, each));
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
index c6daa8a..a159388 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementExec
import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
import org.apache.shardingsphere.infra.executor.sql.context.SQLUnit;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.junit.Test;
import org.mockito.Mock;
@@ -68,7 +68,7 @@ public final class BatchPreparedStatementExecutorTest extends AbstractBaseExecut
public void assertNoPreparedStatement() throws SQLException {
PreparedStatement preparedStatement = getPreparedStatement();
when(preparedStatement.executeBatch()).thenReturn(new int[] {0, 0});
- setExecuteGroups(Collections.singletonList(preparedStatement));
+ setExecutionGroups(Collections.singletonList(preparedStatement));
assertThat(actual.executeBatch(sqlStatementContext), is(new int[] {0, 0}));
}
@@ -76,7 +76,7 @@ public final class BatchPreparedStatementExecutorTest extends AbstractBaseExecut
public void assertExecuteBatchForSinglePreparedStatementSuccess() throws SQLException {
PreparedStatement preparedStatement = getPreparedStatement();
when(preparedStatement.executeBatch()).thenReturn(new int[] {10, 20});
- setExecuteGroups(Collections.singletonList(preparedStatement));
+ setExecutionGroups(Collections.singletonList(preparedStatement));
assertThat(actual.executeBatch(sqlStatementContext), is(new int[] {10, 20}));
verify(preparedStatement).executeBatch();
}
@@ -97,7 +97,7 @@ public final class BatchPreparedStatementExecutorTest extends AbstractBaseExecut
PreparedStatement preparedStatement2 = getPreparedStatement();
when(preparedStatement1.executeBatch()).thenReturn(new int[] {10, 20});
when(preparedStatement2.executeBatch()).thenReturn(new int[] {20, 40});
- setExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2));
+ setExecutionGroups(Arrays.asList(preparedStatement1, preparedStatement2));
assertThat(actual.executeBatch(sqlStatementContext), is(new int[] {30, 60}));
verify(preparedStatement1).executeBatch();
verify(preparedStatement2).executeBatch();
@@ -108,7 +108,7 @@ public final class BatchPreparedStatementExecutorTest extends AbstractBaseExecut
PreparedStatement preparedStatement = getPreparedStatement();
SQLException ex = new SQLException("");
when(preparedStatement.executeBatch()).thenThrow(ex);
- setExecuteGroups(Collections.singletonList(preparedStatement));
+ setExecutionGroups(Collections.singletonList(preparedStatement));
assertThat(actual.executeBatch(sqlStatementContext), is(new int[] {0, 0}));
verify(preparedStatement).executeBatch();
}
@@ -120,16 +120,16 @@ public final class BatchPreparedStatementExecutorTest extends AbstractBaseExecut
SQLException ex = new SQLException("");
when(preparedStatement1.executeBatch()).thenThrow(ex);
when(preparedStatement2.executeBatch()).thenThrow(ex);
- setExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2));
+ setExecutionGroups(Arrays.asList(preparedStatement1, preparedStatement2));
assertThat(actual.executeBatch(sqlStatementContext), is(new int[] {0, 0}));
verify(preparedStatement1).executeBatch();
verify(preparedStatement2).executeBatch();
}
- private void setExecuteGroups(final List<PreparedStatement> preparedStatements) {
- Collection<InputGroup<StatementExecuteUnit>> executeGroups = new LinkedList<>();
+ private void setExecutionGroups(final List<PreparedStatement> preparedStatements) {
+ Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups = new LinkedList<>();
List<StatementExecuteUnit> preparedStatementExecuteUnits = new LinkedList<>();
- executeGroups.add(new InputGroup<>(preparedStatementExecuteUnits));
+ executionGroups.add(new ExecutionGroup<>(preparedStatementExecuteUnits));
Collection<BatchExecutionUnit> batchExecutionUnits = new LinkedList<>();
for (PreparedStatement each : preparedStatements) {
BatchExecutionUnit batchExecutionUnit = new BatchExecutionUnit(new ExecutionUnit("ds_0", new SQLUnit(SQL, Collections.singletonList(1))));
@@ -139,14 +139,14 @@ public final class BatchPreparedStatementExecutorTest extends AbstractBaseExecut
preparedStatementExecuteUnits.add(new StatementExecuteUnit(new ExecutionUnit("ds_0", new SQLUnit(SQL, Collections.singletonList(1))),
ConnectionMode.MEMORY_STRICTLY, each));
}
- setFields(executeGroups, batchExecutionUnits);
+ setFields(executionGroups, batchExecutionUnits);
}
@SneakyThrows(ReflectiveOperationException.class)
- private void setFields(final Collection<InputGroup<StatementExecuteUnit>> inputGroups, final Collection<BatchExecutionUnit> batchExecutionUnits) {
- Field field = BatchPreparedStatementExecutor.class.getDeclaredField("inputGroups");
+ private void setFields(final Collection<ExecutionGroup<StatementExecuteUnit>> executionGroups, final Collection<BatchExecutionUnit> batchExecutionUnits) {
+ Field field = BatchPreparedStatementExecutor.class.getDeclaredField("executionGroups");
field.setAccessible(true);
- field.set(actual, inputGroups);
+ field.set(actual, executionGroups);
field = BatchPreparedStatementExecutor.class.getDeclaredField("batchExecutionUnits");
field.setAccessible(true);
field.set(actual, batchExecutionUnits);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/JDBCExecuteEngine.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/JDBCExecuteEngine.java
index dacd03b..41400f3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/JDBCExecuteEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/JDBCExecuteEngine.java
@@ -19,17 +19,17 @@ package org.apache.shardingsphere.proxy.backend.communication.jdbc.execute.engin
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.ExecutorConstant;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionContext;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
-import org.apache.shardingsphere.infra.executor.sql.group.ExecuteGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.ExecutionGroupEngine;
import org.apache.shardingsphere.infra.executor.sql.raw.RawSQLExecuteUnit;
import org.apache.shardingsphere.infra.executor.sql.raw.execute.callback.RawSQLExecutorCallback;
import org.apache.shardingsphere.infra.executor.sql.raw.execute.result.ExecuteResult;
import org.apache.shardingsphere.infra.executor.sql.raw.execute.result.query.ExecuteQueryResult;
import org.apache.shardingsphere.infra.executor.sql.raw.execute.result.query.QueryHeader;
-import org.apache.shardingsphere.infra.executor.sql.raw.group.RawExecuteGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.raw.RawExecutionGroupEngine;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementExecuteUnit;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.executor.ExecutorExceptionHandler;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.executor.SQLExecutor;
@@ -127,25 +127,25 @@ public final class JDBCExecuteEngine implements SQLExecuteEngine {
private Collection<ExecuteResult> executeWithManagedResource(final ExecutionContext executionContext,
final int maxConnectionsSizePerQuery, final boolean isReturnGeneratedKeys, final boolean isExceptionThrown) throws SQLException {
DatabaseType databaseType = ProxyContext.getInstance().getMetaDataContexts().getDatabaseType();
- return sqlExecutor.execute(generateInputGroups(executionContext.getExecutionUnits(), maxConnectionsSizePerQuery, isReturnGeneratedKeys, executionContext.getRouteContext()),
+ return sqlExecutor.execute(createExecutionGroups(executionContext.getExecutionUnits(), maxConnectionsSizePerQuery, isReturnGeneratedKeys, executionContext.getRouteContext()),
new ProxySQLExecutorCallback(databaseType, executionContext.getSqlStatementContext(), backendConnection, accessor, isExceptionThrown, isReturnGeneratedKeys, true),
new ProxySQLExecutorCallback(databaseType, executionContext.getSqlStatementContext(), backendConnection, accessor, isExceptionThrown, isReturnGeneratedKeys, false));
}
@SuppressWarnings({"unchecked", "rawtypes"})
- private Collection<InputGroup<StatementExecuteUnit>> generateInputGroups(final Collection<ExecutionUnit> executionUnits, final int maxConnectionsSizePerQuery, final boolean isReturnGeneratedKeys,
- final RouteContext routeContext) throws SQLException {
+ private Collection<ExecutionGroup<StatementExecuteUnit>> createExecutionGroups(final Collection<ExecutionUnit> executionUnits, final int maxConnectionsSizePerQuery,
+ final boolean isReturnGeneratedKeys, final RouteContext routeContext) throws SQLException {
Collection<ShardingSphereRule> rules = ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName()).getRuleMetaData().getRules();
- ExecuteGroupEngine executeGroupEngine = accessor.getExecuteGroupEngine(backendConnection, maxConnectionsSizePerQuery, new StatementOption(isReturnGeneratedKeys), rules);
- return (Collection<InputGroup<StatementExecuteUnit>>) executeGroupEngine.group(routeContext, executionUnits);
+ ExecutionGroupEngine groupEngine = accessor.getExecutionGroupEngine(backendConnection, maxConnectionsSizePerQuery, new StatementOption(isReturnGeneratedKeys), rules);
+ return (Collection<ExecutionGroup<StatementExecuteUnit>>) groupEngine.group(routeContext, executionUnits);
}
private Collection<ExecuteResult> executeWithUnmanagedResource(final ExecutionContext executionContext, final int maxConnectionsSizePerQuery) throws SQLException {
Collection<ShardingSphereRule> rules = ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName()).getRuleMetaData().getRules();
- Collection<InputGroup<RawSQLExecuteUnit>> inputGroups = new RawExecuteGroupEngine(maxConnectionsSizePerQuery, rules).group(executionContext.getRouteContext(),
+ Collection<ExecutionGroup<RawSQLExecuteUnit>> executionGroups = new RawExecutionGroupEngine(maxConnectionsSizePerQuery, rules).group(executionContext.getRouteContext(),
executionContext.getExecutionUnits());
// TODO handle query header
- return rawExecutor.execute(inputGroups, new RawSQLExecutorCallback());
+ return rawExecutor.execute(executionGroups, new RawSQLExecutorCallback());
}
private BackendResponse getExecuteQueryResponse(final List<QueryHeader> queryHeaders, final Collection<ExecuteResult> executeResults) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/RawProxyExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/RawProxyExecutor.java
index a7c81c0..38be436 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/RawProxyExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/RawProxyExecutor.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.communication.jdbc.execute.engin
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorKernel;
-import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
+import org.apache.shardingsphere.infra.executor.kernel.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.sql.raw.RawSQLExecuteUnit;
import org.apache.shardingsphere.infra.executor.sql.raw.execute.callback.RawSQLExecutorCallback;
import org.apache.shardingsphere.infra.executor.sql.raw.execute.result.ExecuteResult;
@@ -44,14 +44,14 @@ public final class RawProxyExecutor {
/**
* Execute.
*
- * @param inputGroups input groups
+ * @param executionGroups execution groups
* @param callback raw SQL execute callback
* @return return true if is DQL, false if is DML
* @throws SQLException SQL exception
*/
- public Collection<ExecuteResult> execute(final Collection<InputGroup<RawSQLExecuteUnit>> inputGroups, final RawSQLExecutorCallback callback) throws SQLException {
+ public Collection<ExecuteResult> execute(final Collection<ExecutionGroup<RawSQLExecuteUnit>> executionGroups, final RawSQLExecutorCallback callback) throws SQLException {
// TODO Load query header for first query
- List<ExecuteResult> results = doExecute(inputGroups, null, callback);
+ List<ExecuteResult> results = doExecute(executionGroups, null, callback);
// TODO refresh metadata
if (null == results || results.isEmpty() || null == results.get(0)) {
return Collections.singleton(new ExecuteUpdateResult(0, 0L));
@@ -65,9 +65,10 @@ public final class RawProxyExecutor {
}
@SuppressWarnings("unchecked")
- private <T> List<T> doExecute(final Collection<InputGroup<RawSQLExecuteUnit>> inputGroups, final RawSQLExecutorCallback firstCallback, final RawSQLExecutorCallback callback) throws SQLException {
+ private <T> List<T> doExecute(final Collection<ExecutionGroup<RawSQLExecuteUnit>> executionGroups,
+ final RawSQLExecutorCallback firstCallback, final RawSQLExecutorCallback callback) throws SQLException {
try {
- return executorKernel.execute((Collection) inputGroups, firstCallback, callback, serial);
+ return executorKernel.execute((Collection) executionGroups, firstCallback, callback, serial);
} catch (final SQLException ex) {
ExecutorExceptionHandler.handleException(ex);
return Collections.emptyList();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/accessor/JDBCAccessor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/accessor/JDBCAccessor.java
index 745a85d..765c7aa 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/accessor/JDBCAccessor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/accessor/JDBCAccessor.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.accessor;
-import org.apache.shardingsphere.infra.executor.sql.group.ExecuteGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.ExecutionGroupEngine;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementOption;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
@@ -32,15 +32,15 @@ import java.util.Collection;
public interface JDBCAccessor {
/**
- * Get execute group engine.
+ * Get execution group engine.
*
* @param backendConnection backend connection
* @param maxConnectionsSizePerQuery max connections size per query
* @param option statement option
* @param rules rules
- * @return execute group engine
+ * @return execution group engine
*/
- ExecuteGroupEngine<?> getExecuteGroupEngine(BackendConnection backendConnection, int maxConnectionsSizePerQuery, StatementOption option, Collection<ShardingSphereRule> rules);
+ ExecutionGroupEngine<?> getExecutionGroupEngine(BackendConnection backendConnection, int maxConnectionsSizePerQuery, StatementOption option, Collection<ShardingSphereRule> rules);
/**
* Execute SQL.
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/accessor/impl/PreparedStatementAccessor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/accessor/impl/PreparedStatementAccessor.java
index ce2b594..225fb78 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/accessor/impl/PreparedStatementAccessor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/accessor/impl/PreparedStatementAccessor.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.accessor.impl;
-import org.apache.shardingsphere.infra.executor.sql.group.ExecuteGroupEngine;
-import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.group.PreparedStatementExecuteGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.ExecutionGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.resourced.jdbc.PreparedStatementExecutionGroupEngine;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementOption;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
@@ -35,9 +35,9 @@ import java.util.Collection;
public final class PreparedStatementAccessor implements JDBCAccessor {
@Override
- public ExecuteGroupEngine<?> getExecuteGroupEngine(final BackendConnection backendConnection,
- final int maxConnectionsSizePerQuery, final StatementOption option, final Collection<ShardingSphereRule> rules) {
- return new PreparedStatementExecuteGroupEngine(maxConnectionsSizePerQuery, backendConnection, option, rules);
+ public ExecutionGroupEngine<?> getExecutionGroupEngine(final BackendConnection backendConnection,
+ final int maxConnectionsSizePerQuery, final StatementOption option, final Collection<ShardingSphereRule> rules) {
+ return new PreparedStatementExecutionGroupEngine(maxConnectionsSizePerQuery, backendConnection, option, rules);
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/accessor/impl/StatementAccessor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/accessor/impl/StatementAccessor.java
index 452e6eb..056374d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/accessor/impl/StatementAccessor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/accessor/impl/StatementAccessor.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.accessor.impl;
-import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.group.StatementExecuteGroupEngine;
+import org.apache.shardingsphere.infra.executor.sql.group.resourced.jdbc.StatementExecutionGroupEngine;
import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.StatementOption;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
@@ -33,9 +33,9 @@ import java.util.Collection;
public final class StatementAccessor implements JDBCAccessor {
@Override
- public StatementExecuteGroupEngine getExecuteGroupEngine(final BackendConnection backendConnection,
- final int maxConnectionsSizePerQuery, final StatementOption option, final Collection<ShardingSphereRule> rules) {
- return new StatementExecuteGroupEngine(maxConnectionsSizePerQuery, backendConnection, option, rules);
+ public StatementExecutionGroupEngine getExecutionGroupEngine(final BackendConnection backendConnection,
+ final int maxConnectionsSizePerQuery, final StatementOption option, final Collection<ShardingSphereRule> rules) {
+ return new StatementExecutionGroupEngine(maxConnectionsSizePerQuery, backendConnection, option, rules);
}
@Override