You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2020/04/17 09:34:08 UTC
[incubator-iotdb] branch master updated: [IOTDB-573]claim the error
output can be igonred in UT/ITs (#1032)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new f79266d [IOTDB-573]claim the error output can be igonred in UT/ITs (#1032)
f79266d is described below
commit f79266d81891868d4ce7bc8d21151b409286f31b
Author: Xiangdong Huang <hx...@qq.com>
AuthorDate: Fri Apr 17 17:33:56 2020 +0800
[IOTDB-573]claim the error output can be igonred in UT/ITs (#1032)
* claim the error output can be igonred in UT/ITs
---
.../iotdb/db/concurrent/WrappedRunnable.java | 9 ++++--
.../db/concurrent/IoTDBThreadPoolFactoryTest.java | 32 +++++++++++-----------
2 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/concurrent/WrappedRunnable.java b/server/src/main/java/org/apache/iotdb/db/concurrent/WrappedRunnable.java
index 7b143a3..7d6ff7f 100644
--- a/server/src/main/java/org/apache/iotdb/db/concurrent/WrappedRunnable.java
+++ b/server/src/main/java/org/apache/iotdb/db/concurrent/WrappedRunnable.java
@@ -32,11 +32,16 @@ public abstract class WrappedRunnable implements Runnable {
try {
runMayThrow();
} catch (Exception e) {
- LOGGER.error("error", e);
- throw Throwables.propagate(e);
+ LOGGER.error(e.getMessage(), e);
+ throw propagate(e);
}
}
abstract public void runMayThrow() throws Exception;
+ @SuppressWarnings("squid:S112")
+ private static RuntimeException propagate(Throwable throwable) {
+ Throwables.throwIfUnchecked(throwable);
+ throw new RuntimeException(throwable);
+ }
}
diff --git a/server/src/test/java/org/apache/iotdb/db/concurrent/IoTDBThreadPoolFactoryTest.java b/server/src/test/java/org/apache/iotdb/db/concurrent/IoTDBThreadPoolFactoryTest.java
index def7c4d..9d4fe89 100644
--- a/server/src/test/java/org/apache/iotdb/db/concurrent/IoTDBThreadPoolFactoryTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/concurrent/IoTDBThreadPoolFactoryTest.java
@@ -51,12 +51,12 @@ public class IoTDBThreadPoolFactoryTest {
@Test
public void testNewFixedThreadPool() throws InterruptedException, ExecutionException {
- String reason = "NewFixedThreadPool";
+ String reason = "(can be ignored in Tests) NewFixedThreadPool";
Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason);
- int threadCount = 5;
+ int threadCount = 4;
latch = new CountDownLatch(threadCount);
ExecutorService exec = IoTDBThreadPoolFactory
- .newFixedThreadPool(threadCount, POOL_NAME, handler);
+ .newFixedThreadPool(threadCount / 2, POOL_NAME, handler);
for (int i = 0; i < threadCount; i++) {
Runnable task = new TestThread(reason);
exec.execute(task);
@@ -71,9 +71,9 @@ public class IoTDBThreadPoolFactoryTest {
@Test
public void testNewSingleThreadExecutor() throws InterruptedException {
- String reason = "NewSingleThreadExecutor";
+ String reason = "(can be ignored in Tests)NewSingleThreadExecutor";
Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason);
- int threadCount = 1;
+ int threadCount = 2;
latch = new CountDownLatch(threadCount);
ExecutorService exec = IoTDBThreadPoolFactory.newSingleThreadExecutor(POOL_NAME, handler);
for (int i = 0; i < threadCount; i++) {
@@ -90,9 +90,9 @@ public class IoTDBThreadPoolFactoryTest {
@Test
public void testNewCachedThreadPool() throws InterruptedException {
- String reason = "NewCachedThreadPool";
+ String reason = "(can be ignored in Tests) NewCachedThreadPool";
Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason);
- int threadCount = 10;
+ int threadCount = 4;
latch = new CountDownLatch(threadCount);
ExecutorService exec = IoTDBThreadPoolFactory.newCachedThreadPool(POOL_NAME, handler);
for (int i = 0; i < threadCount; i++) {
@@ -109,9 +109,9 @@ public class IoTDBThreadPoolFactoryTest {
@Test
public void testNewSingleThreadScheduledExecutor() throws InterruptedException {
- String reason = "NewSingleThreadScheduledExecutor";
+ String reason = "(can be ignored in Tests) NewSingleThreadScheduledExecutor";
Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason);
- int threadCount = 1;
+ int threadCount = 2;
latch = new CountDownLatch(threadCount);
ScheduledExecutorService exec = IoTDBThreadPoolFactory
.newSingleThreadScheduledExecutor(POOL_NAME, handler);
@@ -136,12 +136,12 @@ public class IoTDBThreadPoolFactoryTest {
@Test
public void testNewScheduledThreadPool() throws InterruptedException {
- String reason = "NewScheduledThreadPool";
+ String reason = "(can be ignored in Tests) NewScheduledThreadPool";
Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason);
- int threadCount = 10;
+ int threadCount = 4;
latch = new CountDownLatch(threadCount);
ScheduledExecutorService exec = IoTDBThreadPoolFactory
- .newScheduledThreadPool(threadCount, POOL_NAME, handler);
+ .newScheduledThreadPool(threadCount / 2, POOL_NAME, handler);
for (int i = 0; i < threadCount; i++) {
Runnable task = new TestThread(reason);
ScheduledFuture<?> future = exec.scheduleAtFixedRate(task, 0, 1, TimeUnit.SECONDS);
@@ -163,14 +163,14 @@ public class IoTDBThreadPoolFactoryTest {
@Test
public void testCreateJDBCClientThreadPool() throws InterruptedException {
- String reason = "CreateJDBCClientThreadPool";
+ String reason = "(can be ignored in Tests) CreateJDBCClientThreadPool";
TThreadPoolServer.Args args = new Args(null);
- args.maxWorkerThreads = 100;
- args.minWorkerThreads = 10;
+ args.maxWorkerThreads = 4;
+ args.minWorkerThreads = 2;
args.stopTimeoutVal = 10;
args.stopTimeoutUnit = TimeUnit.SECONDS;
Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason);
- int threadCount = 50;
+ int threadCount = 4;
latch = new CountDownLatch(threadCount);
ExecutorService exec = IoTDBThreadPoolFactory
.createThriftRpcClientThreadPool(args, POOL_NAME, handler);