Skip to content

Commit

Permalink
Add cache thread pool to handle cache loading of async caches (bloo…
Browse files Browse the repository at this point in the history
…m filter), closes #1777.
  • Loading branch information
kimchy committed Mar 9, 2012
1 parent c08b968 commit b83378f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -144,7 +144,7 @@ public BloomFilter filter(IndexReader reader, String fieldName, boolean asyncLoa
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);
Expand All @@ -159,7 +159,7 @@ public BloomFilter filter(IndexReader reader, String fieldName, boolean asyncLoa
// 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);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/elasticsearch/threadpool/ThreadPool.java
Expand Up @@ -66,6 +66,7 @@ public static class Names {
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";
}
Expand Down Expand Up @@ -96,6 +97,7 @@ public ThreadPool(Settings settings) {
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);
Expand Down

0 comments on commit b83378f

Please sign in to comment.