Package 

Interface TaskExecutionInterceptor

  • All Implemented Interfaces:
    com.netflix.spinnaker.kork.plugins.api.internal.SpinnakerExtensionPoint , org.pf4j.ExtensionPoint

    @Beta() 
    public interface TaskExecutionInterceptor
     implements SpinnakerExtensionPoint
                        

    TaskExecutionInterceptor is a hook point to customize the specific execution of a task.

    Before execute is called on a Task, all TaskExecutionInterceptors will be called. The resulting Stage object from beforeTaskExecution is passed to subsequent invocations of TaskExecutionInterceptor and then used for the invocation of execute on Task.

    After a Task completes with a TaskResult, all TaskExecutionInterceptors are called. The resulting TaskResult is passed to subsequent invocations ot TaskExecutionInterceptor and the final TaskResult is used as the output of the task.

    A TaskExecutionInterceptor can specify the maximum backoff that should be allowed. As an example, the LockExtendingTaskExecutionInterceptor needs to ensure that a task doesn't delay longer than the lock extension. The minimum maxTaskBackoff among all registered TaskExecutionInterceptors will be used to constrain the task backoff supplied by a RetryableTask.

    • Method Summary

      Modifier and Type Method Description
      long maxTaskBackoff() hook that is called to program the collective maximum backoff of all TaskExecutionInterceptors.
      StageExecution beforeTaskExecution(Task task, StageExecution stage) hook that is called before a task executes.
      TaskResult afterTaskExecution(Task task, StageExecution stage, TaskResult taskResult) hook that is called after a task executes successfully.
      void finallyAfterTaskExecution(Task task, StageExecution stage, TaskResult taskResult, Exception e) hook that is guaranteed to be called, even when a task throws an exception which will cause afterTaskExecution to not be called.
      • Methods inherited from class com.netflix.spinnaker.kork.plugins.api.internal.SpinnakerExtensionPoint

        getExtensionClass, getPluginId
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • maxTaskBackoff

         long maxTaskBackoff()

        hook that is called to program the collective maximum backoff of all TaskExecutionInterceptors. A retryable task has a backoff period which is configured by defaults and then constrained by the minimum backoff configured by all registered interceptors.

      • afterTaskExecution

         TaskResult afterTaskExecution(Task task, StageExecution stage, TaskResult taskResult)

        hook that is called after a task executes successfully.

        As an example you can modify the taskResult here before it gets propagated.

        Parameters:
        task - The task that is being handled.
        stage - The stage for the task execution.
        taskResult - The result of executing the task.
      • finallyAfterTaskExecution

         void finallyAfterTaskExecution(Task task, StageExecution stage, TaskResult taskResult, Exception e)

        hook that is guaranteed to be called, even when a task throws an exception which will cause afterTaskExecution to not be called.

        As an example you can clear the security context here if you set it in the beforeTaskExecution hook.

        Parameters:
        task - The task that is being handled.
        stage - The stage for the task execution.
        taskResult - Will be null if the task failed with an exception.
        e - Will be not null if the task failed with an exception.