Migrate query caching settings to the new settings infra.
This commit is contained in:
parent
783c1608f3
commit
7923dbc298
|
@ -55,6 +55,7 @@ import org.elasticsearch.index.IndexSettings;
|
|||
import org.elasticsearch.index.store.IndexStoreConfig;
|
||||
import org.elasticsearch.indices.analysis.HunspellService;
|
||||
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
|
||||
import org.elasticsearch.indices.cache.query.IndicesQueryCache;
|
||||
import org.elasticsearch.indices.cache.request.IndicesRequestCache;
|
||||
import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache;
|
||||
import org.elasticsearch.indices.recovery.RecoverySettings;
|
||||
|
@ -138,6 +139,8 @@ public final class ClusterSettings extends AbstractScopedSettings {
|
|||
FsRepository.REPOSITORIES_LOCATION_SETTING,
|
||||
IndexStoreConfig.INDICES_STORE_THROTTLE_TYPE_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,
|
||||
MappingUpdatedAction.INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING,
|
||||
MetaData.SETTING_READ_ONLY_SETTING,
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.index.cache.query.index;
|
|||
import org.apache.lucene.search.QueryCachingPolicy;
|
||||
import org.apache.lucene.search.Weight;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.cache.query.QueryCache;
|
||||
|
@ -36,7 +35,6 @@ public class IndexQueryCache extends AbstractIndexComponent implements QueryCach
|
|||
|
||||
final IndicesQueryCache indicesQueryCache;
|
||||
|
||||
@Inject
|
||||
public IndexQueryCache(IndexSettings indexSettings, IndicesQueryCache indicesQueryCache) {
|
||||
super(indexSettings);
|
||||
this.indicesQueryCache = indicesQueryCache;
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.elasticsearch.index.cache.query.QueryCache;
|
|||
*/
|
||||
public class NoneQueryCache extends AbstractIndexComponent implements QueryCache {
|
||||
|
||||
@Inject
|
||||
public NoneQueryCache(IndexSettings indexSettings) {
|
||||
super(indexSettings);
|
||||
logger.debug("Using no query cache");
|
||||
|
|
|
@ -32,9 +32,10 @@ import org.apache.lucene.search.Weight;
|
|||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
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.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.unit.MemorySizeValue;
|
||||
import org.elasticsearch.index.cache.query.QueryCacheStats;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
|
||||
|
@ -48,10 +49,10 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
public class IndicesQueryCache extends AbstractComponent implements QueryCache, Closeable {
|
||||
|
||||
public static final String INDICES_CACHE_QUERY_SIZE = "indices.queries.cache.size";
|
||||
@Deprecated
|
||||
public static final String DEPRECATED_INDICES_CACHE_QUERY_SIZE = "indices.cache.filter.size";
|
||||
public static final String INDICES_CACHE_QUERY_COUNT = "indices.queries.cache.count";
|
||||
public static final Setting<ByteSizeValue> INDICES_CACHE_QUERY_SIZE_SETTING = Setting.byteSizeSetting(
|
||||
"indices.queries.cache.size", "10%", false, Scope.CLUSTER);
|
||||
public static final Setting<Integer> INDICES_CACHE_QUERY_COUNT_SETTING = Setting.intSetting(
|
||||
"indices.queries.cache.count", 10000, 1, false, Scope.CLUSTER);
|
||||
|
||||
private final LRUQueryCache cache;
|
||||
private final ShardCoreKeyMap shardKeyMap = new ShardCoreKeyMap();
|
||||
|
@ -66,21 +67,10 @@ public class IndicesQueryCache extends AbstractComponent implements QueryCache,
|
|||
@Inject
|
||||
public IndicesQueryCache(Settings settings) {
|
||||
super(settings);
|
||||
String sizeString = settings.get(INDICES_CACHE_QUERY_SIZE);
|
||||
if (sizeString == null) {
|
||||
sizeString = settings.get(DEPRECATED_INDICES_CACHE_QUERY_SIZE);
|
||||
if (sizeString != null) {
|
||||
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);
|
||||
final ByteSizeValue size = INDICES_CACHE_QUERY_SIZE_SETTING.get(settings);
|
||||
final int count = INDICES_CACHE_QUERY_COUNT_SETTING.get(settings);
|
||||
logger.debug("using [node] query cache with size [{}] max filter count [{}]",
|
||||
size, count);
|
||||
cache = new LRUQueryCache(count, size.bytes()) {
|
||||
|
||||
private Stats getStats(Object coreKey) {
|
||||
|
|
|
@ -92,7 +92,7 @@ public class IndicesQueryCacheTests extends ESTestCase {
|
|||
s.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE);
|
||||
|
||||
Settings settings = Settings.builder()
|
||||
.put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT, 10)
|
||||
.put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT_SETTING.getKey(), 10)
|
||||
.build();
|
||||
IndicesQueryCache cache = new IndicesQueryCache(settings);
|
||||
s.setQueryCache(cache);
|
||||
|
@ -172,7 +172,7 @@ public class IndicesQueryCacheTests extends ESTestCase {
|
|||
s2.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE);
|
||||
|
||||
Settings settings = Settings.builder()
|
||||
.put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT, 10)
|
||||
.put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT_SETTING.getKey(), 10)
|
||||
.build();
|
||||
IndicesQueryCache cache = new IndicesQueryCache(settings);
|
||||
s1.setQueryCache(cache);
|
||||
|
@ -297,7 +297,7 @@ public class IndicesQueryCacheTests extends ESTestCase {
|
|||
s2.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE);
|
||||
|
||||
Settings settings = Settings.builder()
|
||||
.put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT, 10)
|
||||
.put(IndicesQueryCache.INDICES_CACHE_QUERY_COUNT_SETTING.getKey(), 10)
|
||||
.build();
|
||||
IndicesQueryCache cache = new IndicesQueryCache(settings);
|
||||
s1.setQueryCache(cache);
|
||||
|
|
Loading…
Reference in New Issue