From b83378f4ce5b2738d3725e743daea16c1e5682a8 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Fri, 9 Mar 2012 20:47:59 +0200 Subject: [PATCH] Add `cache` thread pool to handle cache loading of async caches (bloom filter), closes #1777. --- .../index/cache/bloom/simple/SimpleBloomCache.java | 4 ++-- src/main/java/org/elasticsearch/threadpool/ThreadPool.java | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/cache/bloom/simple/SimpleBloomCache.java b/src/main/java/org/elasticsearch/index/cache/bloom/simple/SimpleBloomCache.java index fb1f640f62d..90e5f338d98 100644 --- a/src/main/java/org/elasticsearch/index/cache/bloom/simple/SimpleBloomCache.java +++ b/src/main/java/org/elasticsearch/index/cache/bloom/simple/SimpleBloomCache.java @@ -144,7 +144,7 @@ public class SimpleBloomCache extends AbstractIndexComponent implements BloomCac filter.loading.set(true); BloomFilterLoader loader = new BloomFilterLoader(reader, fieldName); if (asyncLoad) { - threadPool.generic().execute(loader); + threadPool.executor(ThreadPool.Names.CACHE).execute(loader); } else { loader.run(); filter = fieldCache.get(fieldName); @@ -159,7 +159,7 @@ public class SimpleBloomCache extends AbstractIndexComponent implements BloomCac // do the async loading BloomFilterLoader loader = new BloomFilterLoader(reader, fieldName); if (asyncLoad) { - threadPool.generic().execute(loader); + threadPool.executor(ThreadPool.Names.CACHE).execute(loader); } else { loader.run(); filter = fieldCache.get(fieldName); diff --git a/src/main/java/org/elasticsearch/threadpool/ThreadPool.java b/src/main/java/org/elasticsearch/threadpool/ThreadPool.java index 3571eb3cdaa..e599ead7954 100644 --- a/src/main/java/org/elasticsearch/threadpool/ThreadPool.java +++ b/src/main/java/org/elasticsearch/threadpool/ThreadPool.java @@ -66,6 +66,7 @@ public class ThreadPool extends AbstractComponent { public static final String MANAGEMENT = "management"; public static final String FLUSH = "flush"; public static final String MERGE = "merge"; + public static final String CACHE = "cache"; public static final String REFRESH = "refresh"; public static final String SNAPSHOT = "snapshot"; } @@ -96,6 +97,7 @@ public class ThreadPool extends AbstractComponent { executors.put(Names.FLUSH, build(Names.FLUSH, "scaling", groupSettings.get(Names.FLUSH), settingsBuilder().put("keep_alive", "5m").put("size", 10).build())); executors.put(Names.MERGE, build(Names.MERGE, "scaling", groupSettings.get(Names.MERGE), settingsBuilder().put("keep_alive", "5m").put("size", 20).build())); executors.put(Names.REFRESH, build(Names.REFRESH, "cached", groupSettings.get(Names.REFRESH), settingsBuilder().put("keep_alive", "1m").build())); + executors.put(Names.CACHE, build(Names.CACHE, "scaling", groupSettings.get(Names.CACHE), settingsBuilder().put("keep_alive", "5m").put("size", 4).build())); executors.put(Names.SNAPSHOT, build(Names.SNAPSHOT, "scaling", groupSettings.get(Names.SNAPSHOT), settingsBuilder().put("keep_alive", "5m").put("size", 5).build())); executors.put(Names.SAME, new ExecutorHolder(MoreExecutors.sameThreadExecutor(), new Info(Names.SAME, "same"))); this.executors = ImmutableMap.copyOf(executors);