Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
javanna committed Aug 4, 2023
1 parent 3b86ab1 commit 438d76d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private ContextIndexSearcher(
if (forceSequentialCollection) {
// we offload to the executor unconditionally, including requests that don't support concurrency
// TODO are we good offloading aggs that don't support concurrency to the concurrent executor or is postCollect an issue?
this.leafSlices = new LeafSlice[]{new LeafSlice(new ArrayList<>(getLeafContexts()))};
this.leafSlices = new LeafSlice[] { new LeafSlice(new ArrayList<>(getLeafContexts())) };
} else {
this.leafSlices = computeSlices(getLeafContexts(), executor.getBound(), minimumDocsPerSlice);
assert (this.leafSlices.length <= executor.getBound());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class BoundedExecutorTests extends ESTestCase {
Expand All @@ -34,8 +30,14 @@ public void testBound() {
int numThreads = randomIntBetween(1, 10);
ThreadPoolExecutor executor = null;
try {
executor = EsExecutors.newFixed(BoundedExecutorTests.class.getName(), numThreads, numThreads,
EsExecutors.daemonThreadFactory(""), new ThreadContext(Settings.EMPTY), EsExecutors.TaskTrackingConfig.DO_NOT_TRACK);
executor = EsExecutors.newFixed(
BoundedExecutorTests.class.getName(),
numThreads,
numThreads,
EsExecutors.daemonThreadFactory(""),
new ThreadContext(Settings.EMPTY),
EsExecutors.TaskTrackingConfig.DO_NOT_TRACK
);
BoundedExecutor boundedExecutor = new BoundedExecutor(executor);
assertEquals(numThreads, boundedExecutor.getBound());
} finally {
Expand All @@ -46,8 +48,14 @@ public void testBound() {
public void testExecute() throws Exception {
int numThreads = randomIntBetween(1, 10);
int numTasks = randomIntBetween(500, 1000);
ThreadPoolExecutor executor = EsExecutors.newFixed(BoundedExecutorTests.class.getName(), numThreads, numThreads,
EsExecutors.daemonThreadFactory(""), new ThreadContext(Settings.EMPTY), EsExecutors.TaskTrackingConfig.DO_NOT_TRACK);
ThreadPoolExecutor executor = EsExecutors.newFixed(
BoundedExecutorTests.class.getName(),
numThreads,
numThreads,
EsExecutors.daemonThreadFactory(""),
new ThreadContext(Settings.EMPTY),
EsExecutors.TaskTrackingConfig.DO_NOT_TRACK
);
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
try {
BoundedExecutor boundedExecutor = new BoundedExecutor(executor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

import static org.elasticsearch.search.internal.ContextIndexSearcher.intersectScorerAndBitSet;
Expand Down Expand Up @@ -547,8 +545,15 @@ public void testCancelSliceTasksOnException() throws Exception {
int numThreads = randomIntBetween(4, 6);
int numBusyThreads = randomIntBetween(0, 3);
int numAvailableThreads = numThreads - numBusyThreads;
ThreadPoolExecutor executor = EsExecutors.newFixed(BoundedExecutorTests.class.getName(), numThreads, numThreads,
EsExecutors.daemonThreadFactory(""), new ThreadContext(Settings.EMPTY), EsExecutors.TaskTrackingConfig.DO_NOT_TRACK);;
ThreadPoolExecutor executor = EsExecutors.newFixed(
BoundedExecutorTests.class.getName(),
numThreads,
numThreads,
EsExecutors.daemonThreadFactory(""),
new ThreadContext(Settings.EMPTY),
EsExecutors.TaskTrackingConfig.DO_NOT_TRACK
);
;
AssertingBoundedExecutor boundedExecutor = new AssertingBoundedExecutor(executor, numBusyThreads);
try (DirectoryReader directoryReader = DirectoryReader.open(dir)) {
Set<LeafReaderContext> throwingLeaves = new HashSet<>();
Expand Down Expand Up @@ -683,8 +688,15 @@ public void testCancelSliceTasksOnTimeout() throws Exception {
int numThreads = randomIntBetween(4, 6);
int numBusyThreads = randomIntBetween(0, 3);
int numAvailableThreads = numThreads - numBusyThreads;
ThreadPoolExecutor executor = EsExecutors.newFixed(BoundedExecutorTests.class.getName(), numThreads, numThreads,
EsExecutors.daemonThreadFactory(""), new ThreadContext(Settings.EMPTY), EsExecutors.TaskTrackingConfig.DO_NOT_TRACK);;
ThreadPoolExecutor executor = EsExecutors.newFixed(
BoundedExecutorTests.class.getName(),
numThreads,
numThreads,
EsExecutors.daemonThreadFactory(""),
new ThreadContext(Settings.EMPTY),
EsExecutors.TaskTrackingConfig.DO_NOT_TRACK
);
;
AssertingBoundedExecutor boundedExecutor = new AssertingBoundedExecutor(executor, numBusyThreads);
try (DirectoryReader directoryReader = DirectoryReader.open(dir)) {
Set<LeafReaderContext> throwingLeaves = new HashSet<>();
Expand Down

0 comments on commit 438d76d

Please sign in to comment.