Don't pull the engine for access to the QueryCachingPolicy

This commit is contained in:
Simon Willnauer 2015-06-29 20:45:59 +02:00
parent 0ae638fbb2
commit fcbd0dddcd
2 changed files with 11 additions and 6 deletions

View File

@ -254,7 +254,6 @@ public class IndexShard extends AbstractIndexShardComponent {
cachingPolicy = new UsageTrackingQueryCachingPolicy();
}
this.engineConfig = newEngineConfig(translogConfig, cachingPolicy);
this.indexShardOperationCounter = new IndexShardOperationCounter(logger, shardId);
}
@ -324,6 +323,10 @@ public class IndexShard extends AbstractIndexShardComponent {
return this.shardRouting;
}
public QueryCachingPolicy getQueryCachingPolicy() {
return this.engineConfig.getQueryCachingPolicy();
}
/**
* Updates the shards routing entry. This mutate the shards internal state depending
* on the changes that get introduced by the new routing value. This method will persist shard level metadata

View File

@ -372,9 +372,10 @@ public class SearchService extends AbstractLifecycleComponent<SearchService> {
public QuerySearchResult executeQueryPhase(QuerySearchRequest request) {
final SearchContext context = findContext(request.id());
contextProcessing(context);
IndexShard indexShard = context.indexShard();
try {
final IndexCache indexCache = context.indexShard().indexService().cache();
final QueryCachingPolicy cachingPolicy = context.indexShard().engine().config().getQueryCachingPolicy();
final IndexCache indexCache = indexShard.indexService().cache();
final QueryCachingPolicy cachingPolicy = indexShard.getQueryCachingPolicy();
context.searcher().dfSource(new CachedDfSource(context.searcher().getIndexReader(), request.dfs(), context.similarityService().similarity(),
indexCache.query(), cachingPolicy));
} catch (Throwable e) {
@ -382,7 +383,7 @@ public class SearchService extends AbstractLifecycleComponent<SearchService> {
cleanContext(context);
throw new QueryPhaseExecutionException(context, "Failed to set aggregated df", e);
}
ShardSearchStats shardSearchStats = context.indexShard().searchService();
ShardSearchStats shardSearchStats = indexShard.searchService();
try {
shardSearchStats.onPreQueryPhase(context);
long time = System.nanoTime();
@ -448,8 +449,9 @@ public class SearchService extends AbstractLifecycleComponent<SearchService> {
final SearchContext context = findContext(request.id());
contextProcessing(context);
try {
final IndexCache indexCache = context.indexShard().indexService().cache();
final QueryCachingPolicy cachingPolicy = context.indexShard().engine().config().getQueryCachingPolicy();
final IndexShard indexShard = context.indexShard();
final IndexCache indexCache = indexShard.indexService().cache();
final QueryCachingPolicy cachingPolicy = indexShard.getQueryCachingPolicy();
context.searcher().dfSource(new CachedDfSource(context.searcher().getIndexReader(), request.dfs(), context.similarityService().similarity(),
indexCache.query(), cachingPolicy));
} catch (Throwable e) {