Class TaskManager

java.lang.Object
io.goobi.viewer.api.rest.model.tasks.TaskManager

public class TaskManager extends Object
Manages (possibly timeconsuming) tasks within the viewer which can be triggered and monitored via the TasksResource. The tasks are not executed sequentially or queued in any way, except through the limit of the internal thread pool (5 parallel tasks)
Author:
Florian Alpers
  • Constructor Details

    • TaskManager

      public TaskManager(Duration jobLiveTime)
      Creates new JobManager.
      Parameters:
      jobLiveTime - The guaranteed live time of jobs in the jobManager
  • Method Details

    • addTask

      public Long addTask(Task job)
    • getTask

      public Task getTask(long jobId)
    • removeTask

      public Task removeTask(long jobId)
    • triggerTaskInThread

      public Future triggerTaskInThread(long jobId, HttpServletRequest request)
    • getTasks

      public List<Task> getTasks(TaskType type)
    • getTasks

      public List<Task> getTasks()
    • shutdown

      public void shutdown()
      Shuts down the internal thread pool. Attempts to stop running tasks; waits up to 5 seconds for threads to terminate. Should be called from the servlet context listener on undeploy.
    • isShutdown

      public boolean isShutdown()
      Returns:
      true if the internal executor service has been shut down
    • createTask

      public static BiConsumer<HttpServletRequest,Task> createTask(TaskType type)
      Parameters:
      type - task type for which to create the handler
      Returns:
      BiConsumer<HttpServletRequest, Task>