Skip to content

Commit 9d8e64e

Browse files
committed
iter
1 parent e215c78 commit 9d8e64e

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

server/src/test/java/org/elasticsearch/search/DefaultSearchContextTests.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.elasticsearch.common.settings.Settings;
3636
import org.elasticsearch.common.util.concurrent.EsExecutors;
3737
import org.elasticsearch.common.util.concurrent.ThreadContext;
38+
import org.elasticsearch.core.SuppressForbidden;
3839
import org.elasticsearch.core.TimeValue;
3940
import org.elasticsearch.index.IndexService;
4041
import org.elasticsearch.index.IndexSettings;
@@ -981,14 +982,7 @@ public void testSingleThreadNoSearchConcurrency() throws IOException, ExecutionE
981982
int numIters = randomIntBetween(10, 50);
982983
int numSegmentTasks = randomIntBetween(50, 100);
983984
AtomicInteger completedTasks = new AtomicInteger(0);
984-
ThreadPoolExecutor executor = new ThreadPoolExecutor(
985-
executorPoolSize,
986-
executorPoolSize,
987-
0L,
988-
TimeUnit.MILLISECONDS,
989-
new LinkedBlockingQueue<>()
990-
);
991-
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
985+
ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(executorPoolSize);
992986
try {
993987
doTestSearchConcurrency(executor, numIters, numSegmentTasks, completedTasks);
994988
} finally {
@@ -999,6 +993,7 @@ public void testSingleThreadNoSearchConcurrency() throws IOException, ExecutionE
999993
assertEquals(numIters, executor.getCompletedTaskCount());
1000994
}
1001995

996+
@SuppressForbidden(reason = "need to provide queue to ThreadPoolExecutor")
1002997
public void testNoSearchConcurrencyWhenQueueing() throws IOException, ExecutionException, InterruptedException {
1003998
// with multiple threads, but constant queueing, the max number of slices will always be 1, hence we won't provide the
1004999
// executor to the searcher
@@ -1030,6 +1025,7 @@ public int size() {
10301025
assertEquals(numIters, executor.getCompletedTaskCount());
10311026
}
10321027

1028+
@SuppressForbidden(reason = "need to provide queue to ThreadPoolExecutor")
10331029
public void testSearchConcurrencyDoesNotCreateMoreTasksThanThreads() throws Exception {
10341030
// with multiple threads, but not enough queueing to disable parallelism, we will provide the executor to the searcher
10351031
int executorPoolSize = randomIntBetween(2, 5);
@@ -1050,14 +1046,12 @@ public int size() {
10501046
}
10511047
};
10521048
ThreadPoolExecutor executor = new ThreadPoolExecutor(executorPoolSize, executorPoolSize, 0L, TimeUnit.MILLISECONDS, queue);
1053-
10541049
try {
10551050
doTestSearchConcurrency(executor, numIters, numSegmentTasks, completedTasks);
10561051
terminating.set(true);
10571052
} finally {
10581053
terminate(executor);
10591054
}
1060-
10611055
// make sure that we do parallelize execution: each operation will use at minimum as many tasks as threads available
10621056
assertThat(executor.getCompletedTaskCount(), greaterThanOrEqualTo((long) numIters * executorPoolSize));
10631057
// while we parallelize we also limit the number of tasks that each searcher submits

0 commit comments

Comments
 (0)