diff --git a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java index 25f317a2894..db0b3651d79 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -3179,7 +3179,6 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl return new RefreshListeners( indexSettings::getMaxRefreshListeners, () -> refresh("too_many_listeners"), - threadPool.executor(ThreadPool.Names.LISTENER), logger, threadPool.getThreadContext(), externalRefreshMetric); } diff --git a/server/src/main/java/org/elasticsearch/index/shard/RefreshListeners.java b/server/src/main/java/org/elasticsearch/index/shard/RefreshListeners.java index d343f8630a6..71ec4c3dabd 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/RefreshListeners.java +++ b/server/src/main/java/org/elasticsearch/index/shard/RefreshListeners.java @@ -32,7 +32,6 @@ import java.io.Closeable; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Executor; import java.util.function.Consumer; import java.util.function.IntSupplier; import java.util.function.Supplier; @@ -48,7 +47,6 @@ import static java.util.Objects.requireNonNull; public final class RefreshListeners implements ReferenceManager.RefreshListener, Closeable { private final IntSupplier getMaxRefreshListeners; private final Runnable forceRefresh; - private final Executor listenerExecutor; private final Logger logger; private final ThreadContext threadContext; private final MeanMetric refreshMetric; @@ -82,11 +80,15 @@ public final class RefreshListeners implements ReferenceManager.RefreshListener, */ private volatile Translog.Location lastRefreshedLocation; - public RefreshListeners(IntSupplier getMaxRefreshListeners, Runnable forceRefresh, Executor listenerExecutor, Logger logger, - ThreadContext threadContext, MeanMetric refreshMetric) { + public RefreshListeners( + final IntSupplier getMaxRefreshListeners, + final Runnable forceRefresh, + final Logger logger, + final ThreadContext threadContext, + final MeanMetric refreshMetric + ) { this.getMaxRefreshListeners = getMaxRefreshListeners; this.forceRefresh = forceRefresh; - this.listenerExecutor = listenerExecutor; this.logger = logger; this.threadContext = threadContext; this.refreshMetric = refreshMetric; @@ -282,24 +284,22 @@ public final class RefreshListeners implements ReferenceManager.RefreshListener, } } } - // Lastly, fire the listeners that are ready on the listener thread pool + // Lastly, fire the listeners that are ready fireListeners(listenersToFire); } /** * Fire some listeners. Does nothing if the list of listeners is null. */ - private void fireListeners(List>> listenersToFire) { + private void fireListeners(final List>> listenersToFire) { if (listenersToFire != null) { - listenerExecutor.execute(() -> { - for (Tuple> listener : listenersToFire) { - try { - listener.v2().accept(false); - } catch (Exception e) { - logger.warn("Error firing refresh listener", e); - } + for (final Tuple> listener : listenersToFire) { + try { + listener.v2().accept(false); + } catch (final Exception e) { + logger.warn("error firing refresh listener", e); } - }); + } } } } diff --git a/server/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java b/server/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java index e264d33ffed..97b04340ce3 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java @@ -102,8 +102,6 @@ public class RefreshListenersTests extends ESTestCase { listeners = new RefreshListeners( () -> maxListeners, () -> engine.refresh("too-many-listeners"), - // Immediately run listeners rather than adding them to the listener thread pool like IndexShard does to simplify the test. - Runnable::run, logger, threadPool.getThreadContext(), refreshMetric);