This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 97395363c2c Remove generic type of ParallelRunnerExecutor (#22521)
97395363c2c is described below
commit 97395363c2c20d7f1fe4afb12e2cfc77b7f17285
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Nov 30 13:33:29 2022 +0800
Remove generic type of ParallelRunnerExecutor (#22521)
* Remove generic type of ParallelRunnerExecutor
* Remove generic type of ParallelRunnerExecutor
---
.../ParameterizedParallelRunnerScheduler.java | 3 ++-
.../parallel/impl/CaseParallelRunnerExecutor.java | 2 +-
.../impl/ScenarioParallelRunnerExecutor.java | 26 ++++++++++------------
.../runner/executor/ParallelRunnerExecutor.java | 3 +--
.../impl/NormalParallelRunnerExecutor.java | 6 ++---
5 files changed, 19 insertions(+), 21 deletions(-)
diff --git
a/test/integration-test/test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/runner/parallel/ParameterizedParallelRunnerScheduler.java
b/test/integration-test/test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/runner/parallel/ParameterizedParallelRunnerScheduler.java
index 91fe077279f..c2951e76b02 100644
---
a/test/integration-test/test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/runner/parallel/ParameterizedParallelRunnerScheduler.java
+++
b/test/integration-test/test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/runner/parallel/ParameterizedParallelRunnerScheduler.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.test.integration.framework.runner.parallel;
import
org.apache.shardingsphere.test.integration.framework.param.model.ITParameterizedArray;
+import
org.apache.shardingsphere.test.integration.framework.runner.parallel.impl.ScenarioParallelRunnerExecutor.ScenarioKey;
import
org.apache.shardingsphere.test.runner.ParallelRunningStrategy.ParallelLevel;
import org.apache.shardingsphere.test.runner.executor.ParallelRunnerExecutors;
import org.apache.shardingsphere.test.runner.param.RunnerParameters;
@@ -35,6 +36,6 @@ public final class ParameterizedParallelRunnerScheduler
extends ParallelRunnerSc
@Override
public void schedule(final Runnable childStatement) {
ITParameterizedArray parameterizedArray = (ITParameterizedArray) new
RunnerParameters(childStatement).getParameterizedArray();
-
getExecutorEngine().getExecutor(parameterizedArray.getDatabaseType().getType(),
getParallelLevel()).execute(parameterizedArray, childStatement);
+
getExecutorEngine().getExecutor(parameterizedArray.getDatabaseType().getType(),
getParallelLevel()).execute(new ScenarioKey(parameterizedArray).toString(),
childStatement);
}
}
diff --git
a/test/integration-test/test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/runner/parallel/impl/CaseParallelRunnerExecutor.java
b/test/integration-test/test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/runner/parallel/impl/CaseParallelRunnerExecutor.java
index 9abb856c8e7..c390c83c2c8 100644
---
a/test/integration-test/test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/runner/parallel/impl/CaseParallelRunnerExecutor.java
+++
b/test/integration-test/test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/runner/parallel/impl/CaseParallelRunnerExecutor.java
@@ -26,7 +26,7 @@ import
org.apache.shardingsphere.test.runner.executor.impl.NormalParallelRunnerE
public final class CaseParallelRunnerExecutor extends
NormalParallelRunnerExecutor {
@Override
- public void execute(final Object parameterizedArray, final Runnable
childStatement) {
+ public void execute(final String key, final Runnable childStatement) {
execute(childStatement);
}
diff --git
a/test/integration-test/test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/runner/parallel/impl/ScenarioParallelRunnerExecutor.java
b/test/integration-test/test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/runner/parallel/impl/ScenarioParallelRunnerExecutor.java
index 3c96e2d67af..635ddaf536b 100644
---
a/test/integration-test/test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/runner/parallel/impl/ScenarioParallelRunnerExecutor.java
+++
b/test/integration-test/test-suite/src/test/java/org/apache/shardingsphere/test/integration/framework/runner/parallel/impl/ScenarioParallelRunnerExecutor.java
@@ -31,19 +31,17 @@ import java.util.concurrent.Executors;
public final class ScenarioParallelRunnerExecutor extends
NormalParallelRunnerExecutor {
@Override
- protected ExecutorService getExecutorService(final Object key) {
- ScenarioKey scenarioKey = new ScenarioKey((ITParameterizedArray) key);
- if (getExecutorServices().containsKey(scenarioKey)) {
- return getExecutorServices().get(scenarioKey);
+ protected ExecutorService getExecutorService(final String key) {
+ if (getExecutorServices().containsKey(key)) {
+ return getExecutorServices().get(key);
}
- String threadPoolNameFormat = String.join("-", "ScenarioExecutorPool",
scenarioKey.toString(), "%d");
+ String threadPoolNameFormat = String.join("-", "ScenarioExecutorPool",
key, "%d");
ExecutorService executorService = Executors.newFixedThreadPool(
- Runtime.getRuntime().availableProcessors(),
- new
ThreadFactoryBuilder().setDaemon(true).setNameFormat(threadPoolNameFormat).build());
- if (null != getExecutorServices().putIfAbsent(scenarioKey,
executorService)) {
+ Runtime.getRuntime().availableProcessors(), new
ThreadFactoryBuilder().setDaemon(true).setNameFormat(threadPoolNameFormat).build());
+ if (null != getExecutorServices().putIfAbsent(key, executorService)) {
executorService.shutdownNow();
}
- return getExecutorServices().get(scenarioKey);
+ return getExecutorServices().get(key);
}
@Override
@@ -55,23 +53,23 @@ public final class ScenarioParallelRunnerExecutor extends
NormalParallelRunnerEx
* Scenario key.
*/
@EqualsAndHashCode
- private static final class ScenarioKey {
+ public static final class ScenarioKey {
private final String adapter;
private final String scenario;
- private final String databaseTypeName;
+ private final String databaseType;
- private ScenarioKey(final ITParameterizedArray parameterizedArray) {
+ public ScenarioKey(final ITParameterizedArray parameterizedArray) {
adapter = parameterizedArray.getAdapter();
scenario = parameterizedArray.getScenario();
- databaseTypeName = parameterizedArray.getDatabaseType().getType();
+ databaseType = parameterizedArray.getDatabaseType().getType();
}
@Override
public String toString() {
- return String.join("-", adapter, scenario, databaseTypeName);
+ return String.join("-", adapter, scenario, databaseType);
}
}
}
diff --git
a/test/runner/src/main/java/org/apache/shardingsphere/test/runner/executor/ParallelRunnerExecutor.java
b/test/runner/src/main/java/org/apache/shardingsphere/test/runner/executor/ParallelRunnerExecutor.java
index 5d1d46cc24a..255f8916436 100644
---
a/test/runner/src/main/java/org/apache/shardingsphere/test/runner/executor/ParallelRunnerExecutor.java
+++
b/test/runner/src/main/java/org/apache/shardingsphere/test/runner/executor/ParallelRunnerExecutor.java
@@ -29,9 +29,8 @@ public interface ParallelRunnerExecutor {
*
* @param key executor key
* @param childStatement child statement
- * @param <T> type of key
*/
- <T> void execute(T key, Runnable childStatement);
+ void execute(String key, Runnable childStatement);
/**
* Execute child statement.
diff --git
a/test/runner/src/main/java/org/apache/shardingsphere/test/runner/executor/impl/NormalParallelRunnerExecutor.java
b/test/runner/src/main/java/org/apache/shardingsphere/test/runner/executor/impl/NormalParallelRunnerExecutor.java
index 9450a75f806..288b4578a30 100644
---
a/test/runner/src/main/java/org/apache/shardingsphere/test/runner/executor/impl/NormalParallelRunnerExecutor.java
+++
b/test/runner/src/main/java/org/apache/shardingsphere/test/runner/executor/impl/NormalParallelRunnerExecutor.java
@@ -43,7 +43,7 @@ public class NormalParallelRunnerExecutor implements
ParallelRunnerExecutor {
private volatile ExecutorService defaultExecutorService;
@Override
- public <T> void execute(final T key, final Runnable childStatement) {
+ public void execute(final String key, final Runnable childStatement) {
futures.add(getExecutorService(key).submit(childStatement));
}
@@ -52,11 +52,11 @@ public class NormalParallelRunnerExecutor implements
ParallelRunnerExecutor {
futures.add(getExecutorService().submit(childStatement));
}
- protected <T> ExecutorService getExecutorService(final T key) {
+ protected ExecutorService getExecutorService(final String key) {
if (executorServices.containsKey(key)) {
return executorServices.get(key);
}
- String threadPoolNameFormat = String.join("-",
"ShardingSphere-KeyedParallelTestThread", key.toString(), "%d");
+ String threadPoolNameFormat = String.join("-",
"ShardingSphere-KeyedParallelTestThread", key, "%d");
ExecutorService executorService = Executors.newFixedThreadPool(
Runtime.getRuntime().availableProcessors(), new
ThreadFactoryBuilder().setDaemon(true).setNameFormat(threadPoolNameFormat).build());
if (null != executorServices.putIfAbsent(key, executorService)) {