You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/02/23 12:11:28 UTC
[shardingsphere] branch master updated: Add
ParallelRunnerExecutorFactory (#9477)
This is an automated email from the ASF dual-hosted git repository.
zhangyonglun 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 172b6fc Add ParallelRunnerExecutorFactory (#9477)
172b6fc is described below
commit 172b6fc5e41f657dd3b86fa2e1fc51a4c5d8547e
Author: Liang Zhang <te...@163.com>
AuthorDate: Tue Feb 23 20:11:03 2021 +0800
Add ParallelRunnerExecutorFactory (#9477)
---
.../parallel/ParallelRunnerExecutorFactory.java | 48 ++++++++++++++++++++++
.../junit/parallel/ParallelRunnerScheduler.java | 15 +------
2 files changed, 49 insertions(+), 14 deletions(-)
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutorFactory.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutorFactory.java
new file mode 100644
index 0000000..eb035bd
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutorFactory.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.test.integration.engine.junit.parallel;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelLevel;
+import org.apache.shardingsphere.test.integration.engine.junit.parallel.impl.CaseParallelRunnerExecutor;
+import org.apache.shardingsphere.test.integration.engine.junit.parallel.impl.ScenarioParallelRunnerExecutor;
+
+/**
+ * Parallel runner executor factory.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ParallelRunnerExecutorFactory {
+
+ /**
+ * Create new instance of parallel runner executor.
+ *
+ * @param parallelLevel parallel level
+ * @return new instance of parallel runner executor
+ */
+ public static ParallelRunnerExecutor newInstance(final ParallelLevel parallelLevel) {
+ switch (parallelLevel) {
+ case CASE:
+ return new CaseParallelRunnerExecutor();
+ case SCENARIO:
+ return new ScenarioParallelRunnerExecutor();
+ default:
+ throw new UnsupportedOperationException("Unsupported runtime strategy.");
+ }
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerScheduler.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerScheduler.java
index 6375324..5e75d36 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerScheduler.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerScheduler.java
@@ -20,8 +20,6 @@ package org.apache.shardingsphere.test.integration.engine.junit.parallel;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelLevel;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.impl.CaseParallelRunnerExecutor;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.impl.ScenarioParallelRunnerExecutor;
import org.apache.shardingsphere.test.integration.engine.param.RunnerParameters;
import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
import org.junit.runners.model.RunnerScheduler;
@@ -49,21 +47,10 @@ public final class ParallelRunnerScheduler implements RunnerScheduler {
if (runnerExecutors.containsKey(databaseType)) {
return runnerExecutors.get(databaseType);
}
- runnerExecutors.putIfAbsent(databaseType, getRunnerExecutor());
+ runnerExecutors.putIfAbsent(databaseType, ParallelRunnerExecutorFactory.newInstance(parallelLevel));
return runnerExecutors.get(databaseType);
}
- private ParallelRunnerExecutor getRunnerExecutor() {
- switch (parallelLevel) {
- case CASE:
- return new CaseParallelRunnerExecutor();
- case SCENARIO:
- return new ScenarioParallelRunnerExecutor();
- default:
- throw new UnsupportedOperationException("Unsupported runtime strategy.");
- }
- }
-
@Override
public void finished() {
runnerExecutors.values().forEach(ParallelRunnerExecutor::finished);