Class LocalTaskQueue

java.lang.Object
org.duracloud.common.queue.local.LocalTaskQueue
All Implemented Interfaces:
TaskQueue

public class LocalTaskQueue extends Object implements TaskQueue
This class implements a local, in-memory task queue. (It is intended to use for testing purposes.)
Author:
Daniel Bernstein Date: Oct 24, 2013
  • Constructor Details

    • LocalTaskQueue

      public LocalTaskQueue()
  • Method Details

    • getName

      public String getName()
      Description copied from interface: TaskQueue
      A name identifying the queue used for logging and analysis purposes.
      Specified by:
      getName in interface TaskQueue
      Returns:
    • put

      public void put(Task task)
      Description copied from interface: TaskQueue
      puts a task on the queue
      Specified by:
      put in interface TaskQueue
    • put

      public void put(Task... tasks)
      Description copied from interface: TaskQueue
      puts multiple tasks on the queue using batch puts if the queue implementation supports batch puts
      Specified by:
      put in interface TaskQueue
    • put

      public void put(Set<Task> tasks)
      Description copied from interface: TaskQueue
      puts multiple tasks on the queue using batch puts if the queue implementation supports batch puts
      Specified by:
      put in interface TaskQueue
    • take

      public Task take() throws TimeoutException
      Description copied from interface: TaskQueue
      Blocks until a task is available
      Specified by:
      take in interface TaskQueue
      Returns:
      Throws:
      TimeoutException
    • extendVisibilityTimeout

      public void extendVisibilityTimeout(Task task) throws TaskNotFoundException
      Description copied from interface: TaskQueue
      Responsible for robustly extending the visibility timeout of a Task.
      Specified by:
      extendVisibilityTimeout in interface TaskQueue
      Throws:
      TaskNotFoundException
    • deleteTask

      public void deleteTask(Task task) throws TaskNotFoundException
      Description copied from interface: TaskQueue
      Deletes a task from the queue.
      Specified by:
      deleteTask in interface TaskQueue
      Throws:
      TaskNotFoundException
    • size

      public Integer size()
      Specified by:
      size in interface TaskQueue
      Returns:
      The approximate number of elements in this queue (does not include invisible and delayed tasks).
    • getInprocessCount

      public int getInprocessCount()
    • getCompletedCount

      public long getCompletedCount()
    • sizeIncludingInvisibleAndDelayed

      public Integer sizeIncludingInvisibleAndDelayed()
      Specified by:
      sizeIncludingInvisibleAndDelayed in interface TaskQueue
      Returns:
      The approximate number of elements in this queue including all items that are visible (available for takes), invisible (in process - not yet completed), and delayed (pending addition to the queue).
    • requeue

      public void requeue(Task task)
      Description copied from interface: TaskQueue
      Requeues the task by deleting the task, incrementing the "attempts" counter, and re-adding back to the queue. Any subsequent calls on the requeued task via the task queue should fail due to the task not being found.
      Specified by:
      requeue in interface TaskQueue
    • deleteTasks

      public void deleteTasks(Set<Task> tasks) throws TaskException
      Description copied from interface: TaskQueue
      Deletes a set of tasks
      Specified by:
      deleteTasks in interface TaskQueue
      Throws:
      TaskException
    • take

      public Set<Task> take(int maxTasks) throws TimeoutException
      Description copied from interface: TaskQueue
      Take a max of specified number of tasks. Blocks until at least one task is available.
      Specified by:
      take in interface TaskQueue
      Parameters:
      maxTasks - to take from queue. Must be between 1 and 10 inclusive.
      Returns:
      Throws:
      TimeoutException