|
22 | 22 | import java.util.ArrayList;
|
23 | 23 | import java.util.concurrent.Callable;
|
24 | 24 | import java.util.concurrent.CountDownLatch;
|
| 25 | +import java.util.concurrent.ExecutorService; |
| 26 | +import java.util.concurrent.Executors; |
25 | 27 | import java.util.concurrent.Future;
|
26 | 28 | import java.util.concurrent.LinkedBlockingQueue;
|
27 | 29 | import java.util.concurrent.TimeUnit;
|
@@ -441,9 +443,34 @@ public void testCallInTxAsync_Error() throws InterruptedException {
|
441 | 443 | }
|
442 | 444 |
|
443 | 445 | @Test
|
444 |
| - public void transactionsOnLargeThreadPool() throws Exception { |
| 446 | + public void transactionsOnUnboundedThreadPool() throws Exception { |
| 447 | + //Silence the unnecessary debug output and set the max readers |
| 448 | + resetBoxStoreWithoutDebugFlags(100); |
| 449 | + |
| 450 | + runThreadPoolTransactionTest(new ObjectBoxThreadPool(store)); |
| 451 | + } |
| 452 | + |
| 453 | + @Test |
| 454 | + public void transactionsOnBoundedThreadPool() throws Exception { |
| 455 | + //Silence the unnecessary debug output and set the max readers |
| 456 | + int maxReaders = 100; |
| 457 | + resetBoxStoreWithoutDebugFlags(maxReaders); |
| 458 | + |
| 459 | + runThreadPoolTransactionTest(Executors.newFixedThreadPool(maxReaders)); |
| 460 | + } |
| 461 | + |
| 462 | + private void resetBoxStoreWithoutDebugFlags(int maxReaders) { |
| 463 | + // Remove existing store |
| 464 | + tearDown(); |
| 465 | + |
| 466 | + BoxStoreBuilder builder = createBoxStoreBuilder(false); |
| 467 | + builder.maxReaders = maxReaders; |
| 468 | + builder.debugFlags = 0; |
| 469 | + store = builder.build(); |
| 470 | + } |
| 471 | + |
| 472 | + private void runThreadPoolTransactionTest(ExecutorService pool) throws Exception { |
445 | 473 | //Create a bunch of transactions on a thread pool. We can even run them synchronously.
|
446 |
| - ObjectBoxThreadPool pool = new ObjectBoxThreadPool(store); |
447 | 474 | ArrayList<Future<Integer>> txTasks = new ArrayList<>(10000);
|
448 | 475 | for (int i = 0; i < 10000; i++) {
|
449 | 476 | final int txNumber = i;
|
|
0 commit comments