Scripting: Watcher defaults to unlimited compile rate (#62655) (#62671)

Backport of #62655
This commit is contained in:
Stuart Tettemer 2020-09-24 10:22:50 -05:00 committed by GitHub
parent 8ca33feffd
commit 8d69334c2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View File

@ -51,6 +51,7 @@ import org.elasticsearch.plugins.SystemIndexPlugin;
import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestHandler; import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.script.ScriptCache;
import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.ScriptContext;
import org.elasticsearch.script.ScriptService; import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.TemplateScript; import org.elasticsearch.script.TemplateScript;
@ -225,7 +226,8 @@ public class Watcher extends Plugin implements SystemIndexPlugin, ScriptPlugin,
new ByteSizeValue(1, ByteSizeUnit.MB), new ByteSizeValue(10, ByteSizeUnit.MB), NodeScope); new ByteSizeValue(1, ByteSizeUnit.MB), new ByteSizeValue(10, ByteSizeUnit.MB), NodeScope);
public static final ScriptContext<TemplateScript.Factory> SCRIPT_TEMPLATE_CONTEXT public static final ScriptContext<TemplateScript.Factory> SCRIPT_TEMPLATE_CONTEXT
= new ScriptContext<>("xpack_template", TemplateScript.Factory.class); = new ScriptContext<>("xpack_template", TemplateScript.Factory.class,
200, TimeValue.timeValueMillis(0), ScriptCache.UNLIMITED_COMPILATION_RATE.asTuple());
private static final Logger logger = LogManager.getLogger(Watcher.class); private static final Logger logger = LogManager.getLogger(Watcher.class);
private WatcherIndexingListener listener; private WatcherIndexingListener listener;

View File

@ -5,6 +5,8 @@
*/ */
package org.elasticsearch.xpack.watcher.condition; package org.elasticsearch.xpack.watcher.condition;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.script.ScriptCache;
import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.ScriptContext;
import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext; import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext;
import org.elasticsearch.xpack.watcher.support.Variables; import org.elasticsearch.xpack.watcher.support.Variables;
@ -41,5 +43,6 @@ public abstract class WatcherConditionScript {
WatcherConditionScript newInstance(Map<String, Object> params, WatchExecutionContext watcherContext); WatcherConditionScript newInstance(Map<String, Object> params, WatchExecutionContext watcherContext);
} }
public static ScriptContext<Factory> CONTEXT = new ScriptContext<>("watcher_condition", Factory.class); public static ScriptContext<Factory> CONTEXT = new ScriptContext<>("watcher_condition", Factory.class,
200, TimeValue.timeValueMillis(0), ScriptCache.UNLIMITED_COMPILATION_RATE.asTuple());
} }

View File

@ -5,6 +5,8 @@
*/ */
package org.elasticsearch.xpack.watcher.transform.script; package org.elasticsearch.xpack.watcher.transform.script;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.script.ScriptCache;
import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.ScriptContext;
import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext; import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext;
import org.elasticsearch.xpack.core.watcher.watch.Payload; import org.elasticsearch.xpack.core.watcher.watch.Payload;
@ -42,5 +44,6 @@ public abstract class WatcherTransformScript {
WatcherTransformScript newInstance(Map<String, Object> params, WatchExecutionContext watcherContext, Payload payload); WatcherTransformScript newInstance(Map<String, Object> params, WatchExecutionContext watcherContext, Payload payload);
} }
public static ScriptContext<Factory> CONTEXT = new ScriptContext<>("watcher_transform", Factory.class); public static ScriptContext<Factory> CONTEXT = new ScriptContext<>("watcher_transform", Factory.class,
200, TimeValue.timeValueMillis(0), ScriptCache.UNLIMITED_COMPILATION_RATE.asTuple());
} }