mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#775 - Change DefaultBackgroundExecutor to use JDK cached thread pool (rather than configure min/max size etc)
This commit is contained in:
@@ -32,6 +32,8 @@ public class ServerConfigTest {
|
||||
props.setProperty("dbuuid","binary");
|
||||
props.setProperty("jdbcFetchSizeFindEach", "42");
|
||||
props.setProperty("jdbcFetchSizeFindList", "43");
|
||||
props.setProperty("backgroundExecutorShutdownSecs", "98");
|
||||
props.setProperty("backgroundExecutorSchedulePoolSize", "4");
|
||||
|
||||
serverConfig.loadFromProperties(props);
|
||||
|
||||
@@ -40,6 +42,8 @@ public class ServerConfigTest {
|
||||
assertEquals(ServerConfig.DbUuid.BINARY, serverConfig.getDbUuid());
|
||||
assertEquals(42, serverConfig.getJdbcFetchSizeFindEach());
|
||||
assertEquals(43, serverConfig.getJdbcFetchSizeFindList());
|
||||
assertEquals(4, serverConfig.getBackgroundExecutorSchedulePoolSize());
|
||||
assertEquals(98, serverConfig.getBackgroundExecutorShutdownSecs());
|
||||
|
||||
serverConfig.setPersistBatch(PersistBatch.NONE);
|
||||
serverConfig.setPersistBatchOnCascade(PersistBatch.NONE);
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.avaje.ebeaninternal.server.core;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DefaultBackgroundExecutorTest {
|
||||
|
||||
@Test @Ignore
|
||||
public void shutdown_when_running_expect_waitAndNiceShutdown() throws Exception {
|
||||
|
||||
DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, 20, "test");
|
||||
|
||||
es.execute(new RunFor(3000,"a"));
|
||||
es.execute(new RunFor(3000,"b"));
|
||||
es.execute(new RunFor(3000,"c"));
|
||||
|
||||
es.shutdown();
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
public void shutdown_when_rougeRunnable_expect_InterruptedException() throws Exception {
|
||||
|
||||
DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, 10, "test");
|
||||
|
||||
es.execute(new RunFor(300000,"a"));
|
||||
es.execute(new RunFor(3000,"b"));
|
||||
es.execute(new RunFor(3000,"c"));
|
||||
|
||||
es.shutdown();
|
||||
}
|
||||
|
||||
|
||||
class RunFor implements Runnable {
|
||||
|
||||
final long wait;
|
||||
final String id;
|
||||
|
||||
RunFor(long wait, String id) {
|
||||
this.wait = wait;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
System.out.println("start " + id);
|
||||
Thread.sleep(wait);
|
||||
System.out.println("done " + id);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class TestDataSourceMaxWithEntity extends BaseTestCase {
|
||||
EbeanServer server = Ebean.getServer(null);
|
||||
|
||||
|
||||
DefaultBackgroundExecutor bg = new DefaultBackgroundExecutor(1, 1, 2, 180, 30, "testDs");
|
||||
DefaultBackgroundExecutor bg = new DefaultBackgroundExecutor(1, 30, "testDs");
|
||||
|
||||
try {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
|
||||
Reference in New Issue
Block a user