Interface TaskInvokable

    • Method Detail

      • invoke

        void invoke()
             throws Exception
        Starts the execution.

        This method is called by the task manager when the actual execution of the task starts.

        All resources should be cleaned up by calling cleanUp(Throwable) after the method returns.

        Throws:
        Exception
      • restore

        void restore()
              throws Exception
        This method can be called before invoke() to restore an invokable object for the last valid state, if it has it.

        If invoke() is not called after this method for some reason (e.g. task cancellation); then all resources should be cleaned up by calling cleanUp(Throwable) ()} after the method returns.

        Throws:
        Exception
      • cleanUp

        void cleanUp​(@Nullable
                     Throwable throwable)
              throws Exception
        Cleanup any resources used in invoke() OR restore(). This method must be called regardless whether the aforementioned calls succeeded or failed.
        Parameters:
        throwable - iff failure happened during the execution of restore() or invoke(), null otherwise.

        ATTENTION: CancelTaskException should not be treated as a failure.

        Throws:
        Exception
      • cancel

        void cancel()
             throws Exception
        This method is called when a task is canceled either as a result of a user abort or an execution failure. It can be overwritten to respond to shut down the user code properly.
        Throws:
        Exception
      • isUsingNonBlockingInput

        boolean isUsingNonBlockingInput()
        Returns:
        true if blocking input such as InputGate.getNext() is used (as opposed to InputGate.pollNext(). To be removed together with the DataSet API.
      • maybeInterruptOnCancel

        void maybeInterruptOnCancel​(Thread toInterrupt,
                                    @Nullable
                                    String taskName,
                                    @Nullable
                                    Long timeout)
        Checks whether the task should be interrupted during cancellation and if so, execute the specified Runnable interruptAction.
        Parameters:
        toInterrupt -
        taskName - optional taskName to log stack trace
        timeout - optional timeout to log stack trace