From 76733944d3796480c3d8afd87a3943afb10f93ee Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 22 Jan 2016 06:11:47 -0500 Subject: [PATCH] Script auto reload enabled setting This commit converts the script auto reload enabled setting "script.auto_reload_enabled" to the new settings infrastructure. --- .../src/main/java/org/elasticsearch/script/ScriptService.java | 4 ++-- .../org/elasticsearch/index/query/AbstractQueryTestCase.java | 4 ++-- .../test/java/org/elasticsearch/script/FileScriptTests.java | 2 +- .../java/org/elasticsearch/script/ScriptContextTests.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/script/ScriptService.java b/core/src/main/java/org/elasticsearch/script/ScriptService.java index 58014c180fc..87b1911a1f4 100644 --- a/core/src/main/java/org/elasticsearch/script/ScriptService.java +++ b/core/src/main/java/org/elasticsearch/script/ScriptService.java @@ -89,7 +89,7 @@ public class ScriptService extends AbstractComponent implements Closeable { public static final Setting SCRIPT_CACHE_EXPIRE_SETTING = Setting.positiveTimeSetting("script.cache.expire", TimeValue.timeValueMillis(0), false, Setting.Scope.CLUSTER); public static final String SCRIPT_INDEX = ".scripts"; public static final String DEFAULT_LANG = "groovy"; - public static final String SCRIPT_AUTO_RELOAD_ENABLED_SETTING = "script.auto_reload_enabled"; + public static final Setting SCRIPT_AUTO_RELOAD_ENABLED_SETTING = Setting.boolSetting("script.auto_reload_enabled", true, false, Setting.Scope.CLUSTER); private final String defaultLang; @@ -188,7 +188,7 @@ public class ScriptService extends AbstractComponent implements Closeable { FileWatcher fileWatcher = new FileWatcher(scriptsDirectory); fileWatcher.addListener(new ScriptChangesListener()); - if (settings.getAsBoolean(SCRIPT_AUTO_RELOAD_ENABLED_SETTING, true)) { + if (SCRIPT_AUTO_RELOAD_ENABLED_SETTING.get(settings)) { // automatic reload is enabled - register scripts resourceWatcherService.add(fileWatcher); } else { diff --git a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java index 8c6bfff3fac..456a630ea03 100644 --- a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java @@ -187,7 +187,7 @@ public abstract class AbstractQueryTestCase> Settings settings = Settings.settingsBuilder() .put("name", AbstractQueryTestCase.class.toString()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) - .put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING, false) + .put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING.getKey(), false) .build(); Settings indexSettings = Settings.settingsBuilder() .put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); @@ -220,7 +220,7 @@ public abstract class AbstractQueryTestCase> Settings settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) // no file watching, so we don't need a ResourceWatcherService - .put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING, false) + .put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING.getKey(), false) .build(); MockScriptEngine mockScriptEngine = new MockScriptEngine(); Multibinder multibinder = Multibinder.newSetBinder(binder(), ScriptEngineService.class); diff --git a/core/src/test/java/org/elasticsearch/script/FileScriptTests.java b/core/src/test/java/org/elasticsearch/script/FileScriptTests.java index d639411db8c..0fdb42b5bd6 100644 --- a/core/src/test/java/org/elasticsearch/script/FileScriptTests.java +++ b/core/src/test/java/org/elasticsearch/script/FileScriptTests.java @@ -41,7 +41,7 @@ public class FileScriptTests extends ESTestCase { settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), homeDir) // no file watching, so we don't need a ResourceWatcherService - .put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING, false) + .put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING.getKey(), false) .put(settings) .build(); Set engines = new HashSet<>(Collections.singletonList(new MockScriptEngine())); diff --git a/core/src/test/java/org/elasticsearch/script/ScriptContextTests.java b/core/src/test/java/org/elasticsearch/script/ScriptContextTests.java index 36865f254bd..4505b2b0d9a 100644 --- a/core/src/test/java/org/elasticsearch/script/ScriptContextTests.java +++ b/core/src/test/java/org/elasticsearch/script/ScriptContextTests.java @@ -40,7 +40,7 @@ public class ScriptContextTests extends ESTestCase { Settings settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) // no file watching, so we don't need a ResourceWatcherService - .put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING, false) + .put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING.getKey(), false) .put("script." + PLUGIN_NAME + "_custom_globally_disabled_op", false) .put("script.engine." + MockScriptEngine.NAME + ".inline." + PLUGIN_NAME + "_custom_exp_disabled_op", false) .build();