Interface Task

  • All Known Implementing Classes:
    AbstractTask

    public interface Task
    A Task is an executable entity that is run by the gateway. It is a long running operation that can be paused, canceled, and monitored. A Task instance is created through a TaskType, in conjunction with task settings. It is configured in the gateway web UI, according to the TaskType.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  Task.TaskStateModel
      If a task can be suspended and resumed, this is an arbitrary state that will be used to resume.
    • Method Detail

      • getId

        java.util.UUID getId()
      • run

        void run​(TaskContext context)
          throws java.lang.Exception
        Executes the task. This function should block until completion. If there is a problem executing the task, an exception should be thrown. It is important to note that while this function should block, the task must expect that at some point, suspend or cancel may be called.
        Throws:
        java.lang.Exception
      • suspend

        java.util.Optional<Task.TaskStateModel> suspend​(long timeoutMS)
                                                 throws java.util.concurrent.TimeoutException,
                                                        java.lang.InterruptedException
        When called, the task should stop as quickly as possible. If the task is able to resume, it should return a state that will be provided to it when restarted. If this function returns an empty value, it will not be resumed. If appropriate, the call should try to implement the timeout restriction passed in. A timeout of 0 means "no timeout".
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
      • cancel

        void cancel​(long timeoutMS)
             throws java.util.concurrent.TimeoutException,
                    java.lang.InterruptedException
        When called, the task should stop as quickly as possible. If appropriate, the call should try to implement the timeout restriction passed in. A timeout of 0 means "no timeout".
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
      • getErrors

        java.util.List<java.lang.Throwable> getErrors()
        Returns a List of all the exceptions that occurred when running a task. If no exceptions occurred, an empty List is returned.