From 438d76dbde89e3337e036986f3a7481b10c3fc4b Mon Sep 17 00:00:00 2001 From: Luca Cavanna Date: Fri, 4 Aug 2023 17:47:13 +0200 Subject: [PATCH] spotless --- .../search/internal/ContextIndexSearcher.java | 2 +- .../util/concurrent/BoundedExecutorTests.java | 24 ++++++++++++------- .../internal/ContextIndexSearcherTests.java | 24 ++++++++++++++----- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java b/server/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java index 8806dfe0c3c6a..8c442dc5d9285 100644 --- a/server/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java +++ b/server/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java @@ -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()); diff --git a/server/src/test/java/org/elasticsearch/common/util/concurrent/BoundedExecutorTests.java b/server/src/test/java/org/elasticsearch/common/util/concurrent/BoundedExecutorTests.java index 7a921e9d800cf..6ba0ed921dd25 100644 --- a/server/src/test/java/org/elasticsearch/common/util/concurrent/BoundedExecutorTests.java +++ b/server/src/test/java/org/elasticsearch/common/util/concurrent/BoundedExecutorTests.java @@ -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 { @@ -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 { @@ -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); diff --git a/server/src/test/java/org/elasticsearch/search/internal/ContextIndexSearcherTests.java b/server/src/test/java/org/elasticsearch/search/internal/ContextIndexSearcherTests.java index 39e922025a1c4..cfb272103e7d6 100644 --- a/server/src/test/java/org/elasticsearch/search/internal/ContextIndexSearcherTests.java +++ b/server/src/test/java/org/elasticsearch/search/internal/ContextIndexSearcherTests.java @@ -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; @@ -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 throwingLeaves = new HashSet<>(); @@ -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 throwingLeaves = new HashSet<>();