Module org.elasticsearch.xcore
Class WatchExecutionContext
java.lang.Object
org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext
-
Constructor Summary
ConstructorsConstructorDescriptionWatchExecutionContext(String watchId, ZonedDateTime executionTime, TriggerEvent triggerEvent, org.elasticsearch.core.TimeValue defaultThrottlePeriod) -
Method Summary
Modifier and TypeMethodDescriptionabortBeforeExecution(ExecutionState state, String message) abortFailedExecution(String message) voidvoidvoidvoidcreateSnapshot(Thread executionThread) org.elasticsearch.core.TimeValuefinal voidensureWatchExists(CheckedSupplier<Watch, Exception> supplier) finish()getUser()static StringgetUsernameFromWatch(Watch watch) Given a watch, this extracts and decodes the relevant auth header and returns the principal of the user that is executing the watch.id()abstract booleanvoidonActionResult(ActionWrapperResult result) voidonConditionResult(Condition.Result result) voidonInputResult(Input.Result result) voidbooleanpayload()abstract booleanvoidabstract booleanabstract booleansimulateAction(String actionId) abstract booleanskipThrottling(String actionId) voidstart()vars()watch()
-
Constructor Details
-
WatchExecutionContext
public WatchExecutionContext(String watchId, ZonedDateTime executionTime, TriggerEvent triggerEvent, org.elasticsearch.core.TimeValue defaultThrottlePeriod)
-
-
Method Details
-
knownWatch
public abstract boolean knownWatch()- Returns:
- true if the watch associated with this context is known to watcher (i.e. it's stored
in watcher. This plays a key role in how we handle execution. For example, if
the watch is known, but then the watch is not there (perhaps deleted in between)
we abort execution. It also plays a part (along with
recordExecution()in the decision of whether the watch record should be stored and if the watch status should be updated.
-
simulateAction
- Returns:
- true if this action should be simulated
-
skipThrottling
-
shouldBeExecuted
public abstract boolean shouldBeExecuted()- Returns:
- true if execution is allowed (this depends on the type of the watch context)
-
recordExecution
public abstract boolean recordExecution()- Returns:
- true if this execution should be recorded in the .watcher-history index
-
watch
-
ensureWatchExists
- Throws:
Exception
-
id
-
executionTime
-
defaultThrottlePeriod
public org.elasticsearch.core.TimeValue defaultThrottlePeriod()- Returns:
- The default throttle period in the system.
-
overrideRecordOnConflict
public boolean overrideRecordOnConflict() -
triggerEvent
-
payload
-
vars
-
executionPhase
-
setNodeId
- Parameters:
nodeId- The node id this watch execution context runs on
-
getNodeId
- Returns:
- The node this watch execution context runs on, which will be stored in the watch history
-
getUser
- Returns:
- The user that executes the watch, which will be stored in the watch history
-
start
public void start() -
beforeInput
public void beforeInput() -
onInputResult
-
inputResult
-
beforeCondition
public void beforeCondition() -
onConditionResult
-
conditionResult
-
beforeWatchTransform
public void beforeWatchTransform() -
onWatchTransformResult
-
transformResult
-
beforeActions
public void beforeActions() -
onActionResult
-
actionsResults
-
abortBeforeExecution
-
abortFailedExecution
-
abortFailedExecution
-
finish
-
createSnapshot
-
getUsernameFromWatch
Given a watch, this extracts and decodes the relevant auth header and returns the principal of the user that is executing the watch.- Throws:
IOException
-