This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new ae1681273c Add more test for broker jersey bounded thread pool (#11705)
ae1681273c is described below
commit ae1681273c4929587729d71c6dc9526c62ca1fcc
Author: Pratik Tibrewal <[email protected]>
AuthorDate: Sat Sep 30 10:59:41 2023 +0530
Add more test for broker jersey bounded thread pool (#11705)
---
.../BrokerManagedAsyncExecutorProviderTest.java | 34 +++++++++++++++++-----
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git
a/pinot-broker/src/test/java/org/apache/pinot/broker/broker/BrokerManagedAsyncExecutorProviderTest.java
b/pinot-broker/src/test/java/org/apache/pinot/broker/broker/BrokerManagedAsyncExecutorProviderTest.java
index 25c1d099ca..2cab3985d5 100644
---
a/pinot-broker/src/test/java/org/apache/pinot/broker/broker/BrokerManagedAsyncExecutorProviderTest.java
+++
b/pinot-broker/src/test/java/org/apache/pinot/broker/broker/BrokerManagedAsyncExecutorProviderTest.java
@@ -25,6 +25,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -78,23 +79,42 @@ public class BrokerManagedAsyncExecutorProviderTest {
@Test
public void testGet()
throws InterruptedException {
- BrokerManagedAsyncExecutorProvider provider = new
BrokerManagedAsyncExecutorProvider(1, 1, 1, _brokerMetrics);
- ExecutorService executorService = provider.getExecutorService();
- // verify that the executor has the expected properties
+ // verify executor has correct properties when queue size is
Integer.MAX_VALUE
+ BrokerManagedAsyncExecutorProvider provider =
+ new BrokerManagedAsyncExecutorProvider(1, 1, Integer.MAX_VALUE,
_brokerMetrics);
+ ExecutorService executorService = provider.getExecutorService();
assertNotNull(executorService);
assertTrue(executorService instanceof ThreadPoolExecutor);
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor)
executorService;
- assertEquals(1, threadPoolExecutor.getCorePoolSize());
- assertEquals(1, threadPoolExecutor.getMaximumPoolSize());
+ assertEquals(threadPoolExecutor.getCorePoolSize(), 1);
+ assertEquals(threadPoolExecutor.getMaximumPoolSize(), 1);
BlockingQueue<Runnable> blockingQueue = threadPoolExecutor.getQueue();
assertNotNull(blockingQueue);
+ assertTrue(blockingQueue instanceof LinkedBlockingQueue);
+ assertEquals(blockingQueue.size(), 0);
+ assertEquals(blockingQueue.remainingCapacity(), Integer.MAX_VALUE);
+
+
+ // verify that the executor has the expected properties when queue size is
1
+ provider = new BrokerManagedAsyncExecutorProvider(1, 1, 1, _brokerMetrics);
+ executorService = provider.getExecutorService();
+ assertNotNull(executorService);
+ assertTrue(executorService instanceof ThreadPoolExecutor);
+
+ threadPoolExecutor = (ThreadPoolExecutor) executorService;
+
+ assertEquals(threadPoolExecutor.getCorePoolSize(), 1);
+ assertEquals(threadPoolExecutor.getMaximumPoolSize(), 1);
+
+ blockingQueue = threadPoolExecutor.getQueue();
+ assertNotNull(blockingQueue);
assertTrue(blockingQueue instanceof ArrayBlockingQueue);
- assertEquals(0, blockingQueue.size());
- assertEquals(1, blockingQueue.remainingCapacity());
+ assertEquals(blockingQueue.size(), 0);
+ assertEquals(blockingQueue.remainingCapacity(), 1);
RejectedExecutionHandler rejectedExecutionHandler =
threadPoolExecutor.getRejectedExecutionHandler();
assertNotNull(rejectedExecutionHandler);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]