Class WatchExecutionContext

java.lang.Object
org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext

public abstract class WatchExecutionContext extends Object
  • 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

      public abstract boolean simulateAction(String actionId)
      Returns:
      true if this action should be simulated
    • skipThrottling

      public abstract boolean skipThrottling(String actionId)
    • 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

      public Watch watch()
    • ensureWatchExists

      public final void ensureWatchExists(CheckedSupplier<Watch,Exception> supplier) throws Exception
      Throws:
      Exception
    • id

      public Wid id()
    • executionTime

      public ZonedDateTime executionTime()
    • defaultThrottlePeriod

      public org.elasticsearch.core.TimeValue defaultThrottlePeriod()
      Returns:
      The default throttle period in the system.
    • overrideRecordOnConflict

      public boolean overrideRecordOnConflict()
    • triggerEvent

      public TriggerEvent triggerEvent()
    • payload

      public Payload payload()
    • vars

      public Map<String,Object> vars()
    • executionPhase

      public ExecutionPhase executionPhase()
    • setNodeId

      public void setNodeId(String nodeId)
      Parameters:
      nodeId - The node id this watch execution context runs on
    • getNodeId

      public String getNodeId()
      Returns:
      The node this watch execution context runs on, which will be stored in the watch history
    • getUser

      public String 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

      public void onInputResult(Input.Result result)
    • inputResult

      public Input.Result inputResult()
    • beforeCondition

      public void beforeCondition()
    • onConditionResult

      public void onConditionResult(Condition.Result result)
    • conditionResult

      public Condition.Result conditionResult()
    • beforeWatchTransform

      public void beforeWatchTransform()
    • onWatchTransformResult

      public void onWatchTransformResult(Transform.Result result)
    • transformResult

      public Transform.Result transformResult()
    • beforeActions

      public void beforeActions()
    • onActionResult

      public void onActionResult(ActionWrapperResult result)
    • actionsResults

      public Map<String,ActionWrapperResult> actionsResults()
    • abortBeforeExecution

      public WatchRecord abortBeforeExecution(ExecutionState state, String message)
    • abortFailedExecution

      public WatchRecord abortFailedExecution(String message)
    • abortFailedExecution

      public WatchRecord abortFailedExecution(Exception e)
    • finish

      public WatchRecord finish()
    • createSnapshot

      public WatchExecutionSnapshot createSnapshot(Thread executionThread)
    • getUsernameFromWatch

      public static String getUsernameFromWatch(Watch watch) throws IOException
      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