java.lang.Object
org.elasticsearch.script.ScriptService
- All Implemented Interfaces:
Closeable,AutoCloseable,ClusterStateApplier,ScriptCompiler
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCollect settings related to script context and general caches. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Setting.AffixSetting<TimeValue> static final Setting.AffixSetting<Integer> static final Setting<ScriptCache.CompilationRate> static final Setting.AffixSetting<ScriptCache.CompilationRate> static final StringFields inherited from interface org.elasticsearch.script.ScriptCompiler
NONE -
Constructor Summary
ConstructorsConstructorDescriptionScriptService(Settings settings, Map<String, ScriptEngine> engines, Map<String, ScriptContext<?>> contexts, LongSupplier timeProvider) -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when a new cluster state (ClusterChangedEvent.state()needs to be applied.voidclose()<FactoryType>
FactoryTypecompile(Script script, ScriptContext<FactoryType> context) Compiles a script using the given context.static StringcontextDeprecationMessage(Settings settings) static voiddeleteStoredScript(ClusterService clusterService, DeleteStoredScriptRequest request, ActionListener<AcknowledgedResponse> listener) Map<String, ScriptContext<?>> protected StoredScriptSourcestatic StoredScriptSourcegetStoredScript(ClusterState state, GetStoredScriptRequest request) booleanbooleanisContextEnabled(ScriptContext<?> scriptContext) static booleanisImplicitContextCacheSet(Settings settings) booleanisLangSupported(String lang) booleanisTypeEnabled(ScriptType scriptType) static booleanisUseContextCacheSet(Settings settings) voidputStoredScript(ClusterService clusterService, PutStoredScriptRequest request, ActionListener<AcknowledgedResponse> listener) stats()
-
Field Details
-
SCRIPT_GENERAL_CACHE_SIZE_SETTING
-
SCRIPT_GENERAL_CACHE_EXPIRE_SETTING
-
SCRIPT_MAX_SIZE_IN_BYTES
-
SCRIPT_GENERAL_MAX_COMPILATIONS_RATE_SETTING
public static final Setting<ScriptCache.CompilationRate> SCRIPT_GENERAL_MAX_COMPILATIONS_RATE_SETTING -
USE_CONTEXT_RATE_KEY_DEPRECATION_MESSAGE
-
SCRIPT_CACHE_SIZE_SETTING
-
SCRIPT_CACHE_EXPIRE_SETTING
-
SCRIPT_MAX_COMPILATIONS_RATE_SETTING
public static final Setting.AffixSetting<ScriptCache.CompilationRate> SCRIPT_MAX_COMPILATIONS_RATE_SETTING -
SCRIPT_DISABLE_MAX_COMPILATIONS_RATE_SETTING
-
ALLOW_NONE
- See Also:
-
TYPES_ALLOWED_SETTING
-
CONTEXTS_ALLOWED_SETTING
-
-
Constructor Details
-
ScriptService
public ScriptService(Settings settings, Map<String, ScriptEngine> engines, Map<String, ScriptContext<?>> contexts, LongSupplier timeProvider)
-
-
Method Details
-
isUseContextCacheSet
-
isImplicitContextCacheSet
-
contextDeprecationMessage
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getScriptContexts
- Returns:
- an unmodifiable
Mapof available script context names toScriptContexts
-
compile
Compiles a script using the given context.- Specified by:
compilein interfaceScriptCompiler- Type Parameters:
FactoryType- the class of the compiled Script factory- Parameters:
script- the Script to compilecontext- the ScriptContext defining how to compile the script- Returns:
- a compiled script which may be used to construct instances of a script for the given context
-
isLangSupported
-
isTypeEnabled
-
isContextEnabled
-
isAnyContextEnabled
public boolean isAnyContextEnabled() -
getScriptFromClusterState
-
putStoredScript
public void putStoredScript(ClusterService clusterService, PutStoredScriptRequest request, ActionListener<AcknowledgedResponse> listener) -
deleteStoredScript
public static void deleteStoredScript(ClusterService clusterService, DeleteStoredScriptRequest request, ActionListener<AcknowledgedResponse> listener) -
getStoredScript
public static StoredScriptSource getStoredScript(ClusterState state, GetStoredScriptRequest request) -
getContextInfos
-
getScriptLanguages
-
stats
-
cacheStats
-
applyClusterState
Description copied from interface:ClusterStateApplierCalled when a new cluster state (ClusterChangedEvent.state()needs to be applied. The cluster state to be applied is already committed when this method is called, so an applier must therefore be prepared to deal with any state it receives without throwing an exception. Throwing an exception from an applier is very bad because it will stop the application of this state before it has reached all the other appliers, and will likely result in another attempt to apply the same (or very similar) cluster state which might continue until this node is removed from the cluster.Cluster states are applied one-by-one which means they can be a performance bottleneck. Implementations of this method should therefore be fast, so please consider forking work into the background rather than doing everything inline.
- Specified by:
applyClusterStatein interfaceClusterStateApplier
-