Reduce executors count
This commit is contained in:
parent
33d8f83933
commit
afa159de67
@ -36,12 +36,12 @@ import reactor.core.scheduler.Schedulers;
|
|||||||
public class CachedIndexSearcherManager implements IndexSearcherManager {
|
public class CachedIndexSearcherManager implements IndexSearcherManager {
|
||||||
|
|
||||||
private static final Logger LOG = LogManager.getLogger(CachedIndexSearcherManager.class);
|
private static final Logger LOG = LogManager.getLogger(CachedIndexSearcherManager.class);
|
||||||
private final ExecutorService searchExecutor = Executors.newFixedThreadPool(
|
private static final ExecutorService SEARCH_EXECUTOR = Executors.newFixedThreadPool(
|
||||||
Runtime.getRuntime().availableProcessors(),
|
Runtime.getRuntime().availableProcessors(),
|
||||||
new ShortNamedThreadFactory("lucene-search")
|
new ShortNamedThreadFactory("lucene-search")
|
||||||
.setDaemon(true).withGroup(new ThreadGroup("lucene-search"))
|
.setDaemon(true).withGroup(new ThreadGroup("lucene-search"))
|
||||||
);
|
);
|
||||||
private final SearcherFactory SEARCHER_FACTORY = new ExecutorSearcherFactory(searchExecutor);
|
private static final SearcherFactory SEARCHER_FACTORY = new ExecutorSearcherFactory(SEARCH_EXECUTOR);
|
||||||
|
|
||||||
private final SnapshotsManager snapshotsManager;
|
private final SnapshotsManager snapshotsManager;
|
||||||
private final Scheduler luceneHeavyTasksScheduler;
|
private final Scheduler luceneHeavyTasksScheduler;
|
||||||
@ -128,11 +128,11 @@ public class CachedIndexSearcherManager implements IndexSearcherManager {
|
|||||||
LOG.debug("Stopping searcher executor...");
|
LOG.debug("Stopping searcher executor...");
|
||||||
cachedSnapshotSearchers.invalidateAll();
|
cachedSnapshotSearchers.invalidateAll();
|
||||||
cachedSnapshotSearchers.cleanUp();
|
cachedSnapshotSearchers.cleanUp();
|
||||||
searchExecutor.shutdown();
|
SEARCH_EXECUTOR.shutdown();
|
||||||
try {
|
try {
|
||||||
//noinspection BlockingMethodInNonBlockingContext
|
//noinspection BlockingMethodInNonBlockingContext
|
||||||
if (!searchExecutor.awaitTermination(15, TimeUnit.SECONDS)) {
|
if (!SEARCH_EXECUTOR.awaitTermination(15, TimeUnit.SECONDS)) {
|
||||||
searchExecutor.shutdownNow();
|
SEARCH_EXECUTOR.shutdownNow();
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
LOG.error("Failed to stop executor", e);
|
LOG.error("Failed to stop executor", e);
|
||||||
@ -155,7 +155,7 @@ public class CachedIndexSearcherManager implements IndexSearcherManager {
|
|||||||
indexSearcher = searcherManager.acquire();
|
indexSearcher = searcherManager.acquire();
|
||||||
fromSnapshot = false;
|
fromSnapshot = false;
|
||||||
} else {
|
} else {
|
||||||
indexSearcher = snapshotsManager.resolveSnapshot(snapshot).getIndexSearcher(searchExecutor);
|
indexSearcher = snapshotsManager.resolveSnapshot(snapshot).getIndexSearcher(SEARCH_EXECUTOR);
|
||||||
fromSnapshot = true;
|
fromSnapshot = true;
|
||||||
}
|
}
|
||||||
indexSearcher.setSimilarity(similarity);
|
indexSearcher.setSimilarity(similarity);
|
||||||
|
Loading…
Reference in New Issue
Block a user