mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-22 12:56:53 +00:00
Convert to the new settings infra
This commit is contained in:
parent
cbd0a8b067
commit
1fb2f22f32
@ -44,6 +44,7 @@ import org.elasticsearch.index.store.IndexStoreConfig;
|
||||
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
|
||||
import org.elasticsearch.indices.recovery.RecoverySettings;
|
||||
import org.elasticsearch.indices.ttl.IndicesTTLService;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
@ -158,5 +159,6 @@ public final class ClusterSettings extends AbstractScopedSettings {
|
||||
Transport.TRANSPORT_TCP_COMPRESS,
|
||||
IndexSettings.QUERY_STRING_ANALYZE_WILDCARD,
|
||||
IndexSettings.QUERY_STRING_ALLOW_LEADING_WILDCARD,
|
||||
PrimaryShardAllocator.NODE_INITIAL_SHARDS_SETTING)));
|
||||
PrimaryShardAllocator.NODE_INITIAL_SHARDS_SETTING,
|
||||
ScriptService.SCRIPT_CACHE_SIZE_SETTING)));
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.Streams;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||
@ -84,8 +85,7 @@ public class ScriptService extends AbstractComponent implements Closeable {
|
||||
static final String DISABLE_DYNAMIC_SCRIPTING_SETTING = "script.disable_dynamic";
|
||||
|
||||
public static final String DEFAULT_SCRIPTING_LANGUAGE_SETTING = "script.default_lang";
|
||||
public static final String SCRIPT_CACHE_SIZE_SETTING = "script.cache.max_size";
|
||||
public static final int SCRIPT_CACHE_SIZE_DEFAULT = 100;
|
||||
public static final Setting<Integer> SCRIPT_CACHE_SIZE_SETTING = Setting.intSetting("script.cache.max_size", 100, 0, false, Setting.Scope.CLUSTER);
|
||||
public static final String SCRIPT_CACHE_EXPIRE_SETTING = "script.cache.expire";
|
||||
public static final String SCRIPT_INDEX = ".scripts";
|
||||
public static final String DEFAULT_LANG = "groovy";
|
||||
@ -148,7 +148,7 @@ public class ScriptService extends AbstractComponent implements Closeable {
|
||||
|
||||
this.scriptEngines = scriptEngines;
|
||||
this.scriptContextRegistry = scriptContextRegistry;
|
||||
int cacheMaxSize = settings.getAsInt(SCRIPT_CACHE_SIZE_SETTING, SCRIPT_CACHE_SIZE_DEFAULT);
|
||||
int cacheMaxSize = SCRIPT_CACHE_SIZE_SETTING.get(settings);
|
||||
TimeValue cacheExpire = settings.getAsTime(SCRIPT_CACHE_EXPIRE_SETTING, null);
|
||||
logger.debug("using script cache with max_size [{}], expire [{}]", cacheMaxSize, cacheExpire);
|
||||
|
||||
|
@ -378,7 +378,7 @@ public class ScriptServiceTests extends ESTestCase {
|
||||
public void testCompilationStatsOnCacheHit() throws IOException {
|
||||
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
|
||||
Settings.Builder builder = Settings.builder();
|
||||
builder.put(ScriptService.SCRIPT_CACHE_SIZE_SETTING, 1);
|
||||
builder.put(ScriptService.SCRIPT_CACHE_SIZE_SETTING.getKey(), 1);
|
||||
buildScriptService(builder.build());
|
||||
scriptService.executable(new Script("1+1", ScriptType.INLINE, "test", null), randomFrom(scriptContexts), contextAndHeaders, Collections.emptyMap());
|
||||
scriptService.executable(new Script("1+1", ScriptType.INLINE, "test", null), randomFrom(scriptContexts), contextAndHeaders, Collections.emptyMap());
|
||||
@ -403,7 +403,7 @@ public class ScriptServiceTests extends ESTestCase {
|
||||
public void testCacheEvictionCountedInCacheEvictionsStats() throws IOException {
|
||||
ContextAndHeaderHolder contextAndHeaders = new ContextAndHeaderHolder();
|
||||
Settings.Builder builder = Settings.builder();
|
||||
builder.put(ScriptService.SCRIPT_CACHE_SIZE_SETTING, 1);
|
||||
builder.put(ScriptService.SCRIPT_CACHE_SIZE_SETTING.getKey(), 1);
|
||||
buildScriptService(builder.build());
|
||||
scriptService.executable(new Script("1+1", ScriptType.INLINE, "test", null), randomFrom(scriptContexts), contextAndHeaders, Collections.emptyMap());
|
||||
scriptService.executable(new Script("2+2", ScriptType.INLINE, "test", null), randomFrom(scriptContexts), contextAndHeaders, Collections.emptyMap());
|
||||
|
@ -457,7 +457,7 @@ public final class InternalTestCluster extends TestCluster {
|
||||
}
|
||||
|
||||
if (random.nextBoolean()) {
|
||||
builder.put(ScriptService.SCRIPT_CACHE_SIZE_SETTING, RandomInts.randomIntBetween(random, -100, 2000));
|
||||
builder.put(ScriptService.SCRIPT_CACHE_SIZE_SETTING.getKey(), RandomInts.randomIntBetween(random, -100, 2000));
|
||||
}
|
||||
if (random.nextBoolean()) {
|
||||
builder.put(ScriptService.SCRIPT_CACHE_EXPIRE_SETTING, TimeValue.timeValueMillis(RandomInts.randomIntBetween(random, 750, 10000000)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user