You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2023/08/10 11:31:26 UTC
[shardingsphere] branch master updated: Remove useless ExecutorEngine.createExecutorEngineWithCPU (#28024)
This is an automated email from the ASF dual-hosted git repository.
sunnianjun 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 4a7671474ce Remove useless ExecutorEngine.createExecutorEngineWithCPU (#28024)
4a7671474ce is described below
commit 4a7671474cece7f210af87651f1f43aaa262f9de
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Aug 10 19:31:19 2023 +0800
Remove useless ExecutorEngine.createExecutorEngineWithCPU (#28024)
* Remove useless ExecutorEngine.createExecutorEngineWithCPU
---
.../shardingsphere/infra/executor/kernel/ExecutorEngine.java | 12 ------------
.../jdbc/core/statement/ShardingSpherePreparedStatement.java | 2 +-
.../executor/batch/BatchPreparedStatementExecutorTest.java | 2 +-
.../test/e2e/env/DataSetEnvironmentManager.java | 2 +-
4 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorEngine.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorEngine.java
index 5e2c679bc91..b4b540bfd6b 100644
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorEngine.java
+++ b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/kernel/ExecutorEngine.java
@@ -39,8 +39,6 @@ import java.util.concurrent.Future;
@Getter
public final class ExecutorEngine implements AutoCloseable {
- private static final int CPU_CORES = Runtime.getRuntime().availableProcessors();
-
private final ExecutorServiceManager executorServiceManager;
private ExecutorEngine(final int executorSize) {
@@ -57,16 +55,6 @@ public final class ExecutorEngine implements AutoCloseable {
return new ExecutorEngine(executorSize);
}
- /**
- * Create executor engine with CPU.
- *
- * @return created executor engine
- */
- public static ExecutorEngine createExecutorEngineWithCPU() {
- int cpuThreadCount = CPU_CORES * 2 - 1;
- return new ExecutorEngine(cpuThreadCount);
- }
-
/**
* Execute.
*
diff --git a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
index d0d4daa6b92..edac8bc1021 100644
--- a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
+++ b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
@@ -264,7 +264,7 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = createDriverExecutionPrepareEngine();
ExecutionUnit executionUnit = new ExecutionUnit(trafficInstanceId, new SQLUnit(queryContext.getSql(), queryContext.getParameters()));
ExecutionGroupContext<JDBCExecutionUnit> context =
- prepareEngine.prepare(new RouteContext(), Collections.singletonList(executionUnit), new ExecutionGroupReportContext(databaseName));
+ prepareEngine.prepare(new RouteContext(), Collections.singleton(executionUnit), new ExecutionGroupReportContext(databaseName));
if (context.getInputGroups().isEmpty() || context.getInputGroups().iterator().next().getInputs().isEmpty()) {
throw new EmptyTrafficExecutionUnitException();
}
diff --git a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
index 1b9a5125517..948b9f60f35 100644
--- a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
+++ b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
@@ -79,7 +79,7 @@ class BatchPreparedStatementExecutorTest {
private static final String SQL = "DELETE FROM table_x WHERE id=?";
- private final ExecutorEngine executorEngine = ExecutorEngine.createExecutorEngineWithCPU();
+ private final ExecutorEngine executorEngine = ExecutorEngine.createExecutorEngineWithSize(Runtime.getRuntime().availableProcessors() * 2 - 1);
private BatchPreparedStatementExecutor executor;
diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/env/DataSetEnvironmentManager.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/env/DataSetEnvironmentManager.java
index 57b17831152..bde8b7a3987 100644
--- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/env/DataSetEnvironmentManager.java
+++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/env/DataSetEnvironmentManager.java
@@ -60,7 +60,7 @@ import java.util.concurrent.Future;
public final class DataSetEnvironmentManager {
// TODO ExecutorEngine.execute and callback
- private static final ExecutorServiceManager EXECUTOR_SERVICE_MANAGER = ExecutorEngine.createExecutorEngineWithCPU().getExecutorServiceManager();
+ private static final ExecutorServiceManager EXECUTOR_SERVICE_MANAGER = ExecutorEngine.createExecutorEngineWithSize(Runtime.getRuntime().availableProcessors() * 2 - 1).getExecutorServiceManager();
private static final String DATA_COLUMN_DELIMITER = ", ";