Skip to content

Commit

Permalink
Remove useless ExecutorEngine.createExecutorEngineWithCPU (#28024)
Browse files Browse the repository at this point in the history
* Remove useless ExecutorEngine.createExecutorEngineWithCPU
  • Loading branch information
terrymanu authored Aug 10, 2023
1 parent eeffeb6 commit 4a76714
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
@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) {
Expand All @@ -57,16 +55,6 @@ public static ExecutorEngine createExecutorEngineWithSize(final int executorSize
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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private JDBCExecutionUnit createTrafficExecutionUnit(final String trafficInstanc
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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
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 = ", ";

Expand Down

0 comments on commit 4a76714

Please sign in to comment.