File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed
server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change 5151import java .util .HashMap ;
5252import java .util .List ;
5353import java .util .Map ;
54- import java .util .concurrent .CyclicBarrier ;
54+ import java .util .concurrent .CountDownLatch ;
5555
5656import static org .elasticsearch .cluster .metadata .IndexMetadata .SETTING_NUMBER_OF_REPLICAS ;
5757import static org .elasticsearch .cluster .metadata .IndexMetadata .SETTING_NUMBER_OF_SHARDS ;
@@ -286,22 +286,19 @@ public void testMaxQueueLatencyMetricIsPublished() {
286286
287287 // Fill the write thread pool
288288 final int writeThreadPoolSize = threadPoolToDelay .info (ThreadPool .Names .WRITE ).getMax ();
289- final CyclicBarrier delayLatch = new CyclicBarrier (writeThreadPoolSize + 1 );
289+ final var latch = new CountDownLatch (1 );
290+ final var writeThreadPool = threadPoolToDelay .executor (ThreadPool .Names .WRITE );
290291 for (int i = 0 ; i < writeThreadPoolSize ; i ++) {
291- threadPoolToDelay .executor (ThreadPool .Names .WRITE ).execute (() -> {
292- safeAwait (delayLatch );
293- safeAwait (delayLatch );
294- });
292+ writeThreadPool .execute (() -> safeAwait (latch ));
295293 }
296- safeAwait (delayLatch );
297294 // Submit a task that will be delayed
298- threadPoolToDelay . executor ( ThreadPool . Names . WRITE ) .execute (() -> {
295+ writeThreadPool .execute (() -> {
299296 // Doesn't need to do anything
300297 });
301298 final long delayMillis = randomIntBetween (100 , 200 );
302299 safeSleep (delayMillis );
303300 // Unblock the pool
304- safeAwait ( delayLatch );
301+ latch . countDown ( );
305302
306303 refreshClusterInfo (masterName );
307304 mostRecentQueueLatencyMetrics = getMostRecentQueueLatencyMetrics (dataNodes );
You can’t perform that action at this time.
0 commit comments