simplify by directly getting the search TP info

This commit is contained in:
Shay Banon 2014-01-06 21:45:21 +01:00
parent 01c5be1da3
commit 6d1fe75799
1 changed files with 8 additions and 14 deletions

View File

@ -19,7 +19,6 @@
package org.elasticsearch.cache.recycler;
import org.elasticsearch.ElasticSearchIllegalStateException;
import org.elasticsearch.cache.recycler.CacheRecycler.Type;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject;
@ -30,7 +29,6 @@ import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.threadpool.ThreadPoolInfo;
import java.util.Arrays;
@ -57,10 +55,9 @@ public class PageCacheRecycler extends AbstractComponent {
}
private static int maximumSearchThreadPoolSize(ThreadPool threadPool, Settings settings) {
final ThreadPoolInfo infos = threadPool.info();
for (ThreadPool.Info info : infos) {
if (info.getName().equals(ThreadPool.Names.SEARCH)) {
final int maxSize = info.getMax();
ThreadPool.Info searchThreadPool = threadPool.info(ThreadPool.Names.SEARCH);
assert searchThreadPool != null;
final int maxSize = searchThreadPool.getMax();
if (maxSize <= 0) {
// happens with cached thread pools, let's assume there are at most 3x ${number of processors} threads
return 3 * EsExecutors.boundedNumberOfProcessors(settings);
@ -68,9 +65,6 @@ public class PageCacheRecycler extends AbstractComponent {
return maxSize;
}
}
}
throw new ElasticSearchIllegalStateException("Couldn't find the [" + ThreadPool.Names.SEARCH + "] thread pool");
}
// return the maximum number of pages that may be cached depending on
// - limit: the total amount of memory available