Migrate query caching settings to the new settings infra.

This commit is contained in:
Adrien Grand 2016-01-27 15:24:55 +01:00
parent 783c1608f3
commit 7923dbc298
5 changed files with 16 additions and 26 deletions

View File

@ -55,6 +55,7 @@ import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.store.IndexStoreConfig; import org.elasticsearch.index.store.IndexStoreConfig;
import org.elasticsearch.indices.analysis.HunspellService; import org.elasticsearch.indices.analysis.HunspellService;
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService; import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
import org.elasticsearch.indices.cache.query.IndicesQueryCache;
import org.elasticsearch.indices.cache.request.IndicesRequestCache; import org.elasticsearch.indices.cache.request.IndicesRequestCache;
import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache; import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache;
import org.elasticsearch.indices.recovery.RecoverySettings; import org.elasticsearch.indices.recovery.RecoverySettings;
@ -138,6 +139,8 @@ public final class ClusterSettings extends AbstractScopedSettings {
FsRepository.REPOSITORIES_LOCATION_SETTING, FsRepository.REPOSITORIES_LOCATION_SETTING,
IndexStoreConfig.INDICES_STORE_THROTTLE_TYPE_SETTING, IndexStoreConfig.INDICES_STORE_THROTTLE_TYPE_SETTING,
IndexStoreConfig.INDICES_STORE_THROTTLE_MAX_BYTES_PER_SEC_SETTING, IndexStoreConfig.INDICES_STORE_THROTTLE_MAX_BYTES_PER_SEC_SETTING,
IndicesQueryCache.INDICES_CACHE_QUERY_SIZE_SETTING,
IndicesQueryCache.INDICES_CACHE_QUERY_COUNT_SETTING,
IndicesTTLService.INDICES_TTL_INTERVAL_SETTING, IndicesTTLService.INDICES_TTL_INTERVAL_SETTING,
MappingUpdatedAction.INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING, MappingUpdatedAction.INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING,
MetaData.SETTING_READ_ONLY_SETTING, MetaData.SETTING_READ_ONLY_SETTING,

View File

@ -22,7 +22,6 @@ package org.elasticsearch.index.cache.query.index;
import org.apache.lucene.search.QueryCachingPolicy; import org.apache.lucene.search.QueryCachingPolicy;
import org.apache.lucene.search.Weight; import org.apache.lucene.search.Weight;
import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.index.AbstractIndexComponent; import org.elasticsearch.index.AbstractIndexComponent;
import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.cache.query.QueryCache; import org.elasticsearch.index.cache.query.QueryCache;
@ -36,7 +35,6 @@ public class IndexQueryCache extends AbstractIndexComponent implements QueryCach
final IndicesQueryCache indicesQueryCache; final IndicesQueryCache indicesQueryCache;
@Inject
public IndexQueryCache(IndexSettings indexSettings, IndicesQueryCache indicesQueryCache) { public IndexQueryCache(IndexSettings indexSettings, IndicesQueryCache indicesQueryCache) {
super(indexSettings); super(indexSettings);
this.indicesQueryCache = indicesQueryCache; this.indicesQueryCache = indicesQueryCache;

View File

@ -31,7 +31,6 @@ import org.elasticsearch.index.cache.query.QueryCache;
*/ */
public class NoneQueryCache extends AbstractIndexComponent implements QueryCache { public class NoneQueryCache extends AbstractIndexComponent implements QueryCache {
@Inject
public NoneQueryCache(IndexSettings indexSettings) { public NoneQueryCache(IndexSettings indexSettings) {
super(indexSettings); super(indexSettings);
logger.debug("Using no query cache"); logger.debug("Using no query cache");

View File

@ -32,9 +32,10 @@ import org.apache.lucene.search.Weight;
import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.lucene.ShardCoreKeyMap; import org.elasticsearch.common.lucene.ShardCoreKeyMap;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Scope;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.MemorySizeValue;
import org.elasticsearch.index.cache.query.QueryCacheStats; import org.elasticsearch.index.cache.query.QueryCacheStats;
import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardId;
@ -48,10 +49,10 @@ import java.util.concurrent.ConcurrentHashMap;
public class IndicesQueryCache extends AbstractComponent implements QueryCache, Closeable { public class IndicesQueryCache extends AbstractComponent implements QueryCache, Closeable {
public static final String INDICES_CACHE_QUERY_SIZE = "indices.queries.cache.size"; public static final Setting<ByteSizeValue> INDICES_CACHE_QUERY_SIZE_SETTING = Setting.byteSizeSetting(
@Deprecated "indices.queries.cache.size", "10%", false, Scope.CLUSTER);
public static final String DEPRECATED_INDICES_CACHE_QUERY_SIZE = "indices.cache.filter.size"; public static final Setting<Integer> INDICES_CACHE_QUERY_COUNT_SETTING = Setting.intSetting(
public static final String INDICES_CACHE_QUERY_COUNT = "indices.queries.cache.count"; "indices.queries.cache.count", 10000, 1, false, Scope.CLUSTER);
private final LRUQueryCache cache; private final LRUQueryCache cache;
private final ShardCoreKeyMap shardKeyMap = new ShardCoreKeyMap(); private final ShardCoreKeyMap shardKeyMap = new ShardCoreKeyMap();
@ -66,21 +67,10 @@ public class IndicesQueryCache extends AbstractComponent implements QueryCache,
@Inject @Inject
public IndicesQueryCache(Settings settings) { public IndicesQueryCache(Settings settings) {
super(settings); super(settings);
String sizeString = settings.get(INDICES_CACHE_QUERY_SIZE); final ByteSizeValue size = INDICES_CACHE_QUERY_SIZE_SETTING.get(settings);
if (sizeString == null) { final int count = INDICES_CACHE_QUERY_COUNT_SETTING.get(settings);
sizeString = settings.get(DEPRECATED_INDICES_CACHE_QUERY_SIZE); logger.debug("using [node] query cache with size [{}] max filter count [{}]",
if (sizeString != null) { size, count);
deprecationLogger.deprecated("The [" + DEPRECATED_INDICES_CACHE_QUERY_SIZE
+ "] settings is now deprecated, use [" + INDICES_CACHE_QUERY_SIZE + "] instead");
}
}
if (sizeString == null) {
sizeString = "10%";
}
final ByteSizeValue size = MemorySizeValue.parseBytesSizeValueOrHeapRatio(sizeString, INDICES_CACHE_QUERY_SIZE);
final int count = settings.getAsInt(INDICES_CACHE_QUERY_COUNT, 1000);
logger.debug("using [node] query cache with size [{}], actual_size [{}], max filter count [{}]",
sizeString, size, count);
cache = new LRUQueryCache(count, size.bytes()) { cache = new LRUQueryCache(count, size.bytes()) {
private Stats getStats(Object coreKey) { private Stats getStats(Object coreKey) {

View File

@ -92,7 +92,7 @@ public class IndicesQueryCacheTests extends ESTestCase {
s.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE); s.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE);
Settings settings = Settings.builder() Settings settings = Settings.builder()
.put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT, 10) .put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT_SETTING.getKey(), 10)
.build(); .build();
IndicesQueryCache cache = new IndicesQueryCache(settings); IndicesQueryCache cache = new IndicesQueryCache(settings);
s.setQueryCache(cache); s.setQueryCache(cache);
@ -172,7 +172,7 @@ public class IndicesQueryCacheTests extends ESTestCase {
s2.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE); s2.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE);
Settings settings = Settings.builder() Settings settings = Settings.builder()
.put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT, 10) .put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT_SETTING.getKey(), 10)
.build(); .build();
IndicesQueryCache cache = new IndicesQueryCache(settings); IndicesQueryCache cache = new IndicesQueryCache(settings);
s1.setQueryCache(cache); s1.setQueryCache(cache);
@ -297,7 +297,7 @@ public class IndicesQueryCacheTests extends ESTestCase {
s2.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE); s2.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE);
Settings settings = Settings.builder() Settings settings = Settings.builder()
.put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT, 10) .put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT_SETTING.getKey(), 10)
.build(); .build();
IndicesQueryCache cache = new IndicesQueryCache(settings); IndicesQueryCache cache = new IndicesQueryCache(settings);
s1.setQueryCache(cache); s1.setQueryCache(cache);