[ThreadPool] Use DirectExecutor instead of deprecated API

Guava deprecated MoreExecutors#sameThreadExecutor in favour of
a more efficient implemenation. We should move over to the new impl.
This commit is contained in:
Simon Willnauer 2014-09-08 11:26:26 +02:00
parent 4638d23484
commit cb839b56b2
2 changed files with 3 additions and 2 deletions

View File

@ -286,7 +286,7 @@ public class ThreadPool extends AbstractComponent {
} else {
logger.debug("creating thread_pool [{}], type [{}]", name, type);
}
return new ExecutorHolder(MoreExecutors.sameThreadExecutor(), new Info(name, type));
return new ExecutorHolder(MoreExecutors.directExecutor(), new Info(name, type));
} else if ("cached".equals(type)) {
TimeValue defaultKeepAlive = defaultSettings.getAsTime("keep_alive", timeValueMinutes(5));
if (previousExecutorHolder != null) {

View File

@ -20,6 +20,7 @@
package org.elasticsearch.threadpool;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor;
import org.elasticsearch.test.ElasticsearchTestCase;
@ -61,7 +62,7 @@ public class UpdateThreadPoolSettingsTests extends ElasticsearchTestCase {
// Replace with different type
threadPool.updateSettings(settingsBuilder().put("threadpool.search.type", "same").build());
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("same"));
assertThat(threadPool.executor(Names.SEARCH), instanceOf(ListeningExecutorService.class));
assertThat(threadPool.executor(Names.SEARCH), instanceOf(MoreExecutors.directExecutor().getClass()));
// Replace with different type again
threadPool.updateSettings(settingsBuilder()