File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed
server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change 5353import java .util .Map ;
5454import java .util .concurrent .CountDownLatch ;
5555
56+ import static java .util .stream .IntStream .range ;
5657import static org .elasticsearch .cluster .metadata .IndexMetadata .SETTING_NUMBER_OF_REPLICAS ;
5758import static org .elasticsearch .cluster .metadata .IndexMetadata .SETTING_NUMBER_OF_SHARDS ;
5859import static org .hamcrest .Matchers .everyItem ;
@@ -284,17 +285,11 @@ public void testMaxQueueLatencyMetricIsPublished() {
284285 final String dataNodeToDelay = randomFrom (dataNodes );
285286 final ThreadPool threadPoolToDelay = internalCluster ().getInstance (ThreadPool .class , dataNodeToDelay );
286287
287- // Fill the write thread pool
288+ // Fill the write thread pool and block a task for some time
288289 final int writeThreadPoolSize = threadPoolToDelay .info (ThreadPool .Names .WRITE ).getMax ();
289290 final var latch = new CountDownLatch (1 );
290291 final var writeThreadPool = threadPoolToDelay .executor (ThreadPool .Names .WRITE );
291- for (int i = 0 ; i < writeThreadPoolSize ; i ++) {
292- writeThreadPool .execute (() -> safeAwait (latch ));
293- }
294- // Submit a task that will be delayed
295- writeThreadPool .execute (() -> {
296- // Doesn't need to do anything
297- });
292+ range (0 , writeThreadPoolSize + 1 ).forEach (i -> writeThreadPool .execute (() -> safeAwait (latch )));
298293 final long delayMillis = randomIntBetween (100 , 200 );
299294 safeSleep (delayMillis );
300295 // Unblock the pool
You can’t perform that action at this time.
0 commit comments