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/19 06:57:26 UTC

[shardingsphere] branch master updated: Add impl package for ITRunnerExecutor (#9435)

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 94531c6  Add impl package for ITRunnerExecutor (#9435)
94531c6 is described below

commit 94531c661fb7bc401f915d6cea3809b5c7f56162
Author: Liang Zhang <te...@163.com>
AuthorDate: Fri Feb 19 14:57:10 2021 +0800

    Add impl package for ITRunnerExecutor (#9435)
    
    * Refactor ITRunnerParallelExecutor
    
    * Refactor ITRunnerParallelExecutor
    
    * Add impl package for ITRunnerExecutor
---
 .../engine/junit/ITRunnerScheduler.java            |  3 +++
 .../junit/{ => impl}/ITRunnerParallelExecutor.java | 23 ++++++++--------------
 .../{ => impl}/ITRunnerScenariosExecutor.java      |  3 ++-
 .../junit/{ => impl}/ITRunnerSerialExecutor.java   |  3 ++-
 4 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITRunnerScheduler.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITRunnerScheduler.java
index 95a4782..363e478 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITRunnerScheduler.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITRunnerScheduler.java
@@ -21,6 +21,9 @@ import lombok.SneakyThrows;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
 import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
+import org.apache.shardingsphere.test.integration.engine.junit.impl.ITRunnerParallelExecutor;
+import org.apache.shardingsphere.test.integration.engine.junit.impl.ITRunnerScenariosExecutor;
+import org.apache.shardingsphere.test.integration.engine.junit.impl.ITRunnerSerialExecutor;
 import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
 import org.apache.shardingsphere.test.integration.env.IntegrationTestEnvironment;
 import org.junit.runners.model.RunnerScheduler;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITRunnerParallelExecutor.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/impl/ITRunnerParallelExecutor.java
similarity index 67%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITRunnerParallelExecutor.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/impl/ITRunnerParallelExecutor.java
index fb3c7fd..246ba61 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITRunnerParallelExecutor.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/impl/ITRunnerParallelExecutor.java
@@ -15,9 +15,11 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.test.integration.engine.junit;
+package org.apache.shardingsphere.test.integration.engine.junit.impl;
 
+import lombok.SneakyThrows;
 import org.apache.shardingsphere.infra.executor.kernel.thread.ExecutorServiceManager;
+import org.apache.shardingsphere.test.integration.engine.junit.ITRunnerExecutor;
 import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
 
 import java.util.concurrent.ExecutorService;
@@ -28,27 +30,18 @@ import java.util.concurrent.TimeUnit;
  */
 public final class ITRunnerParallelExecutor implements ITRunnerExecutor {
     
-    private final ExecutorServiceManager executorServiceManager;
-    
-    public ITRunnerParallelExecutor() {
-        executorServiceManager = new ExecutorServiceManager(Runtime.getRuntime().availableProcessors() * 2 - 1);
-    }
+    private final ExecutorServiceManager executorServiceManager = new ExecutorServiceManager(Runtime.getRuntime().availableProcessors() * 2 - 1);
     
     @Override
     public void execute(final ParameterizedArray parameterizedArray, final Runnable childStatement) {
         executorServiceManager.getExecutorService().submit(childStatement);
     }
     
+    @SneakyThrows(InterruptedException.class)
     @Override
     public void finished() {
-        if (null != executorServiceManager) {
-            try {
-                ExecutorService executorService = executorServiceManager.getExecutorService();
-                executorService.shutdown();
-                executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
-            } catch (InterruptedException e) {
-                e.printStackTrace(System.err);
-            }
-        }
+        ExecutorService executorService = executorServiceManager.getExecutorService();
+        executorService.shutdown();
+        executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
     }
 }
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITRunnerScenariosExecutor.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/impl/ITRunnerScenariosExecutor.java
similarity index 97%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITRunnerScenariosExecutor.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/impl/ITRunnerScenariosExecutor.java
index fbe112d..ae7922d 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITRunnerScenariosExecutor.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/impl/ITRunnerScenariosExecutor.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.test.integration.engine.junit;
+package org.apache.shardingsphere.test.integration.engine.junit.impl;
 
 import com.google.common.base.Charsets;
 import com.google.common.hash.Hasher;
@@ -34,6 +34,7 @@ import lombok.Setter;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.test.integration.engine.junit.ITRunnerExecutor;
 import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
 import org.apache.shardingsphere.test.integration.env.IntegrationTestEnvironment;
 
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITRunnerSerialExecutor.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/impl/ITRunnerSerialExecutor.java
similarity index 88%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITRunnerSerialExecutor.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/impl/ITRunnerSerialExecutor.java
index aae7959..86e5584 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITRunnerSerialExecutor.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/impl/ITRunnerSerialExecutor.java
@@ -15,8 +15,9 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.test.integration.engine.junit;
+package org.apache.shardingsphere.test.integration.engine.junit.impl;
 
+import org.apache.shardingsphere.test.integration.engine.junit.ITRunnerExecutor;
 import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
 
 /**